godot/scene/gui/control.cpp

/**************************************************************************/
/*  control.cpp                                                           */
/**************************************************************************/
/*                         This file is part of:                          */
/*                             GODOT ENGINE                               */
/*                        https://godotengine.org                         */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */
/*                                                                        */
/* 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.                 */
/**************************************************************************/

#include "control.h"

#include "container.h"
#include "core/config/project_settings.h"
#include "core/math/geometry_2d.h"
#include "core/os/os.h"
#include "core/string/translation_server.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/window.h"
#include "scene/theme/theme_db.h"
#include "scene/theme/theme_owner.h"
#include "servers/rendering_server.h"
#include "servers/text_server.h"

#ifdef TOOLS_ENABLED
#include "editor/plugins/control_editor_plugin.h"
#endif

// Editor plugin interoperability.

// TODO: Decouple controls from their editor plugin and get rid of this.
#ifdef TOOLS_ENABLED
Dictionary Control::_edit_get_state() const {}

void Control::_edit_set_state(const Dictionary &p_state) {}

void Control::_edit_set_position(const Point2 &p_position) {
	ERR_FAIL_COND_MSG(!Engine::get_singleton()->is_editor_hint(), "This function can only be used from editor plugins.");
	set_position(p_position, ControlEditorToolbar::get_singleton()->is_anchors_mode_enabled() && get_parent_control());
};

Point2 Control::_edit_get_position() const {
	return get_position();
};

void Control::_edit_set_scale(const Size2 &p_scale) {}

Size2 Control::_edit_get_scale() const {}

void Control::_edit_set_rect(const Rect2 &p_edit_rect) {}

Rect2 Control::_edit_get_rect() const {}

bool Control::_edit_use_rect() const {}

void Control::_edit_set_rotation(real_t p_rotation) {}

real_t Control::_edit_get_rotation() const {}

bool Control::_edit_use_rotation() const {}

void Control::_edit_set_pivot(const Point2 &p_pivot) {}

Point2 Control::_edit_get_pivot() const {}

bool Control::_edit_use_pivot() const {}

Size2 Control::_edit_get_minimum_size() const {}
#endif

void Control::reparent(Node *p_parent, bool p_keep_global_transform) {}

// Editor integration.

int Control::root_layout_direction =;

void Control::set_root_layout_direction(int p_root_dir) {}

#ifdef TOOLS_ENABLED
void Control::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {}
#endif

PackedStringArray Control::get_configuration_warnings() const {}

bool Control::is_text_field() const {}

// Dynamic properties.

String Control::properties_managed_by_container[] =;

bool Control::_set(const StringName &p_name, const Variant &p_value) {}

bool Control::_get(const StringName &p_name, Variant &r_ret) const {}

void Control::_get_property_list(List<PropertyInfo> *p_list) const {}

void Control::_validate_property(PropertyInfo &p_property) const {}

bool Control::_property_can_revert(const StringName &p_name) const {}

bool Control::_property_get_revert(const StringName &p_name, Variant &r_property) const {}

// Global relations.

bool Control::is_top_level_control() const {}

Control *Control::get_parent_control() const {}

Window *Control::get_parent_window() const {}

Control *Control::get_root_parent_control() const {}

Rect2 Control::get_parent_anchorable_rect() const {}

Size2 Control::get_parent_area_size() const {}

// Positioning and sizing.

Transform2D Control::_get_internal_transform() const {}

void Control::_update_canvas_item_transform() {}

Transform2D Control::get_transform() const {}

void Control::_top_level_changed_on_parent() {}

/// Anchors and offsets.

void Control::_set_anchor(Side p_side, real_t p_anchor) {}

void Control::set_anchor(Side p_side, real_t p_anchor, bool p_keep_offset, bool p_push_opposite_anchor) {}

real_t Control::get_anchor(Side p_side) const {}

void Control::set_offset(Side p_side, real_t p_value) {}

real_t Control::get_offset(Side p_side) const {}

void Control::set_anchor_and_offset(Side p_side, real_t p_anchor, real_t p_pos, bool p_push_opposite_anchor) {}

void Control::set_begin(const Point2 &p_point) {}

Point2 Control::get_begin() const {}

void Control::set_end(const Point2 &p_point) {}

Point2 Control::get_end() const {}

void Control::set_h_grow_direction(GrowDirection p_direction) {}

Control::GrowDirection Control::get_h_grow_direction() const {}

void Control::set_v_grow_direction(GrowDirection p_direction) {}

Control::GrowDirection Control::get_v_grow_direction() const {}

void Control::_compute_anchors(Rect2 p_rect, const real_t p_offsets[4], real_t (&r_anchors)[4]) {}

void Control::_compute_offsets(Rect2 p_rect, const real_t p_anchors[4], real_t (&r_offsets)[4]) {}

/// Presets and layout modes.

void Control::_set_layout_mode(LayoutMode p_mode) {}

void Control::_update_layout_mode() {}

Control::LayoutMode Control::_get_layout_mode() const {}

Control::LayoutMode Control::_get_default_layout_mode() const {}

void Control::_set_anchors_layout_preset(int p_preset) {}

