aboutsummaryrefslogtreecommitdiff
path: root/editor/plugins/texture_editor_plugin.cpp
diff options
context:
space:
mode:
authorMarc Gilleron2017-04-30 16:27:10 +0200
committerMarc Gilleron2017-06-24 01:01:36 +0200
commit659897cfb8bda0377d798a6f73505d537e521cf9 (patch)
treedb94c76d34d51e9ec97213a08c9654825707fad4 /editor/plugins/texture_editor_plugin.cpp
parent00e5ba314393ce2cc4df883bc1742306007ed117 (diff)
downloadgodot-659897cfb8bda0377d798a6f73505d537e521cf9.tar.gz
godot-659897cfb8bda0377d798a6f73505d537e521cf9.tar.zst
godot-659897cfb8bda0377d798a6f73505d537e521cf9.zip
Diffstat (limited to 'editor/plugins/texture_editor_plugin.cpp')
-rw-r--r--editor/plugins/texture_editor_plugin.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index 676e50d61..c4fe15e61 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -61,9 +61,21 @@ void TextureEditor::_notification(int p_what) {
tex_height = texture->get_height() * tex_width / texture->get_width();
}
+ // Prevent the texture from being unpreviewable after the rescale, so that we can still see something
+ if (tex_height <= 0)
+ tex_height = 1;
+ if (tex_width <= 0)
+ tex_width = 1;
+
int ofs_x = (size.width - tex_width) / 2;
int ofs_y = (size.height - tex_height) / 2;
+ if (texture->cast_to<CurveTexture>()) {
+ // In the case of CurveTextures we know they are 1 in height, so fill the preview to see the gradient
+ ofs_y = 0;
+ tex_height = size.height;
+ }
+
draw_texture_rect(texture, Rect2(ofs_x, ofs_y, tex_width, tex_height));
Ref<Font> font = get_font("font", "Label");