Merge pull request #72086 from KoBeWi/set_rekt

Don't change region_rect when setting texture
This commit is contained in:
Rémi Verschelde 2023-01-26 23:52:19 +01:00
commit 3b086aa062
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 4 additions and 5 deletions

View file

@ -82,6 +82,7 @@
<member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2(0, 0, 0, 0)"> <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2(0, 0, 0, 0)">
Species a sub-region of the texture to use. Species a sub-region of the texture to use.
This is equivalent to first wrapping the texture in an [AtlasTexture] with the same region. This is equivalent to first wrapping the texture in an [AtlasTexture] with the same region.
If empty ([code]Rect2(0, 0, 0, 0)[/code]), the whole texture will be used.
</member> </member>
<member name="texture" type="Texture2D" setter="set_texture" getter="get_texture"> <member name="texture" type="Texture2D" setter="set_texture" getter="get_texture">
The texture to use when drawing this style box. The texture to use when drawing this style box.

View file

@ -740,6 +740,9 @@ void TextureRegionEditor::_update_rect() {
} }
} else if (obj_styleBox.is_valid()) { } else if (obj_styleBox.is_valid()) {
rect = obj_styleBox->get_region_rect(); rect = obj_styleBox->get_region_rect();
if (rect == Rect2()) {
rect = Rect2(Vector2(), obj_styleBox->get_texture()->get_size());
}
} }
} }

View file

@ -151,11 +151,6 @@ void StyleBoxTexture::set_texture(Ref<Texture2D> p_texture) {
return; return;
} }
texture = p_texture; texture = p_texture;
if (p_texture.is_null()) {
region_rect = Rect2(0, 0, 0, 0);
} else {
region_rect = Rect2(Point2(), texture->get_size());
}
emit_changed(); emit_changed();
} }