summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/line_2d.cpp2
-rw-r--r--scene/gui/base_button.cpp10
-rw-r--r--scene/gui/popup_menu.cpp1
-rw-r--r--scene/gui/tree.cpp64
-rw-r--r--scene/main/scene_tree.cpp12
-rw-r--r--scene/main/scene_tree.h2
-rw-r--r--scene/resources/material.cpp12
7 files changed, 73 insertions, 30 deletions
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index 7f25face15..4a022f0a9c 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -316,7 +316,7 @@ void Line2D::_draw() {
lb.colors,
lb.uvs, Vector<int>(), Vector<float>(),
texture_rid, -1, RID(),
- _antialiased);
+ _antialiased, true);
// DEBUG
// Draw wireframe
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 56467517d1..65912c1c07 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -171,9 +171,17 @@ void BaseButton::on_action_event(Ref<InputEvent> p_event) {
}
}
- if (!p_event->is_pressed()) { // pressed state should be correct with button_up signal
+ if (!p_event->is_pressed()) {
+ Ref<InputEventMouseButton> mouse_button = p_event;
+ if (mouse_button.is_valid()) {
+ if (!has_point(mouse_button->get_position())) {
+ status.hovering = false;
+ }
+ }
+ // pressed state should be correct with button_up signal
emit_signal("button_up");
status.press_attempt = false;
+ status.pressing_inside = false;
}
update();
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index e6333a6179..87f17838cf 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -309,6 +309,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
bool was_during_grabbed_click = during_grabbed_click;
during_grabbed_click = false;
+ initial_button_mask = 0;
int over = _get_mouse_over(b->get_position());
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 3cf17bd210..964f376dbd 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2745,9 +2745,13 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventPanGesture> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
- double prev_value = v_scroll->get_value();
+ double prev_v = v_scroll->get_value();
v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8);
- if (v_scroll->get_value() != prev_value) {
+
+ double prev_h = h_scroll->get_value();
+ h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8);
+
+ if (v_scroll->get_value() != prev_v || h_scroll->get_value() != prev_h) {
accept_event();
}
}
@@ -3455,30 +3459,48 @@ int Tree::get_item_offset(TreeItem *p_item) const {
}
void Tree::ensure_cursor_is_visible() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
+ if (!selected_item || (selected_col == -1)) {
+ return; // Nothing under cursor.
+ }
- TreeItem *selected = get_selected();
- if (!selected)
- return;
- int ofs = get_item_offset(selected);
- if (ofs == -1)
- return;
+ const Size2 area_size = get_size() - cache.bg->get_minimum_size();
- const int tbh = _get_title_button_height();
- ofs -= tbh;
+ int y_offset = get_item_offset(selected_item);
+ if (y_offset != -1) {
+ const int tbh = _get_title_button_height();
+ y_offset -= tbh;
- const int marginh = cache.bg->get_margin(MARGIN_TOP) + cache.bg->get_margin(MARGIN_BOTTOM);
- int h = compute_item_height(selected) + cache.vseparation;
- int screenh = get_size().height - h_scroll->get_combined_minimum_size().height - marginh - tbh;
+ const int cell_h = compute_item_height(selected_item) + cache.vseparation;
+ const int screen_h = area_size.height - h_scroll->get_combined_minimum_size().height - tbh;
- if (h > screenh) { //screen size is too small, maybe it was not resized yet.
- v_scroll->set_value(ofs);
- } else if (ofs + h > v_scroll->get_value() + screenh) {
- v_scroll->call_deferred("set_value", ofs - screenh + h);
- } else if (ofs < v_scroll->get_value()) {
- v_scroll->set_value(ofs);
+ if (cell_h > screen_h) { // Screen size is too small, maybe it was not resized yet.
+ v_scroll->set_value(y_offset);
+ } else if (y_offset + cell_h > v_scroll->get_value() + screen_h) {
+ v_scroll->call_deferred("set_value", y_offset - screen_h + cell_h);
+ } else if (y_offset < v_scroll->get_value()) {
+ v_scroll->set_value(y_offset);
+ }
+ }
+
+ if (select_mode != SELECT_ROW) { // Cursor always at col 0 in this mode.
+ int x_offset = 0;
+ for (int i = 0; i < selected_col; i++) {
+ x_offset += get_column_width(i);
+ }
+
+ const int cell_w = get_column_width(selected_col);
+ const int screen_w = area_size.width - v_scroll->get_combined_minimum_size().width;
+
+ if (cell_w > screen_w) {
+ h_scroll->set_value(x_offset);
+ } else if (x_offset + cell_w > h_scroll->get_value() + screen_w) {
+ h_scroll->call_deferred("set_value", x_offset - screen_w + cell_w);
+ } else if (x_offset < h_scroll->get_value()) {
+ h_scroll->set_value(x_offset);
+ }
}
}
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 09b001b377..da147e7112 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -631,7 +631,13 @@ void SceneTree::finish() {
timers.clear();
}
-void SceneTree::quit() {
+void SceneTree::quit(int p_exit_code) {
+
+ if (p_exit_code >= 0) {
+ // Override the exit code if a positive argument is given (the default is `-1`).
+ // This is a shorthand for calling `set_exit_code()` on the OS singleton then quitting.
+ OS::get_singleton()->set_exit_code(p_exit_code);
+ }
_quit = true;
}
@@ -1812,8 +1818,6 @@ bool SceneTree::is_refusing_new_network_connections() const {
void SceneTree::_bind_methods() {
- //ClassDB::bind_method(D_METHOD("call_group","call_flags","group","method","arg1","arg2"),&SceneMainLoop::_call_group,DEFVAL(Variant()),DEFVAL(Variant()));
-
ClassDB::bind_method(D_METHOD("get_root"), &SceneTree::get_root);
ClassDB::bind_method(D_METHOD("has_group", "name"), &SceneTree::has_group);
@@ -1837,7 +1841,7 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_node_count"), &SceneTree::get_node_count);
ClassDB::bind_method(D_METHOD("get_frame"), &SceneTree::get_frame);
- ClassDB::bind_method(D_METHOD("quit"), &SceneTree::quit);
+ ClassDB::bind_method(D_METHOD("quit", "exit_code"), &SceneTree::quit, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("set_screen_stretch", "mode", "aspect", "minsize", "shrink"), &SceneTree::set_screen_stretch, DEFVAL(1));
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 9bb24238f2..55304fb12d 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -303,7 +303,7 @@ public:
void set_auto_accept_quit(bool p_enable);
void set_quit_on_go_back(bool p_enable);
- void quit();
+ void quit(int p_exit_code = -1);
void set_input_as_handled();
bool is_input_handled();
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index b74b0fac1f..ab4dbb758a 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -30,6 +30,8 @@
#include "material.h"
+#include "core/engine.h"
+
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
#endif
@@ -191,7 +193,10 @@ Variant ShaderMaterial::property_get_revert(const String &p_name) {
void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
- if (shader.is_valid()) {
+ // Only connect/disconnect the signal when running in the editor.
+ // This can be a slow operation, and `_change_notify()` (which is called by `_shader_changed()`)
+ // does nothing in non-editor builds anyway. See GH-34741 for details.
+ if (shader.is_valid() && Engine::get_singleton()->is_editor_hint()) {
shader->disconnect("changed", this, "_shader_changed");
}
@@ -200,7 +205,10 @@ void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
RID rid;
if (shader.is_valid()) {
rid = shader->get_rid();
- shader->connect("changed", this, "_shader_changed");
+
+ if (Engine::get_singleton()->is_editor_hint()) {
+ shader->connect("changed", this, "_shader_changed");
+ }
}
VS::get_singleton()->material_set_shader(_get_material(), rid);