summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-10 11:10:04 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-10 12:57:37 +0100
commitf92e0f7d80c04e04fb93cd3a507ad97fa400fd4b (patch)
tree60e921309093f501c238e616ea13032c6cca0851
parent2da058c7f28bbcb5c9135978e6178704e5c4162b (diff)
downloadserenity-f92e0f7d80c04e04fb93cd3a507ad97fa400fd4b.zip
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.
-rw-r--r--DevTools/HackStudio/FormEditorWidget.h3
-rw-r--r--DevTools/HackStudio/main.cpp6
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), [&reg](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));
});