From fb2d2dd5d01f7f695728658b2f3e8af89bf992d9 Mon Sep 17 00:00:00 2001 From: Guilherme Felipe Date: Sun, 5 Apr 2020 17:43:02 -0300 Subject: [PATCH] Fix TextureRect::flip_* when used with atlas texture Fix #37526 --- scene/gui/texture_rect.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index baa138847f2..92f3c5b5d91 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 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;