scroll_bar.h
1 /*************************************************************************/
2 /* scroll_bar.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
9 /* */
10 /* Permission is hereby granted, free of charge, to any person obtaining */
11 /* a copy of this software and associated documentation files (the */
12 /* "Software"), to deal in the Software without restriction, including */
13 /* without limitation the rights to use, copy, modify, merge, publish, */
14 /* distribute, sublicense, and/or sell copies of the Software, and to */
15 /* permit persons to whom the Software is furnished to do so, subject to */
16 /* the following conditions: */
17 /* */
18 /* The above copyright notice and this permission notice shall be */
19 /* included in all copies or substantial portions of the Software. */
20 /* */
21 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
22 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
23 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
24 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
25 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
26 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
27 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28 /*************************************************************************/
29 #ifndef SCROLL_BAR_H
30 #define SCROLL_BAR_H
31 
32 #include "scene/gui/range.h"
33 
34 
38 class ScrollBar : public Range {
39 
40  OBJ_TYPE( ScrollBar, Range );
41 
42  enum HiliteStatus {
43  HILITE_NONE,
44  HILITE_DECR,
45  HILITE_RANGE,
46  HILITE_INCR,
47  };
48 
49  static bool focus_by_default;
50 
51  Orientation orientation;
52  Size2 size;
53  float custom_step;
54 
55  HiliteStatus hilite;
56 
57  struct Drag {
58 
59  bool active;
60  float pos_at_click;
61  float value_at_click;
62  } drag;
63 
64 
65  double get_grabber_size() const;
66  double get_grabber_min_size() const;
67  double get_area_size() const;
68  double get_area_offset() const;
69  double get_click_pos(const Point2& p_pos) const;
70  double get_grabber_offset() const;
71 
72  static void set_can_focus_by_default(bool p_can_focus);
73 
74  Node* drag_slave;
75  NodePath drag_slave_path;
76 
77  Vector2 drag_slave_speed;
78  Vector2 drag_slave_accum;
79  Vector2 drag_slave_from;
80  Vector2 last_drag_slave_accum;
81  float last_drag_slave_time;
82  float time_since_motion;
83  bool drag_slave_touching;
84  bool drag_slave_touching_deaccel;
85  bool click_handled;
86 
87  void _drag_slave_exit();
88  void _drag_slave_input(const InputEvent& p_input);
89 
90  void _input_event(InputEvent p_event);
91 protected:
92  void _notification(int p_what);
93 
94  static void _bind_methods();
95 
96 public:
97 
98  void set_custom_step(float p_custom_step);
99  float get_custom_step() const;
100 
101  void set_drag_slave(const NodePath& p_path);
102  NodePath get_drag_slave() const;
103 
104  virtual Size2 get_minimum_size() const;
105  ScrollBar(Orientation p_orientation=VERTICAL);
106  ~ScrollBar();
107 
108 };
109 
110 class HScrollBar : public ScrollBar {
111 
112  OBJ_TYPE( HScrollBar, ScrollBar );
113 public:
114 
115  HScrollBar() : ScrollBar(HORIZONTAL) { set_v_size_flags(0); }
116 };
117 
118 class VScrollBar : public ScrollBar {
119 
120  OBJ_TYPE( VScrollBar, ScrollBar );
121 public:
122 
123  VScrollBar() : ScrollBar(VERTICAL) { set_h_size_flags(0); }
124 };
125 
126 
127 #endif
Definition: scroll_bar.h:110
Definition: path_db.h:41
Definition: node.h:42
Definition: scroll_bar.h:118
Definition: scroll_bar.h:38
Definition: range.h:36
Definition: input_event.h:263
Definition: math_2d.h:65