| 
									
										
										
										
											2019-02-09 11:19:38 +01:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibGUI/GWidget.h>
 | 
					
						
							|  |  |  | #include <AK/Function.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class GScrollBar final : public GWidget { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2019-02-10 11:57:19 +01:00
										 |  |  |     explicit GScrollBar(Orientation, GWidget* parent); | 
					
						
							| 
									
										
										
										
											2019-02-09 11:19:38 +01:00
										 |  |  |     virtual ~GScrollBar() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-10 11:57:19 +01:00
										 |  |  |     Orientation orientation() const { return m_orientation; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-09 11:19:38 +01:00
										 |  |  |     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; } | 
					
						
							| 
									
										
										
										
											2019-02-10 07:11:01 +01:00
										 |  |  |     bool has_scrubber() const; | 
					
						
							| 
									
										
										
										
											2019-02-09 11:19:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Function<void(int)> on_change; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     virtual void paint_event(GPaintEvent&) override; | 
					
						
							|  |  |  |     virtual void mousedown_event(GMouseEvent&) override; | 
					
						
							| 
									
										
										
										
											2019-02-10 06:51:01 +01:00
										 |  |  |     virtual void mouseup_event(GMouseEvent&) override; | 
					
						
							|  |  |  |     virtual void mousemove_event(GMouseEvent&) override; | 
					
						
							| 
									
										
										
										
											2019-02-09 11:19:38 +01:00
										 |  |  |     virtual const char* class_name() const override { return "GScrollBar"; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-10 11:57:19 +01:00
										 |  |  |     int button_size() const { return orientation() == Orientation::Vertical ? width() : height(); } | 
					
						
							| 
									
										
										
										
											2019-02-09 11:19:38 +01:00
										 |  |  |     Rect up_button_rect() const; | 
					
						
							|  |  |  |     Rect down_button_rect() const; | 
					
						
							| 
									
										
										
										
											2019-02-10 06:51:01 +01:00
										 |  |  |     Rect upper_gutter_rect() const; | 
					
						
							|  |  |  |     Rect lower_gutter_rect() const; | 
					
						
							| 
									
										
										
										
											2019-02-09 11:19:38 +01:00
										 |  |  |     Rect scrubber_rect() const; | 
					
						
							| 
									
										
										
										
											2019-02-10 06:51:01 +01:00
										 |  |  |     int scrubbable_range_in_pixels() const; | 
					
						
							| 
									
										
										
										
											2019-02-09 11:19:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     int m_min { 0 }; | 
					
						
							|  |  |  |     int m_max { 0 }; | 
					
						
							|  |  |  |     int m_value { 0 }; | 
					
						
							|  |  |  |     int m_step { 1 }; | 
					
						
							|  |  |  |     int m_big_step { 5 }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-10 06:51:01 +01:00
										 |  |  |     bool m_scrubbing { false }; | 
					
						
							|  |  |  |     int m_scrub_start_value { 0 }; | 
					
						
							|  |  |  |     Point m_scrub_origin; | 
					
						
							| 
									
										
										
										
											2019-02-10 11:57:19 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Orientation m_orientation { Orientation::Vertical }; | 
					
						
							| 
									
										
										
										
											2019-02-10 06:51:01 +01:00
										 |  |  | }; |