mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:27:35 +00:00
VisualBuilder: Add icons to the toolbox, and support for GProgressBar.
This commit is contained in:
parent
75c76f6692
commit
b5d1cfef58
9 changed files with 40 additions and 16 deletions
|
@ -5,6 +5,7 @@
|
|||
#include <LibGUI/GButton.h>
|
||||
#include <LibGUI/GSpinBox.h>
|
||||
#include <LibGUI/GTextEditor.h>
|
||||
#include <LibGUI/GProgressBar.h>
|
||||
|
||||
static GWidget* build_gwidget(WidgetType type, GWidget* parent)
|
||||
{
|
||||
|
@ -22,6 +23,13 @@ static GWidget* build_gwidget(WidgetType type, GWidget* parent)
|
|||
editor->set_ruler_visible(false);
|
||||
return editor;
|
||||
}
|
||||
case WidgetType::GProgressBar: {
|
||||
auto* bar = new GProgressBar(parent);
|
||||
bar->set_format(GProgressBar::Format::NoText);
|
||||
bar->set_range(0, 100);
|
||||
bar->set_value(50);
|
||||
return bar;
|
||||
}
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
return nullptr;
|
||||
|
|
|
@ -30,6 +30,7 @@ enum class WidgetType {
|
|||
GLabel,
|
||||
GSpinBox,
|
||||
GTextEditor,
|
||||
GProgressBar,
|
||||
};
|
||||
|
||||
class VBWidget : public Retainable<VBWidget>, public Weakable<VBWidget> {
|
||||
|
|
|
@ -67,22 +67,32 @@ GWindow* make_toolbox_window()
|
|||
window->set_main_widget(widget);
|
||||
|
||||
auto* button_button = new GButton(widget);
|
||||
button_button->set_caption("Button");
|
||||
button_button->set_tooltip("GButton");
|
||||
button_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/button.png"));
|
||||
button_button->on_click = [] (GButton&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(WidgetType::GButton);
|
||||
};
|
||||
auto* spinbox_button = new GButton(widget);
|
||||
spinbox_button->set_caption("SpinBox");
|
||||
spinbox_button->set_tooltip("GSpinBox");
|
||||
spinbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
|
||||
spinbox_button->on_click = [] (GButton&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(WidgetType::GSpinBox);
|
||||
};
|
||||
auto* editor_button = new GButton(widget);
|
||||
editor_button->set_caption("TextEditor");
|
||||
editor_button->set_tooltip("GTextEditor");
|
||||
editor_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
|
||||
editor_button->on_click = [] (GButton&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(WidgetType::GTextEditor);
|
||||
};
|
||||
auto* progress_bar_button = new GButton(widget);
|
||||
progress_bar_button->set_tooltip("GProgressBar");
|
||||
progress_bar_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/progressbar.png"));
|
||||
progress_bar_button->on_click = [] (GButton&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(WidgetType::GProgressBar);
|
||||
};
|
||||
return window;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue