diff options
Diffstat (limited to 'editor/property_editor.cpp')
-rw-r--r-- | editor/property_editor.cpp | 88 |
1 files changed, 49 insertions, 39 deletions
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 1bd00f3d1e..3d3fecc8f9 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -609,12 +609,9 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: type = Variant::Type(Variant::Type(i)); } } - InputEvent::Type iet = InputEvent::NONE; - if (hint_text.find(".") != -1) { - iet = InputEvent::Type(int(hint_text.get_slice(".", 1).to_int())); - } + if (type) - property_select->select_property_from_basic_type(type, iet, v); + property_select->select_property_from_basic_type(type, v); updating = false; return false; @@ -681,8 +678,8 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: field_names.push_back("h"); config_value_editors(4, 4, 10, field_names); Rect2 r = v; - value_editor[0]->set_text(String::num(r.pos.x)); - value_editor[1]->set_text(String::num(r.pos.y)); + value_editor[0]->set_text(String::num(r.position.x)); + value_editor[1]->set_text(String::num(r.position.y)); value_editor[2]->set_text(String::num(r.size.x)); value_editor[3]->set_text(String::num(r.size.y)); } break; @@ -736,9 +733,9 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: config_value_editors(6, 3, 16, field_names); Rect3 aabb = v; - value_editor[0]->set_text(String::num(aabb.pos.x)); - value_editor[1]->set_text(String::num(aabb.pos.y)); - value_editor[2]->set_text(String::num(aabb.pos.z)); + value_editor[0]->set_text(String::num(aabb.position.x)); + value_editor[1]->set_text(String::num(aabb.position.y)); + value_editor[2]->set_text(String::num(aabb.position.z)); value_editor[3]->set_text(String::num(aabb.size.x)); value_editor[4]->set_text(String::num(aabb.size.y)); value_editor[5]->set_text(String::num(aabb.size.z)); @@ -979,9 +976,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: return false; } break; - case Variant::INPUT_EVENT: { - - } break; case Variant::DICTIONARY: { } break; @@ -1401,11 +1395,13 @@ void CustomPropertyEditor::_scroll_modified(double p_value) { */ } -void CustomPropertyEditor::_drag_easing(const InputEvent &p_ev) { +void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) { + + Ref<InputEventMouseMotion> mm = p_ev; - if (p_ev.type == InputEvent::MOUSE_MOTION && p_ev.mouse_motion.button_mask & BUTTON_MASK_LEFT) { + if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) { - float rel = p_ev.mouse_motion.relative_x; + float rel = mm->get_relative().x; if (rel == 0) return; @@ -1434,8 +1430,8 @@ void CustomPropertyEditor::_drag_easing(const InputEvent &p_ev) { //emit_signal("variant_changed"); emit_signal("variant_changed"); } - if (p_ev.type == InputEvent::MOUSE_BUTTON && p_ev.mouse_button.button_index == BUTTON_LEFT) { - } + // if (p_ev.type == Ref<InputEvent>::MOUSE_BUTTON && p_ev->get_button_index() == BUTTON_LEFT) { + // } } void CustomPropertyEditor::_draw_easing() { @@ -1543,13 +1539,13 @@ void CustomPropertyEditor::_modified(String p_string) { Rect2 r2; if (evaluator) { - r2.pos.x = evaluator->eval(value_editor[0]->get_text()); - r2.pos.y = evaluator->eval(value_editor[1]->get_text()); + r2.position.x = evaluator->eval(value_editor[0]->get_text()); + r2.position.y = evaluator->eval(value_editor[1]->get_text()); r2.size.x = evaluator->eval(value_editor[2]->get_text()); r2.size.y = evaluator->eval(value_editor[3]->get_text()); } else { - r2.pos.x = value_editor[0]->get_text().to_double(); - r2.pos.y = value_editor[1]->get_text().to_double(); + r2.position.x = value_editor[0]->get_text().to_double(); + r2.position.y = value_editor[1]->get_text().to_double(); r2.size.x = value_editor[2]->get_text().to_double(); r2.size.y = value_editor[3]->get_text().to_double(); } @@ -1715,9 +1711,6 @@ void CustomPropertyEditor::_modified(String p_string) { v = NodePath(value_editor[0]->get_text()); emit_signal("variant_changed"); } break; - case Variant::INPUT_EVENT: { - - } break; case Variant::DICTIONARY: { } break; @@ -2317,6 +2310,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p if (obj->get(p_name).get_type() == Variant::NIL || obj->get(p_name).operator RefPtr().is_null()) { p_item->set_text(1, "<null>"); p_item->set_icon(1, Ref<Texture>()); + p_item->set_custom_as_button(1, false); Dictionary d = p_item->get_metadata(0); int hint = d.has("hint") ? d["hint"].operator int() : -1; @@ -2326,6 +2320,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p } } else { + p_item->set_custom_as_button(1, true); 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"); @@ -2692,6 +2687,10 @@ void PropertyEditor::_notification(int p_what) { changing = false; } + + if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { + update_tree(); + } } TreeItem *PropertyEditor::get_parent_node(String p_path, HashMap<String, TreeItem *> &item_paths, TreeItem *root) { @@ -3543,17 +3542,21 @@ void PropertyEditor::update_tree() { item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); item->set_editable(1, !read_only); - item->add_button(1, get_icon("EditResource", "EditorIcons")); + //item->add_button(1, get_icon("EditResource", "EditorIcons")); String type; if (p.hint == PROPERTY_HINT_RESOURCE_TYPE) type = p.hint_string; - if (obj->get(p.name).get_type() == Variant::NIL || obj->get(p.name).operator RefPtr().is_null()) { + RES res = obj->get(p.name).operator RefPtr(); + + if (obj->get(p.name).get_type() == Variant::NIL || res.is_null()) { item->set_text(1, "<null>"); item->set_icon(1, Ref<Texture>()); + item->set_custom_as_button(1, false); - } else { - RES res = obj->get(p.name).operator RefPtr(); + } else if (res.is_valid()) { + + item->set_custom_as_button(1, true); if (res->is_class("Texture")) { int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width"); @@ -3671,7 +3674,7 @@ void PropertyEditor::_draw_transparency(Object *t, const Rect2 &p_rect) { // make a little space between consecutive color fields Rect2 area = p_rect; - area.pos.y += 1; + area.position.y += 1; area.size.height -= 2; area.size.width -= arrow->get_size().width + 5; tree->draw_texture_rect(get_icon("Transparent", "EditorIcons"), area, true); @@ -3857,10 +3860,17 @@ void PropertyEditor::_item_edited() { _edit_set(name, NodePath(item->get_text(1)), refresh_all); } break; + case Variant::OBJECT: { + if (!item->is_custom_set_as_button(1)) + break; - case Variant::INPUT_EVENT: { + RES res = obj->get(name); + if (res.is_valid()) { + emit_signal("resource_selected", res.get_ref_ptr(), name); + } } break; + case Variant::DICTIONARY: { } break; @@ -3932,7 +3942,7 @@ void PropertyEditor::_custom_editor_request(bool p_arrow) { int hint = d.has("hint") ? d["hint"].operator int() : -1; String hint_text = d.has("hint_text") ? d["hint_text"] : ""; Rect2 where = tree->get_custom_popup_rect(); - custom_editor->set_position(where.pos); + custom_editor->set_position(where.position); if (custom_editor->edit(obj, name, type, v, hint, hint_text)) { custom_editor->popup(); @@ -4039,9 +4049,9 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { Variant v = obj->get(n); custom_editor->edit(obj, n, (Variant::Type)t, v, h, ht); Rect2 where = tree->get_item_rect(ti, 1); - where.pos -= tree->get_scroll(); - where.pos += tree->get_global_position(); - custom_editor->set_position(where.pos); + where.position -= tree->get_scroll(); + where.position += tree->get_global_position(); + custom_editor->set_position(where.position); custom_editor->popup(); } else if (t == Variant::STRING) { @@ -4052,9 +4062,9 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { if (h == PROPERTY_HINT_FILE || h == PROPERTY_HINT_DIR || h == PROPERTY_HINT_GLOBAL_DIR || h == PROPERTY_HINT_GLOBAL_FILE) { Rect2 where = tree->get_item_rect(ti, 1); - where.pos -= tree->get_scroll(); - where.pos += tree->get_global_position(); - custom_editor->set_position(where.pos); + where.position -= tree->get_scroll(); + where.position += tree->get_global_position(); + custom_editor->set_position(where.position); custom_editor->popup(); } else { custom_editor->popup_centered_ratio(); @@ -4130,7 +4140,7 @@ void PropertyEditor::_draw_flags(Object *t, const Rect2 &p_rect) { if (i == 1) ofs.y += bsize + 1; - ofs += p_rect.pos; + ofs += p_rect.position; for (int j = 0; j < 10; j++) { Point2 o = ofs + Point2(j * (bsize + 1), 0); |