diff --git a/Applications/VisualBuilder/VBWidget.cpp b/Applications/VisualBuilder/VBWidget.cpp index be7b9669863..4bf5e9b377e 100644 --- a/Applications/VisualBuilder/VBWidget.cpp +++ b/Applications/VisualBuilder/VBWidget.cpp @@ -6,18 +6,29 @@ #include #include #include +#include static GWidget* build_gwidget(WidgetType type, GWidget* parent) { switch (type) { case WidgetType::GWidget: return new GWidget(parent); - case WidgetType::GLabel: - return new GLabel(parent); - case WidgetType::GButton: - return new GButton(parent); - case WidgetType::GSpinBox: - return new GSpinBox(parent); + case WidgetType::GLabel: { + auto* label = new GLabel(parent); + label->set_text("label_1"); + return label; + } + case WidgetType::GButton: { + auto* button = new GButton(parent); + button->set_caption("button_1"); + return button; + } + case WidgetType::GSpinBox: { + auto* box = new GSpinBox(parent); + box->set_range(0, 100); + box->set_value(0); + return box; + } case WidgetType::GTextEditor: { auto* editor = new GTextEditor(GTextEditor::Type::MultiLine, parent); editor->set_ruler_visible(false); @@ -30,6 +41,11 @@ static GWidget* build_gwidget(WidgetType type, GWidget* parent) bar->set_value(50); return bar; } + case WidgetType::GCheckBox: { + auto* box = new GCheckBox(parent); + box->set_caption("checkbox_1"); + return box; + } default: ASSERT_NOT_REACHED(); return nullptr; diff --git a/Applications/VisualBuilder/VBWidget.h b/Applications/VisualBuilder/VBWidget.h index d0576bdf0cc..c88305b5f1a 100644 --- a/Applications/VisualBuilder/VBWidget.h +++ b/Applications/VisualBuilder/VBWidget.h @@ -31,6 +31,7 @@ enum class WidgetType { GSpinBox, GTextEditor, GProgressBar, + GCheckBox, }; class VBWidget : public Retainable, public Weakable { diff --git a/Applications/VisualBuilder/main.cpp b/Applications/VisualBuilder/main.cpp index 5926a57352f..b1ed9ee5fcc 100644 --- a/Applications/VisualBuilder/main.cpp +++ b/Applications/VisualBuilder/main.cpp @@ -66,6 +66,14 @@ GWindow* make_toolbox_window() widget->set_layout(make(Orientation::Vertical)); window->set_main_widget(widget); + auto* label_button = new GButton(widget); + label_button->set_tooltip("GLabel"); + label_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/label.png")); + label_button->on_click = [] (GButton&) { + if (auto* form = VBForm::current()) + form->insert_widget(WidgetType::GLabel); + }; + auto* button_button = new GButton(widget); button_button->set_tooltip("GButton"); button_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/button.png")); @@ -94,5 +102,12 @@ GWindow* make_toolbox_window() if (auto* form = VBForm::current()) form->insert_widget(WidgetType::GProgressBar); }; + auto* checkbox_button = new GButton(widget); + checkbox_button->set_tooltip("GCheckBox"); + checkbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/checkbox.png")); + checkbox_button->on_click = [] (GButton&) { + if (auto* form = VBForm::current()) + form->insert_widget(WidgetType::GCheckBox); + }; return window; } diff --git a/Base/res/icons/vbwidgets/checkbox.png b/Base/res/icons/vbwidgets/checkbox.png new file mode 100644 index 00000000000..192972a22ca Binary files /dev/null and b/Base/res/icons/vbwidgets/checkbox.png differ diff --git a/Base/res/icons/vbwidgets/label.png b/Base/res/icons/vbwidgets/label.png new file mode 100644 index 00000000000..b6eb3a49f68 Binary files /dev/null and b/Base/res/icons/vbwidgets/label.png differ