summaryrefslogtreecommitdiffstats
path: root/editor/editor_properties_array_dict.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_properties_array_dict.cpp')
-rw-r--r--editor/editor_properties_array_dict.cpp49
1 files changed, 32 insertions, 17 deletions
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index c59c221e02..b5f34ecb3d 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -39,7 +39,9 @@
#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"
bool EditorPropertyArrayObject::_set(const StringName &p_name, const Variant &p_value) {
@@ -233,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) {
@@ -271,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));
@@ -285,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);
@@ -352,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);
@@ -382,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);
@@ -814,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() {
}
@@ -824,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);
@@ -839,6 +847,7 @@ EditorPropertyArray::EditorPropertyArray() {
subtype = Variant::NIL;
subtype_hint = PROPERTY_HINT_NONE;
subtype_hint_string = "";
+ has_borders = true;
}
///////////////////// DICTIONARY ///////////////////////////
@@ -895,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);
@@ -954,6 +963,7 @@ void EditorPropertyDictionary::update_property() {
memdelete(container);
button_add_item = nullptr;
container = nullptr;
+ add_panel = nullptr;
slots.clear();
}
return;
@@ -973,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);
@@ -996,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);
@@ -1006,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);
}
@@ -1092,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;
}
@@ -1126,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"));
@@ -1133,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);
@@ -1145,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 ///////////////////////////
@@ -1279,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();
}
@@ -1287,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);
}
@@ -1347,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);