blob: 59d3690d1ffff5e57031fd2b35c6b5c5839901a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#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::remove_widget(GWidget& widget)
{
m_entries.remove_first_matching([&] (auto& entry) {
return entry.widget.ptr() == &widget;
});
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>());
}
|