From 659897cfb8bda0377d798a6f73505d537e521cf9 Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Sun, 30 Apr 2017 16:27:10 +0200 Subject: Added Curve resource - New resource for curves in y(x) form - CurveTexture now has a Curve - Curve and CurveTexture share the same editor --- editor/plugins/texture_editor_plugin.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'editor/plugins/texture_editor_plugin.cpp') 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()) { + // 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 = get_font("font", "Label"); -- cgit v1.2.3-70-g09d2