summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-30 16:18:05 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-30 16:18:05 +0200
commit86aad5081839ba834bb938abad934b73061f24c1 (patch)
tree3e0aa497e88322cad635a9e5ec67f57791df2012 /Applications
parentfb0c598d22909f479558f2eb543836c1d82dc4e7 (diff)
downloadserenity-86aad5081839ba834bb938abad934b73061f24c1.zip
VisualBuilder: Add GSlider to the widgets toolbox.
Diffstat (limited to 'Applications')
-rw-r--r--Applications/VisualBuilder/VBWidget.cpp7
-rw-r--r--Applications/VisualBuilder/VBWidgetRegistry.cpp8
-rw-r--r--Applications/VisualBuilder/VBWidgetType.h1
-rw-r--r--Applications/VisualBuilder/main.cpp7
4 files changed, 23 insertions, 0 deletions
diff --git a/Applications/VisualBuilder/VBWidget.cpp b/Applications/VisualBuilder/VBWidget.cpp
index 6341b35cd3..83e92167de 100644
--- a/Applications/VisualBuilder/VBWidget.cpp
+++ b/Applications/VisualBuilder/VBWidget.cpp
@@ -12,6 +12,7 @@
#include <LibGUI/GGroupBox.h>
#include <LibGUI/GCheckBox.h>
#include <LibGUI/GProgressBar.h>
+#include <LibGUI/GSlider.h>
VBWidget::VBWidget(VBWidgetType type, VBForm& form)
: m_type(type)
@@ -148,6 +149,12 @@ void VBWidget::setup_properties()
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) {
VB_ADD_PROPERTY(GTextEditor, "text", text, set_text, string);
VB_ADD_PROPERTY(GTextEditor, "ruler_visible", is_ruler_visible, set_ruler_visible, bool);
diff --git a/Applications/VisualBuilder/VBWidgetRegistry.cpp b/Applications/VisualBuilder/VBWidgetRegistry.cpp
index 7aacaddda3..3bde68ec3d 100644
--- a/Applications/VisualBuilder/VBWidgetRegistry.cpp
+++ b/Applications/VisualBuilder/VBWidgetRegistry.cpp
@@ -8,6 +8,7 @@
#include <LibGUI/GCheckBox.h>
#include <LibGUI/GScrollBar.h>
#include <LibGUI/GGroupBox.h>
+#include <LibGUI/GSlider.h>
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::GScrollBar: return "GScrollBar";
case VBWidgetType::GGroupBox: return "GGroupBox";
+ case VBWidgetType::GSlider: return "GSlider";
default: ASSERT_NOT_REACHED();
}
}
@@ -63,6 +65,12 @@ static GWidget* build_gwidget(VBWidgetType type, GWidget* parent)
bar->set_value(50);
return bar;
}
+ case VBWidgetType::GSlider: {
+ auto* slider = new GSlider(parent);
+ slider->set_range(0, 100);
+ slider->set_value(50);
+ return slider;
+ }
case VBWidgetType::GCheckBox: {
auto* box = new GCheckBox(parent);
box->set_caption("checkbox_1");
diff --git a/Applications/VisualBuilder/VBWidgetType.h b/Applications/VisualBuilder/VBWidgetType.h
index 6ca8a6f4b2..1d0487a478 100644
--- a/Applications/VisualBuilder/VBWidgetType.h
+++ b/Applications/VisualBuilder/VBWidgetType.h
@@ -11,5 +11,6 @@ enum class VBWidgetType {
GCheckBox,
GScrollBar,
GGroupBox,
+ GSlider,
__Count
};
diff --git a/Applications/VisualBuilder/main.cpp b/Applications/VisualBuilder/main.cpp
index b994315a36..0e00ab45c5 100644
--- a/Applications/VisualBuilder/main.cpp
+++ b/Applications/VisualBuilder/main.cpp
@@ -112,6 +112,13 @@ GWindow* make_toolbox_window()
if (auto* form = VBForm::current())
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);
checkbox_button->set_tooltip("GCheckBox");
checkbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));