control.h 23 KB

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