scroll_container.h
1 /*************************************************************************/
2 /* scroll_container.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_CONTAINER_H
30 #define SCROLL_CONTAINER_H
31 
32 #include "container.h"
33 
34 #include "scroll_bar.h"
35 
36 class ScrollContainer : public Container {
37 
38  OBJ_TYPE(ScrollContainer, Container);
39 
40  HScrollBar* h_scroll;
41  VScrollBar* v_scroll;
42 
43  Size2 child_max_size;
44  Size2 scroll;
45 
46  void update_scrollbars();
47 
48  Vector2 drag_speed;
49  Vector2 drag_accum;
50  Vector2 drag_from;
51  Vector2 last_drag_accum;
52  float last_drag_time;
53  float time_since_motion;
54  bool drag_touching;
55  bool drag_touching_deaccel;
56  bool click_handled;
57 
58  bool scroll_h;
59  bool scroll_v;
60 
61  void _cancel_drag();
62 
63 protected:
64  Size2 get_minimum_size() const;
65 
66 
67  void _input_event(const InputEvent& p_input_event);
68  void _notification(int p_what);
69 
70  void _scroll_moved(float);
71  static void _bind_methods();
72 
73  void _update_scrollbar_pos();
74 public:
75 
76  int get_v_scroll() const;
77  void set_v_scroll(int p_pos);
78 
79  int get_h_scroll() const;
80  void set_h_scroll(int p_pos);
81 
82  void set_enable_h_scroll(bool p_enable);
83  bool is_h_scroll_enabled() const;
84 
85  void set_enable_v_scroll(bool p_enable);
86  bool is_v_scroll_enabled() const;
87 
88  virtual bool clips_input() const;
90 };
91 
92 #endif
Definition: scroll_bar.h:110
Definition: container.h:34
Definition: scroll_container.h:36
Definition: scroll_bar.h:118
Definition: input_event.h:263
Definition: math_2d.h:65