From f92e0f7d80c04e04fb93cd3a507ad97fa400fd4b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 10 Nov 2019 11:10:04 +0100 Subject: HackStudio: Add placeholder code to test widget factory construction We now use the magical widget registry to factory-construct widgets and place them into the form. This will need all kinds of work, but it's nice that the mechanism is working as intended. --- DevTools/HackStudio/FormEditorWidget.h | 3 +++ DevTools/HackStudio/main.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/DevTools/HackStudio/FormEditorWidget.h b/DevTools/HackStudio/FormEditorWidget.h index ef53044f8f..7f04cf4248 100644 --- a/DevTools/HackStudio/FormEditorWidget.h +++ b/DevTools/HackStudio/FormEditorWidget.h @@ -9,6 +9,9 @@ class FormEditorWidget final : public GScrollableWidget { public: virtual ~FormEditorWidget() override; + FormWidget& form_widget() { return *m_form_widget; } + const FormWidget& form_widget() const { return *m_form_widget; } + private: virtual void paint_event(GPaintEvent&) override; diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index cf8df9a7d6..0da3e184fe 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -3,6 +3,7 @@ #include "EditorWrapper.h" #include "FindInFilesWidget.h" #include "FormEditorWidget.h" +#include "FormWidget.h" #include "Locator.h" #include "Project.h" #include "TerminalWrapper.h" @@ -132,8 +133,9 @@ int main(int argc, char** argv) GWidgetClassRegistration::for_each([&](const GWidgetClassRegistration& reg) { auto icon_path = String::format("/res/icons/widgets/%s.png", reg.class_name().characters()); - auto action = GAction::create(reg.class_name(), GraphicsBitmap::load_from_file(icon_path), [&](auto&) { - + auto action = GAction::create(reg.class_name(), GraphicsBitmap::load_from_file(icon_path), [®](auto&) { + auto widget = reg.construct(&g_form_editor_widget->form_widget()); + widget->set_relative_rect(30, 30, 30, 30); }); form_widgets_toolbar->add_action(move(action)); }); -- cgit v1.2.3