summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/graph_edit.cpp6
-rw-r--r--scene/gui/graph_node.cpp2
-rw-r--r--scene/gui/texture_progress_bar.cpp49
-rw-r--r--scene/gui/texture_progress_bar.h2
-rw-r--r--scene/gui/view_panner.cpp7
5 files changed, 35 insertions, 31 deletions
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 9c0c25b1ac..946e8a2ad5 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -533,7 +533,6 @@ void GraphEdit::_notification(int p_what) {
void GraphEdit::_update_comment_enclosed_nodes_list(GraphNode *p_node, HashMap<StringName, Vector<GraphNode *>> &p_comment_enclosed_nodes) {
Rect2 comment_node_rect = p_node->get_rect();
- comment_node_rect.size *= zoom;
Vector<GraphNode *> enclosed_nodes;
for (int i = 0; i < get_child_count(); i++) {
@@ -543,7 +542,6 @@ void GraphEdit::_update_comment_enclosed_nodes_list(GraphNode *p_node, HashMap<S
}
Rect2 node_rect = gn->get_rect();
- node_rect.size *= zoom;
bool included = comment_node_rect.encloses(node_rect);
if (included) {
@@ -806,7 +804,6 @@ bool GraphEdit::_check_clickable_control(Control *p_control, const Vector2 &mpos
}
Rect2 control_rect = p_control->get_rect();
- control_rect.size *= zoom;
control_rect.position *= zoom;
control_rect.position += p_offset;
@@ -873,7 +870,6 @@ bool GraphEdit::is_in_port_hotzone(const Vector2 &p_pos, const Vector2 &p_mouse_
continue;
}
Rect2 child_rect = child->get_rect();
- child_rect.size *= zoom;
if (child_rect.has_point(p_mouse_pos * zoom)) {
for (int j = 0; j < child->get_child_count(); j++) {
@@ -1169,7 +1165,6 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) {
}
Rect2 r = gn->get_rect();
- r.size *= zoom;
bool in_box = r.intersects(box_selecting_rect);
if (in_box) {
@@ -1215,7 +1210,6 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) {
if (gn) {
Rect2 r = gn->get_rect();
- r.size *= zoom;
if (r.has_point(mb->get_position())) {
gn->set_selected(false);
}
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 7d9cdd62ff..8b2d462d85 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -664,7 +664,7 @@ Size2 GraphNode::get_minimum_size() const {
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c) {
+ if (!c || !c->is_visible()) {
continue;
}
if (c->is_set_as_top_level()) {
diff --git a/scene/gui/texture_progress_bar.cpp b/scene/gui/texture_progress_bar.cpp
index 2526ee8215..2464e005ee 100644
--- a/scene/gui/texture_progress_bar.cpp
+++ b/scene/gui/texture_progress_bar.cpp
@@ -31,15 +31,10 @@
#include "texture_progress_bar.h"
#include "core/config/engine.h"
+#include "core/core_string_names.h"
void TextureProgressBar::set_under_texture(const Ref<Texture2D> &p_texture) {
- if (under == p_texture) {
- return;
- }
-
- under = p_texture;
- queue_redraw();
- update_minimum_size();
+ _set_texture(&under, p_texture);
}
Ref<Texture2D> TextureProgressBar::get_under_texture() const {
@@ -47,15 +42,7 @@ Ref<Texture2D> TextureProgressBar::get_under_texture() const {
}
void TextureProgressBar::set_over_texture(const Ref<Texture2D> &p_texture) {
- if (over == p_texture) {
- return;
- }
-
- over = p_texture;
- queue_redraw();
- if (under.is_null()) {
- update_minimum_size();
- }
+ _set_texture(&over, p_texture);
}
Ref<Texture2D> TextureProgressBar::get_over_texture() const {
@@ -108,13 +95,7 @@ Size2 TextureProgressBar::get_minimum_size() const {
}
void TextureProgressBar::set_progress_texture(const Ref<Texture2D> &p_texture) {
- if (progress == p_texture) {
- return;
- }
-
- progress = p_texture;
- queue_redraw();
- update_minimum_size();
+ _set_texture(&progress, p_texture);
}
Ref<Texture2D> TextureProgressBar::get_progress_texture() const {
@@ -173,6 +154,28 @@ Color TextureProgressBar::get_tint_over() const {
return tint_over;
}
+void TextureProgressBar::_set_texture(Ref<Texture2D> *p_destination, const Ref<Texture2D> &p_texture) {
+ DEV_ASSERT(p_destination);
+ Ref<Texture2D> &destination = *p_destination;
+ if (destination == p_texture) {
+ return;
+ }
+ if (destination.is_valid()) {
+ destination->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TextureProgressBar::_texture_changed));
+ }
+ destination = p_texture;
+ if (destination.is_valid()) {
+ // Pass `CONNECT_REFERENCE_COUNTED` to avoid early disconnect in case the same texture is assigned to different "slots".
+ destination->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TextureProgressBar::_texture_changed), CONNECT_REFERENCE_COUNTED);
+ }
+ _texture_changed();
+}
+
+void TextureProgressBar::_texture_changed() {
+ update_minimum_size();
+ queue_redraw();
+}
+
Point2 TextureProgressBar::unit_val_to_uv(float val) {
if (progress.is_null()) {
return Point2();
diff --git a/scene/gui/texture_progress_bar.h b/scene/gui/texture_progress_bar.h
index 53ec6fa2ae..5999aa986b 100644
--- a/scene/gui/texture_progress_bar.h
+++ b/scene/gui/texture_progress_bar.h
@@ -113,6 +113,8 @@ private:
Color tint_progress = Color(1, 1, 1);
Color tint_over = Color(1, 1, 1);
+ void _set_texture(Ref<Texture2D> *p_destination, const Ref<Texture2D> &p_texture);
+ void _texture_changed();
Point2 unit_val_to_uv(float val);
Point2 get_relative_center();
void draw_nine_patch_stretched(const Ref<Texture2D> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate);
diff --git a/scene/gui/view_panner.cpp b/scene/gui/view_panner.cpp
index 51af886709..6d1905f111 100644
--- a/scene/gui/view_panner.cpp
+++ b/scene/gui/view_panner.cpp
@@ -130,7 +130,12 @@ bool ViewPanner::gui_input(const Ref<InputEvent> &p_event, Rect2 p_canvas_rect)
Ref<InputEventScreenDrag> screen_drag = p_event;
if (screen_drag.is_valid()) {
- callback_helper(pan_callback, varray(screen_drag->get_relative(), p_event));
+ if (Input::get_singleton()->is_emulating_mouse_from_touch() || Input::get_singleton()->is_emulating_touch_from_mouse()) {
+ // This set of events also generates/is generated by
+ // InputEventMouseButton/InputEventMouseMotion events which will be processed instead.
+ } else {
+ callback_helper(pan_callback, varray(screen_drag->get_relative(), p_event));
+ }
}
Ref<InputEventKey> k = p_event;