Debian Codegraph @

scene/gui/scroll_bar.h

raw symbols SCIP
1 /**************************************************************************/
2 /* scroll_bar.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "scene/gui/range.h"
34
35 class ScrollBar : public Range {
36 GDCLASS(ScrollBar, Range);
37
38 enum HighlightStatus {
39 HIGHLIGHT_NONE,
40 HIGHLIGHT_DECR,
41 HIGHLIGHT_RANGE,
42 HIGHLIGHT_INCR,
43 };
44
45 static bool focus_by_default;
46
47 Orientation orientation;
48 Size2 size;
49 float custom_step = -1.0;
50
51 HighlightStatus highlight = HIGHLIGHT_NONE;
52
53 bool incr_active = false;
54 bool decr_active = false;
55
56 struct Drag {
57 bool active = false;
58 float pos_at_click = 0.0;
59 float value_at_click = 0.0;
60 } drag;
61
62 double get_grabber_size() const;
63 double get_grabber_min_size() const;
64 double get_area_size() const;
65 double get_grabber_offset() const;
66
67 static void set_can_focus_by_default(bool p_can_focus);
68
69 Node *drag_node = nullptr;
70 NodePath drag_node_path;
71 bool drag_node_enabled = true;
72
73 Vector2 drag_node_speed;
74 Vector2 drag_node_accum;
75 Vector2 drag_node_from;
76 Vector2 last_drag_node_accum;
77 float time_since_motion = 0.0;
78 bool drag_node_touching = false;
79 bool drag_node_touching_deaccel = false;
80
81 bool scrolling = false;
82 double target_scroll = 0.0;
83 bool smooth_scroll_enabled = false;
84
85 void _drag_node_exit();
86 void _drag_node_input(const Ref<InputEvent> &p_input);
87
88 virtual void gui_input(const Ref<InputEvent> &p_event) override;
89
90 protected:
91 struct ThemeCache {
92 Ref<StyleBox> scroll_style;
93 Ref<StyleBox> scroll_focus_style;
94 Ref<StyleBox> scroll_offset_style;
95 Ref<StyleBox> grabber_style;
96 Ref<StyleBox> grabber_hl_style;
97 Ref<StyleBox> grabber_pressed_style;
98
99 Ref<Texture2D> increment_icon;
100 Ref<Texture2D> increment_hl_icon;
101 Ref<Texture2D> increment_pressed_icon;
102 Ref<Texture2D> decrement_icon;
103 Ref<Texture2D> decrement_hl_icon;
104 Ref<Texture2D> decrement_pressed_icon;
105
106 int padding_left = 0;
107 int padding_top = 0;
108 int padding_right = 0;
109 int padding_bottom = 0;
110 } theme_cache;
111
112 void _notification(int p_what);
113 static void _bind_methods();
114
115 public:
116 static inline const int PAGE_DIVISOR = 8;
117
118 void scroll(double p_amount);
119 void scroll_to(double p_position);
120
121 void set_custom_step(float p_custom_step);
122 float get_custom_step() const;
123
124 void set_drag_node(const NodePath &p_path);
125 NodePath get_drag_node() const;
126 void set_drag_node_enabled(bool p_enable);
127
128 void set_smooth_scroll_enabled(bool p_enable);
129 bool is_smooth_scroll_enabled() const;
130
131 virtual Size2 get_minimum_size() const override;
132 ScrollBar(Orientation p_orientation = VERTICAL);
133 ~ScrollBar();
134 };
135
136 class HScrollBar : public ScrollBar {
137 GDCLASS(HScrollBar, ScrollBar);
138
139 protected:
140 static void _bind_methods();
141
142 public:
143 HScrollBar() :
144 ScrollBar(HORIZONTAL) { set_v_size_flags(0); }
145 };
146
147 class VScrollBar : public ScrollBar {
148 GDCLASS(VScrollBar, ScrollBar);
149
150 protected:
151 static void _bind_methods();
152
153 public:
154 VScrollBar() :
155 ScrollBar(VERTICAL) { set_h_size_flags(0); }
156 };