diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-01-02 08:01:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-02 08:01:55 +0100 |
commit | ca3819036351c296edb58e56613e318b1ac48877 (patch) | |
tree | aef7a2cf8a117375ddc1c5987900032ec58f9842 | |
parent | 27b74f42b4fd6b6e56b7a4924697d8881488bee1 (diff) | |
parent | 7b86688ddfd599bcf6ad1da6b8d942acd542076e (diff) |
Merge pull request #34735 from YeldhamDev/texturerect_code_format
Minor code formatting in TextureRect file
-rw-r--r-- | scene/gui/texture_rect.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index 9ac2415575..514eff358e 100644 --- a/scene/gui/texture_rect.cpp +++ b/scene/gui/texture_rect.cpp @@ -36,8 +36,9 @@ void TextureRect::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - if (texture.is_null()) + if (texture.is_null()) { return; + } Size2 size; Point2 offset; @@ -85,11 +86,11 @@ void TextureRect::_notification(int p_what) { size = get_size(); Size2 tex_size = texture->get_size(); - Size2 scaleSize(size.width / tex_size.width, size.height / tex_size.height); - float scale = scaleSize.width > scaleSize.height ? scaleSize.width : scaleSize.height; - Size2 scaledTexSize = tex_size * scale; + Size2 scale_size(size.width / tex_size.width, size.height / tex_size.height); + float scale = scale_size.width > scale_size.height ? scale_size.width : scale_size.height; + Size2 scaled_tex_size = tex_size * scale; - region.position = ((scaledTexSize - size) / scale).abs() / 2.0f; + region.position = ((scaled_tex_size - size) / scale).abs() / 2.0f; region.size = size / scale; } break; } @@ -107,11 +108,13 @@ void TextureRect::_notification(int p_what) { Size2 TextureRect::get_minimum_size() const { - if (!expand && !texture.is_null()) + if (!expand && !texture.is_null()) { return texture->get_size(); - else + } else { return Size2(); + } } + void TextureRect::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture", "texture"), &TextureRect::set_texture); @@ -152,22 +155,21 @@ void TextureRect::_texture_changed() { void TextureRect::set_texture(const Ref<Texture> &p_tex) { - if (p_tex == texture) + if (p_tex == texture) { return; + } - if (texture.is_valid()) + if (texture.is_valid()) { texture->disconnect(CoreStringNames::get_singleton()->changed, this, "_texture_changed"); + } texture = p_tex; - if (texture.is_valid()) + if (texture.is_valid()) { texture->connect(CoreStringNames::get_singleton()->changed, this, "_texture_changed"); + } update(); - /* - if (texture.is_valid()) - texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites - */ minimum_size_changed(); } @@ -182,6 +184,7 @@ void TextureRect::set_expand(bool p_expand) { update(); minimum_size_changed(); } + bool TextureRect::has_expand() const { return expand; @@ -203,6 +206,7 @@ void TextureRect::set_flip_h(bool p_flip) { hflip = p_flip; update(); } + bool TextureRect::is_flipped_h() const { return hflip; @@ -213,6 +217,7 @@ void TextureRect::set_flip_v(bool p_flip) { vflip = p_flip; update(); } + bool TextureRect::is_flipped_v() const { return vflip; |