summaryrefslogtreecommitdiffstats
path: root/scene/gui/tree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/tree.cpp')
-rw-r--r--scene/gui/tree.cpp173
1 files changed, 87 insertions, 86 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 382707fd04..2d3166270b 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -40,6 +40,7 @@
#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>
@@ -1475,7 +1476,7 @@ Size2 TreeItem::get_minimum_size(int p_column) {
void TreeItem::_call_recursive_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
if (p_argcount < 1) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
- r_error.argument = 0;
+ r_error.expected = 1;
return;
}
@@ -1700,76 +1701,6 @@ TreeItem::~TreeItem() {
void Tree::_update_theme_item_cache() {
Control::_update_theme_item_cache();
- theme_cache.panel_style = get_theme_stylebox(SNAME("panel"));
- theme_cache.focus_style = get_theme_stylebox(SNAME("focus"));
-
- theme_cache.font = get_theme_font(SNAME("font"));
- theme_cache.font_size = get_theme_font_size(SNAME("font_size"));
- theme_cache.tb_font = get_theme_font(SNAME("title_button_font"));
- theme_cache.tb_font_size = get_theme_font_size(SNAME("title_button_font_size"));
-
- theme_cache.selected = get_theme_stylebox(SNAME("selected"));
- theme_cache.selected_focus = get_theme_stylebox(SNAME("selected_focus"));
- theme_cache.cursor = get_theme_stylebox(SNAME("cursor"));
- theme_cache.cursor_unfocus = get_theme_stylebox(SNAME("cursor_unfocused"));
- theme_cache.button_pressed = get_theme_stylebox(SNAME("button_pressed"));
-
- theme_cache.checked = get_theme_icon(SNAME("checked"));
- theme_cache.unchecked = get_theme_icon(SNAME("unchecked"));
- theme_cache.indeterminate = get_theme_icon(SNAME("indeterminate"));
- theme_cache.arrow = get_theme_icon(SNAME("arrow"));
- theme_cache.arrow_collapsed = get_theme_icon(SNAME("arrow_collapsed"));
- theme_cache.arrow_collapsed_mirrored = get_theme_icon(SNAME("arrow_collapsed_mirrored"));
- theme_cache.select_arrow = get_theme_icon(SNAME("select_arrow"));
- theme_cache.updown = get_theme_icon(SNAME("updown"));
-
- theme_cache.custom_button = get_theme_stylebox(SNAME("custom_button"));
- theme_cache.custom_button_hover = get_theme_stylebox(SNAME("custom_button_hover"));
- theme_cache.custom_button_pressed = get_theme_stylebox(SNAME("custom_button_pressed"));
- theme_cache.custom_button_font_highlight = get_theme_color(SNAME("custom_button_font_highlight"));
-
- theme_cache.font_color = get_theme_color(SNAME("font_color"));
- theme_cache.font_selected_color = get_theme_color(SNAME("font_selected_color"));
- theme_cache.drop_position_color = get_theme_color(SNAME("drop_position_color"));
- theme_cache.h_separation = get_theme_constant(SNAME("h_separation"));
- theme_cache.v_separation = get_theme_constant(SNAME("v_separation"));
- theme_cache.inner_item_margin_bottom = get_theme_constant(SNAME("inner_item_margin_bottom"));
- theme_cache.inner_item_margin_left = get_theme_constant(SNAME("inner_item_margin_left"));
- theme_cache.inner_item_margin_right = get_theme_constant(SNAME("inner_item_margin_right"));
- theme_cache.inner_item_margin_top = get_theme_constant(SNAME("inner_item_margin_top"));
- theme_cache.item_margin = get_theme_constant(SNAME("item_margin"));
- theme_cache.button_margin = get_theme_constant(SNAME("button_margin"));
- theme_cache.icon_max_width = get_theme_constant(SNAME("icon_max_width"));
-
- theme_cache.font_outline_color = get_theme_color(SNAME("font_outline_color"));
- theme_cache.font_outline_size = get_theme_constant(SNAME("outline_size"));
-
- theme_cache.draw_guides = get_theme_constant(SNAME("draw_guides"));
- theme_cache.guide_color = get_theme_color(SNAME("guide_color"));
- theme_cache.draw_relationship_lines = get_theme_constant(SNAME("draw_relationship_lines"));
- theme_cache.relationship_line_width = get_theme_constant(SNAME("relationship_line_width"));
- theme_cache.parent_hl_line_width = get_theme_constant(SNAME("parent_hl_line_width"));
- theme_cache.children_hl_line_width = get_theme_constant(SNAME("children_hl_line_width"));
- theme_cache.parent_hl_line_margin = get_theme_constant(SNAME("parent_hl_line_margin"));
- theme_cache.relationship_line_color = get_theme_color(SNAME("relationship_line_color"));
- theme_cache.parent_hl_line_color = get_theme_color(SNAME("parent_hl_line_color"));
- theme_cache.children_hl_line_color = get_theme_color(SNAME("children_hl_line_color"));
-
- theme_cache.scroll_border = get_theme_constant(SNAME("scroll_border"));
- theme_cache.scroll_speed = get_theme_constant(SNAME("scroll_speed"));
-
- theme_cache.scrollbar_margin_top = get_theme_constant(SNAME("scrollbar_margin_top"));
- theme_cache.scrollbar_margin_right = get_theme_constant(SNAME("scrollbar_margin_right"));
- theme_cache.scrollbar_margin_bottom = get_theme_constant(SNAME("scrollbar_margin_bottom"));
- theme_cache.scrollbar_margin_left = get_theme_constant(SNAME("scrollbar_margin_left"));
- theme_cache.scrollbar_h_separation = get_theme_constant(SNAME("scrollbar_h_separation"));
- theme_cache.scrollbar_v_separation = get_theme_constant(SNAME("scrollbar_v_separation"));
-
- theme_cache.title_button = get_theme_stylebox(SNAME("title_button_normal"));
- theme_cache.title_button_pressed = get_theme_stylebox(SNAME("title_button_pressed"));
- theme_cache.title_button_hover = get_theme_stylebox(SNAME("title_button_hover"));
- theme_cache.title_button_color = get_theme_color(SNAME("title_button_color"));
-
theme_cache.base_scale = get_theme_default_base_scale();
}
@@ -2839,21 +2770,9 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
x -= theme_cache.h_separation;
}
- if (!p_item->disable_folding && !hide_folding && !p_item->cells[col].editable && !p_item->cells[col].selectable && p_item->get_first_child()) {
- if (enable_recursive_folding && p_mod->is_shift_pressed()) {
- p_item->set_collapsed_recursive(!p_item->is_collapsed());
- } else {
- p_item->set_collapsed(!p_item->is_collapsed());
- }
- return -1; //collapse/uncollapse because nothing can be done with item
- }
-
const TreeItem::Cell &c = p_item->cells[col];
- bool already_selected = c.selected;
- bool already_cursor = (p_item == selected_item) && col == selected_col;
-
- if (!cache.rtl && p_item->cells[col].buttons.size()) {
+ if (!cache.rtl && !p_item->cells[col].buttons.is_empty()) {
int button_w = 0;
for (int j = p_item->cells[col].buttons.size() - 1; j >= 0; j--) {
Ref<Texture2D> b = p_item->cells[col].buttons[j].texture;
@@ -2896,6 +2815,18 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
col_width -= w + theme_cache.button_margin;
}
+ if (!p_item->disable_folding && !hide_folding && !p_item->cells[col].editable && !p_item->cells[col].selectable && p_item->get_first_child()) {
+ if (enable_recursive_folding && p_mod->is_shift_pressed()) {
+ p_item->set_collapsed_recursive(!p_item->is_collapsed());
+ } else {
+ p_item->set_collapsed(!p_item->is_collapsed());
+ }
+ return -1; // Collapse/uncollapse, because nothing can be done with the item.
+ }
+
+ bool already_selected = c.selected;
+ bool already_cursor = (p_item == selected_item) && col == selected_col;
+
if (p_button == MouseButton::LEFT || (p_button == MouseButton::RIGHT && allow_rmb_select)) {
/* process selection */
@@ -3211,7 +3142,7 @@ void Tree::value_editor_changed(double p_value) {
TreeItem::Cell &c = popup_edited_item->cells.write[popup_edited_item_col];
c.val = p_value;
- text_editor->set_text(String::num(c.val, Math::range_step_decimals(c.step)));
+ line_editor->set_text(String::num(c.val, Math::range_step_decimals(c.step)));
item_edited(popup_edited_item_col, popup_edited_item);
queue_redraw();
@@ -3884,7 +3815,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
}
if (mb->get_button_index() == MouseButton::LEFT) {
- if (get_item_at_position(mb->get_position()) == nullptr && !mb->is_shift_pressed() && !mb->is_ctrl_pressed() && !mb->is_command_or_control_pressed()) {
+ if (get_item_at_position(mb->get_position()) == nullptr && !mb->is_shift_pressed() && !mb->is_command_or_control_pressed()) {
emit_signal(SNAME("nothing_selected"));
}
}
@@ -5577,6 +5508,76 @@ void Tree::_bind_methods() {
BIND_ENUM_CONSTANT(DROP_MODE_DISABLED);
BIND_ENUM_CONSTANT(DROP_MODE_ON_ITEM);
BIND_ENUM_CONSTANT(DROP_MODE_INBETWEEN);
+
+ BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, Tree, panel_style, "panel");
+ BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, Tree, focus_style, "focus");
+
+ BIND_THEME_ITEM(Theme::DATA_TYPE_FONT, Tree, font);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_FONT_SIZE, Tree, font_size);
+ BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_FONT, Tree, tb_font, "title_button_font");
+ BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_FONT_SIZE, Tree, tb_font_size, "title_button_font_size");
+
+ BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, selected);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, selected_focus);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, cursor);
+ BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, Tree, cursor_unfocus, "cursor_unfocused");
+ BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, button_pressed);
+
+ BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, checked);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, unchecked);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, indeterminate);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, arrow);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, arrow_collapsed);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, arrow_collapsed_mirrored);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, select_arrow);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, updown);
+
+ BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, custom_button);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, custom_button_hover);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, custom_button_pressed);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, custom_button_font_highlight);
+
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, font_color);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, font_selected_color);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, drop_position_color);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, h_separation);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, v_separation);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, inner_item_margin_bottom);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, inner_item_margin_left);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, inner_item_margin_right);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, inner_item_margin_top);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, item_margin);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, button_margin);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, icon_max_width);
+
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, font_outline_color);
+ BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_CONSTANT, Tree, font_outline_size, "outline_size");
+
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, draw_guides);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, guide_color);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, draw_relationship_lines);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, relationship_line_width);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, parent_hl_line_width);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, children_hl_line_width);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, parent_hl_line_margin);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, relationship_line_color);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, parent_hl_line_color);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, children_hl_line_color);
+
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, scroll_border);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, scroll_speed);
+
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, scrollbar_margin_top);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, scrollbar_margin_right);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, scrollbar_margin_bottom);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, scrollbar_margin_left);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, scrollbar_h_separation);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, scrollbar_v_separation);
+
+ BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, Tree, title_button, "title_button_normal");
+ BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, title_button_pressed);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, title_button_hover);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, title_button_color);
}
Tree::Tree() {