2014-02-10 02:10:30 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* tree.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* 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. */
|
|
|
|
/**************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#ifndef TREE_H
|
|
|
|
#define TREE_H
|
|
|
|
|
|
|
|
#include "scene/gui/control.h"
|
|
|
|
#include "scene/gui/line_edit.h"
|
|
|
|
#include "scene/gui/popup_menu.h"
|
|
|
|
#include "scene/gui/scroll_bar.h"
|
|
|
|
#include "scene/gui/slider.h"
|
2023-04-25 17:43:26 +02:00
|
|
|
#include "scene/resources/text_paragraph.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2023-04-25 17:43:26 +02:00
|
|
|
class TextEdit;
|
2014-02-10 02:10:30 +01:00
|
|
|
class Tree;
|
|
|
|
|
|
|
|
class TreeItem : public Object {
|
2017-01-03 03:03:46 +01:00
|
|
|
GDCLASS(TreeItem, Object);
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2014-02-10 02:10:30 +01:00
|
|
|
enum TreeCellMode {
|
|
|
|
CELL_MODE_STRING, ///< just a string
|
|
|
|
CELL_MODE_CHECK, ///< string + check
|
|
|
|
CELL_MODE_RANGE, ///< Contains a range
|
2017-09-02 16:19:06 +02:00
|
|
|
CELL_MODE_ICON, ///< Contains an icon, not editable
|
2014-02-10 02:10:30 +01:00
|
|
|
CELL_MODE_CUSTOM, ///< Contains a custom value, show a string, and an edit button
|
|
|
|
};
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
private:
|
|
|
|
friend class Tree;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
struct Cell {
|
2021-02-09 18:24:36 +01:00
|
|
|
TreeCellMode mode = TreeItem::CELL_MODE_STRING;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> icon;
|
2014-02-10 02:10:30 +01:00
|
|
|
Rect2i icon_region;
|
|
|
|
String text;
|
2023-04-25 17:43:26 +02:00
|
|
|
bool edit_multiline = false;
|
2016-08-31 04:44:14 +02:00
|
|
|
String suffix;
|
2023-04-25 17:43:26 +02:00
|
|
|
Ref<TextParagraph> text_buf;
|
2020-09-03 13:22:16 +02:00
|
|
|
String language;
|
2022-04-19 12:27:18 +02:00
|
|
|
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
2020-09-03 13:22:16 +02:00
|
|
|
Array st_args;
|
|
|
|
Control::TextDirection text_direction = Control::TEXT_DIRECTION_INHERITED;
|
2023-06-03 14:17:35 +02:00
|
|
|
TextServer::AutowrapMode autowrap_mode = TextServer::AUTOWRAP_OFF;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool dirty = true;
|
|
|
|
double min = 0.0;
|
|
|
|
double max = 100.0;
|
|
|
|
double step = 1.0;
|
|
|
|
double val = 0.0;
|
|
|
|
int icon_max_w = 0;
|
|
|
|
bool expr = false;
|
|
|
|
bool checked = false;
|
2021-07-22 22:34:54 +02:00
|
|
|
bool indeterminate = false;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool editable = false;
|
|
|
|
bool selected = false;
|
|
|
|
bool selectable = true;
|
|
|
|
bool custom_color = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
Color color;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool custom_bg_color = false;
|
|
|
|
bool custom_bg_outline = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
Color bg_color;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool custom_button = false;
|
|
|
|
bool expand_right = false;
|
|
|
|
Color icon_color = Color(1, 1, 1);
|
2017-06-25 22:30:28 +02:00
|
|
|
|
2021-09-24 10:11:44 +02:00
|
|
|
Size2i cached_minimum_size;
|
|
|
|
bool cached_minimum_size_dirty = true;
|
|
|
|
|
2021-11-25 03:58:47 +01:00
|
|
|
HorizontalAlignment text_alignment = HORIZONTAL_ALIGNMENT_LEFT;
|
2016-05-11 16:46:08 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Variant meta;
|
|
|
|
String tooltip;
|
|
|
|
|
2024-01-20 17:55:34 +01:00
|
|
|
Callable custom_draw_callback;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
struct Button {
|
2021-02-09 18:24:36 +01:00
|
|
|
int id = 0;
|
|
|
|
bool disabled = false;
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> texture;
|
2021-02-09 18:24:36 +01:00
|
|
|
Color color = Color(1, 1, 1, 1);
|
2017-04-24 21:41:17 +02:00
|
|
|
String tooltip;
|
2023-08-23 21:18:52 +02:00
|
|
|
Rect2i rect;
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Vector<Button> buttons;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2021-05-27 17:32:30 +02:00
|
|
|
Ref<Font> custom_font;
|
2020-12-27 14:30:33 +01:00
|
|
|
int custom_font_size = -1;
|
2021-05-27 17:32:30 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Cell() {
|
2021-06-18 00:03:09 +02:00
|
|
|
text_buf.instantiate();
|
2023-06-27 17:22:10 +02:00
|
|
|
text_buf->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Size2 get_icon_size() const;
|
2017-07-19 22:00:46 +02:00
|
|
|
void draw_icon(const RID &p_where, const Point2 &p_pos, const Size2 &p_size = Size2(), const Color &p_color = Color()) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Vector<Cell> cells;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2021-03-07 21:07:30 +01:00
|
|
|
bool collapsed = false; // won't show children
|
2022-04-03 10:37:08 +02:00
|
|
|
bool visible = true;
|
2021-03-07 21:07:30 +01:00
|
|
|
bool disable_folding = false;
|
|
|
|
int custom_min_height = 0;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2021-03-07 21:07:30 +01:00
|
|
|
TreeItem *parent = nullptr; // parent item
|
|
|
|
TreeItem *prev = nullptr; // previous in list
|
|
|
|
TreeItem *next = nullptr; // next in list
|
|
|
|
TreeItem *first_child = nullptr;
|
|
|
|
|
|
|
|
Vector<TreeItem *> children_cache;
|
|
|
|
bool is_root = false; // for tree root
|
2022-04-04 15:06:57 +02:00
|
|
|
Tree *tree = nullptr; // tree (for reference)
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2015-12-08 19:04:56 +01:00
|
|
|
TreeItem(Tree *p_tree);
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void _changed_notify(int p_cell);
|
|
|
|
void _changed_notify();
|
|
|
|
void _cell_selected(int p_cell);
|
|
|
|
void _cell_deselected(int p_cell);
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2021-03-07 21:07:30 +01:00
|
|
|
void _change_tree(Tree *p_tree);
|
|
|
|
|
|
|
|
_FORCE_INLINE_ void _create_children_cache() {
|
|
|
|
if (children_cache.is_empty()) {
|
|
|
|
TreeItem *c = first_child;
|
|
|
|
while (c) {
|
|
|
|
children_cache.append(c);
|
|
|
|
c = c->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_FORCE_INLINE_ void _unlink_from_tree() {
|
|
|
|
TreeItem *p = get_prev();
|
|
|
|
if (p) {
|
|
|
|
p->next = next;
|
|
|
|
}
|
|
|
|
if (next) {
|
|
|
|
next->prev = p;
|
|
|
|
}
|
|
|
|
if (parent) {
|
|
|
|
if (!parent->children_cache.is_empty()) {
|
2021-07-04 00:17:03 +02:00
|
|
|
parent->children_cache.remove_at(get_index());
|
2021-03-07 21:07:30 +01:00
|
|
|
}
|
|
|
|
if (parent->first_child == this) {
|
|
|
|
parent->first_child = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-01 15:43:39 +02:00
|
|
|
bool _is_any_collapsed(bool p_only_visible);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2021-03-07 21:07:30 +01:00
|
|
|
|
|
|
|
// Bind helpers
|
2016-03-09 00:00:52 +01:00
|
|
|
Dictionary _get_range_config(int p_column) {
|
2014-02-10 02:10:30 +01:00
|
|
|
Dictionary d;
|
2019-11-20 16:22:16 +01:00
|
|
|
double min = 0.0, max = 0.0, step = 0.0;
|
2014-02-10 02:10:30 +01:00
|
|
|
get_range_config(p_column, min, max, step);
|
|
|
|
d["min"] = min;
|
|
|
|
d["max"] = max;
|
|
|
|
d["step"] = step;
|
|
|
|
d["expr"] = false;
|
|
|
|
|
|
|
|
return d;
|
|
|
|
}
|
2021-03-07 21:07:30 +01:00
|
|
|
|
2022-02-22 12:15:43 +01:00
|
|
|
void _call_recursive_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
2018-10-07 18:25:57 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2014-02-10 02:10:30 +01:00
|
|
|
/* cell mode */
|
|
|
|
void set_cell_mode(int p_column, TreeCellMode p_mode);
|
|
|
|
TreeCellMode get_cell_mode(int p_column) const;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2023-04-25 17:43:26 +02:00
|
|
|
/* multiline editable */
|
|
|
|
void set_edit_multiline(int p_column, bool p_multiline);
|
|
|
|
bool is_edit_multiline(int p_column) const;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
/* check mode */
|
|
|
|
void set_checked(int p_column, bool p_checked);
|
2021-07-22 22:34:54 +02:00
|
|
|
void set_indeterminate(int p_column, bool p_indeterminate);
|
2014-02-10 02:10:30 +01:00
|
|
|
bool is_checked(int p_column) const;
|
2021-07-22 22:34:54 +02:00
|
|
|
bool is_indeterminate(int p_column) const;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2021-09-17 17:50:24 +02:00
|
|
|
void propagate_check(int p_column, bool p_emit_signal = true);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Check helpers.
|
|
|
|
void _propagate_check_through_children(int p_column, bool p_checked, bool p_emit_signal);
|
|
|
|
void _propagate_check_through_parents(int p_column, bool p_emit_signal);
|
|
|
|
|
2023-05-11 04:17:03 +02:00
|
|
|
TreeItem *_get_prev_in_tree(bool p_wrap = false, bool p_include_invisible = false);
|
|
|
|
TreeItem *_get_next_in_tree(bool p_wrap = false, bool p_include_invisible = false);
|
2022-04-03 10:37:08 +02:00
|
|
|
|
2021-09-17 17:50:24 +02:00
|
|
|
public:
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_text(int p_column, String p_text);
|
|
|
|
String get_text(int p_column) const;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2020-09-03 13:22:16 +02:00
|
|
|
void set_text_direction(int p_column, Control::TextDirection p_text_direction);
|
|
|
|
Control::TextDirection get_text_direction(int p_column) const;
|
|
|
|
|
2023-06-03 14:17:35 +02:00
|
|
|
void set_autowrap_mode(int p_column, TextServer::AutowrapMode p_mode);
|
|
|
|
TextServer::AutowrapMode get_autowrap_mode(int p_column) const;
|
|
|
|
|
2023-06-27 17:22:10 +02:00
|
|
|
void set_text_overrun_behavior(int p_column, TextServer::OverrunBehavior p_behavior);
|
|
|
|
TextServer::OverrunBehavior get_text_overrun_behavior(int p_column) const;
|
|
|
|
|
2022-04-19 12:27:18 +02:00
|
|
|
void set_structured_text_bidi_override(int p_column, TextServer::StructuredTextParser p_parser);
|
|
|
|
TextServer::StructuredTextParser get_structured_text_bidi_override(int p_column) const;
|
2020-09-03 13:22:16 +02:00
|
|
|
|
|
|
|
void set_structured_text_bidi_override_options(int p_column, Array p_args);
|
|
|
|
Array get_structured_text_bidi_override_options(int p_column) const;
|
|
|
|
|
|
|
|
void set_language(int p_column, const String &p_language);
|
|
|
|
String get_language(int p_column) const;
|
|
|
|
|
2016-08-31 04:44:14 +02:00
|
|
|
void set_suffix(int p_column, String p_suffix);
|
|
|
|
String get_suffix(int p_column) const;
|
|
|
|
|
2019-06-11 20:43:37 +02:00
|
|
|
void set_icon(int p_column, const Ref<Texture2D> &p_icon);
|
|
|
|
Ref<Texture2D> get_icon(int p_column) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
void set_icon_region(int p_column, const Rect2 &p_icon_region);
|
|
|
|
Rect2 get_icon_region(int p_column) const;
|
|
|
|
|
2019-08-24 17:13:48 +02:00
|
|
|
void set_icon_modulate(int p_column, const Color &p_modulate);
|
|
|
|
Color get_icon_modulate(int p_column) const;
|
2017-07-19 22:00:46 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_icon_max_width(int p_column, int p_max);
|
|
|
|
int get_icon_max_width(int p_column) const;
|
|
|
|
|
2019-06-11 20:43:37 +02:00
|
|
|
void add_button(int p_column, const Ref<Texture2D> &p_button, int p_id = -1, bool p_disabled = false, const String &p_tooltip = "");
|
2014-02-10 02:10:30 +01:00
|
|
|
int get_button_count(int p_column) const;
|
2022-12-22 08:05:04 +01:00
|
|
|
String get_button_tooltip_text(int p_column, int p_index) const;
|
|
|
|
Ref<Texture2D> get_button(int p_column, int p_index) const;
|
|
|
|
int get_button_id(int p_column, int p_index) const;
|
|
|
|
void erase_button(int p_column, int p_index);
|
2014-02-10 02:10:30 +01:00
|
|
|
int get_button_by_id(int p_column, int p_id) const;
|
2024-01-28 20:55:48 +01:00
|
|
|
Color get_button_color(int p_column, int p_index) const;
|
2023-06-18 10:51:58 +02:00
|
|
|
void set_button_tooltip_text(int p_column, int p_index, const String &p_tooltip);
|
2022-12-22 08:05:04 +01:00
|
|
|
void set_button(int p_column, int p_index, const Ref<Texture2D> &p_button);
|
|
|
|
void set_button_color(int p_column, int p_index, const Color &p_color);
|
|
|
|
void set_button_disabled(int p_column, int p_index, bool p_disabled);
|
|
|
|
bool is_button_disabled(int p_column, int p_index) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
/* range works for mode number or mode combo */
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_range(int p_column, double p_value);
|
|
|
|
double get_range(int p_column) const;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_range_config(int p_column, double p_min, double p_max, double p_step, bool p_exp = false);
|
|
|
|
void get_range_config(int p_column, double &r_min, double &r_max, double &r_step) const;
|
|
|
|
bool is_range_exponential(int p_column) const;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_metadata(int p_column, const Variant &p_meta);
|
|
|
|
Variant get_metadata(int p_column) const;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2024-01-20 17:55:34 +01:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_custom_draw(int p_column, Object *p_object, const StringName &p_callback);
|
2024-01-20 17:55:34 +01:00
|
|
|
#endif // DISABLE_DEPRECATED
|
|
|
|
void set_custom_draw_callback(int p_column, const Callable &p_callback);
|
|
|
|
Callable get_custom_draw_callback(int p_column) const;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_collapsed(bool p_collapsed);
|
|
|
|
bool is_collapsed();
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2022-07-01 15:43:39 +02:00
|
|
|
void set_collapsed_recursive(bool p_collapsed);
|
|
|
|
bool is_any_collapsed(bool p_only_visible = false);
|
|
|
|
|
2022-04-03 10:37:08 +02:00
|
|
|
void set_visible(bool p_visible);
|
|
|
|
bool is_visible();
|
|
|
|
|
2021-03-19 13:57:52 +01:00
|
|
|
void uncollapse_tree();
|
|
|
|
|
2017-09-05 14:31:07 +02:00
|
|
|
void set_custom_minimum_height(int p_height);
|
|
|
|
int get_custom_minimum_height() const;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_selectable(int p_column, bool p_selectable);
|
|
|
|
bool is_selectable(int p_column) const;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
bool is_selected(int p_column);
|
|
|
|
void select(int p_column);
|
|
|
|
void deselect(int p_column);
|
|
|
|
void set_as_cursor(int p_column);
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_editable(int p_column, bool p_editable);
|
|
|
|
bool is_editable(int p_column);
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_custom_color(int p_column, const Color &p_color);
|
2016-03-12 14:44:12 +01:00
|
|
|
Color get_custom_color(int p_column) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
void clear_custom_color(int p_column);
|
|
|
|
|
2021-05-27 17:32:30 +02:00
|
|
|
void set_custom_font(int p_column, const Ref<Font> &p_font);
|
|
|
|
Ref<Font> get_custom_font(int p_column) const;
|
2020-12-27 14:30:33 +01:00
|
|
|
|
|
|
|
void set_custom_font_size(int p_column, int p_font_size);
|
|
|
|
int get_custom_font_size(int p_column) const;
|
2021-05-27 17:32:30 +02:00
|
|
|
|
2016-05-11 16:46:08 +02:00
|
|
|
void set_custom_bg_color(int p_column, const Color &p_color, bool p_bg_outline = false);
|
2014-02-10 02:10:30 +01:00
|
|
|
void clear_custom_bg_color(int p_column);
|
|
|
|
Color get_custom_bg_color(int p_column) const;
|
|
|
|
|
2017-06-05 01:35:08 +02:00
|
|
|
void set_custom_as_button(int p_column, bool p_button);
|
|
|
|
bool is_custom_set_as_button(int p_column) const;
|
|
|
|
|
2022-08-29 15:55:49 +02:00
|
|
|
void set_tooltip_text(int p_column, const String &p_tooltip);
|
|
|
|
String get_tooltip_text(int p_column) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-11-25 03:58:47 +01:00
|
|
|
void set_text_alignment(int p_column, HorizontalAlignment p_alignment);
|
|
|
|
HorizontalAlignment get_text_alignment(int p_column) const;
|
2017-06-25 22:30:28 +02:00
|
|
|
|
|
|
|
void set_expand_right(int p_column, bool p_enable);
|
|
|
|
bool get_expand_right(int p_column) const;
|
|
|
|
|
|
|
|
void set_disable_folding(bool p_disable);
|
|
|
|
bool is_folding_disabled() const;
|
|
|
|
|
2021-06-28 15:40:56 +02:00
|
|
|
Size2 get_minimum_size(int p_column);
|
|
|
|
|
2021-03-07 21:07:30 +01:00
|
|
|
/* Item manipulation */
|
|
|
|
|
2022-12-22 08:05:04 +01:00
|
|
|
TreeItem *create_child(int p_index = -1);
|
2023-05-31 11:31:43 +02:00
|
|
|
void add_child(TreeItem *p_item);
|
|
|
|
void remove_child(TreeItem *p_item);
|
2021-03-07 21:07:30 +01:00
|
|
|
|
2021-06-28 15:40:56 +02:00
|
|
|
Tree *get_tree() const;
|
2021-03-07 21:07:30 +01:00
|
|
|
|
|
|
|
TreeItem *get_prev();
|
2021-06-28 15:40:56 +02:00
|
|
|
TreeItem *get_next() const;
|
|
|
|
TreeItem *get_parent() const;
|
|
|
|
TreeItem *get_first_child() const;
|
2021-03-07 21:07:30 +01:00
|
|
|
|
2023-05-11 04:17:03 +02:00
|
|
|
TreeItem *get_prev_in_tree(bool p_wrap = false);
|
|
|
|
TreeItem *get_next_in_tree(bool p_wrap = false);
|
|
|
|
|
2021-03-07 21:07:30 +01:00
|
|
|
TreeItem *get_prev_visible(bool p_wrap = false);
|
|
|
|
TreeItem *get_next_visible(bool p_wrap = false);
|
|
|
|
|
2022-12-22 08:05:04 +01:00
|
|
|
TreeItem *get_child(int p_index);
|
2022-04-03 10:37:08 +02:00
|
|
|
int get_visible_child_count();
|
2021-03-07 21:07:30 +01:00
|
|
|
int get_child_count();
|
2022-08-08 00:52:20 +02:00
|
|
|
TypedArray<TreeItem> get_children();
|
2023-05-31 11:31:43 +02:00
|
|
|
void clear_children();
|
2021-03-07 21:07:30 +01:00
|
|
|
int get_index();
|
|
|
|
|
2022-08-04 00:08:16 +02:00
|
|
|
#ifdef DEV_ENABLED
|
|
|
|
// This debugging code can be removed once the current refactoring of this class is complete.
|
|
|
|
void validate_cache() const;
|
|
|
|
#else
|
|
|
|
void validate_cache() const {}
|
|
|
|
#endif
|
|
|
|
|
2021-03-07 21:07:30 +01:00
|
|
|
void move_before(TreeItem *p_item);
|
|
|
|
void move_after(TreeItem *p_item);
|
|
|
|
|
2020-02-19 20:27:19 +01:00
|
|
|
void call_recursive(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
2018-10-07 18:25:57 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
~TreeItem();
|
|
|
|
};
|
|
|
|
|
|
|
|
VARIANT_ENUM_CAST(TreeItem::TreeCellMode);
|
|
|
|
|
2020-03-20 03:32:09 +01:00
|
|
|
class VBoxContainer;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
class Tree : public Control {
|
2017-01-03 03:03:46 +01:00
|
|
|
GDCLASS(Tree, Control);
|
2017-03-05 16:44:50 +01:00
|
|
|
|
2016-03-09 00:00:52 +01:00
|
|
|
public:
|
2014-02-10 02:10:30 +01:00
|
|
|
enum SelectMode {
|
|
|
|
SELECT_SINGLE,
|
|
|
|
SELECT_ROW,
|
|
|
|
SELECT_MULTI
|
|
|
|
};
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2016-05-11 16:46:08 +02:00
|
|
|
enum DropModeFlags {
|
|
|
|
DROP_MODE_DISABLED = 0,
|
|
|
|
DROP_MODE_ON_ITEM = 1,
|
|
|
|
DROP_MODE_INBETWEEN = 2
|
|
|
|
};
|
|
|
|
|
2016-03-09 00:00:52 +01:00
|
|
|
private:
|
|
|
|
friend class TreeItem;
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
TreeItem *root = nullptr;
|
|
|
|
TreeItem *popup_edited_item = nullptr;
|
|
|
|
TreeItem *selected_item = nullptr;
|
|
|
|
TreeItem *edited_item = nullptr;
|
2015-08-29 06:43:21 +02:00
|
|
|
|
2022-04-07 13:49:28 +02:00
|
|
|
TreeItem *popup_pressing_edited_item = nullptr; // Candidate.
|
|
|
|
int popup_pressing_edited_item_column = -1;
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
TreeItem *drop_mode_over = nullptr;
|
|
|
|
int drop_mode_section = 0;
|
2016-05-11 16:46:08 +02:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
TreeItem *single_select_defer = nullptr;
|
|
|
|
int single_select_defer_column = 0;
|
2015-08-29 06:43:21 +02:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
int pressed_button = -1;
|
|
|
|
bool pressing_for_editor = false;
|
2015-08-29 06:43:21 +02:00
|
|
|
String pressing_for_editor_text;
|
|
|
|
Vector2 pressing_pos;
|
|
|
|
Rect2 pressing_item_rect;
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
float range_drag_base = 0.0;
|
|
|
|
bool range_drag_enabled = false;
|
2015-08-29 06:43:21 +02:00
|
|
|
Vector2 range_drag_capture_pos;
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
bool propagate_mouse_activated = false;
|
2019-01-14 21:20:33 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
//TreeItem *cursor_item;
|
|
|
|
//int cursor_column;
|
|
|
|
|
|
|
|
Rect2 custom_popup_rect;
|
2021-02-09 18:24:36 +01:00
|
|
|
int edited_col = -1;
|
|
|
|
int selected_col = -1;
|
|
|
|
int popup_edited_item_col = -1;
|
|
|
|
bool hide_root = false;
|
|
|
|
SelectMode select_mode = SELECT_SINGLE;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
int blocked = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
int drop_mode_flags = 0;
|
2016-05-11 16:46:08 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
struct ColumnInfo {
|
2021-06-28 15:40:56 +02:00
|
|
|
int custom_min_width = 0;
|
2021-07-04 05:13:28 +02:00
|
|
|
int expand_ratio = 1;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool expand = true;
|
2021-07-04 05:13:28 +02:00
|
|
|
bool clip_content = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
String title;
|
2023-03-26 03:13:31 +02:00
|
|
|
HorizontalAlignment title_alignment = HORIZONTAL_ALIGNMENT_CENTER;
|
2023-04-25 17:43:26 +02:00
|
|
|
Ref<TextParagraph> text_buf;
|
2020-09-03 13:22:16 +02:00
|
|
|
String language;
|
|
|
|
Control::TextDirection text_direction = Control::TEXT_DIRECTION_INHERITED;
|
2023-07-11 10:58:19 +02:00
|
|
|
|
|
|
|
mutable int cached_minimum_width = 0;
|
|
|
|
mutable bool cached_minimum_width_dirty = true;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
ColumnInfo() {
|
2021-06-18 00:03:09 +02:00
|
|
|
text_buf.instantiate();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
bool show_column_titles = false;
|
2020-03-20 03:32:09 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
VBoxContainer *popup_editor_vb = nullptr;
|
2020-03-20 03:32:09 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Popup *popup_editor = nullptr;
|
2023-04-25 17:43:26 +02:00
|
|
|
LineEdit *line_editor = nullptr;
|
|
|
|
TextEdit *text_editor = nullptr;
|
2022-04-04 15:06:57 +02:00
|
|
|
HSlider *value_editor = nullptr;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool updating_value_editor = false;
|
|
|
|
uint64_t focus_in_id = 0;
|
|
|
|
PopupMenu *popup_menu = nullptr;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
Vector<ColumnInfo> columns;
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Timer *range_click_timer = nullptr;
|
2021-02-09 18:24:36 +01:00
|
|
|
TreeItem *range_item_last = nullptr;
|
|
|
|
bool range_up_last = false;
|
2015-12-08 19:04:56 +01:00
|
|
|
void _range_click_timeout();
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
int compute_item_height(TreeItem *p_item) const;
|
|
|
|
int get_item_height(TreeItem *p_item) const;
|
2020-09-03 13:22:16 +02:00
|
|
|
void _update_all();
|
|
|
|
void update_column(int p_col);
|
|
|
|
void update_item_cell(TreeItem *p_item, int p_col);
|
|
|
|
void update_item_cache(TreeItem *p_item);
|
2019-06-11 20:43:37 +02:00
|
|
|
//void draw_item_text(String p_text,const Ref<Texture2D>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color);
|
2023-04-28 09:45:29 +02:00
|
|
|
void 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);
|
2023-07-11 10:58:19 +02:00
|
|
|
int draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item, int &r_self_height);
|
2020-04-02 01:20:12 +02:00
|
|
|
void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = nullptr, bool *r_in_range = nullptr, bool p_force_deselect = false);
|
2021-08-13 23:31:57 +02:00
|
|
|
int 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);
|
2023-04-25 17:43:26 +02:00
|
|
|
void _line_editor_submit(String p_text);
|
|
|
|
void _apply_multiline_edit();
|
|
|
|
void _text_editor_popup_modal_close();
|
|
|
|
void _text_editor_gui_input(const Ref<InputEvent> &p_event);
|
2014-02-10 02:10:30 +01:00
|
|
|
void value_editor_changed(double p_value);
|
|
|
|
|
|
|
|
void popup_select(int p_option);
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2022-05-26 12:12:57 +02:00
|
|
|
void item_edited(int p_column, TreeItem *p_item, MouseButton p_custom_mouse_index = MouseButton::NONE);
|
2014-02-10 02:10:30 +01:00
|
|
|
void item_changed(int p_column, TreeItem *p_item);
|
|
|
|
void item_selected(int p_column, TreeItem *p_item);
|
|
|
|
void item_deselected(int p_column, TreeItem *p_item);
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void propagate_set_columns(TreeItem *p_item);
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2022-08-31 14:02:40 +02:00
|
|
|
struct ThemeCache {
|
2022-09-06 19:09:32 +02:00
|
|
|
Ref<StyleBox> panel_style;
|
|
|
|
Ref<StyleBox> focus_style;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Ref<Font> font;
|
|
|
|
Ref<Font> tb_font;
|
2021-02-09 18:24:36 +01:00
|
|
|
int font_size = 0;
|
|
|
|
int tb_font_size = 0;
|
2022-09-06 19:09:32 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Ref<StyleBox> selected;
|
|
|
|
Ref<StyleBox> selected_focus;
|
|
|
|
Ref<StyleBox> cursor;
|
|
|
|
Ref<StyleBox> cursor_unfocus;
|
|
|
|
Ref<StyleBox> button_pressed;
|
|
|
|
Ref<StyleBox> title_button;
|
|
|
|
Ref<StyleBox> title_button_hover;
|
|
|
|
Ref<StyleBox> title_button_pressed;
|
2017-06-05 01:35:08 +02:00
|
|
|
Ref<StyleBox> custom_button;
|
|
|
|
Ref<StyleBox> custom_button_hover;
|
|
|
|
Ref<StyleBox> custom_button_pressed;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Color title_button_color;
|
|
|
|
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> checked;
|
|
|
|
Ref<Texture2D> unchecked;
|
2023-11-13 14:38:56 +01:00
|
|
|
Ref<Texture2D> checked_disabled;
|
|
|
|
Ref<Texture2D> unchecked_disabled;
|
2021-07-22 22:34:54 +02:00
|
|
|
Ref<Texture2D> indeterminate;
|
2023-11-13 14:38:56 +01:00
|
|
|
Ref<Texture2D> indeterminate_disabled;
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> arrow;
|
2022-08-31 14:02:40 +02:00
|
|
|
Ref<Texture2D> arrow_collapsed;
|
|
|
|
Ref<Texture2D> arrow_collapsed_mirrored;
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> select_arrow;
|
|
|
|
Ref<Texture2D> updown;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Color font_color;
|
2020-12-08 14:11:45 +01:00
|
|
|
Color font_selected_color;
|
2023-11-13 14:38:56 +01:00
|
|
|
Color font_disabled_color;
|
2014-02-10 02:10:30 +01:00
|
|
|
Color guide_color;
|
2016-05-11 16:46:08 +02:00
|
|
|
Color drop_position_color;
|
2016-06-15 19:10:19 +02:00
|
|
|
Color relationship_line_color;
|
2021-05-02 17:34:29 +02:00
|
|
|
Color parent_hl_line_color;
|
|
|
|
Color children_hl_line_color;
|
2017-06-05 01:35:08 +02:00
|
|
|
Color custom_button_font_highlight;
|
2021-07-04 05:13:28 +02:00
|
|
|
Color font_outline_color;
|
2016-05-11 16:46:08 +02:00
|
|
|
|
2021-10-02 22:07:42 +02:00
|
|
|
float base_scale = 1.0;
|
2023-03-31 21:17:59 +02:00
|
|
|
int font_outline_size = 0;
|
2021-10-02 22:07:42 +02:00
|
|
|
|
2022-11-30 16:06:14 +01:00
|
|
|
int h_separation = 0;
|
|
|
|
int v_separation = 0;
|
2023-04-27 20:16:28 +02:00
|
|
|
int inner_item_margin_bottom = 0;
|
|
|
|
int inner_item_margin_left = 0;
|
|
|
|
int inner_item_margin_right = 0;
|
|
|
|
int inner_item_margin_top = 0;
|
2021-02-09 18:24:36 +01:00
|
|
|
int item_margin = 0;
|
|
|
|
int button_margin = 0;
|
2023-03-31 21:17:59 +02:00
|
|
|
int icon_max_width = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
Point2 offset;
|
2023-03-31 21:17:59 +02:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
int draw_relationship_lines = 0;
|
2021-05-02 17:34:29 +02:00
|
|
|
int relationship_line_width = 0;
|
|
|
|
int parent_hl_line_width = 0;
|
|
|
|
int children_hl_line_width = 0;
|
|
|
|
int parent_hl_line_margin = 0;
|
2021-02-09 18:24:36 +01:00
|
|
|
int draw_guides = 0;
|
2023-03-31 21:17:59 +02:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
int scroll_border = 0;
|
|
|
|
int scroll_speed = 0;
|
2023-01-04 03:59:34 +01:00
|
|
|
|
|
|
|
int scrollbar_margin_top = -1;
|
|
|
|
int scrollbar_margin_right = -1;
|
|
|
|
int scrollbar_margin_bottom = -1;
|
|
|
|
int scrollbar_margin_left = -1;
|
|
|
|
int scrollbar_h_separation = 0;
|
|
|
|
int scrollbar_v_separation = 0;
|
2022-08-31 14:02:40 +02:00
|
|
|
} theme_cache;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-08-31 14:02:40 +02:00
|
|
|
struct Cache {
|
2014-02-10 02:10:30 +01:00
|
|
|
enum ClickType {
|
|
|
|
CLICK_NONE,
|
|
|
|
CLICK_TITLE,
|
|
|
|
CLICK_BUTTON,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
ClickType click_type = Cache::CLICK_NONE;
|
|
|
|
ClickType hover_type = Cache::CLICK_NONE;
|
|
|
|
int click_index = -1;
|
|
|
|
int click_id = -1;
|
|
|
|
TreeItem *click_item = nullptr;
|
|
|
|
int click_column = 0;
|
|
|
|
int hover_index = -1;
|
2017-03-02 19:51:23 +01:00
|
|
|
Point2 click_pos;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
TreeItem *hover_item = nullptr;
|
|
|
|
int hover_cell = -1;
|
2017-06-05 01:35:08 +02:00
|
|
|
|
2021-07-04 05:13:28 +02:00
|
|
|
bool rtl = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
} cache;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
int _get_title_button_height() const;
|
2023-03-31 21:17:59 +02:00
|
|
|
Size2 _get_cell_icon_size(const TreeItem::Cell &p_cell) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
void _scroll_moved(float p_value);
|
2022-04-04 15:06:57 +02:00
|
|
|
HScrollBar *h_scroll = nullptr;
|
|
|
|
VScrollBar *v_scroll = nullptr;
|
2021-07-04 05:13:28 +02:00
|
|
|
|
2021-06-25 21:19:46 +02:00
|
|
|
bool h_scroll_enabled = true;
|
|
|
|
bool v_scroll_enabled = true;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Size2 get_internal_min_size() const;
|
|
|
|
void update_scrollbars();
|
|
|
|
|
|
|
|
Rect2 search_item_rect(TreeItem *p_from, TreeItem *p_item);
|
|
|
|
//Rect2 get_item_rect(TreeItem *p_item);
|
2021-02-09 18:24:36 +01:00
|
|
|
uint64_t last_keypress = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
String incr_search;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool cursor_can_exit_tree = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
void _do_incr_search(const String &p_add);
|
|
|
|
|
|
|
|
TreeItem *_search_item_text(TreeItem *p_at, const String &p_find, int *r_col, bool p_selectable, bool p_backwards = false);
|
|
|
|
|
2017-08-11 21:10:05 +02:00
|
|
|
TreeItem *_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_column, int &h, int §ion) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
/* float drag_speed;
|
|
|
|
float drag_accum;
|
|
|
|
|
|
|
|
float last_drag_accum;
|
|
|
|
float last_drag_time;
|
|
|
|
float time_since_motion;*/
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
float drag_speed = 0.0;
|
|
|
|
float drag_from = 0.0;
|
|
|
|
float drag_accum = 0.0;
|
2014-02-10 02:10:30 +01:00
|
|
|
Vector2 last_speed;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool drag_touching = false;
|
|
|
|
bool drag_touching_deaccel = false;
|
|
|
|
bool click_handled = false;
|
|
|
|
bool allow_rmb_select = false;
|
|
|
|
bool scrolling = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
bool allow_reselect = false;
|
2023-04-18 08:50:24 +02:00
|
|
|
bool allow_search = true;
|
2017-08-18 23:19:12 +02:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
bool force_edit_checkbox_only_on_checkbox = false;
|
2016-05-15 04:48:23 +02:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
bool hide_folding = false;
|
2015-11-14 00:56:44 +01:00
|
|
|
|
2022-07-01 15:43:39 +02:00
|
|
|
bool enable_recursive_folding = true;
|
|
|
|
|
2016-05-11 16:46:08 +02:00
|
|
|
int _count_selected_items(TreeItem *p_from) const;
|
2021-05-02 17:34:29 +02:00
|
|
|
bool _is_branch_selected(TreeItem *p_from) const;
|
|
|
|
bool _is_sibling_branch_selected(TreeItem *p_from) const;
|
2017-12-31 05:56:17 +01:00
|
|
|
void _go_left();
|
|
|
|
void _go_right();
|
|
|
|
void _go_down();
|
|
|
|
void _go_up();
|
2016-05-11 16:46:08 +02:00
|
|
|
|
2022-07-05 19:30:45 +02:00
|
|
|
bool _scroll(bool p_horizontal, float p_pages);
|
|
|
|
|
2023-01-04 03:59:34 +01:00
|
|
|
Rect2 _get_scrollbar_layout_rect() const;
|
|
|
|
Rect2 _get_content_rect() const; // Considering the background stylebox and scrollbars.
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
protected:
|
2022-08-31 14:02:40 +02:00
|
|
|
virtual void _update_theme_item_cache() override;
|
|
|
|
|
2023-09-08 21:00:10 +02:00
|
|
|
void _notification(int p_what);
|
2014-02-10 02:10:30 +01:00
|
|
|
static void _bind_methods();
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
public:
|
2021-08-22 17:37:22 +02:00
|
|
|
virtual void gui_input(const Ref<InputEvent> &p_event) override;
|
|
|
|
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual String get_tooltip(const Point2 &p_pos) const override;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-09-10 15:37:49 +02:00
|
|
|
TreeItem *get_item_at_position(const Point2 &p_pos) const;
|
|
|
|
int get_column_at_position(const Point2 &p_pos) const;
|
|
|
|
int get_drop_section_at_position(const Point2 &p_pos) const;
|
2019-12-13 06:13:47 +01:00
|
|
|
int get_button_id_at_position(const Point2 &p_pos) const;
|
2016-05-11 16:46:08 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void clear();
|
|
|
|
|
2022-12-22 08:05:04 +01:00
|
|
|
TreeItem *create_item(TreeItem *p_parent = nullptr, int p_index = -1);
|
2021-06-28 15:40:56 +02:00
|
|
|
TreeItem *get_root() const;
|
|
|
|
TreeItem *get_last_item() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-06-28 15:40:56 +02:00
|
|
|
void set_column_custom_minimum_width(int p_column, int p_min_width);
|
2016-03-09 00:00:52 +01:00
|
|
|
void set_column_expand(int p_column, bool p_expand);
|
2021-07-04 05:13:28 +02:00
|
|
|
void set_column_expand_ratio(int p_column, int p_ratio);
|
|
|
|
void set_column_clip_content(int p_column, bool p_fit);
|
2021-06-28 15:40:56 +02:00
|
|
|
int get_column_minimum_width(int p_column) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
int get_column_width(int p_column) const;
|
2021-07-04 05:13:28 +02:00
|
|
|
int get_column_expand_ratio(int p_column) const;
|
|
|
|
|
|
|
|
bool is_column_expanding(int p_column) const;
|
|
|
|
bool is_column_clipping_content(int p_column) const;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2017-08-11 21:10:05 +02:00
|
|
|
void set_hide_root(bool p_enabled);
|
2018-01-11 23:35:12 +01:00
|
|
|
bool is_root_hidden() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
TreeItem *get_next_selected(TreeItem *p_item);
|
|
|
|
TreeItem *get_selected() const;
|
2022-11-09 13:45:21 +01:00
|
|
|
void set_selected(TreeItem *p_item, int p_column = 0);
|
2014-02-10 02:10:30 +01:00
|
|
|
int get_selected_column() const;
|
|
|
|
int get_pressed_button() const;
|
|
|
|
void set_select_mode(SelectMode p_mode);
|
2018-01-11 23:35:12 +01:00
|
|
|
SelectMode get_select_mode() const;
|
2017-11-27 16:58:28 +01:00
|
|
|
void deselect_all();
|
|
|
|
bool is_anything_selected();
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_columns(int p_columns);
|
|
|
|
int get_columns() const;
|
|
|
|
|
|
|
|
void set_column_title(int p_column, const String &p_title);
|
|
|
|
String get_column_title(int p_column) const;
|
|
|
|
|
2023-03-26 03:13:31 +02:00
|
|
|
void set_column_title_alignment(int p_column, HorizontalAlignment p_alignment);
|
|
|
|
HorizontalAlignment get_column_title_alignment(int p_column) const;
|
|
|
|
|
2020-09-03 13:22:16 +02:00
|
|
|
void set_column_title_direction(int p_column, Control::TextDirection p_text_direction);
|
|
|
|
Control::TextDirection get_column_title_direction(int p_column) const;
|
|
|
|
|
|
|
|
void set_column_title_language(int p_column, const String &p_language);
|
|
|
|
String get_column_title_language(int p_column) const;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_column_titles_visible(bool p_show);
|
|
|
|
bool are_column_titles_visible() const;
|
|
|
|
|
|
|
|
TreeItem *get_edited() const;
|
|
|
|
int get_edited_column() const;
|
|
|
|
|
|
|
|
void ensure_cursor_is_visible();
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Rect2 get_custom_popup_rect() const;
|
|
|
|
|
|
|
|
int get_item_offset(TreeItem *p_item) const;
|
2022-04-07 13:49:28 +02:00
|
|
|
Rect2 get_item_rect(TreeItem *p_item, int p_column = -1, int p_button = -1) const;
|
2022-11-26 15:58:25 +01:00
|
|
|
bool edit_selected(bool p_force_edit = false);
|
2020-12-31 08:43:03 +01:00
|
|
|
bool is_editing();
|
2022-11-26 15:58:25 +01:00
|
|
|
void set_editor_selection(int p_from_line, int p_to_line, int p_from_column = -1, int p_to_column = -1, int p_caret = 0);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-02-02 04:07:01 +01:00
|
|
|
// First item that starts with the text, from the current focused item down and wraps around.
|
2020-04-02 01:20:12 +02:00
|
|
|
TreeItem *search_item_text(const String &p_find, int *r_col = nullptr, bool p_selectable = false);
|
2020-02-02 04:07:01 +01:00
|
|
|
// First item that matches the whole text, from the first item down.
|
|
|
|
TreeItem *get_item_with_text(const String &p_find) const;
|
2023-05-11 04:17:03 +02:00
|
|
|
TreeItem *get_item_with_metadata(const Variant &p_find, int p_column = -1) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
Point2 get_scroll() const;
|
2020-07-05 20:06:51 +02:00
|
|
|
void scroll_to_item(TreeItem *p_item, bool p_center_on_item = false);
|
2021-06-25 21:19:46 +02:00
|
|
|
void set_h_scroll_enabled(bool p_enable);
|
|
|
|
bool is_h_scroll_enabled() const;
|
|
|
|
void set_v_scroll_enabled(bool p_enable);
|
|
|
|
bool is_v_scroll_enabled() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
void set_cursor_can_exit_tree(bool p_enable);
|
|
|
|
|
2015-06-22 05:03:19 +02:00
|
|
|
VScrollBar *get_vscroll_bar() { return v_scroll; }
|
|
|
|
|
2015-11-14 00:56:44 +01:00
|
|
|
void set_hide_folding(bool p_hide);
|
|
|
|
bool is_folding_hidden() const;
|
|
|
|
|
2022-07-01 15:43:39 +02:00
|
|
|
void set_enable_recursive_folding(bool p_enable);
|
|
|
|
bool is_recursive_folding_enabled() const;
|
|
|
|
|
2016-05-11 16:46:08 +02:00
|
|
|
void set_drop_mode_flags(int p_flags);
|
|
|
|
int get_drop_mode_flags() const;
|
|
|
|
|
2017-01-21 23:00:25 +01:00
|
|
|
void set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable);
|
|
|
|
bool get_edit_checkbox_cell_only_when_checkbox_is_pressed() const;
|
|
|
|
|
2016-05-16 04:41:48 +02:00
|
|
|
void set_allow_rmb_select(bool p_allow);
|
|
|
|
bool get_allow_rmb_select() const;
|
|
|
|
|
2017-08-18 23:19:12 +02:00
|
|
|
void set_allow_reselect(bool p_allow);
|
|
|
|
bool get_allow_reselect() const;
|
|
|
|
|
2023-04-18 08:50:24 +02:00
|
|
|
void set_allow_search(bool p_allow);
|
|
|
|
bool get_allow_search() const;
|
|
|
|
|
2021-07-28 18:10:01 +02:00
|
|
|
Size2 get_minimum_size() const override;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Tree();
|
2016-03-09 00:00:52 +01:00
|
|
|
~Tree();
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
VARIANT_ENUM_CAST(Tree::SelectMode);
|
2017-08-20 17:45:01 +02:00
|
|
|
VARIANT_ENUM_CAST(Tree::DropModeFlags);
|
2022-07-23 23:41:51 +02:00
|
|
|
|
|
|
|
#endif // TREE_H
|