mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +00:00
Libraries: Create top level directory for libraries.
Things were getting a little crowded in the project root, so this patch moves the Lib*/ directories into Libraries/.
This commit is contained in:
parent
63814ffebf
commit
04b9dc2d30
328 changed files with 36 additions and 36 deletions
55
Libraries/LibGUI/GStackWidget.cpp
Normal file
55
Libraries/LibGUI/GStackWidget.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GStackWidget.h>
|
||||
|
||||
GStackWidget::GStackWidget(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
GStackWidget::~GStackWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void GStackWidget::set_active_widget(GWidget* widget)
|
||||
{
|
||||
if (widget == m_active_widget)
|
||||
return;
|
||||
|
||||
if (m_active_widget)
|
||||
m_active_widget->set_visible(false);
|
||||
m_active_widget = widget;
|
||||
if (m_active_widget) {
|
||||
m_active_widget->set_relative_rect(rect());
|
||||
m_active_widget->set_visible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void GStackWidget::resize_event(GResizeEvent& event)
|
||||
{
|
||||
if (!m_active_widget)
|
||||
return;
|
||||
m_active_widget->set_relative_rect({ {}, event.size() });
|
||||
}
|
||||
|
||||
void GStackWidget::child_event(CChildEvent& event)
|
||||
{
|
||||
if (!event.child() || !is<GWidget>(*event.child()))
|
||||
return GWidget::child_event(event);
|
||||
auto& child = to<GWidget>(*event.child());
|
||||
if (event.type() == GEvent::ChildAdded) {
|
||||
if (!m_active_widget)
|
||||
set_active_widget(&child);
|
||||
else if (m_active_widget != &child)
|
||||
child.set_visible(false);
|
||||
} else if (event.type() == GEvent::ChildRemoved) {
|
||||
if (m_active_widget == &child) {
|
||||
GWidget* new_active_widget = nullptr;
|
||||
for_each_child_widget([&](auto& new_child) {
|
||||
new_active_widget = &new_child;
|
||||
return IterationDecision::Break;
|
||||
});
|
||||
set_active_widget(new_active_widget);
|
||||
}
|
||||
}
|
||||
GWidget::child_event(event);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue