Debian Codegraph @

scene/gui/control.h

raw symbols SCIP
1 /**************************************************************************/
2 /* control.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 "core/math/transform_2d.h"
34 #include "core/object/gdvirtual.gen.inc"
35 #include "scene/main/canvas_item.h"
36 #include "scene/resources/theme.h"
37
38 class Viewport;
39 class Label;
40 class Panel;
41 class ThemeOwner;
42 class ThemeContext;
43
44 class Control : public CanvasItem {
45 GDCLASS(Control, CanvasItem);
46
47 #ifdef TOOLS_ENABLED
48 bool saving = false;
49 #endif // TOOLS_ENABLED
50
51 public:
52 static constexpr AncestralClass static_ancestral_class = AncestralClass::CONTROL;
53
54 enum Anchor {
55 ANCHOR_BEGIN = 0,
56 ANCHOR_END = 1
57 };
58
59 enum GrowDirection {
60 GROW_DIRECTION_BEGIN,
61 GROW_DIRECTION_END,
62 GROW_DIRECTION_BOTH
63 };
64
65 enum FocusMode {
66 FOCUS_NONE,
67 FOCUS_CLICK,
68 FOCUS_ALL,
69 FOCUS_ACCESSIBILITY,
70 };
71
72 enum FocusBehaviorRecursive {
73 FOCUS_BEHAVIOR_INHERITED,
74 FOCUS_BEHAVIOR_DISABLED,
75 FOCUS_BEHAVIOR_ENABLED,
76 };
77
78 enum SizeFlags {
79 SIZE_SHRINK_BEGIN = 0,
80 SIZE_FILL = 1,
81 SIZE_EXPAND = 2,
82 SIZE_SHRINK_CENTER = 4,
83 SIZE_SHRINK_END = 8,
84
85 SIZE_EXPAND_FILL = SIZE_EXPAND | SIZE_FILL,
86 };
87
88 enum MouseFilter {
89 MOUSE_FILTER_STOP,
90 MOUSE_FILTER_PASS,
91 MOUSE_FILTER_IGNORE
92 };
93
94 enum MouseBehaviorRecursive {
95 MOUSE_BEHAVIOR_INHERITED,
96 MOUSE_BEHAVIOR_DISABLED,
97 MOUSE_BEHAVIOR_ENABLED,
98 };
99
100 enum CursorShape {
101 CURSOR_ARROW,
102 CURSOR_IBEAM,
103 CURSOR_POINTING_HAND,
104 CURSOR_CROSS,
105 CURSOR_WAIT,
106 CURSOR_BUSY,
107 CURSOR_DRAG,
108 CURSOR_CAN_DROP,
109 CURSOR_FORBIDDEN,
110 CURSOR_VSIZE,
111 CURSOR_HSIZE,
112 CURSOR_BDIAGSIZE,
113 CURSOR_FDIAGSIZE,
114 CURSOR_MOVE,
115 CURSOR_VSPLIT,
116 CURSOR_HSPLIT,
117 CURSOR_HELP,
118 CURSOR_MAX
119 };
120
121 enum LayoutPreset {
122 PRESET_TOP_LEFT,
123 PRESET_TOP_RIGHT,
124 PRESET_BOTTOM_LEFT,
125 PRESET_BOTTOM_RIGHT,
126 PRESET_CENTER_LEFT,
127 PRESET_CENTER_TOP,
128 PRESET_CENTER_RIGHT,
129 PRESET_CENTER_BOTTOM,
130 PRESET_CENTER,
131 PRESET_LEFT_WIDE,
132 PRESET_TOP_WIDE,
133 PRESET_RIGHT_WIDE,
134 PRESET_BOTTOM_WIDE,
135 PRESET_VCENTER_WIDE,
136 PRESET_HCENTER_WIDE,
137 PRESET_FULL_RECT
138 };
139
140 enum LayoutPresetMode {
141 PRESET_MODE_MINSIZE,
142 PRESET_MODE_KEEP_WIDTH,
143 PRESET_MODE_KEEP_HEIGHT,
144 PRESET_MODE_KEEP_SIZE
145 };
146
147 enum LayoutMode {
148 LAYOUT_MODE_POSITION,
149 LAYOUT_MODE_ANCHORS,
150 LAYOUT_MODE_CONTAINER,
151 LAYOUT_MODE_UNCONTROLLED,
152 };
153
154 enum LayoutDirection {
155 LAYOUT_DIRECTION_INHERITED,
156 LAYOUT_DIRECTION_APPLICATION_LOCALE,
157 LAYOUT_DIRECTION_LTR,
158 LAYOUT_DIRECTION_RTL,
159 LAYOUT_DIRECTION_SYSTEM_LOCALE,
160 LAYOUT_DIRECTION_MAX,
161 #ifndef DISABLE_DEPRECATED
162 LAYOUT_DIRECTION_LOCALE = LAYOUT_DIRECTION_APPLICATION_LOCALE,
163 #endif // DISABLE_DEPRECATED
164 };
165
166 enum TextDirection {
167 TEXT_DIRECTION_AUTO = TextServer::DIRECTION_AUTO,
168 TEXT_DIRECTION_LTR = TextServer::DIRECTION_LTR,
169 TEXT_DIRECTION_RTL = TextServer::DIRECTION_RTL,
170 TEXT_DIRECTION_INHERITED = TextServer::DIRECTION_INHERITED,
171 };
172
173 private:
174 struct CComparator {
175 bool operator()(const Control *p_a, const Control *p_b) const {
176 if (p_a->get_canvas_layer() == p_b->get_canvas_layer()) {
177 return p_b->is_greater_than(p_a);
178 }
179
180 return p_a->get_canvas_layer() < p_b->get_canvas_layer();
181 }
182 };
183
184 // This Data struct is to avoid namespace pollution in derived classes.
185 struct Data {
186 bool initialized = false;
187
188 // Global relations.
189
190 List<Control *>::Element *RI = nullptr;
191
192 Control *parent_control = nullptr;
193 Window *parent_window = nullptr;
194 CanvasItem *parent_canvas_item = nullptr;
195 Callable forward_drag;
196 Callable forward_can_drop;
197 Callable forward_drop;
198
199 // Positioning and sizing.
200
201 LayoutMode stored_layout_mode = LayoutMode::LAYOUT_MODE_POSITION;
202 bool stored_use_custom_anchors = false;
203
204 real_t offset[4] = { 0.0, 0.0, 0.0, 0.0 };
205 real_t anchor[4] = { ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN };
206 FocusMode focus_mode = FOCUS_NONE;
207 FocusBehaviorRecursive focus_behavior_recursive = FOCUS_BEHAVIOR_INHERITED;
208 bool parent_focus_behavior_recursive_enabled = false;
209 GrowDirection h_grow = GROW_DIRECTION_END;
210 GrowDirection v_grow = GROW_DIRECTION_END;
211
212 real_t rotation = 0.0;
213 Vector2 scale = Vector2(1, 1);
214 Vector2 pivot_offset;
215 Vector2 pivot_offset_ratio;
216
217 Point2 pos_cache;
218 Size2 size_cache;
219 mutable Size2 minimum_size_cache;
220 mutable bool minimum_size_valid = false;
221
222 Size2 last_minimum_size;
223 bool updating_last_minimum_size = false;
224 bool block_minimum_size_adjust = false;
225
226 bool size_warning = true;
227
228 // Container sizing.
229
230 BitField<SizeFlags> h_size_flags = SIZE_FILL;
231 BitField<SizeFlags> v_size_flags = SIZE_FILL;
232 real_t expand = 1.0;
233 Point2 custom_minimum_size;
234
235 // Input events and rendering.
236
237 MouseFilter mouse_filter = MOUSE_FILTER_STOP;
238 MouseBehaviorRecursive mouse_behavior_recursive = MOUSE_BEHAVIOR_INHERITED;
239 bool parent_mouse_behavior_recursive_enabled = true;
240 bool force_pass_scroll_events = true;
241
242 bool clip_contents = false;
243 bool disable_visibility_clip = false;
244
245 CursorShape default_cursor = CURSOR_ARROW;
246
247 // Focus.
248
249 NodePath focus_neighbor[4];
250 NodePath focus_next;
251 NodePath focus_prev;
252
253 ObjectID shortcut_context;
254
255 // Accessibility.
256
257 String accessibility_name;
258 String accessibility_description;
259 DisplayServer::AccessibilityLiveMode accessibility_live = DisplayServer::AccessibilityLiveMode::LIVE_OFF;
260
261 TypedArray<NodePath> accessibility_controls_nodes;
262 TypedArray<NodePath> accessibility_described_by_nodes;
263 TypedArray<NodePath> accessibility_labeled_by_nodes;
264 TypedArray<NodePath> accessibility_flow_to_nodes;
265
266 // Theming.
267
268 ThemeOwner *theme_owner = nullptr;
269 Ref<Theme> theme;
270 StringName theme_type_variation;
271
272 bool bulk_theme_override = false;
273 Theme::ThemeIconMap theme_icon_override;
274 Theme::ThemeStyleMap theme_style_override;
275 Theme::ThemeFontMap theme_font_override;
276 Theme::ThemeFontSizeMap theme_font_size_override;
277 Theme::ThemeColorMap theme_color_override;
278 Theme::ThemeConstantMap theme_constant_override;
279
280 mutable HashMap<StringName, Theme::ThemeIconMap> theme_icon_cache;
281 mutable HashMap<StringName, Theme::ThemeStyleMap> theme_style_cache;
282 mutable HashMap<StringName, Theme::ThemeFontMap> theme_font_cache;
283 mutable HashMap<StringName, Theme::ThemeFontSizeMap> theme_font_size_cache;
284 mutable HashMap<StringName, Theme::ThemeColorMap> theme_color_cache;
285 mutable HashMap<StringName, Theme::ThemeConstantMap> theme_constant_cache;
286
287 // Internationalization.
288
289 LayoutDirection layout_dir = LAYOUT_DIRECTION_INHERITED;
290 mutable bool is_rtl_dirty = true;
291 mutable bool is_rtl = false;
292
293 bool localize_numeral_system = true;
294
295 // Extra properties.
296
297 String tooltip;
298 AutoTranslateMode tooltip_auto_translate_mode = AUTO_TRANSLATE_MODE_INHERIT;
299
300 } data;
301
302 // Dynamic properties.
303
304 static constexpr unsigned properties_managed_by_container_count = 12;
305 static String properties_managed_by_container[properties_managed_by_container_count];
306
307 // Global relations.
308
309 friend class Viewport;
310
311 // Positioning and sizing.
312
313 void _update_canvas_item_transform();
314 Transform2D _get_internal_transform() const;
315
316 void _set_anchor(Side p_side, real_t p_anchor);
317 void _set_position(const Point2 &p_point);
318 void _set_global_position(const Point2 &p_point);
319 void _set_size(const Size2 &p_size);
320
321 void _compute_offsets(Rect2 p_rect, const real_t p_anchors[4], real_t (&r_offsets)[4]);
322 void _compute_anchors(Rect2 p_rect, const real_t p_offsets[4], real_t (&r_anchors)[4]);
323
324 void _set_layout_mode(LayoutMode p_mode);
325 void _update_layout_mode();
326 LayoutMode _get_layout_mode() const;
327 LayoutMode _get_default_layout_mode() const;
328 void _set_anchors_layout_preset(int p_preset);
329 int _get_anchors_layout_preset() const;
330
331 void _update_minimum_size_cache() const;
332 void _update_minimum_size();
333 void _size_changed();
334
335 void _top_level_changed() override {} // Controls don't need to do anything, only other CanvasItems.
336 void _top_level_changed_on_parent() override;
337
338 void _clear_size_warning();
339
340 // Input events.
341
342 void _call_gui_input(const Ref<InputEvent> &p_event);
343
344 // Mouse Filter.
345
346 bool _is_mouse_filter_enabled() const;
347 void _update_mouse_behavior_recursive();
348 void _propagate_mouse_behavior_recursive_recursively(bool p_enabled, bool p_skip_non_inherited);
349
350 // Focus.
351
352 bool _is_focusable() const;
353 void _window_find_focus_neighbor(const Vector2 &p_dir, Node *p_at, const Rect2 &p_rect, const Rect2 &p_clamp, real_t p_min, real_t &r_closest_dist_squared, Control **r_closest);
354 Control *_get_focus_neighbor(Side p_side, int p_count = 0);
355 bool _is_focus_mode_enabled() const;
356 void _update_focus_behavior_recursive();
357 void _propagate_focus_behavior_recursive_recursively(bool p_enabled, bool p_skip_non_inherited);
358
359 // Theming.
360
361 void _theme_changed();
362 void _notify_theme_override_changed();
363 void _invalidate_theme_cache();
364
365 // Extra properties.
366
367 static int root_layout_direction;
368
369 protected:
370 // Dynamic properties.
371
372 bool _set(const StringName &p_name, const Variant &p_value);
373 bool _get(const StringName &p_name, Variant &r_ret) const;
374 void _get_property_list(List<PropertyInfo> *p_list) const;
375 void _validate_property(PropertyInfo &p_property) const;
376
377 bool _property_can_revert(const StringName &p_name) const;
378 bool _property_get_revert(const StringName &p_name, Variant &r_property) const;
379
380 // Theming.
381
382 virtual void _update_theme_item_cache();
383
384 // Internationalization.
385
386 virtual TypedArray<Vector3i> structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const;
387
388 // Base object overrides.
389
390 void _notification(int p_notification);
391 static void _bind_methods();
392
393 void _accessibility_action_foucs(const Variant &p_data);
394 void _accessibility_action_blur(const Variant &p_data);
395 void _accessibility_action_show_tooltip(const Variant &p_data);
396 void _accessibility_action_hide_tooltip(const Variant &p_data);
397 void _accessibility_action_scroll_into_view(const Variant &p_data);
398
399 #ifndef DISABLE_DEPRECATED
400 bool _has_focus_bind_compat_110250() const;
401 void _grab_focus_bind_compat_110250();
402 static void _bind_compatibility_methods();
403 #endif //DISABLE_DEPRECATED
404
405 // Exposed virtual methods.
406
407 GDVIRTUAL1RC(bool, _has_point, Vector2)
408 GDVIRTUAL2RC(TypedArray<Vector3i>, _structured_text_parser, Array, String)
409 GDVIRTUAL0RC(Vector2, _get_minimum_size)
410 GDVIRTUAL1RC(String, _get_tooltip, Vector2)
411
412 GDVIRTUAL1R(Variant, _get_drag_data, Vector2)
413 GDVIRTUAL2RC(bool, _can_drop_data, Vector2, Variant)
414 GDVIRTUAL2(_drop_data, Vector2, Variant)
415 GDVIRTUAL1RC(Object *, _make_custom_tooltip, String)
416
417 GDVIRTUAL0RC(String, _accessibility_get_contextual_info);
418 GDVIRTUAL1RC(String, _get_accessibility_container_name, RequiredParam<const Node>)
419
420 GDVIRTUAL1(_gui_input, RequiredParam<InputEvent>)
421
422 public:
423 enum {
424 NOTIFICATION_RESIZED = 40,
425 NOTIFICATION_MOUSE_ENTER = 41,
426 NOTIFICATION_MOUSE_EXIT = 42,
427 NOTIFICATION_FOCUS_ENTER = 43,
428 NOTIFICATION_FOCUS_EXIT = 44,
429 NOTIFICATION_THEME_CHANGED = 45,
430 NOTIFICATION_SCROLL_BEGIN = 47,
431 NOTIFICATION_SCROLL_END = 48,
432 NOTIFICATION_LAYOUT_DIRECTION_CHANGED = 49,
433 NOTIFICATION_MOUSE_ENTER_SELF = 60,
434 NOTIFICATION_MOUSE_EXIT_SELF = 61,
435 };
436
437 // Editor plugin interoperability.
438
439 // TODO: Decouple controls from their editor plugin and get rid of this.
440 #ifdef TOOLS_ENABLED
441 virtual Dictionary _edit_get_state() const override;
442 virtual void _edit_set_state(const Dictionary &p_state) override;
443
444 virtual void _edit_set_position(const Point2 &p_position) override;
445 virtual Point2 _edit_get_position() const override;
446
447 virtual void _edit_set_scale(const Size2 &p_scale) override;
448 virtual Size2 _edit_get_scale() const override;
449
450 virtual void _edit_set_rect(const Rect2 &p_edit_rect) override;
451
452 virtual void _edit_set_rotation(real_t p_rotation) override;
453 virtual real_t _edit_get_rotation() const override;
454 virtual bool _edit_use_rotation() const override;
455
456 virtual void _edit_set_pivot(const Point2 &p_pivot) override;
457 virtual Point2 _edit_get_pivot() const override;
458 virtual bool _edit_use_pivot() const override;
459
460 virtual Size2 _edit_get_minimum_size() const override;
461 #endif //TOOLS_ENABLED
462
463 #ifdef DEBUG_ENABLED
464 virtual Rect2 _edit_get_rect() const override;
465 virtual bool _edit_use_rect() const override;
466 #endif // DEBUG_ENABLED
467
468 virtual void reparent(RequiredParam<Node> p_parent, bool p_keep_global_transform = true) override;
469
470 // Editor integration.
471
472 static void set_root_layout_direction(int p_root_dir);
473
474 PackedStringArray get_configuration_warnings() const override;
475 PackedStringArray get_accessibility_configuration_warnings() const override;
476 #ifdef TOOLS_ENABLED
477 virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
478 #endif //TOOLS_ENABLED
479
480 virtual bool is_text_field() const;
481
482 // Global relations.
483
484 Control *get_parent_control() const;
485 Window *get_parent_window() const;
486 Control *get_root_parent_control() const;
487
488 Size2 get_parent_area_size() const;
489 Rect2 get_parent_anchorable_rect() const;
490
491 // Positioning and sizing.
492
493 virtual Transform2D get_transform() const override;
494
495 void set_anchor(Side p_side, real_t p_anchor, bool p_keep_offset = true, bool p_push_opposite_anchor = true);
496 real_t get_anchor(Side p_side) const;
497 void set_offset(Side p_side, real_t p_value);
498 real_t get_offset(Side p_side) const;
499 void set_anchor_and_offset(Side p_side, real_t p_anchor, real_t p_pos, bool p_push_opposite_anchor = true);
500
501 // TODO: Rename to set_begin/end_offsets ?
502 void set_begin(const Point2 &p_point);
503 Point2 get_begin() const;
504 void set_end(const Point2 &p_point);
505 Point2 get_end() const;
506
507 void set_h_grow_direction(GrowDirection p_direction);
508 GrowDirection get_h_grow_direction() const;
509 void set_v_grow_direction(GrowDirection p_direction);
510 GrowDirection get_v_grow_direction() const;
511
512 void set_anchors_preset(LayoutPreset p_preset, bool p_keep_offsets = true);
513 void set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0);
514 void set_anchors_and_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0);
515 void set_grow_direction_preset(LayoutPreset p_preset);
516
517 void set_position(const Point2 &p_point, bool p_keep_offsets = false);
518 void set_global_position(const Point2 &p_point, bool p_keep_offsets = false);
519 Point2 get_position() const;
520 Point2 get_global_position() const;
521 Point2 get_screen_position() const;
522
523 void set_size(const Size2 &p_size, bool p_keep_offsets = false);
524 Size2 get_size() const;
525 void reset_size();
526
527 void set_rect(const Rect2 &p_rect); // Reset anchors to begin and set rect, for faster container children sorting.
528 Rect2 get_rect() const;
529 Rect2 get_global_rect() const;
530 Rect2 get_screen_rect() const;
531 Rect2 get_anchorable_rect() const override;
532
533 void set_scale(const Vector2 &p_scale);
534 Vector2 get_scale() const;
535 void set_rotation(real_t p_radians);
536 void set_rotation_degrees(real_t p_degrees);
537 real_t get_rotation() const;
538 real_t get_rotation_degrees() const;
539 void set_pivot_offset_ratio(const Vector2 &p_ratio);
540 Vector2 get_pivot_offset_ratio() const;
541 void set_pivot_offset(const Vector2 &p_pivot);
542 Vector2 get_pivot_offset() const;
543 Vector2 get_combined_pivot_offset() const;
544
545 void update_minimum_size();
546
547 void set_block_minimum_size_adjust(bool p_block);
548
549 virtual Size2 get_minimum_size() const;
550 virtual Size2 get_combined_minimum_size() const;
551
552 void set_custom_minimum_size(const Size2 &p_custom);
553 Size2 get_custom_minimum_size() const;
554
555 // Container sizing.
556
557 void set_h_size_flags(BitField<SizeFlags> p_flags);
558 BitField<SizeFlags> get_h_size_flags() const;
559 void set_v_size_flags(BitField<SizeFlags> p_flags);
560 BitField<SizeFlags> get_v_size_flags() const;
561 void set_stretch_ratio(real_t p_ratio);
562 real_t get_stretch_ratio() const;
563
564 // Input events.
565
566 virtual void gui_input(const Ref<InputEvent> &p_event);
567 void accept_event();
568
569 virtual bool has_point(const Point2 &p_point) const;
570
571 void set_mouse_filter(MouseFilter p_filter);
572 MouseFilter get_mouse_filter() const;
573 MouseFilter get_mouse_filter_with_override() const;
574
575 void set_mouse_behavior_recursive(MouseBehaviorRecursive p_mouse_behavior_recursive);
576 MouseBehaviorRecursive get_mouse_behavior_recursive() const;
577
578 void set_force_pass_scroll_events(bool p_force_pass_scroll_events);
579 bool is_force_pass_scroll_events() const;
580
581 void warp_mouse(const Point2 &p_position);
582
583 bool is_focus_owner_in_shortcut_context() const;
584 void set_shortcut_context(const Node *p_node);
585 Node *get_shortcut_context() const;
586
587 // Drag and drop handling.
588
589 virtual void set_drag_forwarding(const Callable &p_drag, const Callable &p_can_drop, const Callable &p_drop);
590 virtual Variant get_drag_data(const Point2 &p_point);
591 virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
592 virtual void drop_data(const Point2 &p_point, const Variant &p_data);
593 void set_drag_preview(Control *p_control);
594 void force_drag(const Variant &p_data, Control *p_control);
595 void accessibility_drag();
596 void accessibility_drop();
597 bool is_drag_successful() const;
598
599 // Focus.
600
601 void set_focus_mode(FocusMode p_focus_mode);
602 FocusMode get_focus_mode() const;
603 FocusMode get_focus_mode_with_override() const;
604 void set_focus_behavior_recursive(FocusBehaviorRecursive p_focus_behavior_recursive);
605 FocusBehaviorRecursive get_focus_behavior_recursive() const;
606 bool has_focus(bool p_ignore_hidden_focus = false) const;
607 void grab_focus(bool p_hide_focus = false);
608 void grab_click_focus();
609 void release_focus();
610
611 Control *find_next_valid_focus() const;
612 Control *find_prev_valid_focus() const;
613 Control *find_valid_focus_neighbor(Side p_size) const;
614
615 void set_focus_neighbor(Side p_side, const NodePath &p_neighbor);
616 NodePath get_focus_neighbor(Side p_side) const;
617
618 void set_focus_next(const NodePath &p_next);
619 NodePath get_focus_next() const;
620 void set_focus_previous(const NodePath &p_prev);
621 NodePath get_focus_previous() const;
622
623 // Accessibility.
624
625 virtual String get_accessibility_container_name(const Node *p_node) const;
626
627 void set_accessibility_name(const String &p_name);
628 String get_accessibility_name() const;
629
630 void set_accessibility_description(const String &p_description);
631 String get_accessibility_description() const;
632
633 void set_accessibility_live(DisplayServer::AccessibilityLiveMode p_mode);
634 DisplayServer::AccessibilityLiveMode get_accessibility_live() const;
635
636 void set_accessibility_controls_nodes(const TypedArray<NodePath> &p_node_path);
637 TypedArray<NodePath> get_accessibility_controls_nodes() const;
638
639 void set_accessibility_described_by_nodes(const TypedArray<NodePath> &p_node_path);
640 TypedArray<NodePath> get_accessibility_described_by_nodes() const;
641
642 void set_accessibility_labeled_by_nodes(const TypedArray<NodePath> &p_node_path);
643 TypedArray<NodePath> get_accessibility_labeled_by_nodes() const;
644
645 void set_accessibility_flow_to_nodes(const TypedArray<NodePath> &p_node_path);
646 TypedArray<NodePath> get_accessibility_flow_to_nodes() const;
647
648 // Rendering.
649
650 void set_default_cursor_shape(CursorShape p_shape);
651 CursorShape get_default_cursor_shape() const;
652 virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const;
653
654 void set_clip_contents(bool p_clip);
655 bool is_clipping_contents();
656
657 void set_disable_visibility_clip(bool p_ignore);
658 bool is_visibility_clip_disabled() const;
659
660 // Theming.
661
662 void set_theme_owner_node(Node *p_node);
663 Node *get_theme_owner_node() const;
664 bool has_theme_owner_node() const;
665
666 void set_theme_context(ThemeContext *p_context, bool p_propagate = true);
667
668 void set_theme(const Ref<Theme> &p_theme);
669 Ref<Theme> get_theme() const;
670
671 void set_theme_type_variation(const StringName &p_theme_type);
672 StringName get_theme_type_variation() const;
673
674 void begin_bulk_theme_override();
675 void end_bulk_theme_override();
676
677 void add_theme_icon_override(const StringName &p_name, RequiredParam<Texture2D> rp_icon);
678 void add_theme_style_override(const StringName &p_name, RequiredParam<StyleBox> rp_style);
679 void add_theme_font_override(const StringName &p_name, RequiredParam<Font> rp_font);
680 void add_theme_font_size_override(const StringName &p_name, int p_font_size);
681 void add_theme_color_override(const StringName &p_name, const Color &p_color);
682 void add_theme_constant_override(const StringName &p_name, int p_constant);
683
684 void remove_theme_icon_override(const StringName &p_name);
685 void remove_theme_style_override(const StringName &p_name);
686 void remove_theme_font_override(const StringName &p_name);
687 void remove_theme_font_size_override(const StringName &p_name);
688 void remove_theme_color_override(const StringName &p_name);
689 void remove_theme_constant_override(const StringName &p_name);
690
691 Ref<Texture2D> get_theme_icon(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
692 Ref<StyleBox> get_theme_stylebox(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
693 Ref<Font> get_theme_font(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
694 int get_theme_font_size(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
695 Color get_theme_color(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
696 int get_theme_constant(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
697 Variant get_theme_item(Theme::DataType p_data_type, const StringName &p_name, const StringName &p_theme_type = StringName()) const;
698 Variant get_used_theme_item(const String &p_full_name, const StringName &p_theme_type = StringName()) const;
699 #ifdef TOOLS_ENABLED
700 Ref<Texture2D> get_editor_theme_icon(const StringName &p_name) const;
701 #endif //TOOLS_ENABLED
702
703 bool has_theme_icon_override(const StringName &p_name) const;
704 bool has_theme_stylebox_override(const StringName &p_name) const;
705 bool has_theme_font_override(const StringName &p_name) const;
706 bool has_theme_font_size_override(const StringName &p_name) const;
707 bool has_theme_color_override(const StringName &p_name) const;
708 bool has_theme_constant_override(const StringName &p_name) const;
709
710 bool has_theme_icon(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
711 bool has_theme_stylebox(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
712 bool has_theme_font(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
713 bool has_theme_font_size(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
714 bool has_theme_color(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
715 bool has_theme_constant(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
716
717 float get_theme_default_base_scale() const;
718 Ref<Font> get_theme_default_font() const;
719 int get_theme_default_font_size() const;
720
721 // Internationalization.
722
723 void set_layout_direction(LayoutDirection p_direction);
724 LayoutDirection get_layout_direction() const;
725 virtual bool is_layout_rtl() const;
726
727 void set_localize_numeral_system(bool p_enable);
728 bool is_localizing_numeral_system() const;
729
730 #ifndef DISABLE_DEPRECATED
731 void set_auto_translate(bool p_enable);
732 bool is_auto_translating() const;
733 #endif //DISABLE_DEPRECATED
734
735 void set_tooltip_auto_translate_mode(AutoTranslateMode p_mode);
736 AutoTranslateMode get_tooltip_auto_translate_mode() const;
737
738 // Extra properties.
739
740 String get_tooltip_text() const;
741 void set_tooltip_text(const String &text);
742 virtual String get_tooltip(const Point2 &p_pos) const;
743 virtual Control *make_custom_tooltip(const String &p_text) const;
744
745 virtual String accessibility_get_contextual_info() const;
746
747 Control();
748 ~Control();
749 };
750
751 VARIANT_ENUM_CAST(Control::FocusMode);
752 VARIANT_ENUM_CAST(Control::FocusBehaviorRecursive);
753 VARIANT_ENUM_CAST(Control::MouseBehaviorRecursive);
754 VARIANT_BITFIELD_CAST(Control::SizeFlags);
755 VARIANT_ENUM_CAST(Control::CursorShape);
756 VARIANT_ENUM_CAST(Control::LayoutPreset);
757 VARIANT_ENUM_CAST(Control::LayoutPresetMode);
758 VARIANT_ENUM_CAST(Control::MouseFilter);
759 VARIANT_ENUM_CAST(Control::GrowDirection);
760 VARIANT_ENUM_CAST(Control::Anchor);
761 VARIANT_ENUM_CAST(Control::LayoutMode);
762 VARIANT_ENUM_CAST(Control::LayoutDirection);
763 VARIANT_ENUM_CAST(Control::TextDirection);
764
765 // G = get_drag_data_fw, C = can_drop_data_fw, D = drop_data_fw, U = underscore
766 #define SET_DRAG_FORWARDING_CD(from, to) from->set_drag_forwarding(Callable(), callable_mp(this, &to::can_drop_data_fw).bind(from), callable_mp(this, &to::drop_data_fw).bind(from));
767 #define SET_DRAG_FORWARDING_CDU(from, to) from->set_drag_forwarding(Callable(), callable_mp(this, &to::_can_drop_data_fw).bind(from), callable_mp(this, &to::_drop_data_fw).bind(from));
768 #define SET_DRAG_FORWARDING_GCD(from, to) from->set_drag_forwarding(callable_mp(this, &to::get_drag_data_fw).bind(from), callable_mp(this, &to::can_drop_data_fw).bind(from), callable_mp(this, &to::drop_data_fw).bind(from));
769 #define SET_DRAG_FORWARDING_GCDU(from, to) from->set_drag_forwarding(callable_mp(this, &to::_get_drag_data_fw).bind(from), callable_mp(this, &to::_can_drop_data_fw).bind(from), callable_mp(this, &to::_drop_data_fw).bind(from));