2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* control.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2021-01-01 19:13:46 +00:00
|
|
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef CONTROL_H
|
|
|
|
#define CONTROL_H
|
|
|
|
|
2021-08-22 15:37:22 +00:00
|
|
|
#include "core/input/shortcut.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/math/transform_2d.h"
|
2021-06-19 15:58:49 +00:00
|
|
|
#include "core/object/gdvirtual.gen.inc"
|
2020-11-07 22:33:38 +00:00
|
|
|
#include "core/templates/rid.h"
|
2020-03-27 07:44:44 +00:00
|
|
|
#include "scene/main/canvas_item.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/main/node.h"
|
|
|
|
#include "scene/main/timer.h"
|
|
|
|
#include "scene/resources/theme.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class Viewport;
|
|
|
|
class Label;
|
|
|
|
class Panel;
|
|
|
|
|
|
|
|
class Control : public CanvasItem {
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(Control, CanvasItem);
|
2014-02-10 01:10:30 +00:00
|
|
|
OBJ_CATEGORY("GUI Nodes");
|
|
|
|
|
|
|
|
public:
|
2017-08-15 22:48:38 +00:00
|
|
|
enum Anchor {
|
|
|
|
ANCHOR_BEGIN = 0,
|
|
|
|
ANCHOR_END = 1
|
|
|
|
};
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2017-07-06 16:26:39 +00:00
|
|
|
enum GrowDirection {
|
|
|
|
GROW_DIRECTION_BEGIN,
|
2018-02-12 03:58:39 +00:00
|
|
|
GROW_DIRECTION_END,
|
|
|
|
GROW_DIRECTION_BOTH
|
2017-07-06 16:26:39 +00:00
|
|
|
};
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
enum FocusMode {
|
|
|
|
FOCUS_NONE,
|
|
|
|
FOCUS_CLICK,
|
|
|
|
FOCUS_ALL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SizeFlags {
|
2017-03-05 15:44:50 +00:00
|
|
|
SIZE_FILL = 1,
|
|
|
|
SIZE_EXPAND = 2,
|
2017-07-06 22:06:55 +00:00
|
|
|
SIZE_EXPAND_FILL = SIZE_EXPAND | SIZE_FILL,
|
|
|
|
SIZE_SHRINK_CENTER = 4, //ignored by expand or fill
|
2018-09-13 02:53:10 +00:00
|
|
|
SIZE_SHRINK_END = 8, //ignored by expand or fill
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-01-08 22:54:19 +00:00
|
|
|
enum MouseFilter {
|
|
|
|
MOUSE_FILTER_STOP,
|
|
|
|
MOUSE_FILTER_PASS,
|
|
|
|
MOUSE_FILTER_IGNORE
|
|
|
|
};
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
enum CursorShape {
|
|
|
|
CURSOR_ARROW,
|
|
|
|
CURSOR_IBEAM,
|
|
|
|
CURSOR_POINTING_HAND,
|
|
|
|
CURSOR_CROSS,
|
|
|
|
CURSOR_WAIT,
|
|
|
|
CURSOR_BUSY,
|
|
|
|
CURSOR_DRAG,
|
|
|
|
CURSOR_CAN_DROP,
|
|
|
|
CURSOR_FORBIDDEN,
|
|
|
|
CURSOR_VSIZE,
|
|
|
|
CURSOR_HSIZE,
|
|
|
|
CURSOR_BDIAGSIZE,
|
|
|
|
CURSOR_FDIAGSIZE,
|
|
|
|
CURSOR_MOVE,
|
|
|
|
CURSOR_VSPLIT,
|
|
|
|
CURSOR_HSPLIT,
|
|
|
|
CURSOR_HELP,
|
|
|
|
CURSOR_MAX
|
|
|
|
};
|
|
|
|
|
2017-08-11 16:16:28 +00:00
|
|
|
enum LayoutPreset {
|
|
|
|
PRESET_TOP_LEFT,
|
|
|
|
PRESET_TOP_RIGHT,
|
|
|
|
PRESET_BOTTOM_LEFT,
|
|
|
|
PRESET_BOTTOM_RIGHT,
|
|
|
|
PRESET_CENTER_LEFT,
|
|
|
|
PRESET_CENTER_TOP,
|
|
|
|
PRESET_CENTER_RIGHT,
|
|
|
|
PRESET_CENTER_BOTTOM,
|
|
|
|
PRESET_CENTER,
|
|
|
|
PRESET_LEFT_WIDE,
|
|
|
|
PRESET_TOP_WIDE,
|
|
|
|
PRESET_RIGHT_WIDE,
|
|
|
|
PRESET_BOTTOM_WIDE,
|
|
|
|
PRESET_VCENTER_WIDE,
|
|
|
|
PRESET_HCENTER_WIDE,
|
|
|
|
PRESET_WIDE
|
|
|
|
};
|
|
|
|
|
2017-09-19 20:39:19 +00:00
|
|
|
enum LayoutPresetMode {
|
|
|
|
PRESET_MODE_MINSIZE,
|
|
|
|
PRESET_MODE_KEEP_WIDTH,
|
|
|
|
PRESET_MODE_KEEP_HEIGHT,
|
|
|
|
PRESET_MODE_KEEP_SIZE
|
|
|
|
};
|
|
|
|
|
2020-09-03 11:22:16 +00:00
|
|
|
enum LayoutDirection {
|
|
|
|
LAYOUT_DIRECTION_INHERITED,
|
|
|
|
LAYOUT_DIRECTION_LOCALE,
|
|
|
|
LAYOUT_DIRECTION_LTR,
|
|
|
|
LAYOUT_DIRECTION_RTL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum TextDirection {
|
|
|
|
TEXT_DIRECTION_AUTO = TextServer::DIRECTION_AUTO,
|
|
|
|
TEXT_DIRECTION_LTR = TextServer::DIRECTION_LTR,
|
|
|
|
TEXT_DIRECTION_RTL = TextServer::DIRECTION_RTL,
|
|
|
|
TEXT_DIRECTION_INHERITED,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum StructuredTextParser {
|
|
|
|
STRUCTURED_TEXT_DEFAULT,
|
|
|
|
STRUCTURED_TEXT_URI,
|
|
|
|
STRUCTURED_TEXT_FILE,
|
|
|
|
STRUCTURED_TEXT_EMAIL,
|
|
|
|
STRUCTURED_TEXT_LIST,
|
|
|
|
STRUCTURED_TEXT_NONE,
|
|
|
|
STRUCTURED_TEXT_CUSTOM
|
|
|
|
};
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
private:
|
|
|
|
struct CComparator {
|
2017-03-05 15:44:50 +00:00
|
|
|
bool operator()(const Control *p_a, const Control *p_b) const {
|
2020-05-14 14:41:43 +00:00
|
|
|
if (p_a->get_canvas_layer() == p_b->get_canvas_layer()) {
|
2016-01-24 13:57:42 +00:00
|
|
|
return p_b->is_greater_than(p_a);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2019-06-26 13:08:25 +00:00
|
|
|
|
|
|
|
return p_a->get_canvas_layer() < p_b->get_canvas_layer();
|
2016-01-24 13:57:42 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Data {
|
|
|
|
Point2 pos_cache;
|
|
|
|
Size2 size_cache;
|
2018-05-15 20:12:35 +00:00
|
|
|
Size2 minimum_size_cache;
|
2020-12-11 14:54:03 +00:00
|
|
|
bool minimum_size_valid = false;
|
2018-05-15 20:12:35 +00:00
|
|
|
|
|
|
|
Size2 last_minimum_size;
|
2020-12-11 14:54:03 +00:00
|
|
|
bool updating_last_minimum_size = false;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-01-30 04:10:32 +00:00
|
|
|
real_t offset[4] = { 0.0, 0.0, 0.0, 0.0 };
|
|
|
|
real_t anchor[4] = { ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN };
|
2020-12-11 14:54:03 +00:00
|
|
|
FocusMode focus_mode = FOCUS_NONE;
|
|
|
|
GrowDirection h_grow = GROW_DIRECTION_END;
|
|
|
|
GrowDirection v_grow = GROW_DIRECTION_END;
|
2015-12-12 16:54:26 +00:00
|
|
|
|
2020-12-11 14:54:03 +00:00
|
|
|
LayoutDirection layout_dir = LAYOUT_DIRECTION_INHERITED;
|
2021-07-25 07:33:00 +00:00
|
|
|
bool is_rtl_dirty = true;
|
|
|
|
bool is_rtl = false;
|
2020-09-03 11:22:16 +00:00
|
|
|
|
2021-05-27 17:31:33 +00:00
|
|
|
bool auto_translate = true;
|
|
|
|
|
2021-01-30 04:10:32 +00:00
|
|
|
real_t rotation = 0.0;
|
2020-12-11 14:54:03 +00:00
|
|
|
Vector2 scale = Vector2(1, 1);
|
2017-07-06 20:42:44 +00:00
|
|
|
Vector2 pivot_offset;
|
2020-09-30 10:00:21 +00:00
|
|
|
bool size_warning = true;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-12-11 14:54:03 +00:00
|
|
|
int h_size_flags = SIZE_FILL;
|
|
|
|
int v_size_flags = SIZE_FILL;
|
2021-01-30 04:10:32 +00:00
|
|
|
real_t expand = 1.0;
|
2014-02-10 01:10:30 +00:00
|
|
|
Point2 custom_minimum_size;
|
|
|
|
|
2020-12-11 14:54:03 +00:00
|
|
|
MouseFilter mouse_filter = MOUSE_FILTER_STOP;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-12-11 14:54:03 +00:00
|
|
|
bool clip_contents = false;
|
2017-01-09 18:50:08 +00:00
|
|
|
|
2020-12-11 14:54:03 +00:00
|
|
|
bool block_minimum_size_adjust = false;
|
|
|
|
bool disable_visibility_clip = false;
|
2016-08-25 20:45:20 +00:00
|
|
|
|
2020-12-11 14:54:03 +00:00
|
|
|
Control *parent = nullptr;
|
2016-05-03 14:10:28 +00:00
|
|
|
ObjectID drag_owner;
|
2014-02-10 01:10:30 +00:00
|
|
|
Ref<Theme> theme;
|
2020-12-11 14:54:03 +00:00
|
|
|
Control *theme_owner = nullptr;
|
|
|
|
Window *theme_owner_window = nullptr;
|
2021-07-19 17:25:15 +00:00
|
|
|
Window *parent_window = nullptr;
|
2021-07-04 20:42:23 +00:00
|
|
|
StringName theme_type_variation;
|
2021-03-30 17:16:33 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
String tooltip;
|
2020-12-11 14:54:03 +00:00
|
|
|
CursorShape default_cursor = CURSOR_ARROW;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-12-11 14:54:03 +00:00
|
|
|
List<Control *>::Element *RI = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-12-11 14:54:03 +00:00
|
|
|
CanvasItem *parent_canvas_item = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-12-15 22:42:21 +00:00
|
|
|
NodePath focus_neighbor[4];
|
2017-11-16 09:45:52 +00:00
|
|
|
NodePath focus_next;
|
|
|
|
NodePath focus_prev;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-08-12 17:35:42 +00:00
|
|
|
bool bulk_theme_override = false;
|
2020-03-17 06:33:00 +00:00
|
|
|
HashMap<StringName, Ref<Texture2D>> icon_override;
|
|
|
|
HashMap<StringName, Ref<StyleBox>> style_override;
|
|
|
|
HashMap<StringName, Ref<Font>> font_override;
|
2020-09-03 11:22:16 +00:00
|
|
|
HashMap<StringName, int> font_size_override;
|
2018-07-02 18:08:35 +00:00
|
|
|
HashMap<StringName, Color> color_override;
|
|
|
|
HashMap<StringName, int> constant_override;
|
2016-06-17 19:00:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
} data;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2021-09-05 20:01:36 +00:00
|
|
|
static constexpr unsigned properties_managed_by_container_count = 11;
|
|
|
|
static String properties_managed_by_container[properties_managed_by_container_count];
|
|
|
|
|
2021-01-30 04:10:32 +00:00
|
|
|
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);
|
2020-12-22 16:24:29 +00:00
|
|
|
Control *_get_focus_neighbor(Side p_side, int p_count = 0);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-01-30 04:10:32 +00:00
|
|
|
void _set_anchor(Side p_side, real_t p_anchor);
|
2019-03-31 16:53:24 +00:00
|
|
|
void _set_position(const Point2 &p_point);
|
|
|
|
void _set_global_position(const Point2 &p_point);
|
|
|
|
void _set_size(const Size2 &p_size);
|
2016-03-09 16:59:35 +00:00
|
|
|
|
2016-07-18 19:41:28 +00:00
|
|
|
void _theme_changed();
|
2021-08-12 17:35:42 +00:00
|
|
|
void _notify_theme_changed();
|
2016-07-18 19:41:28 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _update_minimum_size();
|
|
|
|
|
2020-09-30 10:00:21 +00:00
|
|
|
void _clear_size_warning();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-01-30 04:10:32 +00:00
|
|
|
void _compute_offsets(Rect2 p_rect, const real_t p_anchors[4], real_t (&r_offsets)[4]);
|
|
|
|
void _compute_anchors(Rect2 p_rect, const real_t p_offsets[4], real_t (&r_anchors)[4]);
|
2018-05-05 14:59:00 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _size_changed();
|
|
|
|
String _get_tooltip() const;
|
|
|
|
|
2019-02-25 15:13:25 +00:00
|
|
|
void _override_changed();
|
2016-06-17 19:00:27 +00:00
|
|
|
|
2016-08-31 02:44:14 +00:00
|
|
|
void _update_canvas_item_transform();
|
2016-06-17 19:00:27 +00:00
|
|
|
|
2017-07-06 20:42:44 +00:00
|
|
|
Transform2D _get_internal_transform() const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
friend class Viewport;
|
2016-01-17 01:41:10 +00:00
|
|
|
|
2021-08-22 15:37:22 +00:00
|
|
|
void _call_gui_input(const Ref<InputEvent> &p_event);
|
|
|
|
|
2018-05-15 20:12:35 +00:00
|
|
|
void _update_minimum_size_cache();
|
2020-03-06 17:00:16 +00:00
|
|
|
friend class Window;
|
|
|
|
static void _propagate_theme_changed(Node *p_at, Control *p_owner, Window *p_owner_window, bool p_assign = true);
|
|
|
|
|
|
|
|
template <class T>
|
2021-03-30 17:16:33 +00:00
|
|
|
static T get_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner_window, Theme::DataType p_data_type, const StringName &p_name, List<StringName> p_theme_types);
|
|
|
|
static bool has_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner_window, Theme::DataType p_data_type, const StringName &p_name, List<StringName> p_theme_types);
|
|
|
|
_FORCE_INLINE_ void _get_theme_type_dependencies(const StringName &p_theme_type, List<StringName> *p_list) const;
|
2018-05-15 20:12:35 +00:00
|
|
|
|
2016-03-08 23:00:52 +00:00
|
|
|
protected:
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void add_child_notify(Node *p_child) override;
|
|
|
|
virtual void remove_child_notify(Node *p_child) override;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2017-01-08 19:28:12 +00:00
|
|
|
//virtual void _window_gui_input(InputEvent p_event);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-08-27 21:19:51 +00:00
|
|
|
virtual Array structured_text_parser(StructuredTextParser p_theme_type, const Array &p_args, const String p_text) const;
|
2020-09-03 11:22:16 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool _set(const StringName &p_name, const Variant &p_value);
|
|
|
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
|
|
|
void _get_property_list(List<PropertyInfo> *p_list) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void _notification(int p_notification);
|
2016-03-08 23:00:52 +00:00
|
|
|
static void _bind_methods();
|
2021-07-04 20:42:23 +00:00
|
|
|
virtual void _validate_property(PropertyInfo &property) const override;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
|
|
|
//bind helpers
|
|
|
|
|
2021-08-22 15:37:22 +00:00
|
|
|
GDVIRTUAL1RC(bool, _has_point, Vector2)
|
|
|
|
GDVIRTUAL2RC(Array, _structured_text_parser, Array, String)
|
|
|
|
GDVIRTUAL0RC(Vector2, _get_minimum_size)
|
|
|
|
|
|
|
|
GDVIRTUAL1RC(Variant, _get_drag_data, Vector2)
|
|
|
|
GDVIRTUAL2RC(bool, _can_drop_data, Vector2, Variant)
|
|
|
|
GDVIRTUAL2(_drop_data, Vector2, Variant)
|
|
|
|
GDVIRTUAL1RC(Object *, _make_custom_tooltip, String)
|
|
|
|
|
|
|
|
GDVIRTUAL1(_gui_input, Ref<InputEvent>)
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
public:
|
|
|
|
enum {
|
2017-03-05 15:44:50 +00:00
|
|
|
/* NOTIFICATION_DRAW=30,
|
2014-02-10 01:10:30 +00:00
|
|
|
NOTIFICATION_VISIBILITY_CHANGED=38*/
|
2017-03-05 15:44:50 +00:00
|
|
|
NOTIFICATION_RESIZED = 40,
|
|
|
|
NOTIFICATION_MOUSE_ENTER = 41,
|
|
|
|
NOTIFICATION_MOUSE_EXIT = 42,
|
|
|
|
NOTIFICATION_FOCUS_ENTER = 43,
|
|
|
|
NOTIFICATION_FOCUS_EXIT = 44,
|
|
|
|
NOTIFICATION_THEME_CHANGED = 45,
|
2018-02-27 15:37:20 +00:00
|
|
|
NOTIFICATION_SCROLL_BEGIN = 47,
|
|
|
|
NOTIFICATION_SCROLL_END = 48,
|
2020-09-03 11:22:16 +00:00
|
|
|
NOTIFICATION_LAYOUT_DIRECTION_CHANGED = 49,
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-05-05 14:59:00 +00:00
|
|
|
/* EDITOR */
|
2019-10-21 21:37:07 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual Dictionary _edit_get_state() const override;
|
|
|
|
virtual void _edit_set_state(const Dictionary &p_state) override;
|
2017-11-15 22:03:25 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void _edit_set_position(const Point2 &p_position) override;
|
|
|
|
virtual Point2 _edit_get_position() const override;
|
2017-11-15 22:03:25 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void _edit_set_scale(const Size2 &p_scale) override;
|
|
|
|
virtual Size2 _edit_get_scale() const override;
|
2018-03-08 20:35:41 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void _edit_set_rect(const Rect2 &p_edit_rect) override;
|
|
|
|
virtual Rect2 _edit_get_rect() const override;
|
|
|
|
virtual bool _edit_use_rect() const override;
|
2017-11-15 22:03:25 +00:00
|
|
|
|
2021-01-30 04:10:32 +00:00
|
|
|
virtual void _edit_set_rotation(real_t p_rotation) override;
|
|
|
|
virtual real_t _edit_get_rotation() const override;
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual bool _edit_use_rotation() const override;
|
2017-11-15 22:03:25 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void _edit_set_pivot(const Point2 &p_pivot) override;
|
|
|
|
virtual Point2 _edit_get_pivot() const override;
|
|
|
|
virtual bool _edit_use_pivot() const override;
|
2017-11-15 22:03:25 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual Size2 _edit_get_minimum_size() const override;
|
2019-10-21 21:37:07 +00:00
|
|
|
#endif
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-08-22 15:37:22 +00:00
|
|
|
virtual void gui_input(const Ref<InputEvent> &p_event);
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void accept_event();
|
|
|
|
|
|
|
|
virtual Size2 get_minimum_size() const;
|
|
|
|
virtual Size2 get_combined_minimum_size() const;
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual bool has_point(const Point2 &p_point) const;
|
2021-09-29 15:48:27 +00:00
|
|
|
virtual void set_drag_forwarding(Object *p_target);
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual Variant get_drag_data(const Point2 &p_point);
|
|
|
|
virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
|
|
|
|
virtual void drop_data(const Point2 &p_point, const Variant &p_data);
|
2014-02-10 01:10:30 +00:00
|
|
|
void set_drag_preview(Control *p_control);
|
2017-03-05 15:44:50 +00:00
|
|
|
void force_drag(const Variant &p_data, Control *p_control);
|
2021-10-28 07:07:18 +00:00
|
|
|
bool is_drag_successful() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_custom_minimum_size(const Size2 &p_custom);
|
2014-02-10 01:10:30 +00:00
|
|
|
Size2 get_custom_minimum_size() const;
|
2015-12-28 23:36:48 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Control *get_parent_control() const;
|
2021-07-19 17:25:15 +00:00
|
|
|
Window *get_parent_window() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-09-03 11:22:16 +00:00
|
|
|
void set_layout_direction(LayoutDirection p_direction);
|
|
|
|
LayoutDirection get_layout_direction() const;
|
|
|
|
virtual bool is_layout_rtl() const;
|
|
|
|
|
2021-05-27 17:31:33 +00:00
|
|
|
void set_auto_translate(bool p_enable);
|
|
|
|
bool is_auto_translating() const;
|
|
|
|
_FORCE_INLINE_ String atr(const String p_string) const { return is_auto_translating() ? tr(p_string) : p_string; };
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
/* POSITIONING */
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2020-12-22 16:24:29 +00:00
|
|
|
void set_anchors_preset(LayoutPreset p_preset, bool p_keep_offsets = true);
|
|
|
|
void set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0);
|
|
|
|
void set_anchors_and_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0);
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2021-01-30 04:10:32 +00:00
|
|
|
void set_anchor(Side p_side, real_t p_anchor, bool p_keep_offset = true, bool p_push_opposite_anchor = true);
|
|
|
|
real_t get_anchor(Side p_side) const;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2021-01-30 04:10:32 +00:00
|
|
|
void set_offset(Side p_side, real_t p_value);
|
|
|
|
real_t get_offset(Side p_side) const;
|
2017-09-19 20:39:19 +00:00
|
|
|
|
2021-01-30 04:10:32 +00:00
|
|
|
void set_anchor_and_offset(Side p_side, real_t p_anchor, real_t p_pos, bool p_push_opposite_anchor = true);
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_begin(const Point2 &p_point); // helper
|
|
|
|
void set_end(const Point2 &p_point); // helper
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Point2 get_begin() const;
|
|
|
|
Point2 get_end() const;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2020-12-22 16:24:29 +00:00
|
|
|
void set_position(const Point2 &p_point, bool p_keep_offsets = false);
|
|
|
|
void set_global_position(const Point2 &p_point, bool p_keep_offsets = false);
|
2017-03-29 15:29:38 +00:00
|
|
|
Point2 get_position() const;
|
|
|
|
Point2 get_global_position() const;
|
2020-03-12 12:37:40 +00:00
|
|
|
Point2 get_screen_position() const;
|
2017-09-19 20:39:19 +00:00
|
|
|
|
2020-12-22 16:24:29 +00:00
|
|
|
void set_size(const Size2 &p_size, bool p_keep_offsets = false);
|
2014-02-10 01:10:30 +00:00
|
|
|
Size2 get_size() const;
|
2021-11-20 08:04:57 +00:00
|
|
|
void reset_size();
|
2017-09-19 20:39:19 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Rect2 get_rect() const;
|
|
|
|
Rect2 get_global_rect() const;
|
2020-03-12 12:37:40 +00:00
|
|
|
Rect2 get_screen_rect() const;
|
2021-10-07 13:46:55 +00:00
|
|
|
Rect2 get_window_rect() const; ///< use with care, as it blocks waiting for the rendering server
|
2020-07-10 10:34:39 +00:00
|
|
|
Rect2 get_anchorable_rect() const override;
|
2015-12-12 16:54:26 +00:00
|
|
|
|
2020-09-03 11:22:16 +00:00
|
|
|
void set_rect(const Rect2 &p_rect); // Reset anchors to begin and set rect, for faster container children sorting.
|
|
|
|
|
2021-01-30 04:10:32 +00:00
|
|
|
void set_rotation(real_t p_radians);
|
|
|
|
real_t get_rotation() const;
|
2015-12-12 16:54:26 +00:00
|
|
|
|
2017-09-19 20:39:19 +00:00
|
|
|
void set_h_grow_direction(GrowDirection p_direction);
|
|
|
|
GrowDirection get_h_grow_direction() const;
|
|
|
|
|
|
|
|
void set_v_grow_direction(GrowDirection p_direction);
|
|
|
|
GrowDirection get_v_grow_direction() const;
|
|
|
|
|
2017-07-06 20:42:44 +00:00
|
|
|
void set_pivot_offset(const Vector2 &p_pivot);
|
|
|
|
Vector2 get_pivot_offset() const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_scale(const Vector2 &p_scale);
|
2015-12-12 16:54:26 +00:00
|
|
|
Vector2 get_scale() const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_theme(const Ref<Theme> &p_theme);
|
2014-02-10 01:10:30 +00:00
|
|
|
Ref<Theme> get_theme() const;
|
|
|
|
|
2021-07-04 20:42:23 +00:00
|
|
|
void set_theme_type_variation(const StringName &p_theme_type);
|
|
|
|
StringName get_theme_type_variation() const;
|
2021-03-30 17:16:33 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void set_h_size_flags(int p_flags);
|
|
|
|
int get_h_size_flags() const;
|
|
|
|
|
|
|
|
void set_v_size_flags(int p_flags);
|
|
|
|
int get_v_size_flags() const;
|
|
|
|
|
2021-01-30 04:10:32 +00:00
|
|
|
void set_stretch_ratio(real_t p_ratio);
|
|
|
|
real_t get_stretch_ratio() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void minimum_size_changed();
|
|
|
|
|
|
|
|
/* FOCUS */
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void set_focus_mode(FocusMode p_focus_mode);
|
|
|
|
FocusMode get_focus_mode() const;
|
|
|
|
bool has_focus() const;
|
|
|
|
void grab_focus();
|
|
|
|
void release_focus();
|
|
|
|
|
|
|
|
Control *find_next_valid_focus() const;
|
|
|
|
Control *find_prev_valid_focus() const;
|
|
|
|
|
2020-12-22 16:24:29 +00:00
|
|
|
void set_focus_neighbor(Side p_side, const NodePath &p_neighbor);
|
|
|
|
NodePath get_focus_neighbor(Side p_side) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-11-16 09:45:52 +00:00
|
|
|
void set_focus_next(const NodePath &p_next);
|
|
|
|
NodePath get_focus_next() const;
|
|
|
|
void set_focus_previous(const NodePath &p_prev);
|
|
|
|
NodePath get_focus_previous() const;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Control *get_focus_owner() const;
|
|
|
|
|
2017-01-08 22:54:19 +00:00
|
|
|
void set_mouse_filter(MouseFilter p_filter);
|
|
|
|
MouseFilter get_mouse_filter() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
/* SKINNING */
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2021-08-12 17:35:42 +00:00
|
|
|
void begin_bulk_theme_override();
|
|
|
|
void end_bulk_theme_override();
|
|
|
|
|
2020-03-12 12:37:40 +00:00
|
|
|
void add_theme_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon);
|
|
|
|
void add_theme_style_override(const StringName &p_name, const Ref<StyleBox> &p_style);
|
|
|
|
void add_theme_font_override(const StringName &p_name, const Ref<Font> &p_font);
|
2020-09-03 11:22:16 +00:00
|
|
|
void add_theme_font_size_override(const StringName &p_name, int p_font_size);
|
2020-03-12 12:37:40 +00:00
|
|
|
void add_theme_color_override(const StringName &p_name, const Color &p_color);
|
|
|
|
void add_theme_constant_override(const StringName &p_name, int p_constant);
|
|
|
|
|
2021-03-22 01:43:01 +00:00
|
|
|
void remove_theme_icon_override(const StringName &p_name);
|
|
|
|
void remove_theme_style_override(const StringName &p_name);
|
|
|
|
void remove_theme_font_override(const StringName &p_name);
|
|
|
|
void remove_theme_font_size_override(const StringName &p_name);
|
|
|
|
void remove_theme_color_override(const StringName &p_name);
|
|
|
|
void remove_theme_constant_override(const StringName &p_name);
|
|
|
|
|
2021-03-30 17:16:33 +00:00
|
|
|
Ref<Texture2D> get_theme_icon(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
|
|
|
|
Ref<StyleBox> get_theme_stylebox(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
|
|
|
|
Ref<Font> get_theme_font(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
|
|
|
|
int get_theme_font_size(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
|
|
|
|
Color get_theme_color(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
|
|
|
|
int get_theme_constant(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
|
2020-03-12 12:37:40 +00:00
|
|
|
|
|
|
|
bool has_theme_icon_override(const StringName &p_name) const;
|
|
|
|
bool has_theme_stylebox_override(const StringName &p_name) const;
|
|
|
|
bool has_theme_font_override(const StringName &p_name) const;
|
2020-09-03 11:22:16 +00:00
|
|
|
bool has_theme_font_size_override(const StringName &p_name) const;
|
2020-03-12 12:37:40 +00:00
|
|
|
bool has_theme_color_override(const StringName &p_name) const;
|
|
|
|
bool has_theme_constant_override(const StringName &p_name) const;
|
|
|
|
|
2021-03-30 17:16:33 +00:00
|
|
|
bool has_theme_icon(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
|
|
|
|
bool has_theme_stylebox(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
|
|
|
|
bool has_theme_font(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
|
|
|
|
bool has_theme_font_size(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
|
|
|
|
bool has_theme_color(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
|
|
|
|
bool has_theme_constant(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-10-02 20:06:14 +00:00
|
|
|
static float fetch_theme_default_base_scale(Control *p_theme_owner, Window *p_theme_owner_window);
|
|
|
|
static Ref<Font> fetch_theme_default_font(Control *p_theme_owner, Window *p_theme_owner_window);
|
|
|
|
static int fetch_theme_default_font_size(Control *p_theme_owner, Window *p_theme_owner_window);
|
|
|
|
|
|
|
|
float get_theme_default_base_scale() const;
|
|
|
|
Ref<Font> get_theme_default_font() const;
|
|
|
|
int get_theme_default_font_size() const;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
/* TOOLTIP */
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_tooltip(const String &p_tooltip);
|
|
|
|
virtual String get_tooltip(const Point2 &p_pos) const;
|
2018-07-20 21:14:33 +00:00
|
|
|
virtual Control *make_custom_tooltip(const String &p_text) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
/* CURSOR */
|
|
|
|
|
|
|
|
void set_default_cursor_shape(CursorShape p_shape);
|
|
|
|
CursorShape get_default_cursor_shape() const;
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual Transform2D get_transform() const override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-10-02 21:03:52 +00:00
|
|
|
bool is_top_level_control() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Size2 get_parent_area_size() const;
|
2018-05-05 14:59:00 +00:00
|
|
|
Rect2 get_parent_anchorable_rect() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void grab_click_focus();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void warp_mouse(const Point2 &p_to_pos);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-12-12 16:54:26 +00:00
|
|
|
virtual bool is_text_field() const;
|
2015-10-17 13:29:54 +00:00
|
|
|
|
2016-01-19 23:27:27 +00:00
|
|
|
Control *get_root_parent_control() const;
|
|
|
|
|
2017-01-09 18:50:08 +00:00
|
|
|
void set_clip_contents(bool p_clip);
|
|
|
|
bool is_clipping_contents();
|
2016-08-25 20:45:20 +00:00
|
|
|
|
|
|
|
void set_block_minimum_size_adjust(bool p_block);
|
|
|
|
bool is_minimum_size_adjust_blocked() const;
|
|
|
|
|
2016-08-31 02:44:14 +00:00
|
|
|
void set_disable_visibility_clip(bool p_ignore);
|
|
|
|
bool is_visibility_clip_disabled() const;
|
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
|
2020-10-29 10:01:28 +00:00
|
|
|
TypedArray<String> get_configuration_warnings() const override;
|
2016-09-11 14:48:31 +00:00
|
|
|
|
2020-12-11 14:54:03 +00:00
|
|
|
Control() {}
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
VARIANT_ENUM_CAST(Control::FocusMode);
|
|
|
|
VARIANT_ENUM_CAST(Control::SizeFlags);
|
|
|
|
VARIANT_ENUM_CAST(Control::CursorShape);
|
2017-08-11 16:16:28 +00:00
|
|
|
VARIANT_ENUM_CAST(Control::LayoutPreset);
|
2017-09-19 20:39:19 +00:00
|
|
|
VARIANT_ENUM_CAST(Control::LayoutPresetMode);
|
2017-01-08 22:54:19 +00:00
|
|
|
VARIANT_ENUM_CAST(Control::MouseFilter);
|
2017-07-06 16:26:39 +00:00
|
|
|
VARIANT_ENUM_CAST(Control::GrowDirection);
|
2017-08-15 22:48:38 +00:00
|
|
|
VARIANT_ENUM_CAST(Control::Anchor);
|
2020-09-03 11:22:16 +00:00
|
|
|
VARIANT_ENUM_CAST(Control::LayoutDirection);
|
|
|
|
VARIANT_ENUM_CAST(Control::TextDirection);
|
|
|
|
VARIANT_ENUM_CAST(Control::StructuredTextParser);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
#endif
|