diff options
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r-- | editor/editor_properties.cpp | 136 |
1 files changed, 56 insertions, 80 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index ea364d8a0d..103ea3ffc3 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -31,7 +31,6 @@ #include "editor_properties.h" #include "core/config/project_settings.h" -#include "core/core_string_names.h" #include "editor/create_dialog.h" #include "editor/editor_node.h" #include "editor/editor_properties_array_dict.h" @@ -48,6 +47,7 @@ #include "editor/property_selector.h" #include "editor/scene_tree_dock.h" #include "editor/themes/editor_scale.h" +#include "editor/themes/editor_theme_manager.h" #include "scene/2d/gpu_particles_2d.h" #include "scene/3d/fog_volume.h" #include "scene/3d/gpu_particles_3d.h" @@ -235,7 +235,7 @@ EditorPropertyMultilineText::EditorPropertyMultilineText(bool p_expression) { text->set_h_size_flags(SIZE_EXPAND_FILL); open_big_text = memnew(Button); open_big_text->set_flat(true); - open_big_text->connect("pressed", callable_mp(this, &EditorPropertyMultilineText::_open_big_text)); + open_big_text->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyMultilineText::_open_big_text)); hb->add_child(open_big_text); big_text_dialog = nullptr; big_text = nullptr; @@ -382,7 +382,7 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() { edit_button->set_flat(true); edit_button->hide(); default_layout->add_child(edit_button); - edit_button->connect("pressed", callable_mp(this, &EditorPropertyTextEnum::_edit_custom_value)); + edit_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyTextEnum::_edit_custom_value)); custom_value_edit = memnew(LineEdit); custom_value_edit->set_h_size_flags(SIZE_EXPAND_FILL); @@ -392,12 +392,12 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() { accept_button = memnew(Button); accept_button->set_flat(true); edit_custom_layout->add_child(accept_button); - accept_button->connect("pressed", callable_mp(this, &EditorPropertyTextEnum::_custom_value_accepted)); + accept_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyTextEnum::_custom_value_accepted)); cancel_button = memnew(Button); cancel_button->set_flat(true); edit_custom_layout->add_child(cancel_button); - cancel_button->connect("pressed", callable_mp(this, &EditorPropertyTextEnum::_custom_value_canceled)); + cancel_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyTextEnum::_custom_value_canceled)); add_focusable(option_button); add_focusable(edit_button); @@ -456,7 +456,7 @@ EditorPropertyLocale::EditorPropertyLocale() { locale = memnew(LineEdit); locale_hb->add_child(locale); locale->connect("text_submitted", callable_mp(this, &EditorPropertyLocale::_locale_selected)); - locale->connect("focus_exited", callable_mp(this, &EditorPropertyLocale::_locale_focus_exited)); + locale->connect(SceneStringName(focus_exited), callable_mp(this, &EditorPropertyLocale::_locale_focus_exited)); locale->set_h_size_flags(SIZE_EXPAND_FILL); locale_edit = memnew(Button); @@ -464,7 +464,7 @@ EditorPropertyLocale::EditorPropertyLocale() { locale_hb->add_child(locale_edit); add_focusable(locale); dialog = nullptr; - locale_edit->connect("pressed", callable_mp(this, &EditorPropertyLocale::_locale_pressed)); + locale_edit->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyLocale::_locale_pressed)); } ///////////////////// PATH ///////////////////////// @@ -597,7 +597,7 @@ EditorPropertyPath::EditorPropertyPath() { path->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE); path_hb->add_child(path); path->connect("text_submitted", callable_mp(this, &EditorPropertyPath::_path_selected)); - path->connect("focus_exited", callable_mp(this, &EditorPropertyPath::_path_focus_exited)); + path->connect(SceneStringName(focus_exited), callable_mp(this, &EditorPropertyPath::_path_focus_exited)); path->set_h_size_flags(SIZE_EXPAND_FILL); path_edit = memnew(Button); @@ -605,7 +605,7 @@ EditorPropertyPath::EditorPropertyPath() { path_hb->add_child(path_edit); add_focusable(path); dialog = nullptr; - path_edit->connect("pressed", callable_mp(this, &EditorPropertyPath::_path_pressed)); + path_edit->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyPath::_path_pressed)); } ///////////////////// CLASS NAME ///////////////////////// @@ -646,7 +646,7 @@ EditorPropertyClassName::EditorPropertyClassName() { add_child(property); add_focusable(property); property->set_text(selected_type); - property->connect("pressed", callable_mp(this, &EditorPropertyClassName::_property_selected)); + property->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyClassName::_property_selected)); dialog = memnew(CreateDialog); dialog->set_base_type(base_type); dialog->connect("create", callable_mp(this, &EditorPropertyClassName::_dialog_created)); @@ -677,7 +677,7 @@ EditorPropertyCheck::EditorPropertyCheck() { checkbox->set_text(TTR("On")); add_child(checkbox); add_focusable(checkbox); - checkbox->connect("pressed", callable_mp(this, &EditorPropertyCheck::_checkbox_pressed)); + checkbox->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyCheck::_checkbox_pressed)); } ///////////////////// ENUM ///////////////////////// @@ -791,7 +791,7 @@ void EditorPropertyFlags::setup(const Vector<String> &p_options) { CheckBox *cb = memnew(CheckBox); cb->set_text(text_split[0]); cb->set_clip_text(true); - cb->connect("pressed", callable_mp(this, &EditorPropertyFlags::_flag_toggled).bind(flag_index)); + cb->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyFlags::_flag_toggled).bind(flag_index)); add_focusable(cb); vbox->add_child(cb); flags.push_back(cb); @@ -1296,7 +1296,7 @@ EditorPropertyLayers::EditorPropertyLayers() { button = memnew(TextureButton); button->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED); button->set_toggle_mode(true); - button->connect("pressed", callable_mp(this, &EditorPropertyLayers::_button_pressed)); + button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyLayers::_button_pressed)); hb->add_child(button); set_bottom_editor(hb); @@ -1393,7 +1393,7 @@ EditorPropertyObjectID::EditorPropertyObjectID() { add_child(edit); add_focusable(edit); edit->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS); - edit->connect("pressed", callable_mp(this, &EditorPropertyObjectID::_edit_pressed)); + edit->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyObjectID::_edit_pressed)); } ///////////////////// SIGNAL ///////////////////////// @@ -1420,7 +1420,7 @@ EditorPropertySignal::EditorPropertySignal() { edit = memnew(Button); add_child(edit); add_focusable(edit); - edit->connect("pressed", callable_mp(this, &EditorPropertySignal::_edit_pressed)); + edit->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertySignal::_edit_pressed)); } ///////////////////// CALLABLE ///////////////////////// @@ -1680,8 +1680,8 @@ void EditorPropertyEasing::_bind_methods() { EditorPropertyEasing::EditorPropertyEasing() { easing_draw = memnew(Control); - easing_draw->connect("draw", callable_mp(this, &EditorPropertyEasing::_draw_easing)); - easing_draw->connect("gui_input", callable_mp(this, &EditorPropertyEasing::_drag_easing)); + easing_draw->connect(SceneStringName(draw), callable_mp(this, &EditorPropertyEasing::_draw_easing)); + easing_draw->connect(SceneStringName(gui_input), callable_mp(this, &EditorPropertyEasing::_drag_easing)); easing_draw->set_default_cursor_shape(Control::CURSOR_MOVE); add_child(easing_draw); @@ -1698,7 +1698,7 @@ EditorPropertyEasing::EditorPropertyEasing() { spin->set_allow_lesser(true); spin->set_allow_greater(true); spin->connect("value_changed", callable_mp(this, &EditorPropertyEasing::_spin_value_changed)); - spin->get_line_edit()->connect("focus_exited", callable_mp(this, &EditorPropertyEasing::_spin_focus_exited)); + spin->get_line_edit()->connect(SceneStringName(focus_exited), callable_mp(this, &EditorPropertyEasing::_spin_focus_exited)); spin->hide(); add_child(spin); } @@ -2024,6 +2024,7 @@ void EditorPropertyQuaternion::_custom_value_changed(double val) { spin[1]->set_value_no_signal(temp_q.y); spin[2]->set_value_no_signal(temp_q.z); spin[3]->set_value_no_signal(temp_q.w); + _value_changed(-1, ""); } void EditorPropertyQuaternion::_value_changed(double val, const String &p_name) { @@ -2153,7 +2154,7 @@ EditorPropertyQuaternion::EditorPropertyQuaternion() { warning = memnew(Button); warning->set_text(TTR("Temporary Euler may be changed implicitly!")); warning->set_clip_text(true); - warning->connect("pressed", callable_mp(this, &EditorPropertyQuaternion::_warning_pressed)); + warning->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyQuaternion::_warning_pressed)); warning_dialog = memnew(AcceptDialog); add_child(warning_dialog); warning_dialog->set_text(TTR("Temporary Euler will not be stored in the object with the original value. Instead, it will be stored as Quaternion with irreversible conversion.\nThis is due to the fact that the result of Euler->Quaternion can be determined uniquely, but the result of Quaternion->Euler can be multi-existent.")); @@ -2181,7 +2182,7 @@ EditorPropertyQuaternion::EditorPropertyQuaternion() { edit_button->set_flat(true); edit_button->set_toggle_mode(true); default_layout->add_child(edit_button); - edit_button->connect("pressed", callable_mp(this, &EditorPropertyQuaternion::_edit_custom_value)); + edit_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyQuaternion::_edit_custom_value)); add_focusable(edit_button); @@ -2644,7 +2645,7 @@ void EditorPropertyColor::_color_changed(const Color &p_color) { } void EditorPropertyColor::_popup_closed() { - get_edited_object()->set(get_edited_property(), last_color); + get_edited_object()->set(get_edited_property(), was_checked ? Variant(last_color) : Variant()); if (!picker->get_pick_color().is_equal_approx(last_color)) { emit_changed(get_edited_property(), picker->get_pick_color(), "", false); } @@ -2652,6 +2653,7 @@ void EditorPropertyColor::_popup_closed() { void EditorPropertyColor::_picker_opening() { last_color = picker->get_pick_color(); + was_checked = !is_checkable() || is_checked(); } void EditorPropertyColor::_notification(int p_what) { @@ -2980,7 +2982,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() { assign->set_clip_text(true); assign->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); assign->set_expand_icon(true); - assign->connect("pressed", callable_mp(this, &EditorPropertyNodePath::_node_assign)); + assign->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyNodePath::_node_assign)); SET_DRAG_FORWARDING_CD(assign, EditorPropertyNodePath); hbc->add_child(assign); @@ -2998,7 +3000,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() { edit = memnew(LineEdit); edit->set_h_size_flags(SIZE_EXPAND_FILL); edit->hide(); - edit->connect(SNAME("focus_exited"), callable_mp(this, &EditorPropertyNodePath::_accept_text)); + edit->connect(SceneStringName(focus_exited), callable_mp(this, &EditorPropertyNodePath::_accept_text)); edit->connect(SNAME("text_submitted"), callable_mp(this, &EditorPropertyNodePath::_text_submitted)); hbc->add_child(edit); } @@ -3139,7 +3141,7 @@ void EditorPropertyResource::_resource_changed(const Ref<Resource> &p_resource) // Changing the value of Script-type exported variables of the main script should not trigger saving/reloading properties. bool is_script = false; Ref<Script> s = p_resource; - if (get_edited_object() && s.is_valid() && get_edited_property() == CoreStringNames::get_singleton()->_script) { + if (get_edited_object() && s.is_valid() && get_edited_property() == CoreStringName(script)) { is_script = true; InspectorDock::get_singleton()->store_script_properties(get_edited_object()); s->call("set_instance_base_type", get_edited_object()->get_class()); @@ -3216,46 +3218,10 @@ void EditorPropertyResource::_open_editor_pressed() { Ref<Resource> res = get_edited_property_value(); if (res.is_valid()) { // May clear the editor so do it deferred. - callable_mp(EditorNode::get_singleton(), &EditorNode::edit_item).bind(res.ptr(), this).call_deferred(); + callable_mp(EditorNode::get_singleton(), &EditorNode::edit_item).call_deferred(res.ptr(), this); } } -void EditorPropertyResource::_update_property_bg() { - if (!is_inside_tree()) { - return; - } - - updating_theme = true; - - begin_bulk_theme_override(); - if (sub_inspector != nullptr) { - int count_subinspectors = 0; - Node *n = get_parent(); - while (n) { - EditorInspector *ei = Object::cast_to<EditorInspector>(n); - if (ei && ei->is_sub_inspector()) { - count_subinspectors++; - } - n = n->get_parent(); - } - count_subinspectors = MIN(15, count_subinspectors); - - add_theme_color_override("property_color", get_theme_color(SNAME("sub_inspector_property_color"), EditorStringName(Editor))); - add_theme_style_override("bg_selected", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), EditorStringName(Editor))); - add_theme_style_override("bg", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), EditorStringName(Editor))); - add_theme_constant_override("v_separation", 0); - } else { - add_theme_color_override("property_color", get_theme_color(SNAME("property_color"), SNAME("EditorProperty"))); - add_theme_style_override("bg_selected", get_theme_stylebox(SNAME("bg_selected"), SNAME("EditorProperty"))); - add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("EditorProperty"))); - add_theme_constant_override("v_separation", get_theme_constant(SNAME("v_separation"), SNAME("EditorProperty"))); - } - end_bulk_theme_override(); - - updating_theme = false; - queue_redraw(); -} - void EditorPropertyResource::_update_preferred_shader() { Node *parent = get_parent(); EditorProperty *parent_property = nullptr; @@ -3314,7 +3280,7 @@ void EditorPropertyResource::setup(Object *p_object, const String &p_path, const EditorShaderPicker *shader_picker = memnew(EditorShaderPicker); shader_picker->set_edited_material(Object::cast_to<ShaderMaterial>(p_object)); resource_picker = shader_picker; - connect(SNAME("ready"), callable_mp(this, &EditorPropertyResource::_update_preferred_shader)); + connect(SceneStringName(ready), callable_mp(this, &EditorPropertyResource::_update_preferred_shader)); } else if (p_base_type == "AudioStream") { EditorAudioStreamPicker *astream_picker = memnew(EditorAudioStreamPicker); resource_picker = astream_picker; @@ -3362,12 +3328,10 @@ void EditorPropertyResource::update_property() { sub_inspector->set_read_only(is_read_only()); sub_inspector->set_use_folding(is_using_folding()); - sub_inspector_vbox = memnew(VBoxContainer); - sub_inspector_vbox->set_mouse_filter(MOUSE_FILTER_STOP); - add_child(sub_inspector_vbox); - set_bottom_editor(sub_inspector_vbox); + sub_inspector->set_mouse_filter(MOUSE_FILTER_STOP); + add_child(sub_inspector); + set_bottom_editor(sub_inspector); - sub_inspector_vbox->add_child(sub_inspector); resource_picker->set_toggle_pressed(true); Array editor_list; @@ -3383,32 +3347,28 @@ void EditorPropertyResource::update_property() { _open_editor_pressed(); opened_editor = true; } - - _update_property_bg(); } if (res.ptr() != sub_inspector->get_edited_object()) { sub_inspector->edit(res.ptr()); + _update_property_bg(); } } else { if (sub_inspector) { set_bottom_editor(nullptr); - memdelete(sub_inspector_vbox); + memdelete(sub_inspector); sub_inspector = nullptr; - sub_inspector_vbox = nullptr; if (opened_editor) { EditorNode::get_singleton()->hide_unused_editors(); opened_editor = false; } - - _update_property_bg(); } } } - resource_picker->set_edited_resource(res); + resource_picker->set_edited_resource_no_check(res); } void EditorPropertyResource::collapse_all_folding() { @@ -3442,14 +3402,24 @@ void EditorPropertyResource::fold_resource() { } } -void EditorPropertyResource::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_THEME_CHANGED: { - if (!updating_theme) { - _update_property_bg(); +bool EditorPropertyResource::is_colored(ColorationMode p_mode) { + switch (p_mode) { + case COLORATION_CONTAINER_RESOURCE: + return sub_inspector != nullptr; + case COLORATION_RESOURCE: + return true; + case COLORATION_EXTERNAL: + if (sub_inspector) { + Resource *edited_resource = Object::cast_to<Resource>(sub_inspector->get_edited_object()); + return edited_resource && !edited_resource->is_built_in(); } - } break; + break; + } + return false; +} +void EditorPropertyResource::_notification(int p_what) { + switch (p_what) { case NOTIFICATION_EXIT_TREE: { const EditorInspector *ei = get_parent_inspector(); if (ei && !ei->is_main_editor_inspector()) { @@ -3461,6 +3431,7 @@ void EditorPropertyResource::_notification(int p_what) { EditorPropertyResource::EditorPropertyResource() { use_sub_inspector = bool(EDITOR_GET("interface/inspector/open_resources_in_current_inspector")); + has_borders = true; } ////////////// DEFAULT PLUGIN ////////////////////// @@ -3934,6 +3905,11 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ editor->setup(Variant::PACKED_COLOR_ARRAY, p_hint_text); return editor; } break; + case Variant::PACKED_VECTOR4_ARRAY: { + EditorPropertyArray *editor = memnew(EditorPropertyArray); + editor->setup(Variant::PACKED_VECTOR4_ARRAY, p_hint_text); + return editor; + } break; default: { } } |