summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-01-07 10:49:05 +0100
committerGitHub <noreply@github.com>2022-01-07 10:49:05 +0100
commit096a13b3bb6a492e214161e9521570f16cfa6be2 (patch)
tree70cc33028fa4e69788523c08dd5892c3ef09a659
parenta1ea8976f3ed820d0ee8740023a4fa861efda6ba (diff)
parent11111d997ec248ff03cb1250c9dea9f9039e4f71 (diff)
Merge pull request #56472 from KoBeWi/now_focus
-rw-r--r--scene/gui/texture_button.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp
index 4c2229acb7..da202c1c8f 100644
--- a/scene/gui/texture_button.cpp
+++ b/scene/gui/texture_button.cpp
@@ -170,6 +170,12 @@ void TextureButton::_notification(int p_what) {
Point2 ofs;
Size2 size;
+ bool draw_focus = (has_focus() && focused.is_valid());
+
+ // If no other texture is valid, try using focused texture.
+ if (!texdraw.is_valid() && draw_focus) {
+ texdraw = focused;
+ }
if (texdraw.is_valid()) {
size = texdraw->get_size();
@@ -226,7 +232,9 @@ void TextureButton::_notification(int p_what) {
size.width *= hflip ? -1.0f : 1.0f;
size.height *= vflip ? -1.0f : 1.0f;
- if (_tile) {
+ if (texdraw == focused) {
+ // Do nothing, we only needed to calculate the rectangle.
+ } else if (_tile) {
draw_texture_rect(texdraw, Rect2(ofs, size), _tile);
} else {
draw_texture_rect_region(texdraw, Rect2(ofs, size), _texture_region);
@@ -235,7 +243,7 @@ void TextureButton::_notification(int p_what) {
_position_rect = Rect2();
}
- if (has_focus() && focused.is_valid()) {
+ if (draw_focus) {
draw_texture_rect(focused, Rect2(ofs, size), false);
};
} break;