summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-04-07 09:10:44 +0200
committerGitHub <noreply@github.com>2020-04-07 09:10:44 +0200
commit5d82fa74d940d3460f1c902514749a1c5a959c7d (patch)
treec9bbdc75c2c5dc0005bb7cac24c372a2caa4d5dd
parentfedf9c5c947ed430bd559f6a25d45b5d66754e96 (diff)
parentfb2d2dd5d01f7f695728658b2f3e8af89bf992d9 (diff)
Merge pull request #37615 from guilhermefelipecgs/fix_37526
Fix TextureRect::flip_* when used with atlas texture
-rw-r--r--scene/gui/texture_rect.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp
index baa138847f..92f3c5b5d9 100644
--- a/scene/gui/texture_rect.cpp
+++ b/scene/gui/texture_rect.cpp
@@ -95,6 +95,15 @@ void TextureRect::_notification(int p_what) {
} break;
}
+ Ref<AtlasTexture> p_atlas = texture;
+
+ if (p_atlas.is_valid() && region.has_no_area()) {
+ Size2 scale_size(size.width / texture->get_width(), size.height / texture->get_height());
+
+ offset.width += hflip ? p_atlas->get_margin().get_position().width * scale_size.width * 2 : 0;
+ offset.height += vflip ? p_atlas->get_margin().get_position().height * scale_size.height * 2 : 0;
+ }
+
size.width *= hflip ? -1.0f : 1.0f;
size.height *= vflip ? -1.0f : 1.0f;