mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +00:00
LibGUI: Consider content_margins for BoxLayout
This commit is contained in:
parent
4955769ab8
commit
70e5a77794
1 changed files with 8 additions and 4 deletions
|
@ -33,6 +33,7 @@ Gfx::IntSize BoxLayout::preferred_size() const
|
||||||
|
|
||||||
int BoxLayout::preferred_primary_size() const
|
int BoxLayout::preferred_primary_size() const
|
||||||
{
|
{
|
||||||
|
auto widget = verify_cast<GUI::Widget>(parent());
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
for (auto& entry : m_entries) {
|
for (auto& entry : m_entries) {
|
||||||
|
@ -52,10 +53,11 @@ int BoxLayout::preferred_primary_size() const
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
size -= spacing();
|
size -= spacing();
|
||||||
|
|
||||||
|
auto content_margins = widget->content_margins();
|
||||||
if (orientation() == Gfx::Orientation::Horizontal)
|
if (orientation() == Gfx::Orientation::Horizontal)
|
||||||
size += margins().left() + margins().right();
|
size += margins().left() + margins().right() + content_margins.left() + content_margins.right();
|
||||||
else
|
else
|
||||||
size += margins().top() + margins().bottom();
|
size += margins().top() + margins().bottom() + content_margins.top() + content_margins.bottom();
|
||||||
|
|
||||||
if (!size)
|
if (!size)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -64,6 +66,7 @@ int BoxLayout::preferred_primary_size() const
|
||||||
|
|
||||||
int BoxLayout::preferred_secondary_size() const
|
int BoxLayout::preferred_secondary_size() const
|
||||||
{
|
{
|
||||||
|
auto widget = verify_cast<GUI::Widget>(parent());
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (auto& entry : m_entries) {
|
for (auto& entry : m_entries) {
|
||||||
if (!entry.widget || !entry.widget->is_visible())
|
if (!entry.widget || !entry.widget->is_visible())
|
||||||
|
@ -77,10 +80,11 @@ int BoxLayout::preferred_secondary_size() const
|
||||||
size = max(min_size, size);
|
size = max(min_size, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto content_margins = widget->content_margins();
|
||||||
if (orientation() == Gfx::Orientation::Horizontal)
|
if (orientation() == Gfx::Orientation::Horizontal)
|
||||||
size += margins().top() + margins().bottom();
|
size += margins().top() + margins().bottom() + content_margins.top() + content_margins.bottom();
|
||||||
else
|
else
|
||||||
size += margins().left() + margins().right();
|
size += margins().left() + margins().right() + content_margins.left() + content_margins.right();
|
||||||
|
|
||||||
if (!size)
|
if (!size)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue