Layout subviews does not apply `Width` changes to `Bounds`
See original GitHub issueDescribe the bug
Changes to Width
are only reflected in Bounds
after calling LayoutSubviews
on super which seems fine. But subsequent changes to Width
are not applied to Bounds
even after calling LayoutSubviews
again.
If there is a workaround or this is expected behaviour let me know and I can apply to the tests in TerminalGuiDesigner. This is a common use case in the designer (e.g. drag resizing a view) so there are several tests that fail because of it. I notice that Frame
is updated but don’t want to re-write all my tests to just check Frame
instead without understanding if that is correct.
To Reproduce
[Fact, AutoInitShutdown]
public void TestResize ()
{
var w = new Window ();
var v = new View { Width = 8, Height = 8 };
w.Add (v);
Assert.Equal (0, v.Bounds.Width);
w.LayoutSubviews ();
Assert.Equal (8, v.Bounds.Width);
v.Width = 10;
w.LayoutSubviews ();
// Fails here
Assert.Equal (10, v.Bounds.Width);
}
Expected behavior
Calling LayoutSubviews
should always update the Bounds
to respect the Width
/Height
Issue Analytics
- State:
- Created 4 months ago
- Comments:7
Top Results From Across the Web
Subview's bounds are zero in layoutSubviews() - ios
If no layout updates are pending, this method exits without modifying the layout or calling any layout-related callbacks.
Read more >Subview is not resizing properly | Apple Developer Forums
I have a view with an image. When the image is clicked there is a modal popup of that image that is "full...
Read more >Autolayout Fundamental - Manasa M P - Medium
When a view's bounds change, that view automatically resizes its subviews according to each subview's autoresizing mask. The default value of ...
Read more >UIView Frames and Bounds
All UIViews have frame and bounds properties which define their dimensions. The similarity of these properties can cause some confusion when ...
Read more >Frame vs Bounds in iOS: Implementing A Visual ...
Find out what is the difference between frame and bounds in iOS through the implementation of a small app that explains everything visually....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe you and I are aligned on this.
I had created this issue, IIRC, specifically so we can fix this: https://github.com/gui-cs/Terminal.Gui/issues/2465
Here is the reason why
Frame
did change but notBounds
,if (LayoutStyle == LayoutStyle.Computed && !IsInitialized)
:So, if you need calculated
Bounds
you need to runBeginInit/EndInit
on theSuperView
.