mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-19 03:06:39 +00:00
menu_view: ignore zero-sized widgets in box layout
The box layout evenly distributes the child widgets according to the number of children. This is not desired in the special case where a child widget has a size of zero. The patch changes the layout algorithm such that zero-sized widgets are not taken into account for distributing residual space.
This commit is contained in:
parent
b4ded050e1
commit
202bb707ce
@ -56,6 +56,10 @@ struct Menu_view::Box_layout_widget : Widget
|
||||
|
||||
w.position(position);
|
||||
|
||||
/* don't account space for zero-sized child widgets */
|
||||
if (child_min_size.count() == 0)
|
||||
return;
|
||||
|
||||
if (_direction == VERTICAL) {
|
||||
unsigned const next_top_margin = w.next() ? w.next()->margin.top : 0;
|
||||
unsigned const dy = child_min_size.h() - min(w.margin.bottom, next_top_margin);
|
||||
@ -65,6 +69,7 @@ struct Menu_view::Box_layout_widget : Widget
|
||||
unsigned const dx = child_min_size.w() - min(w.margin.right, next_left_margin);
|
||||
position = position + Point(dx, 0);
|
||||
}
|
||||
|
||||
_count++;
|
||||
});
|
||||
|
||||
@ -99,6 +104,9 @@ struct Menu_view::Box_layout_widget : Widget
|
||||
w.position(w.geometry().p1() + Point(consumed_fp >> 8, 0));
|
||||
w.size(Area(w.min_size().w() + padding_pixels, geometry().h()));
|
||||
}
|
||||
|
||||
/* don't account space for zero-sized child widgets */
|
||||
if (w.min_size().count())
|
||||
consumed_fp = next_consumed_fp;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user