VisualBuilder: Add GCheckBox and GLabel, and draw icons for them, too.

This commit is contained in:
Andreas Kling 2019-04-11 06:32:27 +02:00
parent b5d1cfef58
commit f25c524f20
Notes: sideshowbarker 2024-07-19 14:45:33 +09:00
5 changed files with 38 additions and 6 deletions

View File

@ -6,18 +6,29 @@
#include <LibGUI/GSpinBox.h>
#include <LibGUI/GTextEditor.h>
#include <LibGUI/GProgressBar.h>
#include <LibGUI/GCheckBox.h>
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;

View File

@ -31,6 +31,7 @@ enum class WidgetType {
GSpinBox,
GTextEditor,
GProgressBar,
GCheckBox,
};
class VBWidget : public Retainable<VBWidget>, public Weakable<VBWidget> {

View File

@ -66,6 +66,14 @@ GWindow* make_toolbox_window()
widget->set_layout(make<GBoxLayout>(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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B