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