summaryrefslogtreecommitdiffstats
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/base_button.cpp2
-rw-r--r--scene/gui/graph_edit.cpp12
-rw-r--r--scene/gui/graph_node.cpp4
-rw-r--r--scene/gui/menu_bar.cpp5
-rw-r--r--scene/gui/popup_menu.cpp1
-rw-r--r--scene/gui/tab_container.cpp13
-rw-r--r--scene/gui/tab_container.h1
-rw-r--r--scene/gui/text_edit.cpp8
8 files changed, 32 insertions, 14 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index f57afb66b3..66b14dc967 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -380,7 +380,7 @@ void BaseButton::shortcut_input(const Ref<InputEvent> &p_event) {
queue_redraw();
accept_event();
- if (shortcut_feedback) {
+ if (shortcut_feedback && is_inside_tree()) {
if (shortcut_feedback_timer == nullptr) {
shortcut_feedback_timer = memnew(Timer);
shortcut_feedback_timer->set_one_shot(true);
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 1fc501e980..8dddbf78cf 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -598,7 +598,7 @@ bool GraphEdit::_filter_input(const Point2 &p_point) {
// Determine slot height.
int slot_index = graph_node->get_input_port_slot(j);
- Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index));
+ Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index, false));
port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
@@ -612,7 +612,7 @@ bool GraphEdit::_filter_input(const Point2 &p_point) {
// Determine slot height.
int slot_index = graph_node->get_output_port_slot(j);
- Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index));
+ Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index, false));
port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
if (is_in_output_hotzone(graph_node, j, p_point / zoom, port_size)) {
@@ -643,7 +643,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
// Determine slot height.
int slot_index = graph_node->get_output_port_slot(j);
- Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index));
+ Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index, false));
port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
if (is_in_output_hotzone(graph_node, j, click_pos, port_size)) {
@@ -700,7 +700,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
// Determine slot height.
int slot_index = graph_node->get_input_port_slot(j);
- Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index));
+ Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index, false));
port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
if (is_in_input_hotzone(graph_node, j, click_pos, port_size)) {
@@ -777,7 +777,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
// Determine slot height.
int slot_index = graph_node->get_output_port_slot(j);
- Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index));
+ Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index, false));
port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
int type = graph_node->get_output_port_type(j);
@@ -801,7 +801,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
// Determine slot height.
int slot_index = graph_node->get_input_port_slot(j);
- Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index));
+ Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index, false));
port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
int type = graph_node->get_input_port_type(j);
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index fdebca3d28..3b1c1a153f 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -620,7 +620,7 @@ void GraphNode::_port_pos_update() {
port_cache.pos = Point2i(edgeofs, vertical_ofs + size.height / 2);
port_cache.type = slot_table[i].type_left;
port_cache.color = slot_table[i].color_left;
- port_cache.slot_index = child->get_index(); // Index with internal nodes included.
+ port_cache.slot_index = child->get_index(false);
left_port_cache.push_back(port_cache);
}
if (slot_table[i].enable_right) {
@@ -628,7 +628,7 @@ void GraphNode::_port_pos_update() {
port_cache.pos = Point2i(get_size().width - edgeofs, vertical_ofs + size.height / 2);
port_cache.type = slot_table[i].type_right;
port_cache.color = slot_table[i].color_right;
- port_cache.slot_index = child->get_index(); // Index with internal nodes included.
+ port_cache.slot_index = child->get_index(false);
right_port_cache.push_back(port_cache);
}
}
diff --git a/scene/gui/menu_bar.cpp b/scene/gui/menu_bar.cpp
index 371d6c69af..7418ba7333 100644
--- a/scene/gui/menu_bar.cpp
+++ b/scene/gui/menu_bar.cpp
@@ -561,6 +561,7 @@ void MenuBar::add_child_notify(Node *p_child) {
int index = DisplayServer::get_singleton()->global_menu_add_submenu_item("_main", atr(menu.name), submenu_name, _find_global_start_index() + menu_cache.size() - 1);
DisplayServer::get_singleton()->global_menu_set_item_tag("_main", index, global_menu_name + "#" + itos(menu_cache.size() - 1));
}
+ update_minimum_size();
}
void MenuBar::move_child_notify(Node *p_child) {
@@ -621,6 +622,8 @@ void MenuBar::remove_child_notify(Node *p_child) {
p_child->disconnect("renamed", callable_mp(this, &MenuBar::_refresh_menu_names));
p_child->disconnect("about_to_popup", callable_mp(this, &MenuBar::_popup_visibility_changed));
p_child->disconnect("popup_hide", callable_mp(this, &MenuBar::_popup_visibility_changed));
+
+ update_minimum_size();
}
void MenuBar::_bind_methods() {
@@ -808,6 +811,7 @@ void MenuBar::set_menu_title(int p_menu, const String &p_title) {
if (!global_menu_name.is_empty()) {
DisplayServer::get_singleton()->global_menu_set_item_text("_main", _find_global_start_index() + p_menu, atr(menu_cache[p_menu].name));
}
+ update_minimum_size();
}
String MenuBar::get_menu_title(int p_menu) const {
@@ -849,6 +853,7 @@ void MenuBar::set_menu_hidden(int p_menu, bool p_hidden) {
if (!global_menu_name.is_empty()) {
DisplayServer::get_singleton()->global_menu_set_item_hidden("_main", _find_global_start_index() + p_menu, p_hidden);
}
+ update_minimum_size();
}
bool MenuBar::is_menu_hidden(int p_menu) const {
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index dfaf7d88b7..ec9e2cacb4 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -2186,6 +2186,7 @@ void PopupMenu::scroll_to_item(int p_idx) {
}
bool PopupMenu::activate_item_by_event(const Ref<InputEvent> &p_event, bool p_for_global_only) {
+ ERR_FAIL_COND_V(p_event.is_null(), false);
Key code = Key::NONE;
Ref<InputEventKey> k = p_event;
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index c21a9d14cb..7d85468799 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -330,14 +330,23 @@ Vector<Control *> TabContainer::_get_tab_controls() const {
}
Variant TabContainer::_get_drag_data_fw(const Point2 &p_point, Control *p_from_control) {
+ if (!drag_to_rearrange_enabled) {
+ return Variant();
+ }
return tab_bar->_handle_get_drag_data("tab_container_tab", p_point);
}
bool TabContainer::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control) const {
+ if (!drag_to_rearrange_enabled) {
+ return false;
+ }
return tab_bar->_handle_can_drop_data("tab_container_tab", p_point, p_data);
}
void TabContainer::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control) {
+ if (!drag_to_rearrange_enabled) {
+ return;
+ }
return tab_bar->_handle_drop_data("tab_container_tab", p_point, p_data, callable_mp(this, &TabContainer::_drag_move_tab), callable_mp(this, &TabContainer::_drag_move_tab_from));
}
@@ -815,11 +824,11 @@ Popup *TabContainer::get_popup() const {
}
void TabContainer::set_drag_to_rearrange_enabled(bool p_enabled) {
- tab_bar->set_drag_to_rearrange_enabled(p_enabled);
+ drag_to_rearrange_enabled = p_enabled;
}
bool TabContainer::get_drag_to_rearrange_enabled() const {
- return tab_bar->get_drag_to_rearrange_enabled();
+ return drag_to_rearrange_enabled;
}
void TabContainer::set_tabs_rearrange_group(int p_group_id) {
diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h
index 5750c6b82e..b249576e28 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -46,6 +46,7 @@ class TabContainer : public Container {
bool use_hidden_tabs_for_min_size = false;
bool theme_changing = false;
Vector<Control *> children_removing;
+ bool drag_to_rearrange_enabled = false;
struct ThemeCache {
int side_margin = 0;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 479480011c..86e726d9da 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2948,6 +2948,8 @@ void TextEdit::_update_placeholder() {
return; // Not in tree?
}
+ const String placeholder_translated = atr(placeholder_text);
+
// Placeholder is generally smaller then text documents, and updates less so this should be fast enough for now.
placeholder_data_buf->clear();
placeholder_data_buf->set_width(text.get_width());
@@ -2958,9 +2960,9 @@ void TextEdit::_update_placeholder() {
placeholder_data_buf->set_direction((TextServer::Direction)text_direction);
}
placeholder_data_buf->set_preserve_control(draw_control_chars);
- placeholder_data_buf->add_string(placeholder_text, theme_cache.font, theme_cache.font_size, language);
+ placeholder_data_buf->add_string(placeholder_translated, theme_cache.font, theme_cache.font_size, language);
- placeholder_bidi_override = structured_text_parser(st_parser, st_args, placeholder_text);
+ placeholder_bidi_override = structured_text_parser(st_parser, st_args, placeholder_translated);
if (placeholder_bidi_override.is_empty()) {
TS->shaped_text_set_bidi_override(placeholder_data_buf->get_rid(), placeholder_bidi_override);
}
@@ -2985,7 +2987,7 @@ void TextEdit::_update_placeholder() {
placeholder_wraped_rows.clear();
for (int i = 0; i <= wrap_amount; i++) {
Vector2i line_range = placeholder_data_buf->get_line_range(i);
- placeholder_wraped_rows.push_back(placeholder_text.substr(line_range.x, line_range.y - line_range.x));
+ placeholder_wraped_rows.push_back(placeholder_translated.substr(line_range.x, line_range.y - line_range.x));
}
}