-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify/Enforce LayoutStyle.Absolute
when X
, Y
, Width
, and/or Height
are null or Absolute()
#2465
Comments
v = new View (frame.X, frame.Y, "v");
Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
// BUGBUG: v2 - I think the default size should be 0,0
Assert.Equal (new Rect(frame.X, frame.Y, 1, 1), v.Frame);
The reason for this is the call to [Fact]
public void AbsoluteLayout_Change_Height_or_Width_NotAbsolute ()
{
var v = new View (Rect.Empty);
v.Height = Dim.Fill ();
v.Width = Dim.Fill ();
Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // BUGBUG: v2 - Changing the Height or Width should change the LayoutStyle
}
[Fact]
public void AbsoluteLayout_Change_X_or_Y_NotAbsolute ()
{
var v = new View (Rect.Empty);
v.X = Pos.Center ();
v.Y = Pos.Center ();
Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // BUGBUG: v2 - Changing the Height or Width should change the LayoutStyle
}
[Fact]
public void AbsoluteLayout_Change_X_or_Y_Null ()
// BUGBUG: v2 - If all of X, Y, Width, and Height are null or Absolute(n), isn't that the same as LayoutStyle.Absoulte?
v.X = null;
v.Y = null;
v.Height = null;
v.Width = null;
Assert.True (v.LayoutStyle == LayoutStyle.Absolute); // We never automatically change to Absolute from Computed?? If [Fact]
public void AbsoluteLayout_Layout ()
{
var superRect = new Rect (0, 0, 100, 100);
var super = new View (superRect, "super");
Assert.True (super.LayoutStyle == LayoutStyle.Absolute);
var v1 = new View () {
X = 0,
Y = 0,
Width = 10,
Height = 10
};
// BUGBUG: v2 - This should be LayoutStyle.Absolute
Assert.True (v1.LayoutStyle == LayoutStyle.Computed);
Based on your suggestion, yes, but based on the constructor, no. |
@tig I think you are in the right direction. Please go ahead. Thanks. |
… and/or Height are null or Absolute() (#2467) * Merged v2_develop; updated API docs * Code cleanup * Fixed code that was using Dim/Pos before IsInit * Fixed ComboBox using Bounds before IsInitalized and grabbing focus when it shouldn't * Fixed ComboBox tests. Fixed FileDialog * Fixed all !IsInitalized warnings * Fixed AllviewsTester * Fixed CharMap scenario * Fixed ColorPicker (hack) * Fixed CoputedLayout and Csv Editor * Imrpoved warning * Fixed more warnings * Fixed GetTextFormatterSizeNeededForTextAndHotKey * Fixed AllViewsTester * AllViewsTester code cleanup * AllViewsTester code cleanup * AllViewsTester fixed for realz * Decided Fill was better than Percent for default
I keep finding latent bugs and/or extra code in v1 relative to this topic.
The current API docs for
ComputedLayout
read:IOW, these members are to be ignored if
Absolute
is set. However, in reality, nobody keeps this clear in their heads and there's tons of code where Views withAbsolute
get these members set using absolute values (e.g.view.X = 3
).Plus,
Dim
andPos
make this easy with their constructors that takeint
.I propose the following for v2 to simplify and clarify all of this:
View.LayoutStyle
is no longer implemented as a field (theView.layoutStyle
private member), but a calculated property.v1:
v2:
The implications of this are fairly straightforward, but there are sure to be some subtle gotchas in existing code and architecture.
null
. They are either of type Pos/Dim.Absolute or another. Their setters should throwInvalidArgumentException
ifvalue
isnull
.Thoughts? Comments?
The text was updated successfully, but these errors were encountered: