summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-21 15:07:24 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-21 15:25:08 +0200
commitbce58bbbca6086270e74b32ee63435ca7bf2b0fb (patch)
tree359294e05e3d98420ffca3547ccbae4337efa219
parent4616a13e94a78ae4363428ce5c525685ef1c2b45 (diff)
downloadserenity-bce58bbbca6086270e74b32ee63435ca7bf2b0fb.zip
LibGUI: Convert GScrollBar to ObjectPtr
-rw-r--r--Applications/Terminal/TerminalWidget.cpp2
-rw-r--r--Applications/Terminal/TerminalWidget.h2
-rwxr-xr-xDemos/WidgetGallery/main.cpp4
-rw-r--r--DevTools/VisualBuilder/VBWidgetRegistry.cpp2
-rw-r--r--Libraries/LibGUI/GScrollBar.h3
-rw-r--r--Libraries/LibGUI/GScrollableWidget.cpp4
-rw-r--r--Libraries/LibGUI/GScrollableWidget.h4
7 files changed, 11 insertions, 10 deletions
diff --git a/Applications/Terminal/TerminalWidget.cpp b/Applications/Terminal/TerminalWidget.cpp
index a82bb27994..b2591c07c4 100644
--- a/Applications/Terminal/TerminalWidget.cpp
+++ b/Applications/Terminal/TerminalWidget.cpp
@@ -32,7 +32,7 @@ TerminalWidget::TerminalWidget(int ptm_fd, RefPtr<CConfigFile> config)
set_frame_shadow(FrameShadow::Sunken);
set_frame_thickness(2);
- m_scrollbar = new GScrollBar(Orientation::Vertical, this);
+ m_scrollbar = GScrollBar::construct(Orientation::Vertical, this);
m_scrollbar->set_relative_rect(0, 0, 16, 0);
m_scrollbar->on_change = [this](int) {
force_repaint();
diff --git a/Applications/Terminal/TerminalWidget.h b/Applications/Terminal/TerminalWidget.h
index 5324a15f42..d1a2f4321a 100644
--- a/Applications/Terminal/TerminalWidget.h
+++ b/Applications/Terminal/TerminalWidget.h
@@ -100,5 +100,5 @@ private:
ObjectPtr<CTimer> m_visual_beep_timer;
RefPtr<CConfigFile> m_config;
- GScrollBar* m_scrollbar { nullptr };
+ ObjectPtr<GScrollBar> m_scrollbar;
};
diff --git a/Demos/WidgetGallery/main.cpp b/Demos/WidgetGallery/main.cpp
index 5e08783485..0e1c8c89c8 100755
--- a/Demos/WidgetGallery/main.cpp
+++ b/Demos/WidgetGallery/main.cpp
@@ -86,13 +86,13 @@ int main(int argc, char** argv)
slider3->set_max(5);
slider3->set_knob_size_mode(GSlider::KnobSizeMode::Proportional);
- auto* scrollbar1 = new GScrollBar(Orientation::Horizontal, main_widget);
+ auto scrollbar1 = GScrollBar::construct(Orientation::Horizontal, main_widget);
scrollbar1->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
scrollbar1->set_preferred_size(0, 16);
scrollbar1->set_min(0);
scrollbar1->set_max(100);
scrollbar1->set_value(50);
- auto* scrollbar2 = new GScrollBar(Orientation::Horizontal, main_widget);
+ auto scrollbar2 = GScrollBar::construct(Orientation::Horizontal, main_widget);
scrollbar2->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
scrollbar2->set_preferred_size(0, 16);
scrollbar2->set_enabled(false);
diff --git a/DevTools/VisualBuilder/VBWidgetRegistry.cpp b/DevTools/VisualBuilder/VBWidgetRegistry.cpp
index d310f7e1e9..678bf64f28 100644
--- a/DevTools/VisualBuilder/VBWidgetRegistry.cpp
+++ b/DevTools/VisualBuilder/VBWidgetRegistry.cpp
@@ -74,7 +74,7 @@ static GWidget* build_gwidget(VBWidgetType type, GWidget* parent)
case VBWidgetType::GWidget:
return new GWidget(parent);
case VBWidgetType::GScrollBar:
- return new GScrollBar(Orientation::Vertical, parent);
+ return GScrollBar::construct(Orientation::Vertical, parent);
case VBWidgetType::GGroupBox:
return new GGroupBox("groupbox_1", parent);
case VBWidgetType::GLabel: {
diff --git a/Libraries/LibGUI/GScrollBar.h b/Libraries/LibGUI/GScrollBar.h
index ad81d2a8b8..e5d70ce68e 100644
--- a/Libraries/LibGUI/GScrollBar.h
+++ b/Libraries/LibGUI/GScrollBar.h
@@ -7,7 +7,6 @@
class GScrollBar final : public GWidget {
C_OBJECT(GScrollBar)
public:
- explicit GScrollBar(Orientation, GWidget* parent);
virtual ~GScrollBar() override;
Orientation orientation() const { return m_orientation; }
@@ -39,6 +38,8 @@ public:
};
private:
+ explicit GScrollBar(Orientation, GWidget* parent);
+
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
diff --git a/Libraries/LibGUI/GScrollableWidget.cpp b/Libraries/LibGUI/GScrollableWidget.cpp
index 597552a001..9379a6ada8 100644
--- a/Libraries/LibGUI/GScrollableWidget.cpp
+++ b/Libraries/LibGUI/GScrollableWidget.cpp
@@ -4,14 +4,14 @@
GScrollableWidget::GScrollableWidget(GWidget* parent)
: GFrame(parent)
{
- m_vertical_scrollbar = new GScrollBar(Orientation::Vertical, this);
+ m_vertical_scrollbar = GScrollBar::construct(Orientation::Vertical, this);
m_vertical_scrollbar->set_step(4);
m_vertical_scrollbar->on_change = [this](int) {
did_scroll();
update();
};
- m_horizontal_scrollbar = new GScrollBar(Orientation::Horizontal, this);
+ m_horizontal_scrollbar = GScrollBar::construct(Orientation::Horizontal, this);
m_horizontal_scrollbar->set_step(4);
m_horizontal_scrollbar->set_big_step(30);
m_horizontal_scrollbar->on_change = [this](int) {
diff --git a/Libraries/LibGUI/GScrollableWidget.h b/Libraries/LibGUI/GScrollableWidget.h
index e4379f247a..73394c1890 100644
--- a/Libraries/LibGUI/GScrollableWidget.h
+++ b/Libraries/LibGUI/GScrollableWidget.h
@@ -53,8 +53,8 @@ protected:
private:
void update_scrollbar_ranges();
- GScrollBar* m_vertical_scrollbar { nullptr };
- GScrollBar* m_horizontal_scrollbar { nullptr };
+ ObjectPtr<GScrollBar> m_vertical_scrollbar;
+ ObjectPtr<GScrollBar> m_horizontal_scrollbar;
GWidget* m_corner_widget { nullptr };
Size m_content_size;
Size m_size_occupied_by_fixed_elements;