diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-11 19:37:01 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-11 22:20:02 +0100 |
commit | 2fea2386757ffb89e8394be785e24bfdc5bb867b (patch) | |
tree | 002ee897750982ad32c9807c07231b613f3dfea1 /DevTools/HackStudio/FormEditorWidget.h | |
parent | 812ee330e6977fcd7db614b5116581ed1e4c8013 (diff) | |
download | serenity-2fea2386757ffb89e8394be785e24bfdc5bb867b.zip |
HackStudio: Reflect widget selections in the form widget tree view
You can now manipulate the widget selection either by clicking and
dragging the widgets using the cursor tool, or by interacting with
the form widget tree view. :^)
Diffstat (limited to 'DevTools/HackStudio/FormEditorWidget.h')
-rw-r--r-- | DevTools/HackStudio/FormEditorWidget.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/DevTools/HackStudio/FormEditorWidget.h b/DevTools/HackStudio/FormEditorWidget.h index 04758ab263..bfe557be33 100644 --- a/DevTools/HackStudio/FormEditorWidget.h +++ b/DevTools/HackStudio/FormEditorWidget.h @@ -23,6 +23,13 @@ public: class WidgetSelection { public: + Function<void(GWidget&)> on_remove; + Function<void(GWidget&)> on_add; + Function<void()> on_clear; + + void enable_hooks() { m_hooks_enabled = true; } + void disable_hooks() { m_hooks_enabled = false; } + bool is_empty() const { return m_widgets.is_empty(); @@ -51,16 +58,22 @@ public: { ASSERT(m_widgets.contains(&widget)); m_widgets.remove(&widget); + if (m_hooks_enabled && on_remove) + on_remove(widget); } void add(GWidget& widget) { m_widgets.set(&widget); + if (m_hooks_enabled && on_add) + on_add(widget); } void clear() { m_widgets.clear(); + if (m_hooks_enabled && on_clear) + on_clear(); } template<typename Callback> @@ -76,6 +89,7 @@ public: private: HashTable<GWidget*> m_widgets; + bool m_hooks_enabled { true }; }; WidgetSelection& selection() { return m_selection; } |