mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +00:00
VisualBuilder: Add GCheckBox and GLabel, and draw icons for them, too.
This commit is contained in:
parent
b5d1cfef58
commit
f25c524f20
5 changed files with 38 additions and 6 deletions
|
@ -6,18 +6,29 @@
|
||||||
#include <LibGUI/GSpinBox.h>
|
#include <LibGUI/GSpinBox.h>
|
||||||
#include <LibGUI/GTextEditor.h>
|
#include <LibGUI/GTextEditor.h>
|
||||||
#include <LibGUI/GProgressBar.h>
|
#include <LibGUI/GProgressBar.h>
|
||||||
|
#include <LibGUI/GCheckBox.h>
|
||||||
|
|
||||||
static GWidget* build_gwidget(WidgetType type, GWidget* parent)
|
static GWidget* build_gwidget(WidgetType type, GWidget* parent)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WidgetType::GWidget:
|
case WidgetType::GWidget:
|
||||||
return new GWidget(parent);
|
return new GWidget(parent);
|
||||||
case WidgetType::GLabel:
|
case WidgetType::GLabel: {
|
||||||
return new GLabel(parent);
|
auto* label = new GLabel(parent);
|
||||||
case WidgetType::GButton:
|
label->set_text("label_1");
|
||||||
return new GButton(parent);
|
return label;
|
||||||
case WidgetType::GSpinBox:
|
}
|
||||||
return new GSpinBox(parent);
|
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: {
|
case WidgetType::GTextEditor: {
|
||||||
auto* editor = new GTextEditor(GTextEditor::Type::MultiLine, parent);
|
auto* editor = new GTextEditor(GTextEditor::Type::MultiLine, parent);
|
||||||
editor->set_ruler_visible(false);
|
editor->set_ruler_visible(false);
|
||||||
|
@ -30,6 +41,11 @@ static GWidget* build_gwidget(WidgetType type, GWidget* parent)
|
||||||
bar->set_value(50);
|
bar->set_value(50);
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
|
case WidgetType::GCheckBox: {
|
||||||
|
auto* box = new GCheckBox(parent);
|
||||||
|
box->set_caption("checkbox_1");
|
||||||
|
return box;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -31,6 +31,7 @@ enum class WidgetType {
|
||||||
GSpinBox,
|
GSpinBox,
|
||||||
GTextEditor,
|
GTextEditor,
|
||||||
GProgressBar,
|
GProgressBar,
|
||||||
|
GCheckBox,
|
||||||
};
|
};
|
||||||
|
|
||||||
class VBWidget : public Retainable<VBWidget>, public Weakable<VBWidget> {
|
class VBWidget : public Retainable<VBWidget>, public Weakable<VBWidget> {
|
||||||
|
|
|
@ -66,6 +66,14 @@ GWindow* make_toolbox_window()
|
||||||
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||||
window->set_main_widget(widget);
|
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);
|
auto* button_button = new GButton(widget);
|
||||||
button_button->set_tooltip("GButton");
|
button_button->set_tooltip("GButton");
|
||||||
button_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/button.png"));
|
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())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(WidgetType::GProgressBar);
|
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;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
BIN
Base/res/icons/vbwidgets/checkbox.png
Normal file
BIN
Base/res/icons/vbwidgets/checkbox.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 184 B |
BIN
Base/res/icons/vbwidgets/label.png
Normal file
BIN
Base/res/icons/vbwidgets/label.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 162 B |
Loading…
Add table
Add a link
Reference in a new issue