mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:28:11 +00:00
LibGUI: Add a way for GWidgets to do custom layout on child hide/show
This solves an issue in GScrollableWidget where hiding one of the two scrollbars needs to trigger a relayout since the other one should grow into the "shared space" in the bottom right corner. A GWidget can now override custom_layout() which will be called at any time we would normally delegate work to the GLayout, e.g on resize or child visibility changes, size policy changes, etc.
This commit is contained in:
parent
77a58119e7
commit
b615a5c780
4 changed files with 13 additions and 7 deletions
|
@ -144,6 +144,7 @@ void GWidget::set_layout(OwnPtr<GLayout>&& layout)
|
|||
|
||||
void GWidget::do_layout()
|
||||
{
|
||||
custom_layout();
|
||||
if (!m_layout)
|
||||
return;
|
||||
m_layout->run(*this);
|
||||
|
@ -157,8 +158,7 @@ void GWidget::notify_layout_changed(Badge<GLayout>)
|
|||
|
||||
void GWidget::handle_resize_event(GResizeEvent& event)
|
||||
{
|
||||
if (layout())
|
||||
do_layout();
|
||||
do_layout();
|
||||
return resize_event(event);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue