Prevent to take too much space for long vertical texture

This commit is contained in:
volzhs 2017-04-11 20:22:57 +09:00
parent 09ed1113fa
commit c3e6759ca1

View File

@ -2388,6 +2388,10 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p
RES res = obj->get(p_name).operator RefPtr();
if (res->is_class("Texture")) {
int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width");
Vector2 size(res->call("get_width"), res->call("get_height"));
if (size.width < size.height) {
tw = MAX((size.width / size.height) * tw, 1);
}
p_item->set_icon_max_width(1, tw);
p_item->set_icon(1, res);
p_item->set_text(1, "");
@ -3618,6 +3622,10 @@ void PropertyEditor::update_tree() {
if (res->is_class("Texture")) {
int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width");
Vector2 size(res->call("get_width"), res->call("get_height"));
if (size.width < size.height) {
tw = MAX((size.width / size.height) * tw, 1);
}
item->set_icon_max_width(1, tw);
item->set_icon(1, res);
item->set_text(1, "");