summaryrefslogtreecommitdiff
path: root/scene/gui/tree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/tree.cpp')
-rw-r--r--scene/gui/tree.cpp42
1 files changed, 36 insertions, 6 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index c083e727d1..514be00227 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -1158,10 +1158,9 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
r.position.x += icon_width;
r.size.x -= icon_width;
}
- //r.grow(cache.selected->get_margin(MARGIN_LEFT));
+ p_item->set_meta("__focus_rect", Rect2(r.position, r.size));
if (has_focus()) {
cache.selected_focus->draw(ci, r);
- p_item->set_meta("__focus_rect", Rect2(r.position, r.size));
} else {
cache.selected->draw(ci, r);
}
@@ -1419,7 +1418,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
while (c) {
- if (cache.draw_relationship_lines == 1 && (c->get_parent() != root || !hide_root)) {
+ if (cache.draw_relationship_lines > 0 && (!hide_root || c->parent != root)) {
int root_ofs = children_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
int parent_ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs;
@@ -1602,6 +1601,7 @@ void Tree::_range_click_timeout() {
mb.instance();
;
+ propagate_mouse_activated = false; //done from outside, so signal handler cant clear the tree in the middle of emit(which is a common case)
blocked++;
propagate_mouse_event(pos + cache.offset, 0, 0, false, root, BUTTON_LEFT, mb);
blocked--;
@@ -1615,6 +1615,11 @@ void Tree::_range_click_timeout() {
if (!click_handled)
range_click_timer->stop();
+ if (propagate_mouse_activated) {
+ emit_signal("item_activated");
+ propagate_mouse_activated = false;
+ }
+
} else {
range_click_timer->stop();
}
@@ -1723,7 +1728,8 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
if (p_doubleclick && (!c.editable || c.mode == TreeItem::CELL_MODE_CUSTOM || c.mode == TreeItem::CELL_MODE_ICON /*|| c.mode==TreeItem::CELL_MODE_CHECK*/)) { //it's confusing for check
- emit_signal("item_activated");
+ propagate_mouse_activated = true;
+
incr_search.clear();
return -1;
}
@@ -2591,6 +2597,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
click_handled = false;
pressing_for_editor = false;
+ propagate_mouse_activated = false;
blocked++;
propagate_mouse_event(pos + cache.offset, 0, 0, b->is_doubleclick(), root, b->get_button_index(), b);
@@ -2628,6 +2635,11 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
}
+ if (propagate_mouse_activated) {
+ emit_signal("item_activated");
+ propagate_mouse_activated = false;
+ }
+
} break;
case BUTTON_WHEEL_UP: {
@@ -2701,6 +2713,7 @@ bool Tree::edit_selected() {
Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
Point2i textedpos = get_global_position() + rect.position - ofs;
+ cache.text_editor_position = textedpos;
text_editor->set_position(textedpos);
text_editor->set_size(rect.size);
text_editor->clear();
@@ -2956,6 +2969,21 @@ void Tree::_notification(int p_what) {
if (p_what == NOTIFICATION_THEME_CHANGED) {
update_cache();
}
+
+ if (p_what == NOTIFICATION_RESIZED || p_what == NOTIFICATION_TRANSFORM_CHANGED) {
+
+ if (popup_edited_item != NULL) {
+ Rect2 rect = popup_edited_item->get_meta("__focus_rect");
+ Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
+ Point2i textedpos = get_global_position() + rect.position - ofs;
+
+ if (cache.text_editor_position != textedpos) {
+ cache.text_editor_position = textedpos;
+ text_editor->set_position(textedpos);
+ value_editor->set_position(textedpos + Point2i(0, text_editor->get_size().height));
+ }
+ }
+ }
}
Size2 Tree::get_minimum_size() const {
@@ -3884,6 +3912,7 @@ Tree::Tree() {
value_editor->set_as_toplevel(true);
text_editor->set_as_toplevel(true);
+ set_notify_transform(true);
updating_value_editor = false;
pressed_button = -1;
@@ -3928,6 +3957,7 @@ Tree::Tree() {
cache.hover_cell = -1;
allow_reselect = false;
+ propagate_mouse_activated = false;
}
Tree::~Tree() {