int Control::_get_anchors_layout_preset() const {}

void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_offsets) {}

void Control::set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode, int p_margin) {}

void Control::set_anchors_and_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode, int p_margin) {}

void Control::set_grow_direction_preset(LayoutPreset p_preset) {}

/// Manual positioning.

void Control::_set_position(const Point2 &p_point) {}

void Control::set_position(const Point2 &p_point, bool p_keep_offsets) {}

Size2 Control::get_position() const {}

void Control::_set_global_position(const Point2 &p_point) {}

void Control::set_global_position(const Point2 &p_point, bool p_keep_offsets) {}

Point2 Control::get_global_position() const {}

Point2 Control::get_screen_position() const {}

void Control::_set_size(const Size2 &p_size) {}

void Control::set_size(const Size2 &p_size, bool p_keep_offsets) {}

Size2 Control::get_size() const {}

void Control::reset_size() {}

void Control::set_rect(const Rect2 &p_rect) {}

Rect2 Control::get_rect() const {}

Rect2 Control::get_global_rect() const {}

Rect2 Control::get_screen_rect() const {}

Rect2 Control::get_anchorable_rect() const {}

void Control::set_scale(const Vector2 &p_scale) {}

Vector2 Control::get_scale() const {}

void Control::set_rotation(real_t p_radians) {}

void Control::set_rotation_degrees(real_t p_degrees) {}

real_t Control::get_rotation() const {}

real_t Control::get_rotation_degrees() const {}

void Control::set_pivot_offset(const Vector2 &p_pivot) {}

Vector2 Control::get_pivot_offset() const {}

/// Sizes.

void Control::_update_minimum_size() {}

void Control::update_minimum_size() {}

void Control::set_block_minimum_size_adjust(bool p_block) {}

Size2 Control::get_minimum_size() const {}

void Control::set_custom_minimum_size(const Size2 &p_custom) {}

Size2 Control::get_custom_minimum_size() const {}

void Control::_update_minimum_size_cache() {}

Size2 Control::get_combined_minimum_size() const {}

void Control::_size_changed() {}

void Control::_clear_size_warning() {}

// Container sizing.

void Control::set_h_size_flags(BitField<SizeFlags> p_flags) {}

BitField<Control::SizeFlags> Control::get_h_size_flags() const {}

void Control::set_v_size_flags(BitField<SizeFlags> p_flags) {}

BitField<Control::SizeFlags> Control::get_v_size_flags() const {}

void Control::set_stretch_ratio(real_t p_ratio) {}

real_t Control::get_stretch_ratio() const {}

// Input events.

void Control::_call_gui_input(const Ref<InputEvent> &p_event) {}

void Control::gui_input(const Ref<InputEvent> &p_event) {}

void Control::accept_event() {}

bool Control::has_point(const Point2 &p_point) const {}

void Control::set_mouse_filter(MouseFilter p_filter) {}

Control::MouseFilter Control::get_mouse_filter() const {}

void Control::set_force_pass_scroll_events(bool p_force_pass_scroll_events) {}

bool Control::is_force_pass_scroll_events() const {}

void Control::warp_mouse(const Point2 &p_position) {}

void Control::set_shortcut_context(const Node *p_node) {}

Node *Control::get_shortcut_context() const {}

bool Control::is_focus_owner_in_shortcut_context() const {}

// Drag and drop handling.

void Control::set_drag_forwarding(const Callable &p_drag, const Callable &p_can_drop, const Callable &p_drop) {}

Variant Control::get_drag_data(const Point2 &p_point) {}

bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const {}

void Control::drop_data(const Point2 &p_point, const Variant &p_data) {}

void Control::force_drag(const Variant &p_data, Control *p_control) {}

void Control::set_drag_preview(Control *p_control) {}

bool Control::is_drag_successful() const {}

// Focus.

void Control::set_focus_mode(FocusMode p_focus_mode) {}

Control::FocusMode Control::get_focus_mode() const {}

bool Control::has_focus() const {}

void Control::grab_focus() {}

void Control::grab_click_focus() {}

void Control::release_focus() {}

static Control *_next_control(Control *p_from) {}

Control *Control::find_next_valid_focus() const {}

static Control *_prev_control(Control *p_from) {}

Control *Control::find_prev_valid_focus() const {}

void Control::set_focus_neighbor(Side p_side, const NodePath &p_neighbor) {}

NodePath Control::get_focus_neighbor(Side p_side) const {}

void Control::set_focus_next(const NodePath &p_next) {}

NodePath Control::get_focus_next() const {}

void Control::set_focus_previous(const NodePath &p_prev) {}

NodePath Control::get_focus_previous() const {}

#define MAX_NEIGHBOR_SEARCH_COUNT

Control *Control::_get_focus_neighbor(Side p_side, int p_count) {}

Control *Control::find_valid_focus_neighbor(Side p_side) const {}

void Control::_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) {}

// Rendering.

void Control::set_default_cursor_shape(CursorShape p_shape) {}

Control::CursorShape Control::get_default_cursor_shape() const {}

Control::CursorShape Control::get_cursor_shape(const Point2 &p_pos) const {}

void Control::set_disable_visibility_clip(bool p_ignore) {}

bool Control::is_visibility_clip_disabled() const {}

void Control::set_clip_contents(bool p_clip) {}

bool Control::is_clipping_contents() {}

// Theming.

void Control::_theme_changed() {}

void Control::_notify_theme_override_changed() {}

void Control::_invalidate_theme_cache() {}

void Control::_update_theme_item_cache() {}

void Control::set_theme_owner_node(Node *p_node) {}

Node *Control::get_theme_owner_node() const {}

bool Control::has_theme_owner_node() const {}

void Control::set_theme_context(ThemeContext *p_context, bool p_propagate) {}

void Control::set_theme(const Ref<Theme> &p_theme) {}

Ref<Theme> Control::get_theme() const {}

void Control::set_theme_type_variation(const StringName &p_theme_type) {}

StringName Control::get_theme_type_variation() const {}

/// Theme property lookup.

Ref<Texture2D> Control::get_theme_icon(const StringName &p_name, const StringName &p_theme_type) const {}

Ref<StyleBox> Control::get_theme_stylebox(const StringName &p_name, const StringName &p_theme_type) const {}

Ref<Font> Control::get_theme_font(const StringName &p_name, const StringName &p_theme_type) const {}

int Control::get_theme_font_size(const StringName &p_name, const StringName &p_theme_type) const {}

Color Control::get_theme_color(const StringName &p_name, const StringName &p_theme_type) const {}

int Control::get_theme_constant(const StringName &p_name, const StringName &p_theme_type) const {}

Variant Control::get_theme_item(Theme::DataType p_data_type, const StringName &p_name, const StringName &p_theme_type) const {}

#ifdef TOOLS_ENABLED
Ref<Texture2D> Control::get_editor_theme_icon(const StringName &p_name) const {}
#endif

bool Control::has_theme_icon(const StringName &p_name, const StringName &p_theme_type) const {}

bool Control::has_theme_stylebox(const StringName &p_name, const StringName &p_theme_type) const {}

bool Control::has_theme_font(const StringName &p_name, const StringName &p_theme_type) const {}

bool Control::has_theme_font_size(const StringName &p_name, const StringName &p_theme_type) const {}

bool Control::has_theme_color(const StringName &p_name, const StringName &p_theme_type) const {}

bool Control::has_theme_constant(const StringName &p_name, const StringName &p_theme_type) const {}

/// Local property overrides.

void Control::add_theme_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon) {}

void Control::add_theme_style_override(const StringName &p_name, const Ref<StyleBox> &p_style) {}

void Control::add_theme_font_override(const StringName &p_name, const Ref<Font> &p_font) {}

void Control::add_theme_font_size_override(const StringName &p_name, int p_font_size) {}

void Control::add_theme_color_override(const StringName &p_name, const Color &p_color) {}

void Control::add_theme_constant_override(const StringName &p_name, int p_constant) {}

void Control::remove_theme_icon_override(const StringName &p_name) {}

void Control::remove_theme_style_override(const StringName &p_name) {}

void Control::remove_theme_font_override(const StringName &p_name) {}

void Control::remove_theme_font_size_override(const StringName &p_name) {}

void Control::remove_theme_color_override(const StringName &p_name) {}

void Control::remove_theme_constant_override(const StringName &p_name) {}

bool Control::has_theme_icon_override(const StringName &p_name) const {}

bool Control::has_theme_stylebox_override(const StringName &p_name) const {}

bool Control::has_theme_font_override(const StringName &p_name) const {}

bool Control::has_theme_font_size_override(const StringName &p_name) const {}

bool Control::has_theme_color_override(const StringName &p_name) const {}

bool Control::has_theme_constant_override(const StringName &p_name) const {}

/// Default theme properties.

float Control::get_theme_default_base_scale() const {}

Ref<Font> Control::get_theme_default_font() const {}

int Control::get_theme_default_font_size() const {}

/// Bulk actions.

void Control::begin_bulk_theme_override() {}

void Control::end_bulk_theme_override() {}

// Internationalization.

TypedArray<Vector3i> Control::structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const {}

void Control::set_layout_direction(Control::LayoutDirection p_direction) {}

Control::LayoutDirection Control::get_layout_direction() const {}

bool Control::is_layout_rtl() const {}

void Control::set_localize_numeral_system(bool p_enable) {}

bool Control::is_localizing_numeral_system() const {}

#ifndef DISABLE_DEPRECATED
void Control::set_auto_translate(bool p_enable) {}

bool Control::is_auto_translating() const {}
#endif

void Control::set_tooltip_auto_translate_mode(AutoTranslateMode p_mode) {}

Node::AutoTranslateMode Control::get_tooltip_auto_translate_mode() const {}

// Extra properties.

void Control::set_tooltip_text(const String &p_hint) {}

String Control::get_tooltip_text() const {}

String Control::get_tooltip(const Point2 &p_pos) const {}

Control *Control::make_custom_tooltip(const String &p_text) const {}

// Base object overrides.

void Control::_notification(int p_notification) {}

void Control::_bind_methods() {}

Control::Control() {}

Control::~Control() {}