From 7aaad27778790fab3be9056c54d2ba0f6dc78ff3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 21 Sep 2019 16:33:53 +0200 Subject: LibGUI: Convert GSlider to ObjectPtr --- Applications/Terminal/main.cpp | 2 +- Demos/WidgetGallery/main.cpp | 12 ++++++------ DevTools/VisualBuilder/VBWidgetRegistry.cpp | 2 +- Libraries/LibGUI/GSlider.h | 4 +++- 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 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(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 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 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; -- cgit v1.2.3