mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
dc753b58a5
Added spacing and margin concepts to GLayout. Support layout a sequence of nothing but fixed-size objects in the desired orientation. :^)
59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
#include <LibGUI/GLayout.h>
|
|
#include <LibGUI/GWidget.h>
|
|
|
|
GLayout::GLayout()
|
|
{
|
|
}
|
|
|
|
GLayout::~GLayout()
|
|
{
|
|
}
|
|
|
|
void GLayout::notify_adopted(Badge<GWidget>, GWidget& widget)
|
|
{
|
|
if (m_owner.ptr() == &widget)
|
|
return;
|
|
m_owner = widget.make_weak_ptr();
|
|
}
|
|
|
|
void GLayout::notify_disowned(Badge<GWidget>, GWidget& widget)
|
|
{
|
|
ASSERT(m_owner.ptr() == &widget);
|
|
m_owner.clear();
|
|
}
|
|
|
|
void GLayout::add_layout(OwnPtr<GLayout>&& layout)
|
|
{
|
|
Entry entry;
|
|
entry.layout = move(layout);
|
|
m_entries.append(move(entry));
|
|
if (m_owner)
|
|
m_owner->notify_layout_changed(Badge<GLayout>());
|
|
}
|
|
|
|
void GLayout::add_widget(GWidget& widget)
|
|
{
|
|
Entry entry;
|
|
entry.widget = widget.make_weak_ptr();
|
|
m_entries.append(move(entry));
|
|
if (m_owner)
|
|
m_owner->notify_layout_changed(Badge<GLayout>());
|
|
}
|
|
|
|
void GLayout::set_spacing(int spacing)
|
|
{
|
|
if (m_spacing == spacing)
|
|
return;
|
|
m_spacing = spacing;
|
|
if (m_owner)
|
|
m_owner->notify_layout_changed(Badge<GLayout>());
|
|
}
|
|
|
|
void GLayout::set_margins(const GMargins& margins)
|
|
{
|
|
if (m_margins == margins)
|
|
return;
|
|
m_margins = margins;
|
|
if (m_owner)
|
|
m_owner->notify_layout_changed(Badge<GLayout>());
|
|
}
|