@@ -15,6 +15,10 @@ void BoxContainer::adjust_layout() {
1515
1616 // In the first loop, we need to do some calculation.
1717 for (auto &ui_child : ui_children) {
18+ if (!ui_child->get_visibility ()) {
19+ continue ;
20+ }
21+
1822 if (horizontal) {
1923 if (ui_child->container_sizing .expand_h ()) {
2024 expanding_children.push_back (ui_child);
@@ -42,10 +46,18 @@ void BoxContainer::adjust_layout() {
4246 uint32_t expanding_child_count = expanding_children.size ();
4347
4448 // FIXME: same expanding space is not optimal.
45- float extra_space_for_each_expanding_child = available_space_for_expanding / (float )expanding_child_count;
49+ float extra_space_for_each_expanding_child = 0 ;
50+ if (expanding_child_count > 0 ) {
51+ extra_space_for_each_expanding_child = available_space_for_expanding / (float )expanding_child_count;
52+ }
4653
4754 float pos_shift = 0 ;
4855
56+ // When there's at least one expanding child, the alignment doesn't matter because there's no space for it to make a difference.
57+ if (expanding_child_count == 0 && alignment == BoxContainerAlignment::End) {
58+ pos_shift = available_space_for_expanding;
59+ }
60+
4961 // In the second loop, we set child sizes and positions.
5062 for (auto &ui_child : ui_children) {
5163 auto child_min_size = ui_child->get_effective_minimum_size ();
@@ -198,4 +210,8 @@ void BoxContainer::set_separation(float new_separation) {
198210 separation = new_separation;
199211}
200212
213+ void BoxContainer::set_alignment (BoxContainerAlignment new_alignment) {
214+ alignment = new_alignment;
215+ }
216+
201217} // namespace revector
0 commit comments