diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2023-04-26 17:57:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-26 17:57:45 +0200 |
commit | ba004ea1c3b00c5516548edde7bdfe2d72d51ea1 (patch) | |
tree | 534f23706b47017760b8d5e9395b00ef3ebd385a /scene/2d/touch_screen_button.cpp | |
parent | d78691d44fe6e4f38dce3a89164cdae688772031 (diff) | |
parent | e7f4af091331ef10dd2088d82bc552a097d3d4ce (diff) |
Merge pull request #76476 from YuriSizov/4.0-cherrypicks
Cherry-picks for the 4.0 branch (future 4.0.3) - 3rd batch
Diffstat (limited to 'scene/2d/touch_screen_button.cpp')
-rw-r--r-- | scene/2d/touch_screen_button.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp index 1c2903fe22..4c8c4f1e16 100644 --- a/scene/2d/touch_screen_button.cpp +++ b/scene/2d/touch_screen_button.cpp @@ -31,9 +31,19 @@ #include "touch_screen_button.h" #include "scene/main/window.h" +#include "scene/scene_string_names.h" void TouchScreenButton::set_texture_normal(const Ref<Texture2D> &p_texture) { + if (texture_normal == p_texture) { + return; + } + if (texture_normal.is_valid()) { + texture_normal->disconnect(SceneStringNames::get_singleton()->changed, callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); + } texture_normal = p_texture; + if (texture_normal.is_valid()) { + texture_normal->connect(SceneStringNames::get_singleton()->changed, callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); + } queue_redraw(); } @@ -42,7 +52,16 @@ Ref<Texture2D> TouchScreenButton::get_texture_normal() const { } void TouchScreenButton::set_texture_pressed(const Ref<Texture2D> &p_texture_pressed) { + if (texture_pressed == p_texture_pressed) { + return; + } + if (texture_pressed.is_valid()) { + texture_pressed->disconnect(SceneStringNames::get_singleton()->changed, callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); + } texture_pressed = p_texture_pressed; + if (texture_pressed.is_valid()) { + texture_pressed->connect(SceneStringNames::get_singleton()->changed, callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); + } queue_redraw(); } @@ -59,16 +78,16 @@ Ref<BitMap> TouchScreenButton::get_bitmask() const { } void TouchScreenButton::set_shape(const Ref<Shape2D> &p_shape) { + if (shape == p_shape) { + return; + } if (shape.is_valid()) { shape->disconnect("changed", callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); } - shape = p_shape; - if (shape.is_valid()) { shape->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); } - queue_redraw(); } |