diff options
Diffstat (limited to 'tools/editor/property_editor.cpp')
-rw-r--r-- | tools/editor/property_editor.cpp | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index afc6396ab3..3258bc6d74 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -306,14 +306,14 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty slider->set_step((type==Variant::REAL) ? step : 1); slider->set_val(v); slider->show(); - set_size(Size2(110,30)); + set_size(Size2(110,30)*EDSCALE); } else { spinbox->set_min(min); spinbox->set_max(max); spinbox->set_step((type==Variant::REAL) ? step : 1); spinbox->set_val(v); spinbox->show(); - set_size(Size2(70,35)); + set_size(Size2(70,35)*EDSCALE); } @@ -339,7 +339,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty } - set_size(checks20[19]->get_pos()+Size2(20,25)); + set_size(checks20[19]->get_pos()+Size2(20,25)*EDSCALE); } else if (hint==PROPERTY_HINT_EXP_EASING) { @@ -365,7 +365,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty type_button->show(); easing_draw->show(); - set_size(Size2(200,150)); + set_size(Size2(200,150)*EDSCALE); } else if (hint==PROPERTY_HINT_FLAGS) { menu->clear(); Vector<String> flags = hint_text.split(","); @@ -600,7 +600,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty color_picker->show(); color_picker->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA); color_picker->set_color(v); - set_size( Size2(300, color_picker->get_combined_minimum_size().height+10)); + set_size( Size2(300*EDSCALE, color_picker->get_combined_minimum_size().height+10*EDSCALE)); /* int ofs=80; int m=10; @@ -1673,6 +1673,7 @@ void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns,int } + void CustomPropertyEditor::_bind_methods() { ObjectTypeDB::bind_method("_focus_enter", &CustomPropertyEditor::_focus_enter); @@ -1691,6 +1692,7 @@ void CustomPropertyEditor::_bind_methods() { ObjectTypeDB::bind_method( "_menu_option",&CustomPropertyEditor::_menu_option); + ADD_SIGNAL( MethodInfo("variant_changed") ); ADD_SIGNAL( MethodInfo("resource_edit_request") ); } @@ -2180,6 +2182,11 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p } } + if (!res->is_type("Texture")) { + //texture already previews via itself + EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res,this,"_resource_preview_done",p_item->get_instance_ID()); + } + } @@ -3357,6 +3364,10 @@ void PropertyEditor::update_tree() { } else if (res.is_valid()) { item->set_tooltip(1,res->get_name()+" ("+res->get_type()+")"); } + if (!res->is_type("Texture")) { + //texture already previews via itself + EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res,this,"_resource_preview_done",item->get_instance_ID()); + } } @@ -3870,6 +3881,29 @@ void PropertyEditor::_filter_changed(const String& p_text) { update_tree(); } + + +void PropertyEditor::_resource_preview_done(const String& p_path,const Ref<Texture>& p_preview,Variant p_ud) { + + if (p_preview.is_null()) + return; //don't bother with empty preview + + ObjectID id = p_ud; + Object *obj = ObjectDB::get_instance(id); + + if (!obj) + return; + + TreeItem *ti = obj->cast_to<TreeItem>(); + + ERR_FAIL_COND(!ti); + + int tw = EditorSettings::get_singleton()->get("property_editor/texture_preview_width"); + + ti->set_icon(1,p_preview); //should be scaled I think? + ti->set_icon_max_width(1,tw); + ti->set_text(1,""); +} void PropertyEditor::_bind_methods() { ObjectTypeDB::bind_method( "_item_edited",&PropertyEditor::_item_edited); @@ -3884,6 +3918,7 @@ void PropertyEditor::_bind_methods() { ObjectTypeDB::bind_method( "_set_range_def",&PropertyEditor::_set_range_def); ObjectTypeDB::bind_method( "_filter_changed",&PropertyEditor::_filter_changed); ObjectTypeDB::bind_method( "update_tree",&PropertyEditor::update_tree); + ObjectTypeDB::bind_method( "_resource_preview_done",&PropertyEditor::_resource_preview_done); ObjectTypeDB::bind_method(_MD("get_drag_data_fw"), &PropertyEditor::get_drag_data_fw); ObjectTypeDB::bind_method(_MD("can_drop_data_fw"), &PropertyEditor::can_drop_data_fw); @@ -4251,7 +4286,7 @@ PropertyEditor *SectionedPropertyEditor::get_property_editor() { SectionedPropertyEditor::SectionedPropertyEditor() { VBoxContainer *left_vb = memnew( VBoxContainer); - left_vb->set_custom_minimum_size(Size2(160,0)); + left_vb->set_custom_minimum_size(Size2(160,0)*EDSCALE); add_child(left_vb); sections = memnew( ItemList ); |