summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-07-17 18:04:19 +0200
committerGitHub <noreply@github.com>2018-07-17 18:04:19 +0200
commit71b18acb05bd3f2046ad1ab78953c81f6526ce70 (patch)
tree581dc2f6886d51d1c37338323ed1723588f9f2a8 /editor
parent41a2dccd93d79c8c786ea1b4296cd58af8d87d7b (diff)
parentd551f81874307b18e7f52d7486204c5cf6b49a50 (diff)
Merge pull request #20220 from volzhs/texture-size
Fix preview texture size on Inspector
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_properties.cpp22
-rw-r--r--editor/editor_properties.h1
2 files changed, 22 insertions, 1 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 077b58a40f..ca51f6e635 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -1832,7 +1832,18 @@ void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<T
RES p = get_edited_object()->get(get_edited_property());
if (p.is_valid() && p->get_instance_id() == p_obj) {
if (p_preview.is_valid()) {
- assign->set_icon(p_preview);
+ String type = p->get_class_name();
+ preview->set_margin(MARGIN_LEFT, assign->get_icon()->get_width() + assign->get_stylebox("normal")->get_default_margin(MARGIN_LEFT) + get_constant("hseparation", "Button"));
+ if (type == "GradientTexture") {
+ preview->set_stretch_mode(TextureRect::STRETCH_SCALE);
+ assign->set_custom_minimum_size(Size2(1, 1));
+ } else {
+ preview->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
+ int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
+ thumbnail_size *= EDSCALE;
+ assign->set_custom_minimum_size(Size2(1, thumbnail_size));
+ }
+ preview->set_texture(p_preview);
}
}
}
@@ -2073,6 +2084,7 @@ void EditorPropertyResource::update_property() {
#endif
}
+ preview->set_texture(Ref<Texture>());
if (res == RES()) {
assign->set_icon(Ref<Texture>());
assign->set_text(TTR("[empty]"));
@@ -2311,6 +2323,14 @@ EditorPropertyResource::EditorPropertyResource() {
assign->connect("draw", this, "_button_draw");
hbc->add_child(assign);
+ preview = memnew(TextureRect);
+ preview->set_expand(true);
+ preview->set_anchors_and_margins_preset(PRESET_WIDE);
+ preview->set_margin(MARGIN_TOP, 1);
+ preview->set_margin(MARGIN_BOTTOM, -1);
+ preview->set_margin(MARGIN_RIGHT, -1);
+ assign->add_child(preview);
+
menu = memnew(PopupMenu);
add_child(menu);
edit = memnew(Button);
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index ecccd7274d..b53d3ef40f 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -488,6 +488,7 @@ class EditorPropertyResource : public EditorProperty {
};
Button *assign;
+ TextureRect *preview;
Button *edit;
PopupMenu *menu;
EditorFileDialog *file;