summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-21 16:33:53 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-21 16:33:53 +0200
commit7aaad27778790fab3be9056c54d2ba0f6dc78ff3 (patch)
treeb83dbe726b3cee74edd738fe1e9272b3d738ee19
parenta50cfc5f1f7d5675ed27623db4b87469a48f4db4 (diff)
downloadserenity-7aaad27778790fab3be9056c54d2ba0f6dc78ff3.zip
LibGUI: Convert GSlider to ObjectPtr
-rw-r--r--Applications/Terminal/main.cpp2
-rwxr-xr-xDemos/WidgetGallery/main.cpp12
-rw-r--r--DevTools/VisualBuilder/VBWidgetRegistry.cpp2
-rwxr-xr-xLibraries/LibGUI/GSlider.h4
4 files changed, 11 insertions, 9 deletions
diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp
index 87fa692d02..8304cd0b25 100644
--- a/Applications/Terminal/main.cpp
+++ b/Applications/Terminal/main.cpp
@@ -121,7 +121,7 @@ GWindow* create_settings_window(TerminalWidget& terminal, RefPtr<CConfigFile> co
slider_container->set_fill_with_background_color(true);
slider_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
slider_container->set_preferred_size(100, 50);
- auto* slider = new GSlider(Orientation::Horizontal, slider_container);
+ auto slider = GSlider::construct(Orientation::Horizontal, slider_container);
slider->set_fill_with_background_color(true);
slider->set_background_color(Color::WarmGray);
diff --git a/Demos/WidgetGallery/main.cpp b/Demos/WidgetGallery/main.cpp
index 5c870c3646..8ff79ebb72 100755
--- a/Demos/WidgetGallery/main.cpp
+++ b/Demos/WidgetGallery/main.cpp
@@ -70,19 +70,19 @@ int main(int argc, char** argv)
vertical_slider_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
vertical_slider_container->set_preferred_size(0, 100);
vertical_slider_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
- auto* vslider1 = new GSlider(Orientation::Vertical, vertical_slider_container);
+ auto vslider1 = GSlider::construct(Orientation::Vertical, vertical_slider_container);
(void)vslider1;
- auto* vslider2 = new GSlider(Orientation::Vertical, vertical_slider_container);
+ auto vslider2 = GSlider::construct(Orientation::Vertical, vertical_slider_container);
vslider2->set_enabled(false);
- auto* vslider3 = new GSlider(Orientation::Vertical, vertical_slider_container);
+ auto vslider3 = GSlider::construct(Orientation::Vertical, vertical_slider_container);
vslider3->set_max(5);
vslider3->set_knob_size_mode(GSlider::KnobSizeMode::Proportional);
- auto* slider1 = new GSlider(Orientation::Horizontal, main_widget);
+ auto slider1 = GSlider::construct(Orientation::Horizontal, main_widget);
(void)slider1;
- auto* slider2 = new GSlider(Orientation::Horizontal, main_widget);
+ auto slider2 = GSlider::construct(Orientation::Horizontal, main_widget);
slider2->set_enabled(false);
- auto* slider3 = new GSlider(Orientation::Horizontal, main_widget);
+ auto slider3 = GSlider::construct(Orientation::Horizontal, main_widget);
slider3->set_max(5);
slider3->set_knob_size_mode(GSlider::KnobSizeMode::Proportional);
diff --git a/DevTools/VisualBuilder/VBWidgetRegistry.cpp b/DevTools/VisualBuilder/VBWidgetRegistry.cpp
index 8961b55690..e3b9ca25a5 100644
--- a/DevTools/VisualBuilder/VBWidgetRegistry.cpp
+++ b/DevTools/VisualBuilder/VBWidgetRegistry.cpp
@@ -107,7 +107,7 @@ static GWidget* build_gwidget(VBWidgetType type, GWidget* parent)
return bar;
}
case VBWidgetType::GSlider: {
- auto* slider = new GSlider(Orientation::Horizontal, parent);
+ auto slider = GSlider::construct(Orientation::Horizontal, parent);
slider->set_range(0, 100);
slider->set_value(50);
return slider;
diff --git a/Libraries/LibGUI/GSlider.h b/Libraries/LibGUI/GSlider.h
index bfd787cbd3..7aa84ecf83 100755
--- a/Libraries/LibGUI/GSlider.h
+++ b/Libraries/LibGUI/GSlider.h
@@ -3,13 +3,13 @@
#include <LibGUI/GWidget.h>
class GSlider : public GWidget {
+ C_OBJECT(GSlider)
public:
enum class KnobSizeMode {
Fixed,
Proportional,
};
- GSlider(Orientation, GWidget*);
virtual ~GSlider() override;
Orientation orientation() const { return m_orientation; }
@@ -43,6 +43,8 @@ public:
Function<void(int)> on_value_changed;
protected:
+ GSlider(Orientation, GWidget*);
+
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;