mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:57:35 +00:00
VisualBuilder: Add GSlider to the widgets toolbox.
This commit is contained in:
parent
fb0c598d22
commit
86aad50818
6 changed files with 26 additions and 0 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include <LibGUI/GGroupBox.h>
|
#include <LibGUI/GGroupBox.h>
|
||||||
#include <LibGUI/GCheckBox.h>
|
#include <LibGUI/GCheckBox.h>
|
||||||
#include <LibGUI/GProgressBar.h>
|
#include <LibGUI/GProgressBar.h>
|
||||||
|
#include <LibGUI/GSlider.h>
|
||||||
|
|
||||||
VBWidget::VBWidget(VBWidgetType type, VBForm& form)
|
VBWidget::VBWidget(VBWidgetType type, VBForm& form)
|
||||||
: m_type(type)
|
: m_type(type)
|
||||||
|
@ -148,6 +149,12 @@ void VBWidget::setup_properties()
|
||||||
VB_ADD_PROPERTY(GProgressBar, "value", value, set_value, int);
|
VB_ADD_PROPERTY(GProgressBar, "value", value, set_value, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_type == VBWidgetType::GSlider) {
|
||||||
|
VB_ADD_PROPERTY(GSlider, "min", min, set_min, int);
|
||||||
|
VB_ADD_PROPERTY(GSlider, "max", max, set_max, int);
|
||||||
|
VB_ADD_PROPERTY(GSlider, "value", value, set_value, int);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_type == VBWidgetType::GTextEditor) {
|
if (m_type == VBWidgetType::GTextEditor) {
|
||||||
VB_ADD_PROPERTY(GTextEditor, "text", text, set_text, string);
|
VB_ADD_PROPERTY(GTextEditor, "text", text, set_text, string);
|
||||||
VB_ADD_PROPERTY(GTextEditor, "ruler_visible", is_ruler_visible, set_ruler_visible, bool);
|
VB_ADD_PROPERTY(GTextEditor, "ruler_visible", is_ruler_visible, set_ruler_visible, bool);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <LibGUI/GCheckBox.h>
|
#include <LibGUI/GCheckBox.h>
|
||||||
#include <LibGUI/GScrollBar.h>
|
#include <LibGUI/GScrollBar.h>
|
||||||
#include <LibGUI/GGroupBox.h>
|
#include <LibGUI/GGroupBox.h>
|
||||||
|
#include <LibGUI/GSlider.h>
|
||||||
|
|
||||||
static String to_class_name(VBWidgetType type)
|
static String to_class_name(VBWidgetType type)
|
||||||
{
|
{
|
||||||
|
@ -21,6 +22,7 @@ static String to_class_name(VBWidgetType type)
|
||||||
case VBWidgetType::GCheckBox: return "GCheckBox";
|
case VBWidgetType::GCheckBox: return "GCheckBox";
|
||||||
case VBWidgetType::GScrollBar: return "GScrollBar";
|
case VBWidgetType::GScrollBar: return "GScrollBar";
|
||||||
case VBWidgetType::GGroupBox: return "GGroupBox";
|
case VBWidgetType::GGroupBox: return "GGroupBox";
|
||||||
|
case VBWidgetType::GSlider: return "GSlider";
|
||||||
default: ASSERT_NOT_REACHED();
|
default: ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,6 +65,12 @@ static GWidget* build_gwidget(VBWidgetType type, GWidget* parent)
|
||||||
bar->set_value(50);
|
bar->set_value(50);
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
|
case VBWidgetType::GSlider: {
|
||||||
|
auto* slider = new GSlider(parent);
|
||||||
|
slider->set_range(0, 100);
|
||||||
|
slider->set_value(50);
|
||||||
|
return slider;
|
||||||
|
}
|
||||||
case VBWidgetType::GCheckBox: {
|
case VBWidgetType::GCheckBox: {
|
||||||
auto* box = new GCheckBox(parent);
|
auto* box = new GCheckBox(parent);
|
||||||
box->set_caption("checkbox_1");
|
box->set_caption("checkbox_1");
|
||||||
|
|
|
@ -11,5 +11,6 @@ enum class VBWidgetType {
|
||||||
GCheckBox,
|
GCheckBox,
|
||||||
GScrollBar,
|
GScrollBar,
|
||||||
GGroupBox,
|
GGroupBox,
|
||||||
|
GSlider,
|
||||||
__Count
|
__Count
|
||||||
};
|
};
|
||||||
|
|
|
@ -112,6 +112,13 @@ GWindow* make_toolbox_window()
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GProgressBar);
|
form->insert_widget(VBWidgetType::GProgressBar);
|
||||||
};
|
};
|
||||||
|
auto* slider_button = new GButton(widget);
|
||||||
|
slider_button->set_tooltip("GSlider");
|
||||||
|
slider_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
|
||||||
|
slider_button->on_click = [] (GButton&) {
|
||||||
|
if (auto* form = VBForm::current())
|
||||||
|
form->insert_widget(VBWidgetType::GSlider);
|
||||||
|
};
|
||||||
auto* checkbox_button = new GButton(widget);
|
auto* checkbox_button = new GButton(widget);
|
||||||
checkbox_button->set_tooltip("GCheckBox");
|
checkbox_button->set_tooltip("GCheckBox");
|
||||||
checkbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
|
checkbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
|
||||||
|
|
BIN
Base/res/icons/vbwidgets/slider.png
Normal file
BIN
Base/res/icons/vbwidgets/slider.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 177 B |
|
@ -14,6 +14,9 @@ public:
|
||||||
void set_range(int min, int max);
|
void set_range(int min, int max);
|
||||||
void set_value(int);
|
void set_value(int);
|
||||||
|
|
||||||
|
void set_min(int min) { set_range(min, max()); }
|
||||||
|
void set_max(int max) { set_range(min(), max); }
|
||||||
|
|
||||||
int track_height() const { return 2; }
|
int track_height() const { return 2; }
|
||||||
int knob_width() const { return 8; }
|
int knob_width() const { return 8; }
|
||||||
int knob_height() const { return 20; }
|
int knob_height() const { return 20; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue