godot/scene/gui/tree.cpp

/**************************************************************************/
/*  tree.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 "tree.h"

#include "core/config/project_settings.h"
#include "core/input/input.h"
#include "core/math/math_funcs.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "scene/gui/box_container.h"
#include "scene/gui/text_edit.h"
#include "scene/main/window.h"
#include "scene/theme/theme_db.h"

#include <limits.h>

Size2 TreeItem::Cell::get_icon_size() const {}

void TreeItem::Cell::draw_icon(const RID &p_where, const Point2 &p_pos, const Size2 &p_size, const Color &p_color) const {}

void TreeItem::_changed_notify(int p_cell) {}

void TreeItem::_changed_notify() {}

void TreeItem::_cell_selected(int p_cell) {}

void TreeItem::_cell_deselected(int p_cell) {}

void TreeItem::_change_tree(Tree *p_tree) {}

/* cell mode */
void TreeItem::set_cell_mode(int p_column, TreeCellMode p_mode) {}

TreeItem::TreeCellMode TreeItem::get_cell_mode(int p_column) const {}

/* auto translate mode */
void TreeItem::set_auto_translate_mode(int p_column, Node::AutoTranslateMode p_mode) {}

Node::AutoTranslateMode TreeItem::get_auto_translate_mode(int p_column) const {}

/* multiline editable */
void TreeItem::set_edit_multiline(int p_column, bool p_multiline) {}

bool TreeItem::is_edit_multiline(int p_column) const {}

/* check mode */
void TreeItem::set_checked(int p_column, bool p_checked) {}

void TreeItem::set_indeterminate(int p_column, bool p_indeterminate) {}

bool TreeItem::is_checked(int p_column) const {}

bool TreeItem::is_indeterminate(int p_column) const {}

void TreeItem::propagate_check(int p_column, bool p_emit_signal) {}

String TreeItem::atr(int p_column, const String &p_text) const {}

void TreeItem::_propagate_check_through_children(int p_column, bool p_checked, bool p_emit_signal) {}

void TreeItem::_propagate_check_through_parents(int p_column, bool p_emit_signal) {}

void TreeItem::set_text(int p_column, String p_text) {}

String TreeItem::get_text(int p_column) const {}

void TreeItem::set_text_direction(int p_column, Control::TextDirection p_text_direction) {}

Control::TextDirection TreeItem::get_text_direction(int p_column) const {}

void TreeItem::set_autowrap_mode(int p_column, TextServer::AutowrapMode p_mode) {}

TextServer::AutowrapMode TreeItem::get_autowrap_mode(int p_column) const {}

void TreeItem::set_text_overrun_behavior(int p_column, TextServer::OverrunBehavior p_behavior) {}

TextServer::OverrunBehavior TreeItem::get_text_overrun_behavior(int p_column) const {}

void TreeItem::set_structured_text_bidi_override(int p_column, TextServer::StructuredTextParser p_parser) {}

TextServer::StructuredTextParser TreeItem::get_structured_text_bidi_override(int p_column) const {}

void TreeItem::set_structured_text_bidi_override_options(int p_column, Array p_args) {}

Array TreeItem::get_structured_text_bidi_override_options(int p_column) const {}

void TreeItem::set_language(int p_column, const String &p_language) {}

String TreeItem::get_language(int p_column) const {}

void TreeItem::set_suffix(int p_column, String p_suffix) {}

String TreeItem::get_suffix(int p_column) const {}

void TreeItem::set_icon(int p_column, const Ref<Texture2D> &p_icon) {}

Ref<Texture2D> TreeItem::get_icon(int p_column) const {}

void TreeItem::set_icon_overlay(int p_column, const Ref<Texture2D> &p_icon_overlay) {}

Ref<Texture2D> TreeItem::get_icon_overlay(int p_column) const {}

void TreeItem::set_icon_region(int p_column, const Rect2 &p_icon_region) {}

Rect2 TreeItem::get_icon_region(int p_column) const {}

void TreeItem::set_icon_modulate(int p_column, const Color &p_modulate) {}

Color TreeItem::get_icon_modulate(int p_column) const {}

void TreeItem::set_icon_max_width(int p_column, int p_max) {}

int TreeItem::get_icon_max_width(int p_column) const {}

/* range works for mode number or mode combo */
void TreeItem::set_range(int p_column, double p_value) {}

double TreeItem::get_range(int p_column) const {}

bool TreeItem::is_range_exponential(int p_column) const {}

void TreeItem::set_range_config(int p_column, double p_min, double p_max, double p_step, bool p_exp) {}

void TreeItem::get_range_config(int p_column, double &r_min, double &r_max, double &r_step) const {}

void TreeItem::set_metadata(int p_column, const Variant &p_meta) {}

Variant TreeItem::get_metadata(int p_column) const {}

#ifndef DISABLE_DEPRECATED
void TreeItem::set_custom_draw(int p_column, Object *p_object, const StringName &p_callback) {}
#endif // DISABLE_DEPRECATED

void TreeItem::set_custom_draw_callback(int p_column, const Callable &p_callback) {}

Callable TreeItem::get_custom_draw_callback(int p_column) const {}

void TreeItem::set_collapsed(bool p_collapsed) {}

bool TreeItem::is_collapsed() {}

void TreeItem::set_collapsed_recursive(bool p_collapsed) {}

bool TreeItem::_is_any_collapsed(bool p_only_visible) {}

bool TreeItem::is_any_collapsed(bool p_only_visible) {}

void TreeItem::set_visible(bool p_visible) {}

bool TreeItem::is_visible() {}

bool TreeItem::is_visible_in_tree() const {}

void TreeItem::_handle_visibility_changed(bool p_visible) {}

void TreeItem::_propagate_visibility_changed(bool p_parent_visible_in_tree) {}

void TreeItem::uncollapse_tree() {}

void TreeItem::set_custom_minimum_height(int p_height) {}

int TreeItem::get_custom_minimum_height() const {}

/* Item manipulation */

TreeItem *TreeItem::create_child(int p_index) {}

void TreeItem::add_child(TreeItem *p_item) {}

void TreeItem::remove_child(TreeItem *p_item) {}

Tree *TreeItem::get_tree() const {}

TreeItem *TreeItem::get_next() const {}

TreeItem *TreeItem::get_prev() {}

TreeItem *TreeItem::get_parent() const {}

TreeItem *TreeItem::get_first_child() const {}

TreeItem *TreeItem::_get_prev_in_tree(bool p_wrap, bool p_include_invisible) {}

TreeItem *TreeItem::get_prev_visible(bool p_wrap) {}

TreeItem *TreeItem::_get_next_in_tree(bool p_wrap, bool p_include_invisible) {}

TreeItem *TreeItem::get_next_visible(bool p_wrap) {}

TreeItem *TreeItem::get_prev_in_tree(bool p_wrap) {}

TreeItem *TreeItem::get_next_in_tree(bool p_wrap) {}

TreeItem *TreeItem::get_child(int p_index) {}

int TreeItem::get_visible_child_count() {}

int TreeItem::get_child_count() {}

TypedArray<TreeItem> TreeItem::get_children() {}

void TreeItem::clear_children() {
	TreeItem *c = first_child;
	while (c) {
		TreeItem *aux = c;
		c = c->get_next();
		aux->parent = nullptr; // So it won't try to recursively auto-remove from me in here.
		memdelete(aux);
	}

	first_child = nullptr;
	last_child = nullptr;
	children_cache.clear();
};

int TreeItem::get_index() {}

#ifdef DEV_ENABLED
void TreeItem::validate_cache() const {
	if (!parent || parent->children_cache.is_empty()) {
		return;
	}
	TreeItem *scan = parent->first_child;
	int index = 0;
	while (scan) {
		DEV_ASSERT(parent->children_cache[index] == scan);
		++index;
		scan = scan->get_next();
	}
	DEV_ASSERT(index == parent->children_cache.size());
}
#endif

void TreeItem::move_before(TreeItem *p_item) {}

void TreeItem::move_after(TreeItem *p_item) {}

void TreeItem::set_selectable(int p_column, bool p_selectable) {}

bool TreeItem::is_selectable(int p_column) const {}

bool TreeItem::is_selected(int p_column) {}

void TreeItem::set_as_cursor(int p_column) {}

void TreeItem::select(int p_column) {}

void TreeItem::deselect(int p_column) {}

void TreeItem::add_button(int p_column, const Ref<Texture2D> &p_button, int p_id, bool p_disabled, const String &p_tooltip) {}

int TreeItem::get_button_count(int p_column) const {}

Ref<Texture2D> TreeItem::get_button(int p_column, int p_index) const {}

String TreeItem::get_button_tooltip_text(int p_column, int p_index) const {}

int TreeItem::get_button_id(int p_column, int p_index) const {}

void TreeItem::erase_button(int p_column, int p_index) {}

int TreeItem::get_button_by_id(int p_column, int p_id) const {}

Color TreeItem::get_button_color(int p_column, int p_index) const {}

void TreeItem::set_button_tooltip_text(int p_column, int p_index, const String &p_tooltip) {}

void TreeItem::set_button(int p_column, int p_index, const Ref<Texture2D> &p_button) {}

void TreeItem::set_button_color(int p_column, int p_index, const Color &p_color) {}

void TreeItem::set_button_disabled(int p_column, int p_index, bool p_disabled) {}

bool TreeItem::is_button_disabled(int p_column, int p_index) const {}

void TreeItem::set_editable(int p_column, bool p_editable) {}

bool TreeItem::is_editable(int p_column) {}

void TreeItem::set_custom_color(int p_column, const Color &p_color) {}

Color TreeItem::get_custom_color(int p_column) const {}

void TreeItem::clear_custom_color(int p_column) {}

void TreeItem::set_custom_font(int p_column, const Ref<Font> &p_font) {}

Ref<Font> TreeItem::get_custom_font(int p_column) const {}

void TreeItem::set_custom_font_size(int p_column, int p_font_size) {}

int TreeItem::get_custom_font_size(int p_column) const {}

void TreeItem::set_tooltip_text(int p_column, const String &p_tooltip) {}

String TreeItem::get_tooltip_text(int p_column) const {}

void TreeItem::set_custom_bg_color(int p_column, const Color &p_color, bool p_bg_outline) {}

void TreeItem::clear_custom_bg_color(int p_column) {}

Color TreeItem::get_custom_bg_color(int p_column) const {}

void TreeItem::set_custom_as_button(int p_column, bool p_button) {}

bool TreeItem::is_custom_set_as_button(int p_column) const {}

void TreeItem::set_text_alignment(int p_column, HorizontalAlignment p_alignment) {}

HorizontalAlignment TreeItem::get_text_alignment(int p_column) const {}

void TreeItem::set_expand_right(int p_column, bool p_enable) {}

bool TreeItem::get_expand_right(int p_column) const {}

void TreeItem::set_disable_folding(bool p_disable) {}

bool TreeItem::is_folding_disabled() const {}

Size2 TreeItem::get_minimum_size(int p_column) {}

void TreeItem::_call_recursive_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {}

void recursive_call_aux(TreeItem *p_item, const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {}

void TreeItem::call_recursive(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {}

void TreeItem::_bind_methods() {}

TreeItem::TreeItem(Tree *p_tree) {}

TreeItem::~TreeItem() {}

/**********************************************/
/**********************************************/
/**********************************************/
/**********************************************/
/**********************************************/
/**********************************************/

void Tree::_update_theme_item_cache() {}

Size2 Tree::_get_cell_icon_size(const TreeItem::Cell &p_cell) const {}

int Tree::compute_item_height(TreeItem *p_item) const {}

int Tree::get_item_height(TreeItem *p_item) const {}

void Tree::draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color, int p_ol_size, const Color &p_ol_color) {}

void Tree::update_column(int p_col) {}

void Tree::update_item_cell(TreeItem *p_item, int p_col) {}

void Tree::update_item_cache(TreeItem *p_item) {}

int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item, int &r_self_height) {}

int Tree::_count_selected_items(TreeItem *p_from) const {}

bool Tree::_is_branch_selected(TreeItem *p_from) const {}

bool Tree::_is_sibling_branch_selected(TreeItem *p_from) const {}

void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev, bool *r_in_range, bool p_force_deselect) {}

Rect2 Tree::search_item_rect(TreeItem *p_from, TreeItem *p_item) {}

void Tree::_range_click_timeout() {}

int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int x_limit, bool p_double_click, TreeItem *p_item, MouseButton p_button, const Ref<InputEventWithModifiers> &p_mod) {}

void Tree::_text_editor_popup_modal_close() {}

void Tree::_text_editor_gui_input(const Ref<InputEvent> &p_event) {}

void Tree::_apply_multiline_edit() {}

void Tree::_line_editor_submit(String p_text) {}

void Tree::value_editor_changed(double p_value) {}

void Tree::popup_select(int p_option) {}

void Tree::_go_left() {}

void Tree::_go_right() {}

void Tree::_go_up() {}

void Tree::_go_down() {}

bool Tree::_scroll(bool p_horizontal, float p_pages) {}

Rect2 Tree::_get_scrollbar_layout_rect() const {}

Rect2 Tree::_get_content_rect() const {}

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

void Tree::_determine_hovered_item() {}

bool Tree::edit_selected(bool p_force_edit) {}

bool Tree::is_editing() {}

void Tree::set_editor_selection(int p_from_line, int p_to_line, int p_from_column, int p_to_column, int p_caret) {}

Size2 Tree::get_internal_min_size() const {}

void Tree::update_scrollbars() {}

int Tree::_get_title_button_height() const {}

void Tree::_notification(int p_what) {}

void Tree::_update_all() {}

Size2 Tree::get_minimum_size() const {}

TreeItem *Tree::create_item(TreeItem *p_parent, int p_index) {}

TreeItem *Tree::get_root() const {}

TreeItem *Tree::get_last_item() const {}

void Tree::item_edited(int p_column, TreeItem *p_item, MouseButton p_custom_mouse_index) {}

void Tree::item_changed(int p_column, TreeItem *p_item) {}

void Tree::item_selected(int p_column, TreeItem *p_item) {}

void Tree::item_deselected(int p_column, TreeItem *p_item) {}

void Tree::set_select_mode(SelectMode p_mode) {}

Tree::SelectMode Tree::get_select_mode() const {}

void Tree::deselect_all() {}

bool Tree::is_anything_selected() {}

void Tree::clear() {
	ERR_FAIL_COND(blocked > 0);

	if (pressing_for_editor) {
		if (range_drag_enabled) {
			range_drag_enabled = false;
			Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
			warp_mouse(range_drag_capture_pos);
		}
		pressing_for_editor = false;
	}

	if (root) {
		memdelete(root);
		root = nullptr;
	};

	selected_item = nullptr;
	edited_item = nullptr;
	popup_edited_item = nullptr;
	popup_pressing_edited_item = nullptr;

	_determine_hovered_item();

	queue_redraw();
};

void Tree::set_hide_root(bool p_enabled) {}

bool Tree::is_root_hidden() const {}

void Tree::set_column_custom_minimum_width(int p_column, int p_min_width) {}

void Tree::set_column_expand(int p_column, bool p_expand) {}

void Tree::set_column_expand_ratio(int p_column, int p_ratio) {}

void Tree::set_column_clip_content(int p_column, bool p_fit) {}

bool Tree::is_column_expanding(int p_column) const {}

int Tree::get_column_expand_ratio(int p_column) const {}

bool Tree::is_column_clipping_content(int p_column) const {}

TreeItem *Tree::get_selected() const {}

void Tree::set_selected(TreeItem *p_item, int p_column) {}

int Tree::get_selected_column() const {}

TreeItem *Tree::get_edited() const {}

int Tree::get_edited_column() const {}

TreeItem *Tree::get_next_selected(TreeItem *p_item) {}

int Tree::get_column_minimum_width(int p_column) const {}

int Tree::get_column_width(int p_column) const {}

void Tree::propagate_set_columns(TreeItem *p_item) {}

void Tree::set_columns(int p_columns) {}

int Tree::get_columns() const {}

void Tree::_scroll_moved(float) {}

Rect2 Tree::get_custom_popup_rect() const {}

int Tree::get_item_offset(TreeItem *p_item) const {}

int Tree::_get_item_h_offset(TreeItem *p_item) const {}

void Tree::ensure_cursor_is_visible() {}

int Tree::get_pressed_button() const {}

Rect2 Tree::get_item_rect(TreeItem *p_item, int p_column, int p_button) const {}

void Tree::set_column_titles_visible(bool p_show) {}

bool Tree::are_column_titles_visible() const {}

void Tree::set_column_title(int p_column, const String &p_title) {}

String Tree::get_column_title(int p_column) const {}

void Tree::set_column_title_alignment(int p_column, HorizontalAlignment p_alignment) {}

HorizontalAlignment Tree::get_column_title_alignment(int p_column) const {}

void Tree::set_column_title_direction(int p_column, Control::TextDirection p_text_direction) {}

Control::TextDirection Tree::get_column_title_direction(int p_column) const {}

void Tree::set_column_title_language(int p_column, const String &p_language) {}

String Tree::get_column_title_language(int p_column) const {}

Point2 Tree::get_scroll() const {}

void Tree::scroll_to_item(TreeItem *p_item, bool p_center_on_item) {}

void Tree::set_h_scroll_enabled(bool p_enable) {}

bool Tree::is_h_scroll_enabled() const {}

void Tree::set_v_scroll_enabled(bool p_enable) {}

bool Tree::is_v_scroll_enabled() const {}

TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_col, bool p_selectable, bool p_backwards) {}

TreeItem *Tree::search_item_text(const String &p_find, int *r_col, bool p_selectable) {}

TreeItem *Tree::get_item_with_text(const String &p_find) const {}

TreeItem *Tree::get_item_with_metadata(const Variant &p_find, int p_column) const {}

void Tree::_do_incr_search(const String &p_add) {}

TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_column, int &h, int &section) const {}

// When on a button, r_index is valid.
// When on an item, both r_item and r_column are valid.
// Otherwise, all output arguments are invalid.
void Tree::_find_button_at_pos(const Point2 &p_pos, TreeItem *&r_item, int &r_column, int &r_index) const {}

int Tree::get_column_at_position(const Point2 &p_pos) const {}

int Tree::get_drop_section_at_position(const Point2 &p_pos) const {}

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

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

TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const {}

int Tree::get_button_id_at_position(const Point2 &p_pos) const {}

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

void Tree::set_cursor_can_exit_tree(bool p_enable) {}

void Tree::set_hide_folding(bool p_hide) {}

bool Tree::is_folding_hidden() const {}

void Tree::set_enable_recursive_folding(bool p_enable) {}

bool Tree::is_recursive_folding_enabled() const {}

void Tree::set_drop_mode_flags(int p_flags) {}

int Tree::get_drop_mode_flags() const {}

void Tree::set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable) {}

bool Tree::get_edit_checkbox_cell_only_when_checkbox_is_pressed() const {}

void Tree::set_allow_rmb_select(bool p_allow) {}

bool Tree::get_allow_rmb_select() const {}

void Tree::set_allow_reselect(bool p_allow) {}

bool Tree::get_allow_reselect() const {}

void Tree::set_allow_search(bool p_allow) {}

bool Tree::get_allow_search() const {}

void Tree::_bind_methods() {}

Tree::Tree() {}

Tree::~Tree() {}