mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LibGUI: Convert GScrollBar to ObjectPtr
This commit is contained in:
parent
4616a13e94
commit
bce58bbbca
Notes:
sideshowbarker
2024-07-19 12:02:21 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/bce58bbbca6
7 changed files with 11 additions and 10 deletions
|
@ -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();
|
||||
|
|
|
@ -100,5 +100,5 @@ private:
|
|||
ObjectPtr<CTimer> m_visual_beep_timer;
|
||||
RefPtr<CConfigFile> m_config;
|
||||
|
||||
GScrollBar* m_scrollbar { nullptr };
|
||||
ObjectPtr<GScrollBar> m_scrollbar;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue