1 | /**************************************************************************/ |
2 | /* popup_menu.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 | #ifndef POPUP_MENU_H |
32 | #define |
33 | |
34 | #include "core/input/shortcut.h" |
35 | #include "scene/gui/margin_container.h" |
36 | #include "scene/gui/popup.h" |
37 | #include "scene/gui/scroll_container.h" |
38 | #include "scene/resources/text_line.h" |
39 | |
40 | class : public Popup { |
41 | GDCLASS(PopupMenu, Popup); |
42 | |
43 | struct { |
44 | Ref<Texture2D> ; |
45 | int = 0; |
46 | Color = Color(1, 1, 1, 1); |
47 | String ; |
48 | String ; |
49 | Ref<TextLine> ; |
50 | Ref<TextLine> ; |
51 | |
52 | String ; |
53 | Control::TextDirection = Control::TEXT_DIRECTION_AUTO; |
54 | |
55 | bool = false; |
56 | enum { |
57 | , |
58 | , |
59 | , |
60 | } ; |
61 | int = 0; |
62 | int = 0; |
63 | bool = false; |
64 | bool = false; |
65 | bool = true; |
66 | int = 0; |
67 | Variant ; |
68 | String ; |
69 | String ; |
70 | Key = Key::NONE; |
71 | int = 0; |
72 | int = 0; |
73 | int = 0; |
74 | Ref<Shortcut> ; |
75 | bool = false; |
76 | bool = false; |
77 | bool = false; |
78 | |
79 | // Returns (0,0) if icon is null. |
80 | Size2 () const { |
81 | return icon.is_null() ? Size2() : icon->get_size(); |
82 | } |
83 | |
84 | () { |
85 | text_buf.instantiate(); |
86 | accel_text_buf.instantiate(); |
87 | checkable_type = CHECKABLE_TYPE_NONE; |
88 | } |
89 | }; |
90 | |
91 | bool = false; |
92 | bool = false; |
93 | |
94 | Timer * = nullptr; |
95 | Timer * = nullptr; |
96 | List<Rect2> ; |
97 | Vector<Item> ; |
98 | BitField<MouseButtonMask> ; |
99 | bool = false; |
100 | int = -1; |
101 | int = -1; |
102 | String (const Item &p_item) const; |
103 | int (const Point2 &p_over) const; |
104 | virtual Size2 () const override; |
105 | |
106 | int (int p_idx) const; |
107 | int () const; |
108 | Size2 (int p_idx) const; |
109 | |
110 | void (int p_idx); |
111 | |
112 | virtual void (const Ref<InputEvent> &p_event); |
113 | void (int p_over, bool p_by_keyboard = false); |
114 | void (); |
115 | |
116 | uint64_t = 0; |
117 | bool = true; |
118 | bool = true; |
119 | bool = false; |
120 | Vector2 ; |
121 | |
122 | HashMap<Ref<Shortcut>, int> ; |
123 | |
124 | void (Ref<Shortcut> p_sc); |
125 | void (Ref<Shortcut> p_sc); |
126 | |
127 | void (); |
128 | |
129 | bool = true; |
130 | uint64_t = 0; |
131 | String = "" ; |
132 | |
133 | MarginContainer * = nullptr; |
134 | ScrollContainer * = nullptr; |
135 | Control * = nullptr; |
136 | |
137 | const float = 0.5; |
138 | const float = 1.0 / 20; |
139 | float = DEFAULT_GAMEPAD_EVENT_DELAY_MS; |
140 | |
141 | struct { |
142 | Ref<StyleBox> ; |
143 | Ref<StyleBox> ; |
144 | |
145 | Ref<StyleBox> ; |
146 | Ref<StyleBox> ; |
147 | Ref<StyleBox> ; |
148 | |
149 | int = 0; |
150 | int = 0; |
151 | int = 0; |
152 | int = 0; |
153 | int = 0; |
154 | int = 0; |
155 | |
156 | Ref<Texture2D> ; |
157 | Ref<Texture2D> ; |
158 | Ref<Texture2D> ; |
159 | Ref<Texture2D> ; |
160 | Ref<Texture2D> ; |
161 | Ref<Texture2D> ; |
162 | Ref<Texture2D> ; |
163 | Ref<Texture2D> ; |
164 | |
165 | Ref<Texture2D> ; |
166 | Ref<Texture2D> ; |
167 | |
168 | Ref<Font> ; |
169 | int = 0; |
170 | Ref<Font> ; |
171 | int = 0; |
172 | |
173 | Color ; |
174 | Color ; |
175 | Color ; |
176 | Color ; |
177 | int = 0; |
178 | Color ; |
179 | |
180 | Color ; |
181 | int = 0; |
182 | Color ; |
183 | } ; |
184 | |
185 | void (); |
186 | void (); |
187 | |
188 | void (); |
189 | void (); |
190 | void (); |
191 | |
192 | protected: |
193 | virtual void (Node *p_child) override; |
194 | virtual void (Node *p_child) override; |
195 | |
196 | void (int p_what); |
197 | bool (const StringName &p_name, const Variant &p_value); |
198 | bool (const StringName &p_name, Variant &r_ret) const; |
199 | void (List<PropertyInfo> *p_list) const; |
200 | static void (); |
201 | |
202 | #ifndef DISABLE_DEPRECATED |
203 | void (const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false); |
204 | void (const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false); |
205 | static void (); |
206 | #endif |
207 | |
208 | public: |
209 | // ATTENTION: This is used by the POT generator's scene parser. If the number of properties returned by `_get_items()` ever changes, |
210 | // this value should be updated to reflect the new size. |
211 | static const int = 10; |
212 | |
213 | virtual void () override; |
214 | |
215 | void (const String &p_label, int p_id = -1, Key p_accel = Key::NONE); |
216 | void (const Ref<Texture2D> &p_icon, const String &p_label, int p_id = -1, Key p_accel = Key::NONE); |
217 | void (const String &p_label, int p_id = -1, Key p_accel = Key::NONE); |
218 | void (const Ref<Texture2D> &p_icon, const String &p_label, int p_id = -1, Key p_accel = Key::NONE); |
219 | void (const String &p_label, int p_id = -1, Key p_accel = Key::NONE); |
220 | void (const Ref<Texture2D> &p_icon, const String &p_label, int p_id = -1, Key p_accel = Key::NONE); |
221 | |
222 | void (const String &p_label, int p_max_states, int p_default_state = 0, int p_id = -1, Key p_accel = Key::NONE); |
223 | |
224 | void (const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false, bool p_allow_echo = false); |
225 | void (const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false, bool p_allow_echo = false); |
226 | void (const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false); |
227 | void (const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false); |
228 | void (const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false); |
229 | void (const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false); |
230 | |
231 | void (const String &p_label, const String &, int p_id = -1); |
232 | |
233 | void (int p_idx, const String &p_text); |
234 | |
235 | void (int p_idx, Control::TextDirection p_text_direction); |
236 | void (int p_idx, const String &p_language); |
237 | void (int p_idx, const Ref<Texture2D> &p_icon); |
238 | void (int p_idx, int p_width); |
239 | void (int p_idx, const Color &p_modulate); |
240 | void (int p_idx, bool p_checked); |
241 | void (int p_idx, int p_id); |
242 | void (int p_idx, Key p_accel); |
243 | void (int p_idx, const Variant &p_meta); |
244 | void (int p_idx, bool p_disabled); |
245 | void (int p_idx, const String &); |
246 | void (int p_idx, bool p_separator); |
247 | void (int p_idx, bool p_checkable); |
248 | void (int p_idx, bool p_radio_checkable); |
249 | void (int p_idx, const String &p_tooltip); |
250 | void (int p_idx, const Ref<Shortcut> &p_shortcut, bool p_global = false); |
251 | void (int p_idx, int p_indent); |
252 | void (int p_idx, int p_state); |
253 | void (int p_idx); |
254 | void (int p_idx, bool p_disabled); |
255 | |
256 | void (int p_idx); |
257 | |
258 | String (int p_idx) const; |
259 | String (int p_idx) const; |
260 | Control::TextDirection (int p_idx) const; |
261 | String (int p_idx) const; |
262 | int (const String &text) const; |
263 | Ref<Texture2D> (int p_idx) const; |
264 | int (int p_idx) const; |
265 | Color (int p_idx) const; |
266 | bool (int p_idx) const; |
267 | int (int p_idx) const; |
268 | int (int p_id) const; |
269 | Key (int p_idx) const; |
270 | Variant (int p_idx) const; |
271 | bool (int p_idx) const; |
272 | String (int p_idx) const; |
273 | bool (int p_idx) const; |
274 | bool (int p_idx) const; |
275 | bool (int p_idx) const; |
276 | bool (int p_idx) const; |
277 | bool (int p_idx) const; |
278 | String (int p_idx) const; |
279 | Ref<Shortcut> (int p_idx) const; |
280 | int (int p_idx) const; |
281 | int (int p_idx) const; |
282 | int (int p_idx) const; |
283 | |
284 | void (int p_idx); |
285 | int () const; |
286 | |
287 | void (int p_count); |
288 | int () const; |
289 | |
290 | void (int p_idx); |
291 | |
292 | bool (const Ref<InputEvent> &p_event, bool p_for_global_only = false); |
293 | void (int p_idx); |
294 | |
295 | void (int p_idx); |
296 | |
297 | void (const String &p_text = String(), int p_id = -1); |
298 | |
299 | void (); |
300 | |
301 | virtual String (const Point2 &p_pos) const; |
302 | |
303 | void (const Rect2 &p_area); |
304 | void (); |
305 | |
306 | void (bool p_enabled); |
307 | bool () const; |
308 | |
309 | void (bool p_enabled); |
310 | bool () const; |
311 | |
312 | void (bool p_enabled); |
313 | bool () const; |
314 | |
315 | void (float p_time); |
316 | float () const; |
317 | |
318 | void (bool p_allow); |
319 | bool () const; |
320 | |
321 | virtual void (const Rect2i &p_bounds = Rect2i()) override; |
322 | |
323 | void (); |
324 | |
325 | (); |
326 | (); |
327 | }; |
328 | |
329 | #endif // POPUP_MENU_H |
330 | |