1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00
serenity/LibGUI/GScrollBar.h
Andreas Kling 1f355f2a79 LibGUI: Start working on a GScrollBar.
This widget is far from finished, but it's off to a good start.
Also added a GResizeEvent and GWidget::resize_event() so that widgets
can react to being resized.
2019-02-09 11:19:38 +01:00

42 lines
1.1 KiB
C++

#pragma once
#include <LibGUI/GWidget.h>
#include <AK/Function.h>
class GScrollBar final : public GWidget {
public:
explicit GScrollBar(GWidget* parent);
virtual ~GScrollBar() override;
int value() const { return m_value; }
int min() const { return m_min; }
int max() const { return m_max; }
int step() const { return m_step; }
int big_step() const { return m_big_step; }
void set_range(int min, int max);
void set_value(int value);
void set_step(int step) { m_step = step; }
void set_big_step(int big_step) { m_big_step = big_step; }
Function<void(int)> on_change;
private:
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual const char* class_name() const override { return "GScrollBar"; }
int button_size() const { return 16; }
Rect up_button_rect() const;
Rect down_button_rect() const;
Rect pgup_rect() const;
Rect pgdn_rect() const;
Rect scrubber_rect() const;
int m_min { 0 };
int m_max { 0 };
int m_value { 0 };
int m_step { 1 };
int m_big_step { 5 };
};