mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 14:35:07 +00:00
LibGUI: Don't accomodate invisible children in ToolBarContainer height
Skip over invisible children so they don't take up vertical space in the container. Also make sure we update the preferred size whenever the widget layout is invalidated. Fixes #3139.
This commit is contained in:
parent
2c3842bfe6
commit
00f47bba23
2 changed files with 13 additions and 1 deletions
|
@ -58,17 +58,28 @@ void ToolBarContainer::did_add_toolbar(Widget& toolbar)
|
|||
recompute_preferred_size();
|
||||
}
|
||||
|
||||
void ToolBarContainer::custom_layout()
|
||||
{
|
||||
recompute_preferred_size();
|
||||
}
|
||||
|
||||
void ToolBarContainer::recompute_preferred_size()
|
||||
{
|
||||
int preferred_size = 4 + (m_toolbars.size() - 1) * 2;
|
||||
int visible_toolbar_count = 0;
|
||||
int preferred_size = 4;
|
||||
|
||||
for (auto& toolbar : m_toolbars) {
|
||||
if (!toolbar.is_visible())
|
||||
continue;
|
||||
++visible_toolbar_count;
|
||||
if (m_orientation == Gfx::Orientation::Horizontal)
|
||||
preferred_size += toolbar.preferred_size().height();
|
||||
else
|
||||
preferred_size += toolbar.preferred_size().width();
|
||||
}
|
||||
|
||||
preferred_size += (visible_toolbar_count - 1) * 2;
|
||||
|
||||
if (m_orientation == Gfx::Orientation::Horizontal)
|
||||
set_preferred_size(0, preferred_size);
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue