summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-05 14:42:05 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-05 14:42:05 +0100
commite23c5b7e83fe6de92f5d4796ea50e368002a2d2e (patch)
tree53f67575945be08b276d709b269f0a8857bad4c0 /Libraries
parentd16f8214d89348062c19908d8651ac94d13c5aa9 (diff)
downloadserenity-e23c5b7e83fe6de92f5d4796ea50e368002a2d2e.zip
LibGUI+Inspector: Highlight the currently remotely inspected widget
This patch adds a magenta rectangle around the currently inspected widget. This allows you to browse an app's widget tree somewhat visually using the Inspector. :^)
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/Widget.cpp15
-rw-r--r--Libraries/LibGUI/Widget.h3
2 files changed, 18 insertions, 0 deletions
diff --git a/Libraries/LibGUI/Widget.cpp b/Libraries/LibGUI/Widget.cpp
index 08d2273f57..b225598d5a 100644
--- a/Libraries/LibGUI/Widget.cpp
+++ b/Libraries/LibGUI/Widget.cpp
@@ -240,6 +240,11 @@ void Widget::handle_paint_event(PaintEvent& event)
return IterationDecision::Continue;
});
second_paint_event(event);
+
+ if (is_being_inspected()) {
+ Painter painter(*this);
+ painter.draw_rect(rect(), Color::Magenta);
+ }
}
void Widget::set_layout(NonnullRefPtr<Layout> layout)
@@ -763,4 +768,14 @@ Gfx::Palette Widget::palette() const
return Gfx::Palette(*m_palette);
}
+void Widget::did_begin_inspection()
+{
+ update();
+}
+
+void Widget::did_end_inspection()
+{
+ update();
+}
+
}
diff --git a/Libraries/LibGUI/Widget.h b/Libraries/LibGUI/Widget.h
index b0e4b5e3cd..80d4f740cf 100644
--- a/Libraries/LibGUI/Widget.h
+++ b/Libraries/LibGUI/Widget.h
@@ -293,6 +293,9 @@ protected:
virtual void drag_move_event(DragEvent&);
virtual void drop_event(DropEvent&);
+ virtual void did_begin_inspection() override;
+ virtual void did_end_inspection() override;
+
private:
void handle_paint_event(PaintEvent&);
void handle_resize_event(ResizeEvent&);