mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:47:44 +00:00
LibGUI: GTabWidget should not set children to have negative size
This could happen if a child was added to a GTabWidget before the GTabWidget had its first layout. Also add an assertion to catch this in GWidget::set_relative_rect() since it was not immediately obvious what was happening.
This commit is contained in:
parent
93dff5df34
commit
b916e34fed
2 changed files with 10 additions and 3 deletions
|
@ -45,13 +45,18 @@ void GTabWidget::resize_event(GResizeEvent& event)
|
||||||
|
|
||||||
Rect GTabWidget::child_rect_for_size(const Size& size) const
|
Rect GTabWidget::child_rect_for_size(const Size& size) const
|
||||||
{
|
{
|
||||||
|
Rect rect;
|
||||||
switch (m_tab_position) {
|
switch (m_tab_position) {
|
||||||
case TabPosition::Top:
|
case TabPosition::Top:
|
||||||
return { { container_padding(), bar_height() + container_padding() }, { size.width() - container_padding() * 2, size.height() - bar_height() - container_padding() * 2 } };
|
rect = { { container_padding(), bar_height() + container_padding() }, { size.width() - container_padding() * 2, size.height() - bar_height() - container_padding() * 2 } };
|
||||||
|
break;
|
||||||
case TabPosition::Bottom:
|
case TabPosition::Bottom:
|
||||||
return { { container_padding(), container_padding() }, { size.width() - container_padding() * 2, size.height() - bar_height() - container_padding() * 2 } };
|
rect = { { container_padding(), container_padding() }, { size.width() - container_padding() * 2, size.height() - bar_height() - container_padding() * 2 } };
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
ASSERT_NOT_REACHED();
|
if (rect.is_empty())
|
||||||
|
return {};
|
||||||
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTabWidget::child_event(CChildEvent& event)
|
void GTabWidget::child_event(CChildEvent& event)
|
||||||
|
|
|
@ -44,6 +44,8 @@ void GWidget::child_event(CChildEvent& event)
|
||||||
|
|
||||||
void GWidget::set_relative_rect(const Rect& rect)
|
void GWidget::set_relative_rect(const Rect& rect)
|
||||||
{
|
{
|
||||||
|
ASSERT(rect.width() >= 0 && rect.height() >= 0);
|
||||||
|
|
||||||
if (rect == m_relative_rect)
|
if (rect == m_relative_rect)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue