mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
LibGUI: Start adding an automatic widget layout system.
My needs are really quite simple, so I'm just going to add what I need as I go along. The first thing I needed was a simple box layout with widgets being able to say whether they prefer fixed or fill for both their vertical and horizontal sizes. I also made a simple GStatusBar so FileManager can show how many bytes worth of files are in the current directory.
This commit is contained in:
41
LibGUI/GLayout.cpp
Normal file
41
LibGUI/GLayout.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#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>());
|
||||
}
|
||||
Reference in New Issue
Block a user