summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/base_button.cpp5
-rw-r--r--scene/gui/control.cpp10
-rw-r--r--scene/gui/dialogs.cpp1
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/tree.cpp49
-rw-r--r--scene/gui/tree.h5
6 files changed, 65 insertions, 7 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index d8229b5f43..6fef44481a 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -271,6 +271,11 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const {
}
void BaseButton::set_toggle_mode(bool p_on) {
+ // Make sure to set 'pressed' to false if we are not in toggle mode
+ if (!p_on) {
+ set_pressed(false);
+ }
+
toggle_mode = p_on;
}
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 97daeceda9..2cdee4641e 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1173,7 +1173,17 @@ Rect2 Control::get_parent_anchorable_rect() const {
if (data.parent_canvas_item) {
parent_rect = data.parent_canvas_item->get_anchorable_rect();
} else {
+#ifdef TOOLS_ENABLED
+ Node *edited_root = get_tree()->get_edited_scene_root();
+ if (edited_root && (this == edited_root || edited_root->is_a_parent_of(this))) {
+ parent_rect.size = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"));
+ } else {
+ parent_rect = get_viewport()->get_visible_rect();
+ }
+
+#else
parent_rect = get_viewport()->get_visible_rect();
+#endif
}
return parent_rect;
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index bacc65c7bf..faef979090 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -298,6 +298,7 @@ AcceptDialog::AcceptDialog() {
set_visible(false);
set_transient(true);
set_exclusive(true);
+ set_clamp_to_embedder(true);
bg = memnew(Panel);
add_child(bg);
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 251f31ce4e..27c2c70708 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -51,7 +51,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
if (b.is_valid()) {
if (b->is_pressed() && b->get_button_index() == BUTTON_RIGHT && context_menu_enabled) {
- menu->set_position(get_global_transform().xform(get_local_mouse_position()));
+ menu->set_position(get_screen_transform().xform(get_local_mouse_position()));
menu->set_size(Vector2(1, 1));
//menu->set_scale(get_global_transform().get_scale());
menu->popup();
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 34161a9e80..47761d724e 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1786,7 +1786,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
case TreeItem::CELL_MODE_STRING: {
//nothing in particular
- if (select_mode == SELECT_MULTI && (get_tree()->get_event_count() == focus_in_id || !already_cursor)) {
+ if (select_mode == SELECT_MULTI && (get_viewport()->get_processed_events_count() == focus_in_id || !already_cursor)) {
bring_up_editor = false;
}
@@ -1861,7 +1861,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
} else {
editor_text = String::num(p_item->cells[col].val, Math::range_step_decimals(p_item->cells[col].step));
- if (select_mode == SELECT_MULTI && get_tree()->get_event_count() == focus_in_id) {
+ if (select_mode == SELECT_MULTI && get_viewport()->get_processed_events_count() == focus_in_id) {
bring_up_editor = false;
}
}
@@ -2787,7 +2787,7 @@ int Tree::_get_title_button_height() const {
void Tree::_notification(int p_what) {
if (p_what == NOTIFICATION_FOCUS_ENTER) {
- focus_in_id = get_tree()->get_event_count();
+ focus_in_id = get_viewport()->get_processed_events_count();
}
if (p_what == NOTIFICATION_MOUSE_EXIT) {
if (cache.hover_type != Cache::CLICK_NONE) {
@@ -3623,6 +3623,47 @@ TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const {
return nullptr;
}
+int Tree::get_button_id_at_position(const Point2 &p_pos) const {
+ if (root) {
+ Point2 pos = p_pos;
+ pos -= cache.bg->get_offset();
+ pos.y -= _get_title_button_height();
+ if (pos.y < 0) {
+ return -1;
+ }
+
+ if (h_scroll->is_visible_in_tree()) {
+ pos.x += h_scroll->get_value();
+ }
+ if (v_scroll->is_visible_in_tree()) {
+ pos.y += v_scroll->get_value();
+ }
+
+ int col, h, section;
+ TreeItem *it = _find_item_at_pos(root, pos, col, h, section);
+
+ if (it) {
+ const TreeItem::Cell &c = it->cells[col];
+ int col_width = get_column_width(col);
+
+ for (int i = 0; i < col; i++) {
+ pos.x -= get_column_width(i);
+ }
+
+ for (int j = c.buttons.size() - 1; j >= 0; j--) {
+ Ref<Texture2D> b = c.buttons[j].texture;
+ Size2 size = b->get_size() + cache.button_pressed->get_minimum_size();
+ if (pos.x > col_width - size.width) {
+ return c.buttons[j].id;
+ }
+ col_width -= size.width;
+ }
+ }
+ }
+
+ return -1;
+}
+
String Tree::get_tooltip(const Point2 &p_pos) const {
if (root) {
Point2 pos = p_pos;
@@ -3839,7 +3880,7 @@ Tree::Tree() {
add_child(popup_menu);
// popup_menu->set_as_toplevel(true);
- popup_editor = memnew(PopupPanel);
+ popup_editor = memnew(Popup);
popup_editor->set_wrap_controls(true);
add_child(popup_editor);
popup_editor_vb = memnew(VBoxContainer);
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 46842e78a0..cfdc307d03 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -359,11 +359,11 @@ private:
VBoxContainer *popup_editor_vb;
- PopupPanel *popup_editor;
+ Popup *popup_editor;
LineEdit *text_editor;
HSlider *value_editor;
bool updating_value_editor;
- int64_t focus_in_id;
+ uint64_t focus_in_id;
PopupMenu *popup_menu;
Vector<ColumnInfo> columns;
@@ -535,6 +535,7 @@ public:
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;
+ int get_button_id_at_position(const Point2 &p_pos) const;
void clear();