slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.85k stars 555 forks source link

Layouts should offer the possibility to collapse margins #5777

Open Enyium opened 1 month ago

Enyium commented 1 month ago

Layouts should offer the possibility to collapse margins. Such that this code:

VerticalBox {
  HorizontalBox { Widget1{} Widget2{} }
  Widget3{}
}

would be aligned.

This would be a breaking change unless we add a property to enable it. Or that perhaps we create a "second" stdlib under a new import (eg @std)

Original description

Please improve docs on layout padding and nesting

Here's a demo with nested layout widgets. It seems the paddings add up to excessive values. There are large gaps at various places. Please document better how the ...Box layout widgets are supposed to be used in more complex, nested trees. Slint doesn't seem to know concepts like margin collapse or property inheritance from CSS. Are you supposed to specify padding: 0; (still benefitting from spacing) on every ...Box layout but the outermost one inside a Window/inside a GroupBox, and to surround each GridBox in a VerticalLayout with alignment: start; when you don't want its Rows to be stretched?

tronical commented 1 month ago

I'm inclined to suggest that we edit the description of this issue to track support for collapsing margins with ...Box. What do the others think?

cc @ogoffart @FloVanGH @NigelBreslaw

ogoffart commented 1 month ago

Agreed, I updated the description.