Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag to EditorResourcePicker to differentiate selection contexts #54509

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/classes/EditorResourcePicker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@
</signal>
<signal name="resource_selected">
<argument index="0" name="resource" type="Resource" />
<argument index="1" name="edit" type="bool" />
<description>
Emitted when the resource value was set and user clicked to edit it.
Emitted when the resource value was set and user clicked to edit it. When [code]edit[/code] is [code]true[/code], the signal was caused by the context menu "Edit" option.
</description>
</signal>
</signals>
Expand Down
4 changes: 2 additions & 2 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2821,8 +2821,8 @@ void EditorPropertyResource::_set_read_only(bool p_read_only) {
resource_picker->set_editable(!p_read_only);
};

void EditorPropertyResource::_resource_selected(const RES &p_resource) {
if (use_sub_inspector) {
void EditorPropertyResource::_resource_selected(const RES &p_resource, bool p_edit) {
if (!p_edit && use_sub_inspector) {
bool unfold = !get_edited_object()->editor_is_section_unfolded(get_edited_property());
get_edited_object()->editor_set_section_unfold(get_edited_property(), unfold);
update_property();
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ class EditorPropertyResource : public EditorProperty {
bool updating_theme = false;
bool opened_editor = false;

void _resource_selected(const RES &p_resource);
void _resource_selected(const RES &p_resource, bool p_edit);
void _resource_changed(const RES &p_resource);

void _viewport_selected(const NodePath &p_path);
Expand Down
6 changes: 3 additions & 3 deletions editor/editor_resource_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void EditorResourcePicker::_resource_selected() {
return;
}

emit_signal(SNAME("resource_selected"), edited_resource);
emit_signal(SNAME("resource_selected"), edited_resource, false);
}

void EditorResourcePicker::_file_selected(const String &p_path) {
Expand Down Expand Up @@ -266,7 +266,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {

case OBJ_MENU_EDIT: {
if (edited_resource.is_valid()) {
emit_signal(SNAME("resource_selected"), edited_resource);
emit_signal(SNAME("resource_selected"), edited_resource, true);
}
} break;

Expand Down Expand Up @@ -690,7 +690,7 @@ void EditorResourcePicker::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editable"), "set_editable", "is_editable");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "toggle_mode"), "set_toggle_mode", "is_toggle_mode");

ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::BOOL, "edit")));
ADD_SIGNAL(MethodInfo("resource_changed", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
}

Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/theme_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2848,7 +2848,7 @@ void ThemeTypeEditor::_font_size_item_changed(float p_value, String p_item_name)
edited_theme->set_font_size(p_item_name, edited_type, int(p_value));
}

void ThemeTypeEditor::_edit_resource_item(RES p_resource) {
void ThemeTypeEditor::_edit_resource_item(RES p_resource, bool p_edit) {
EditorNode::get_singleton()->edit_resource(p_resource);
}

Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/theme_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class ThemeTypeEditor : public MarginContainer {
void _color_item_changed(Color p_value, String p_item_name);
void _constant_item_changed(float p_value, String p_item_name);
void _font_size_item_changed(float p_value, String p_item_name);
void _edit_resource_item(RES p_resource);
void _edit_resource_item(RES p_resource, bool p_edit);
void _font_item_changed(Ref<Font> p_value, String p_item_name);
void _icon_item_changed(Ref<Texture2D> p_value, String p_item_name);
void _stylebox_item_changed(Ref<StyleBox> p_value, String p_item_name);
Expand Down