diff options
Diffstat (limited to 'editor/editor_properties_array_dict.cpp')
-rw-r--r-- | editor/editor_properties_array_dict.cpp | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index da072744b8..b5f34ecb3d 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -39,6 +39,7 @@ #include "editor/gui/editor_spin_slider.h" #include "editor/inspector_dock.h" #include "editor/themes/editor_scale.h" +#include "editor/themes/editor_theme_manager.h" #include "scene/gui/button.h" #include "scene/gui/margin_container.h" #include "scene/resources/packed_scene.h" @@ -234,6 +235,9 @@ void EditorPropertyArray::_property_changed(const String &p_property, Variant p_ Variant array = object->get_array().duplicate(); array.set(index, p_value); emit_changed(get_edited_property(), array, p_name, p_changing); + if (p_changing) { + object->set_array(array); + } } void EditorPropertyArray::_change_type(Object *p_button, int p_slot_index) { @@ -272,7 +276,7 @@ void EditorPropertyArray::_create_new_property_slot() { reorder_button->set_icon(get_editor_theme_icon(SNAME("TripleBar"))); reorder_button->set_default_cursor_shape(Control::CURSOR_MOVE); reorder_button->set_disabled(is_read_only()); - reorder_button->connect(SNAME("gui_input"), callable_mp(this, &EditorPropertyArray::_reorder_button_gui_input)); + reorder_button->connect(SceneStringName(gui_input), callable_mp(this, &EditorPropertyArray::_reorder_button_gui_input)); reorder_button->connect(SNAME("button_up"), callable_mp(this, &EditorPropertyArray::_reorder_button_up)); reorder_button->connect(SNAME("button_down"), callable_mp(this, &EditorPropertyArray::_reorder_button_down).bind(idx)); @@ -286,13 +290,13 @@ void EditorPropertyArray::_create_new_property_slot() { Button *edit_btn = memnew(Button); edit_btn->set_icon(get_editor_theme_icon(SNAME("Edit"))); edit_btn->set_disabled(is_read_only()); - edit_btn->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type).bind(edit_btn, idx)); + edit_btn->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyArray::_change_type).bind(edit_btn, idx)); hbox->add_child(edit_btn); } else { Button *remove_btn = memnew(Button); remove_btn->set_icon(get_editor_theme_icon(SNAME("Remove"))); remove_btn->set_disabled(is_read_only()); - remove_btn->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed).bind(idx)); + remove_btn->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyArray::_remove_pressed).bind(idx)); hbox->add_child(remove_btn); } property_vbox->add_child(hbox); @@ -353,8 +357,7 @@ void EditorPropertyArray::update_property() { updating = true; if (!container) { - container = memnew(MarginContainer); - container->set_theme_type_variation("MarginContainer4px"); + container = memnew(PanelContainer); container->set_mouse_filter(MOUSE_FILTER_STOP); add_child(container); set_bottom_editor(container); @@ -383,7 +386,7 @@ void EditorPropertyArray::update_property() { button_add_item = EditorInspector::create_inspector_action_button(TTR("Add Element")); button_add_item->set_icon(get_editor_theme_icon(SNAME("Add"))); - button_add_item->connect(SNAME("pressed"), callable_mp(this, &EditorPropertyArray::_add_element)); + button_add_item->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyArray::_add_element)); button_add_item->set_disabled(is_read_only()); vbox->add_child(button_add_item); @@ -815,6 +818,10 @@ void EditorPropertyArray::_reorder_button_up() { _page_changed(page_index); } +bool EditorPropertyArray::is_colored(ColorationMode p_mode) { + return p_mode == COLORATION_CONTAINER_RESOURCE; +} + void EditorPropertyArray::_bind_methods() { } @@ -825,10 +832,10 @@ EditorPropertyArray::EditorPropertyArray() { edit = memnew(Button); edit->set_h_size_flags(SIZE_EXPAND_FILL); edit->set_clip_text(true); - edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_edit_pressed)); + edit->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyArray::_edit_pressed)); edit->set_toggle_mode(true); SET_DRAG_FORWARDING_CD(edit, EditorPropertyArray); - edit->connect("draw", callable_mp(this, &EditorPropertyArray::_button_draw)); + edit->connect(SceneStringName(draw), callable_mp(this, &EditorPropertyArray::_button_draw)); add_child(edit); add_focusable(edit); @@ -840,6 +847,7 @@ EditorPropertyArray::EditorPropertyArray() { subtype = Variant::NIL; subtype_hint = PROPERTY_HINT_NONE; subtype_hint_string = ""; + has_borders = true; } ///////////////////// DICTIONARY /////////////////////////// @@ -896,7 +904,7 @@ void EditorPropertyDictionary::_create_new_property_slot(int p_idx) { Button *edit_btn = memnew(Button); edit_btn->set_icon(get_editor_theme_icon(SNAME("Edit"))); edit_btn->set_disabled(is_read_only()); - edit_btn->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type).bind(edit_btn, slots.size())); + edit_btn->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyDictionary::_change_type).bind(edit_btn, slots.size())); hbox->add_child(edit_btn); if (add_panel) { add_panel->get_child(0)->add_child(hbox); @@ -955,6 +963,7 @@ void EditorPropertyDictionary::update_property() { memdelete(container); button_add_item = nullptr; container = nullptr; + add_panel = nullptr; slots.clear(); } return; @@ -974,8 +983,7 @@ void EditorPropertyDictionary::update_property() { updating = true; if (!container) { - container = memnew(MarginContainer); - container->set_theme_type_variation("MarginContainer4px"); + container = memnew(PanelContainer); container->set_mouse_filter(MOUSE_FILTER_STOP); add_child(container); set_bottom_editor(container); @@ -997,7 +1005,7 @@ void EditorPropertyDictionary::update_property() { add_panel = memnew(PanelContainer); property_vbox->add_child(add_panel); - add_panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("DictionaryAddItem"), EditorStringName(EditorStyles))); + add_panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("DictionaryAddItem"))); VBoxContainer *add_vbox = memnew(VBoxContainer); add_panel->add_child(add_vbox); @@ -1007,7 +1015,7 @@ void EditorPropertyDictionary::update_property() { button_add_item = EditorInspector::create_inspector_action_button(TTR("Add Key/Value Pair")); button_add_item->set_icon(get_theme_icon(SNAME("Add"), EditorStringName(EditorIcons))); button_add_item->set_disabled(is_read_only()); - button_add_item->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_add_key_value)); + button_add_item->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyDictionary::_add_key_value)); add_vbox->add_child(button_add_item); } @@ -1093,6 +1101,7 @@ void EditorPropertyDictionary::_notification(int p_what) { if (button_add_item) { button_add_item->set_icon(get_editor_theme_icon(SNAME("Add"))); + add_panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("DictionaryAddItem"))); } } break; } @@ -1127,6 +1136,10 @@ void EditorPropertyDictionary::_page_changed(int p_page) { void EditorPropertyDictionary::_bind_methods() { } +bool EditorPropertyDictionary::is_colored(ColorationMode p_mode) { + return p_mode == COLORATION_CONTAINER_RESOURCE; +} + EditorPropertyDictionary::EditorPropertyDictionary() { object.instantiate(); page_length = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page")); @@ -1134,7 +1147,7 @@ EditorPropertyDictionary::EditorPropertyDictionary() { edit = memnew(Button); edit->set_h_size_flags(SIZE_EXPAND_FILL); edit->set_clip_text(true); - edit->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_edit_pressed)); + edit->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyDictionary::_edit_pressed)); edit->set_toggle_mode(true); add_child(edit); add_focusable(edit); @@ -1146,6 +1159,7 @@ EditorPropertyDictionary::EditorPropertyDictionary() { add_child(change_type); change_type->connect("id_pressed", callable_mp(this, &EditorPropertyDictionary::_change_type_menu)); changing_type_index = -1; + has_borders = true; } ///////////////////// LOCALIZABLE STRING /////////////////////////// @@ -1280,7 +1294,7 @@ void EditorPropertyLocalizableString::update_property() { Button *edit_btn = memnew(Button); edit_btn->set_icon(get_editor_theme_icon(SNAME("Remove"))); hbox->add_child(edit_btn); - edit_btn->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_remove_item).bind(edit_btn, remove_index)); + edit_btn->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyLocalizableString::_remove_item).bind(edit_btn, remove_index)); prop->update_property(); } @@ -1288,7 +1302,7 @@ void EditorPropertyLocalizableString::update_property() { if (page_index == max_page) { button_add_item = EditorInspector::create_inspector_action_button(TTR("Add Translation")); button_add_item->set_icon(get_editor_theme_icon(SNAME("Add"))); - button_add_item->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_add_locale_popup)); + button_add_item->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyLocalizableString::_add_locale_popup)); property_vbox->add_child(button_add_item); } @@ -1348,7 +1362,7 @@ EditorPropertyLocalizableString::EditorPropertyLocalizableString() { edit = memnew(Button); edit->set_h_size_flags(SIZE_EXPAND_FILL); edit->set_clip_text(true); - edit->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_edit_pressed)); + edit->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyLocalizableString::_edit_pressed)); edit->set_toggle_mode(true); add_child(edit); add_focusable(edit); |