control.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  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. #ifndef CONTROL_H
  31. #define CONTROL_H
  32. #include "core/math/transform_2d.h"
  33. #include "core/object/gdvirtual.gen.inc"
  34. #include "core/templates/rid.h"
  35. #include "scene/main/canvas_item.h"
  36. #include "scene/main/timer.h"
  37. #include "scene/resources/theme.h"
  38. class Viewport;
  39. class Label;
  40. class Panel;
  41. class ThemeOwner;
  42. class ThemeContext;
  43. class Control : public CanvasItem {
  44. GDCLASS(Control, CanvasItem);
  45. public:
  46. enum Anchor {
  47. ANCHOR_BEGIN = 0,
  48. ANCHOR_END = 1
  49. };
  50. enum GrowDirection {
  51. GROW_DIRECTION_BEGIN,
  52. GROW_DIRECTION_END,
  53. GROW_DIRECTION_BOTH
  54. };
  55. enum FocusMode {
  56. FOCUS_NONE,
  57. FOCUS_CLICK,
  58. FOCUS_ALL
  59. };
  60. enum SizeFlags {
  61. SIZE_SHRINK_BEGIN = 0,
  62. SIZE_FILL = 1,
  63. SIZE_EXPAND = 2,
  64. SIZE_SHRINK_CENTER = 4,
  65. SIZE_SHRINK_END = 8,
  66. SIZE_EXPAND_FILL = SIZE_EXPAND | SIZE_FILL,
  67. };
  68. enum MouseFilter {
  69. MOUSE_FILTER_STOP,
  70. MOUSE_FILTER_PASS,
  71. MOUSE_FILTER_IGNORE
  72. };
  73. enum CursorShape {
  74. CURSOR_ARROW,
  75. CURSOR_IBEAM,
  76. CURSOR_POINTING_HAND,
  77. CURSOR_CROSS,
  78. CURSOR_WAIT,
  79. CURSOR_BUSY,
  80. CURSOR_DRAG,
  81. CURSOR_CAN_DROP,
  82. CURSOR_FORBIDDEN,
  83. CURSOR_VSIZE,
  84. CURSOR_HSIZE,
  85. CURSOR_BDIAGSIZE,
  86. CURSOR_FDIAGSIZE,
  87. CURSOR_MOVE,
  88. CURSOR_VSPLIT,
  89. CURSOR_HSPLIT,
  90. CURSOR_HELP,
  91. CURSOR_MAX
  92. };
  93. enum LayoutPreset {
  94. PRESET_TOP_LEFT,
  95. PRESET_TOP_RIGHT,
  96. PRESET_BOTTOM_LEFT,
  97. PRESET_BOTTOM_RIGHT,
  98. PRESET_CENTER_LEFT,
  99. PRESET_CENTER_TOP,
  100. PRESET_CENTER_RIGHT,
  101. PRESET_CENTER_BOTTOM,
  102. PRESET_CENTER,
  103. PRESET_LEFT_WIDE,
  104. PRESET_TOP_WIDE,
  105. PRESET_RIGHT_WIDE,
  106. PRESET_BOTTOM_WIDE,
  107. PRESET_VCENTER_WIDE,
  108. PRESET_HCENTER_WIDE,
  109. PRESET_FULL_RECT
  110. };
  111. enum LayoutPresetMode {
  112. PRESET_MODE_MINSIZE,
  113. PRESET_MODE_KEEP_WIDTH,
  114. PRESET_MODE_KEEP_HEIGHT,
  115. PRESET_MODE_KEEP_SIZE
  116. };
  117. enum LayoutMode {
  118. LAYOUT_MODE_POSITION,
  119. LAYOUT_MODE_ANCHORS,
  120. LAYOUT_MODE_CONTAINER,
  121. LAYOUT_MODE_UNCONTROLLED,
  122. };
  123. enum LayoutDirection {
  124. LAYOUT_DIRECTION_INHERITED,
  125. LAYOUT_DIRECTION_LOCALE,
  126. LAYOUT_DIRECTION_LTR,
  127. LAYOUT_DIRECTION_RTL
  128. };
  129. enum TextDirection {
  130. TEXT_DIRECTION_AUTO = TextServer::DIRECTION_AUTO,
  131. TEXT_DIRECTION_LTR = TextServer::DIRECTION_LTR,
  132. TEXT_DIRECTION_RTL = TextServer::DIRECTION_RTL,
  133. TEXT_DIRECTION_INHERITED = TextServer::DIRECTION_INHERITED,
  134. };
  135. private:
  136. struct CComparator {
  137. bool operator()(const Control *p_a, const Control *p_b) const {
  138. if (p_a->get_canvas_layer() == p_b->get_canvas_layer()) {
  139. return p_b->is_greater_than(p_a);
  140. }
  141. return p_a->get_canvas_layer() < p_b->get_canvas_layer();
  142. }
  143. };
  144. // This Data struct is to avoid namespace pollution in derived classes.
  145. struct Data {
  146. bool initialized = false;
  147. // Global relations.
  148. List<Control *>::Element *RI = nullptr;
  149. Control *parent_control = nullptr;
  150. Window *parent_window = nullptr;
  151. CanvasItem *parent_canvas_item = nullptr;
  152. Callable forward_drag;
  153. Callable forward_can_drop;
  154. Callable forward_drop;
  155. // Positioning and sizing.
  156. LayoutMode stored_layout_mode = LayoutMode::LAYOUT_MODE_POSITION;
  157. bool stored_use_custom_anchors = false;
  158. real_t offset[4] = { 0.0, 0.0, 0.0, 0.0 };
  159. real_t anchor[4] = { ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN };
  160. FocusMode focus_mode = FOCUS_NONE;
  161. GrowDirection h_grow = GROW_DIRECTION_END;
  162. GrowDirection v_grow = GROW_DIRECTION_END;
  163. real_t rotation = 0.0;
  164. Vector2 scale = Vector2(1, 1);
  165. Vector2 pivot_offset;
  166. Point2 pos_cache;
  167. Size2 size_cache;
  168. Size2 minimum_size_cache;
  169. bool minimum_size_valid = false;
  170. Size2 last_minimum_size;
  171. bool updating_last_minimum_size = false;
  172. bool block_minimum_size_adjust = false;
  173. bool size_warning = true;
  174. // Container sizing.
  175. BitField<SizeFlags> h_size_flags = SIZE_FILL;
  176. BitField<SizeFlags> v_size_flags = SIZE_FILL;
  177. real_t expand = 1.0;
  178. Point2 custom_minimum_size;
  179. // Input events and rendering.
  180. MouseFilter mouse_filter = MOUSE_FILTER_STOP;
  181. bool force_pass_scroll_events = true;
  182. bool clip_contents = false;
  183. bool disable_visibility_clip = false;
  184. CursorShape default_cursor = CURSOR_ARROW;
  185. // Focus.
  186. NodePath focus_neighbor[4];
  187. NodePath focus_next;
  188. NodePath focus_prev;
  189. ObjectID shortcut_context;
  190. // Theming.
  191. ThemeOwner *theme_owner = nullptr;
  192. Ref<Theme> theme;
  193. StringName theme_type_variation;
  194. bool bulk_theme_override = false;
  195. Theme::ThemeIconMap theme_icon_override;
  196. Theme::ThemeStyleMap theme_style_override;
  197. Theme::ThemeFontMap theme_font_override;
  198. Theme::ThemeFontSizeMap theme_font_size_override;
  199. Theme::ThemeColorMap theme_color_override;
  200. Theme::ThemeConstantMap theme_constant_override;
  201. mutable HashMap<StringName, Theme::ThemeIconMap> theme_icon_cache;
  202. mutable HashMap<StringName, Theme::ThemeStyleMap> theme_style_cache;
  203. mutable HashMap<StringName, Theme::ThemeFontMap> theme_font_cache;
  204. mutable HashMap<StringName, Theme::ThemeFontSizeMap> theme_font_size_cache;
  205. mutable HashMap<StringName, Theme::ThemeColorMap> theme_color_cache;
  206. mutable HashMap<StringName, Theme::ThemeConstantMap> theme_constant_cache;
  207. // Internationalization.
  208. LayoutDirection layout_dir = LAYOUT_DIRECTION_INHERITED;
  209. bool is_rtl_dirty = true;
  210. bool is_rtl = false;
  211. bool localize_numeral_system = true;
  212. // Extra properties.
  213. String tooltip;
  214. } data;
  215. // Dynamic properties.
  216. static constexpr unsigned properties_managed_by_container_count = 12;
  217. static String properties_managed_by_container[properties_managed_by_container_count];
  218. // Global relations.
  219. friend class Viewport;
  220. // Positioning and sizing.
  221. void _update_canvas_item_transform();
  222. Transform2D _get_internal_transform() const;
  223. void _set_anchor(Side p_side, real_t p_anchor);
  224. void _set_position(const Point2 &p_point);
  225. void _set_global_position(const Point2 &p_point);
  226. void _set_size(const Size2 &p_size);
  227. void _compute_offsets(Rect2 p_rect, const real_t p_anchors[4], real_t (&r_offsets)[4]);
  228. void _compute_anchors(Rect2 p_rect, const real_t p_offsets[4], real_t (&r_anchors)[4]);
  229. void _set_layout_mode(LayoutMode p_mode);
  230. void _update_layout_mode();
  231. LayoutMode _get_layout_mode() const;
  232. LayoutMode _get_default_layout_mode() const;
  233. void _set_anchors_layout_preset(int p_preset);
  234. int _get_anchors_layout_preset() const;
  235. void _update_minimum_size_cache();
  236. void _update_minimum_size();
  237. void _size_changed();
  238. void _top_level_changed() override {} // Controls don't need to do anything, only other CanvasItems.
  239. void _top_level_changed_on_parent() override;
  240. void _clear_size_warning();
  241. // Input events.
  242. void _call_gui_input(const Ref<InputEvent> &p_event);
  243. // Focus.
  244. void _window_find_focus_neighbor(const Vector2 &p_dir, Node *p_at, const Point2 *p_points, real_t p_min, real_t &r_closest_dist, Control **r_closest);
  245. Control *_get_focus_neighbor(Side p_side, int p_count = 0);
  246. // Theming.
  247. void _theme_changed();
  248. void _notify_theme_override_changed();
  249. void _invalidate_theme_cache();
  250. // Extra properties.
  251. static int root_layout_direction;
  252. String get_tooltip_text() const;
  253. protected:
  254. // Dynamic properties.
  255. bool _set(const StringName &p_name, const Variant &p_value);
  256. bool _get(const StringName &p_name, Variant &r_ret) const;
  257. void _get_property_list(List<PropertyInfo> *p_list) const;
  258. void _validate_property(PropertyInfo &p_property) const;
  259. bool _property_can_revert(const StringName &p_name) const;
  260. bool _property_get_revert(const StringName &p_name, Variant &r_property) const;
  261. // Theming.
  262. virtual void _update_theme_item_cache();
  263. // Internationalization.
  264. virtual TypedArray<Vector3i> structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const;
  265. // Base object overrides.
  266. void _notification(int p_notification);
  267. static void _bind_methods();
  268. #ifndef DISABLE_DEPRECATED
  269. static void _bind_compatibility_methods();
  270. #endif
  271. // Exposed virtual methods.
  272. GDVIRTUAL1RC(bool, _has_point, Vector2)
  273. GDVIRTUAL2RC(TypedArray<Vector3i>, _structured_text_parser, Array, String)
  274. GDVIRTUAL0RC(Vector2, _get_minimum_size)
  275. GDVIRTUAL1RC(String, _get_tooltip, Vector2)
  276. GDVIRTUAL1R(Variant, _get_drag_data, Vector2)
  277. GDVIRTUAL2RC(bool, _can_drop_data, Vector2, Variant)
  278. GDVIRTUAL2(_drop_data, Vector2, Variant)
  279. GDVIRTUAL1RC(Object *, _make_custom_tooltip, String)
  280. GDVIRTUAL1(_gui_input, Ref<InputEvent>)
  281. public:
  282. enum {
  283. NOTIFICATION_RESIZED = 40,
  284. NOTIFICATION_MOUSE_ENTER = 41,
  285. NOTIFICATION_MOUSE_EXIT = 42,
  286. NOTIFICATION_FOCUS_ENTER = 43,
  287. NOTIFICATION_FOCUS_EXIT = 44,
  288. NOTIFICATION_THEME_CHANGED = 45,
  289. NOTIFICATION_SCROLL_BEGIN = 47,
  290. NOTIFICATION_SCROLL_END = 48,
  291. NOTIFICATION_LAYOUT_DIRECTION_CHANGED = 49,
  292. NOTIFICATION_MOUSE_ENTER_SELF = 60,
  293. NOTIFICATION_MOUSE_EXIT_SELF = 61,
  294. };
  295. // Editor plugin interoperability.
  296. // TODO: Decouple controls from their editor plugin and get rid of this.
  297. #ifdef TOOLS_ENABLED
  298. virtual Dictionary _edit_get_state() const override;
  299. virtual void _edit_set_state(const Dictionary &p_state) override;
  300. virtual void _edit_set_position(const Point2 &p_position) override;
  301. virtual Point2 _edit_get_position() const override;
  302. virtual void _edit_set_scale(const Size2 &p_scale) override;
  303. virtual Size2 _edit_get_scale() const override;
  304. virtual void _edit_set_rect(const Rect2 &p_edit_rect) override;
  305. virtual Rect2 _edit_get_rect() const override;
  306. virtual bool _edit_use_rect() const override;
  307. virtual void _edit_set_rotation(real_t p_rotation) override;
  308. virtual real_t _edit_get_rotation() const override;
  309. virtual bool _edit_use_rotation() const override;
  310. virtual void _edit_set_pivot(const Point2 &p_pivot) override;
  311. virtual Point2 _edit_get_pivot() const override;
  312. virtual bool _edit_use_pivot() const override;
  313. virtual Size2 _edit_get_minimum_size() const override;
  314. #endif
  315. virtual void reparent(Node *p_parent, bool p_keep_global_transform = true) override;
  316. // Editor integration.
  317. static void set_root_layout_direction(int p_root_dir);
  318. virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
  319. PackedStringArray get_configuration_warnings() const override;
  320. virtual bool is_text_field() const;
  321. // Global relations.
  322. bool is_top_level_control() const;
  323. Control *get_parent_control() const;
  324. Window *get_parent_window() const;
  325. Control *get_root_parent_control() const;
  326. Size2 get_parent_area_size() const;
  327. Rect2 get_parent_anchorable_rect() const;
  328. // Positioning and sizing.
  329. virtual Transform2D get_transform() const override;
  330. void set_anchor(Side p_side, real_t p_anchor, bool p_keep_offset = true, bool p_push_opposite_anchor = true);
  331. real_t get_anchor(Side p_side) const;
  332. void set_offset(Side p_side, real_t p_value);
  333. real_t get_offset(Side p_side) const;
  334. void set_anchor_and_offset(Side p_side, real_t p_anchor, real_t p_pos, bool p_push_opposite_anchor = true);
  335. // TODO: Rename to set_begin/end_offsets ?
  336. void set_begin(const Point2 &p_point);
  337. Point2 get_begin() const;
  338. void set_end(const Point2 &p_point);
  339. Point2 get_end() const;
  340. void set_h_grow_direction(GrowDirection p_direction);
  341. GrowDirection get_h_grow_direction() const;
  342. void set_v_grow_direction(GrowDirection p_direction);
  343. GrowDirection get_v_grow_direction() const;
  344. void set_anchors_preset(LayoutPreset p_preset, bool p_keep_offsets = true);
  345. void set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0);
  346. void set_anchors_and_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0);
  347. void set_grow_direction_preset(LayoutPreset p_preset);
  348. void set_position(const Point2 &p_point, bool p_keep_offsets = false);
  349. void set_global_position(const Point2 &p_point, bool p_keep_offsets = false);
  350. Point2 get_position() const;
  351. Point2 get_global_position() const;
  352. Point2 get_screen_position() const;
  353. void set_size(const Size2 &p_size, bool p_keep_offsets = false);
  354. Size2 get_size() const;
  355. void reset_size();
  356. void set_rect(const Rect2 &p_rect); // Reset anchors to begin and set rect, for faster container children sorting.
  357. Rect2 get_rect() const;
  358. Rect2 get_global_rect() const;
  359. Rect2 get_screen_rect() const;
  360. Rect2 get_anchorable_rect() const override;
  361. void set_scale(const Vector2 &p_scale);
  362. Vector2 get_scale() const;
  363. void set_rotation(real_t p_radians);
  364. void set_rotation_degrees(real_t p_degrees);
  365. real_t get_rotation() const;
  366. real_t get_rotation_degrees() const;
  367. void set_pivot_offset(const Vector2 &p_pivot);
  368. Vector2 get_pivot_offset() const;
  369. void update_minimum_size();
  370. void set_block_minimum_size_adjust(bool p_block);
  371. virtual Size2 get_minimum_size() const;
  372. virtual Size2 get_combined_minimum_size() const;
  373. void set_custom_minimum_size(const Size2 &p_custom);
  374. Size2 get_custom_minimum_size() const;
  375. // Container sizing.
  376. void set_h_size_flags(BitField<SizeFlags> p_flags);
  377. BitField<SizeFlags> get_h_size_flags() const;
  378. void set_v_size_flags(BitField<SizeFlags> p_flags);
  379. BitField<SizeFlags> get_v_size_flags() const;
  380. void set_stretch_ratio(real_t p_ratio);
  381. real_t get_stretch_ratio() const;
  382. // Input events.
  383. virtual void gui_input(const Ref<InputEvent> &p_event);
  384. void accept_event();
  385. virtual bool has_point(const Point2 &p_point) const;
  386. void set_mouse_filter(MouseFilter p_filter);
  387. MouseFilter get_mouse_filter() const;
  388. void set_force_pass_scroll_events(bool p_force_pass_scroll_events);
  389. bool is_force_pass_scroll_events() const;
  390. void warp_mouse(const Point2 &p_position);
  391. bool is_focus_owner_in_shortcut_context() const;
  392. void set_shortcut_context(const Node *p_node);
  393. Node *get_shortcut_context() const;
  394. // Drag and drop handling.
  395. virtual void set_drag_forwarding(const Callable &p_drag, const Callable &p_can_drop, const Callable &p_drop);
  396. virtual Variant get_drag_data(const Point2 &p_point);
  397. virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
  398. virtual void drop_data(const Point2 &p_point, const Variant &p_data);
  399. void set_drag_preview(Control *p_control);
  400. void force_drag(const Variant &p_data, Control *p_control);
  401. bool is_drag_successful() const;
  402. // Focus.
  403. void set_focus_mode(FocusMode p_focus_mode);
  404. FocusMode get_focus_mode() const;
  405. bool has_focus() const;
  406. void grab_focus();
  407. void grab_click_focus();
  408. void release_focus();
  409. Control *find_next_valid_focus() const;
  410. Control *find_prev_valid_focus() const;
  411. Control *find_valid_focus_neighbor(Side p_size) const;
  412. void set_focus_neighbor(Side p_side, const NodePath &p_neighbor);
  413. NodePath get_focus_neighbor(Side p_side) const;
  414. void set_focus_next(const NodePath &p_next);
  415. NodePath get_focus_next() const;
  416. void set_focus_previous(const NodePath &p_prev);
  417. NodePath get_focus_previous() const;
  418. // Rendering.
  419. void set_default_cursor_shape(CursorShape p_shape);
  420. CursorShape get_default_cursor_shape() const;
  421. virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const;
  422. void set_clip_contents(bool p_clip);
  423. bool is_clipping_contents();
  424. void set_disable_visibility_clip(bool p_ignore);
  425. bool is_visibility_clip_disabled() const;
  426. // Theming.
  427. void set_theme_owner_node(Node *p_node);
  428. Node *get_theme_owner_node() const;
  429. bool has_theme_owner_node() const;
  430. void set_theme_context(ThemeContext *p_context, bool p_propagate = true);
  431. void set_theme(const Ref<Theme> &p_theme);
  432. Ref<Theme> get_theme() const;
  433. void set_theme_type_variation(const StringName &p_theme_type);
  434. StringName get_theme_type_variation() const;
  435. void begin_bulk_theme_override();
  436. void end_bulk_theme_override();
  437. void add_theme_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon);
  438. void add_theme_style_override(const StringName &p_name, const Ref<StyleBox> &p_style);
  439. void add_theme_font_override(const StringName &p_name, const Ref<Font> &p_font);
  440. void add_theme_font_size_override(const StringName &p_name, int p_font_size);
  441. void add_theme_color_override(const StringName &p_name, const Color &p_color);
  442. void add_theme_constant_override(const StringName &p_name, int p_constant);
  443. void remove_theme_icon_override(const StringName &p_name);
  444. void remove_theme_style_override(const StringName &p_name);
  445. void remove_theme_font_override(const StringName &p_name);
  446. void remove_theme_font_size_override(const StringName &p_name);
  447. void remove_theme_color_override(const StringName &p_name);
  448. void remove_theme_constant_override(const StringName &p_name);
  449. Ref<Texture2D> get_theme_icon(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  450. Ref<StyleBox> get_theme_stylebox(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  451. Ref<Font> get_theme_font(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  452. int get_theme_font_size(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  453. Color get_theme_color(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  454. int get_theme_constant(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  455. Variant get_theme_item(Theme::DataType p_data_type, const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  456. #ifdef TOOLS_ENABLED
  457. Ref<Texture2D> get_editor_theme_icon(const StringName &p_name) const;
  458. #endif
  459. bool has_theme_icon_override(const StringName &p_name) const;
  460. bool has_theme_stylebox_override(const StringName &p_name) const;
  461. bool has_theme_font_override(const StringName &p_name) const;
  462. bool has_theme_font_size_override(const StringName &p_name) const;
  463. bool has_theme_color_override(const StringName &p_name) const;
  464. bool has_theme_constant_override(const StringName &p_name) const;
  465. bool has_theme_icon(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  466. bool has_theme_stylebox(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  467. bool has_theme_font(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  468. bool has_theme_font_size(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  469. bool has_theme_color(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  470. bool has_theme_constant(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
  471. float get_theme_default_base_scale() const;
  472. Ref<Font> get_theme_default_font() const;
  473. int get_theme_default_font_size() const;
  474. // Internationalization.
  475. void set_layout_direction(LayoutDirection p_direction);
  476. LayoutDirection get_layout_direction() const;
  477. virtual bool is_layout_rtl() const;
  478. void set_localize_numeral_system(bool p_enable);
  479. bool is_localizing_numeral_system() const;
  480. #ifndef DISABLE_DEPRECATED
  481. void set_auto_translate(bool p_enable);
  482. bool is_auto_translating() const;
  483. #endif
  484. // Extra properties.
  485. void set_tooltip_text(const String &text);
  486. virtual String get_tooltip(const Point2 &p_pos) const;
  487. virtual Control *make_custom_tooltip(const String &p_text) const;
  488. Control();
  489. ~Control();
  490. };
  491. VARIANT_ENUM_CAST(Control::FocusMode);
  492. VARIANT_BITFIELD_CAST(Control::SizeFlags);
  493. VARIANT_ENUM_CAST(Control::CursorShape);
  494. VARIANT_ENUM_CAST(Control::LayoutPreset);
  495. VARIANT_ENUM_CAST(Control::LayoutPresetMode);
  496. VARIANT_ENUM_CAST(Control::MouseFilter);
  497. VARIANT_ENUM_CAST(Control::GrowDirection);
  498. VARIANT_ENUM_CAST(Control::Anchor);
  499. VARIANT_ENUM_CAST(Control::LayoutMode);
  500. VARIANT_ENUM_CAST(Control::LayoutDirection);
  501. VARIANT_ENUM_CAST(Control::TextDirection);
  502. // G = get_drag_data_fw, C = can_drop_data_fw, D = drop_data_fw, U = underscore
  503. #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));
  504. #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));
  505. #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));
  506. #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));
  507. #endif // CONTROL_H