summaryrefslogtreecommitdiff
path: root/DevTools
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-08 21:19:49 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-09 00:41:00 +0100
commit489c6ac05cc9326b5b2a7719cdd1ff9d87fcea5c (patch)
treef06eb28cad67c7c30a2ff61cb5d6c4346391df67 /DevTools
parentd22d9874f7e50cfd9b085765bc83b8032bade7cc (diff)
downloadserenity-489c6ac05cc9326b5b2a7719cdd1ff9d87fcea5c.zip
HackStudio: Add a widgets toolbar to the form editing mode
Diffstat (limited to 'DevTools')
-rw-r--r--DevTools/HackStudio/main.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp
index d4e508f399..1505f15f75 100644
--- a/DevTools/HackStudio/main.cpp
+++ b/DevTools/HackStudio/main.cpp
@@ -38,7 +38,8 @@ OwnPtr<Project> g_project;
RefPtr<GWindow> g_window;
RefPtr<GListView> g_project_list_view;
RefPtr<GStackWidget> g_right_hand_stack;
-RefPtr<GSplitter> g_inner_splitter;
+RefPtr<GSplitter> g_text_inner_splitter;
+RefPtr<GWidget> g_form_inner_container;
RefPtr<FormEditorWidget> g_form_editor_widget;
static RefPtr<GTabWidget> s_action_tab_widget;
@@ -64,9 +65,9 @@ enum class EditMode {
void set_edit_mode(EditMode mode)
{
if (mode == EditMode::Text) {
- g_right_hand_stack->set_active_widget(g_inner_splitter);
+ g_right_hand_stack->set_active_widget(g_text_inner_splitter);
} else if (mode == EditMode::Form) {
- g_right_hand_stack->set_active_widget(g_form_editor_widget);
+ g_right_hand_stack->set_active_widget(g_form_inner_container);
}
}
@@ -119,11 +120,20 @@ int main(int argc, char** argv)
g_right_hand_stack = GStackWidget::construct(outer_splitter);
- g_form_editor_widget = FormEditorWidget::construct(g_right_hand_stack);
+ g_form_inner_container = GWidget::construct(g_right_hand_stack);
+ g_form_inner_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
+ auto form_widgets_toolbar = GToolBar::construct(Orientation::Vertical, 26, g_form_inner_container);
+ form_widgets_toolbar->set_preferred_size(38, 0);
- g_inner_splitter = GSplitter::construct(Orientation::Vertical, g_right_hand_stack);
- g_inner_splitter->layout()->set_margins({ 0, 3, 0, 0 });
- add_new_editor(*g_inner_splitter);
+ form_widgets_toolbar->add_action(GAction::create("GLabel", GraphicsBitmap::load_from_file("/res/icons/vbwidgets/label.png"), [&](auto&) {}));
+ form_widgets_toolbar->add_action(GAction::create("GButton", GraphicsBitmap::load_from_file("/res/icons/vbwidgets/button.png"), [&](auto&) {}));
+ form_widgets_toolbar->add_action(GAction::create("GSpinBox", GraphicsBitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"), [&](auto&) {}));
+
+ g_form_editor_widget = FormEditorWidget::construct(g_form_inner_container);
+
+ g_text_inner_splitter = GSplitter::construct(Orientation::Vertical, g_right_hand_stack);
+ g_text_inner_splitter->layout()->set_margins({ 0, 3, 0, 0 });
+ add_new_editor(*g_text_inner_splitter);
auto new_action = GAction::create("Add new file to project...", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GAction&) {
auto input_box = GInputBox::construct("Enter name of new file:", "Add new file to project", g_window);
@@ -159,7 +169,7 @@ int main(int argc, char** argv)
if (g_all_editor_wrappers.size() <= 1)
return;
Vector<EditorWrapper*> wrappers;
- g_inner_splitter->for_each_child_of_type<EditorWrapper>([&](auto& child) {
+ g_text_inner_splitter->for_each_child_of_type<EditorWrapper>([&](auto& child) {
wrappers.append(&child);
return IterationDecision::Continue;
});
@@ -177,7 +187,7 @@ int main(int argc, char** argv)
if (g_all_editor_wrappers.size() <= 1)
return;
Vector<EditorWrapper*> wrappers;
- g_inner_splitter->for_each_child_of_type<EditorWrapper>([&](auto& child) {
+ g_text_inner_splitter->for_each_child_of_type<EditorWrapper>([&](auto& child) {
wrappers.append(&child);
return IterationDecision::Continue;
});
@@ -196,7 +206,7 @@ int main(int argc, char** argv)
return;
auto wrapper = g_current_editor_wrapper;
switch_to_next_editor->activate();
- g_inner_splitter->remove_child(*wrapper);
+ g_text_inner_splitter->remove_child(*wrapper);
g_all_editor_wrappers.remove_first_matching([&](auto& entry) { return entry == wrapper.ptr(); });
update_actions();
});
@@ -225,7 +235,7 @@ int main(int argc, char** argv)
open_file(filename);
};
- s_action_tab_widget = GTabWidget::construct(g_inner_splitter);
+ s_action_tab_widget = GTabWidget::construct(g_text_inner_splitter);
s_action_tab_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
s_action_tab_widget->set_preferred_size(0, 24);
@@ -245,7 +255,7 @@ int main(int argc, char** argv)
});
auto add_editor_action = GAction::create("Add new editor", { Mod_Ctrl | Mod_Alt, Key_E }, [&](auto&) {
- add_new_editor(*g_inner_splitter);
+ add_new_editor(*g_text_inner_splitter);
update_actions();
});
@@ -324,7 +334,7 @@ int main(int argc, char** argv)
remove_current_editor_action->set_enabled(g_all_editor_wrappers.size() > 1);
};
- open_file("main.cpp");
+ open_file("test.frm");
update_actions();
return app.exec();