Repository navigation
How to make the window height adapt to its content? #3634
|
Just like what the following code does in WPF: window.SizeToContent = SizeToContent.Height; |
Replies: 1 comment 1 reply
|
You can build this with the current layout callback and In GPUI Kit 0.8.0, Here is a runnable example with Add/Remove/Reset controls and wrapping text. For content taller than the available screen, use a maximum height with a scrollable content area instead of fitting the whole document. |
You can build this with the current layout callback and
Window::resize: measure an intrinsic-height content child, then defer resizing the window while preserving its current width.In GPUI Kit 0.8.0,
Div::on_children_prepaintedgives you the resolved child bounds. Put padding inside that child and avoidh_full()/flex_1()on it, so its height comes from the content.Window::resizetakes the content size; there is no titlebar offset to add. Recheck the width before applying the deferred measurement, and only resize when the height changes.Here is a runnable example with Add/Remove/Reset controls and wrapping text.
cargo run --locked -- --verifyopens a real native window and exercises tho…