Minor code formatting in TextureRect file
This commit is contained in:
parent
85fa17d3c2
commit
7b86688ddf
1 changed files with 19 additions and 14 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue