summaryrefslogtreecommitdiff
path: root/LibGUI/GWidget.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-15 16:12:06 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-15 16:12:06 +0100
commit497300c492c6272df14b0190f19848a25ab6b0de (patch)
treef6bbba43100045cde823576614ffc518af22bb01 /LibGUI/GWidget.cpp
parentab92252ee641cb5c6eb4f188b3ad403bb4db5caa (diff)
downloadserenity-497300c492c6272df14b0190f19848a25ab6b0de.zip
LibGUI: Add a GStackWidget for many widgets sharing a single location.
Call set_active_widget(GWidget*) to put a new widget on top.
Diffstat (limited to 'LibGUI/GWidget.cpp')
-rw-r--r--LibGUI/GWidget.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/LibGUI/GWidget.cpp b/LibGUI/GWidget.cpp
index f6e5e1568e..5a02ce2887 100644
--- a/LibGUI/GWidget.cpp
+++ b/LibGUI/GWidget.cpp
@@ -91,6 +91,8 @@ void GWidget::handle_paint_event(GPaintEvent& event)
paint_event(event);
for (auto* ch : children()) {
auto* child = (GWidget*)ch;
+ if (!child->is_visible())
+ continue;
if (child->relative_rect().intersects(event.rect())) {
auto local_rect = event.rect();
local_rect.intersect(child->relative_rect());
@@ -303,3 +305,14 @@ void GWidget::invalidate_layout()
return;
w->main_widget()->do_layout();
}
+
+void GWidget::set_visible(bool visible)
+{
+ if (visible == m_visible)
+ return;
+ m_visible = visible;
+ if (auto* parent = parent_widget())
+ parent->invalidate_layout();
+ if (m_visible)
+ update();
+}