summaryrefslogtreecommitdiffstats
path: root/editor/editor_properties.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r--editor/editor_properties.cpp72
1 files changed, 44 insertions, 28 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index c5a35e466c..bdb5ed2ed9 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -192,7 +192,7 @@ void EditorPropertyMultilineText::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: {
Ref<Texture2D> df = get_editor_theme_icon(SNAME("DistractionFree"));
- open_big_text->set_icon(df);
+ open_big_text->set_button_icon(df);
Ref<Font> font;
int font_size;
@@ -340,9 +340,9 @@ void EditorPropertyTextEnum::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- edit_button->set_icon(get_editor_theme_icon(SNAME("Edit")));
- accept_button->set_icon(get_editor_theme_icon(SNAME("ImportCheck")));
- cancel_button->set_icon(get_editor_theme_icon(SNAME("ImportFail")));
+ edit_button->set_button_icon(get_editor_theme_icon(SNAME("Edit")));
+ accept_button->set_button_icon(get_editor_theme_icon(SNAME("ImportCheck")));
+ cancel_button->set_button_icon(get_editor_theme_icon(SNAME("ImportFail")));
} break;
}
}
@@ -428,7 +428,7 @@ void EditorPropertyLocale::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- locale_edit->set_icon(get_editor_theme_icon(SNAME("Translation")));
+ locale_edit->set_button_icon(get_editor_theme_icon(SNAME("Translation")));
} break;
}
}
@@ -462,10 +462,26 @@ void EditorPropertyPath::_set_read_only(bool p_read_only) {
}
void EditorPropertyPath::_path_selected(const String &p_path) {
- emit_changed(get_edited_property(), p_path);
+ String full_path = p_path;
+ ResourceUID::ID id = ResourceLoader::get_resource_uid(full_path);
+
+ if (id != ResourceUID::INVALID_ID) {
+ full_path = ResourceUID::get_singleton()->id_to_text(id);
+ }
+
+ emit_changed(get_edited_property(), full_path);
update_property();
}
+String EditorPropertyPath::_get_path_text() {
+ String full_path = get_edited_property_value();
+ if (full_path.begins_with("uid://")) {
+ full_path = ResourceUID::get_singleton()->get_id_path(ResourceUID::get_singleton()->text_to_id(full_path));
+ }
+
+ return full_path;
+}
+
void EditorPropertyPath::_path_pressed() {
if (!dialog) {
dialog = memnew(EditorFileDialog);
@@ -474,7 +490,7 @@ void EditorPropertyPath::_path_pressed() {
add_child(dialog);
}
- String full_path = get_edited_property_value();
+ String full_path = _get_path_text();
dialog->clear_filters();
@@ -502,7 +518,7 @@ void EditorPropertyPath::_path_pressed() {
}
void EditorPropertyPath::update_property() {
- String full_path = get_edited_property_value();
+ String full_path = _get_path_text();
path->set_text(full_path);
path->set_tooltip_text(full_path);
}
@@ -522,9 +538,9 @@ void EditorPropertyPath::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
if (folder) {
- path_edit->set_icon(get_editor_theme_icon(SNAME("FolderBrowse")));
+ path_edit->set_button_icon(get_editor_theme_icon(SNAME("FolderBrowse")));
} else {
- path_edit->set_icon(get_editor_theme_icon(SNAME("FileBrowse")));
+ path_edit->set_button_icon(get_editor_theme_icon(SNAME("FileBrowse")));
}
} break;
}
@@ -547,8 +563,7 @@ void EditorPropertyPath::_drop_data_fw(const Point2 &p_point, const Variant &p_d
return;
}
- emit_changed(get_edited_property(), filesPaths[0]);
- update_property();
+ _path_selected(filesPaths[0]);
}
bool EditorPropertyPath::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
@@ -1343,12 +1358,12 @@ void EditorPropertyObjectID::update_property() {
edit->set_text(type + " ID: " + uitos(id));
edit->set_tooltip_text(type + " ID: " + uitos(id));
edit->set_disabled(false);
- edit->set_icon(EditorNode::get_singleton()->get_class_icon(type));
+ edit->set_button_icon(EditorNode::get_singleton()->get_class_icon(type));
} else {
edit->set_text(TTR("<empty>"));
edit->set_tooltip_text("");
edit->set_disabled(true);
- edit->set_icon(Ref<Texture2D>());
+ edit->set_button_icon(Ref<Texture2D>());
}
}
@@ -1378,7 +1393,7 @@ void EditorPropertySignal::update_property() {
edit->set_text("Signal: " + signal.get_name());
edit->set_disabled(false);
- edit->set_icon(get_editor_theme_icon(SNAME("Signals")));
+ edit->set_button_icon(get_editor_theme_icon(SNAME("Signals")));
}
EditorPropertySignal::EditorPropertySignal() {
@@ -1397,7 +1412,7 @@ void EditorPropertyCallable::update_property() {
edit->set_text("Callable");
edit->set_disabled(true);
- edit->set_icon(get_editor_theme_icon(SNAME("Callable")));
+ edit->set_button_icon(get_editor_theme_icon(SNAME("Callable")));
}
EditorPropertyCallable::EditorPropertyCallable() {
@@ -2024,9 +2039,9 @@ void EditorPropertyQuaternion::_notification(int p_what) {
for (int i = 0; i < 3; i++) {
euler[i]->add_theme_color_override("label_color", colors[i]);
}
- edit_button->set_icon(get_editor_theme_icon(SNAME("Edit")));
+ edit_button->set_button_icon(get_editor_theme_icon(SNAME("Edit")));
euler_label->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("property_color"), SNAME("EditorProperty")));
- warning->set_icon(get_editor_theme_icon(SNAME("NodeWarning")));
+ warning->set_button_icon(get_editor_theme_icon(SNAME("NodeWarning")));
warning->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
} break;
}
@@ -2638,7 +2653,7 @@ EditorPropertyColor::EditorPropertyColor() {
void EditorPropertyNodePath::_set_read_only(bool p_read_only) {
assign->set_disabled(p_read_only);
menu->set_disabled(p_read_only);
-};
+}
Variant EditorPropertyNodePath::_get_cache_value(const StringName &p_prop, bool &r_valid) const {
if (p_prop == get_edited_property()) {
@@ -2648,7 +2663,7 @@ Variant EditorPropertyNodePath::_get_cache_value(const StringName &p_prop, bool
return Variant();
}
-void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {
+void EditorPropertyNodePath::_node_selected(const NodePath &p_path, bool p_absolute) {
NodePath path = p_path;
Node *base_node = get_base_node();
@@ -2658,7 +2673,7 @@ void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {
path = get_tree()->get_edited_scene_root()->get_path_to(to_node);
}
- if (base_node) { // for AnimationTrackKeyEdit
+ if (p_absolute && base_node) { // for AnimationTrackKeyEdit
path = base_node->get_path().rel_path_to(p_path);
}
@@ -2680,7 +2695,7 @@ void EditorPropertyNodePath::_node_assign() {
scene_tree->get_scene_tree()->set_show_enabled_subscene(true);
scene_tree->set_valid_types(valid_types);
add_child(scene_tree);
- scene_tree->connect("selected", callable_mp(this, &EditorPropertyNodePath::_node_selected));
+ scene_tree->connect("selected", callable_mp(this, &EditorPropertyNodePath::_node_selected).bind(true));
}
Variant val = get_edited_property_value();
@@ -2748,7 +2763,7 @@ void EditorPropertyNodePath::_accept_text() {
void EditorPropertyNodePath::_text_submitted(const String &p_text) {
NodePath np = p_text;
- emit_changed(get_edited_property(), np);
+ _node_selected(np, false);
edit->hide();
assign->show();
menu->show();
@@ -2829,7 +2844,7 @@ void EditorPropertyNodePath::update_property() {
assign->set_tooltip_text(p);
if (p.is_empty()) {
- assign->set_icon(Ref<Texture2D>());
+ assign->set_button_icon(Ref<Texture2D>());
assign->set_text(TTR("Assign..."));
assign->set_flat(false);
return;
@@ -2837,7 +2852,7 @@ void EditorPropertyNodePath::update_property() {
assign->set_flat(true);
if (!base_node || !base_node->has_node(p)) {
- assign->set_icon(Ref<Texture2D>());
+ assign->set_button_icon(Ref<Texture2D>());
assign->set_text(p);
return;
}
@@ -2846,13 +2861,13 @@ void EditorPropertyNodePath::update_property() {
ERR_FAIL_NULL(target_node);
if (String(target_node->get_name()).contains("@")) {
- assign->set_icon(Ref<Texture2D>());
+ assign->set_button_icon(Ref<Texture2D>());
assign->set_text(p);
return;
}
assign->set_text(target_node->get_name());
- assign->set_icon(EditorNode::get_singleton()->get_object_icon(target_node, "Node"));
+ assign->set_button_icon(EditorNode::get_singleton()->get_object_icon(target_node, "Node"));
}
void EditorPropertyNodePath::setup(const Vector<StringName> &p_valid_types, bool p_use_path_from_scene_root, bool p_editing_node) {
@@ -2865,7 +2880,7 @@ void EditorPropertyNodePath::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- menu->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl")));
+ menu->set_button_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl")));
menu->get_popup()->set_item_icon(ACTION_CLEAR, get_editor_theme_icon(SNAME("Clear")));
menu->get_popup()->set_item_icon(ACTION_COPY, get_editor_theme_icon(SNAME("ActionCopy")));
menu->get_popup()->set_item_icon(ACTION_EDIT, get_editor_theme_icon(SNAME("Edit")));
@@ -3221,6 +3236,7 @@ void EditorPropertyResource::setup(Object *p_object, const String &p_path, const
}
resource_picker->set_base_type(p_base_type);
+ resource_picker->set_resource_owner(p_object);
resource_picker->set_editable(true);
resource_picker->set_h_size_flags(SIZE_EXPAND_FILL);
add_child(resource_picker);