|
@@ -305,35 +305,38 @@ void EditorPropertyArray::_create_new_property_slot() {
|
|
|
int idx = slots.size();
|
|
int idx = slots.size();
|
|
|
HBoxContainer *hbox = memnew(HBoxContainer);
|
|
HBoxContainer *hbox = memnew(HBoxContainer);
|
|
|
|
|
|
|
|
|
|
+ EditorProperty *prop = memnew(EditorPropertyNil);
|
|
|
|
|
+
|
|
|
Button *reorder_button = memnew(Button);
|
|
Button *reorder_button = memnew(Button);
|
|
|
reorder_button->set_accessibility_name(TTRC("Reorder"));
|
|
reorder_button->set_accessibility_name(TTRC("Reorder"));
|
|
|
reorder_button->set_button_icon(get_editor_theme_icon(SNAME("TripleBar")));
|
|
reorder_button->set_button_icon(get_editor_theme_icon(SNAME("TripleBar")));
|
|
|
reorder_button->set_default_cursor_shape(Control::CURSOR_MOVE);
|
|
reorder_button->set_default_cursor_shape(Control::CURSOR_MOVE);
|
|
|
reorder_button->set_disabled(is_read_only());
|
|
reorder_button->set_disabled(is_read_only());
|
|
|
|
|
+ reorder_button->set_theme_type_variation(SceneStringName(FlatButton));
|
|
|
reorder_button->connect(SceneStringName(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_up"), callable_mp(this, &EditorPropertyArray::_reorder_button_up));
|
|
|
reorder_button->connect(SNAME("button_down"), callable_mp(this, &EditorPropertyArray::_reorder_button_down).bind(idx));
|
|
reorder_button->connect(SNAME("button_down"), callable_mp(this, &EditorPropertyArray::_reorder_button_down).bind(idx));
|
|
|
|
|
|
|
|
- hbox->add_child(reorder_button);
|
|
|
|
|
- EditorProperty *prop = memnew(EditorPropertyNil);
|
|
|
|
|
hbox->add_child(prop);
|
|
hbox->add_child(prop);
|
|
|
|
|
|
|
|
bool is_untyped_array = object->get_array().get_type() == Variant::ARRAY && subtype == Variant::NIL;
|
|
bool is_untyped_array = object->get_array().get_type() == Variant::ARRAY && subtype == Variant::NIL;
|
|
|
|
|
|
|
|
|
|
+ Button *edit_btn = nullptr;
|
|
|
|
|
+ Button *remove_btn = nullptr;
|
|
|
if (is_untyped_array) {
|
|
if (is_untyped_array) {
|
|
|
- Button *edit_btn = memnew(Button);
|
|
|
|
|
|
|
+ edit_btn = memnew(Button);
|
|
|
edit_btn->set_accessibility_name(TTRC("Edit"));
|
|
edit_btn->set_accessibility_name(TTRC("Edit"));
|
|
|
edit_btn->set_button_icon(get_editor_theme_icon(SNAME("Edit")));
|
|
edit_btn->set_button_icon(get_editor_theme_icon(SNAME("Edit")));
|
|
|
edit_btn->set_disabled(is_read_only());
|
|
edit_btn->set_disabled(is_read_only());
|
|
|
|
|
+ edit_btn->set_theme_type_variation(SceneStringName(FlatButton));
|
|
|
edit_btn->connect(SceneStringName(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 {
|
|
} else {
|
|
|
- Button *remove_btn = memnew(Button);
|
|
|
|
|
|
|
+ remove_btn = memnew(Button);
|
|
|
remove_btn->set_accessibility_name(TTRC("Remove"));
|
|
remove_btn->set_accessibility_name(TTRC("Remove"));
|
|
|
remove_btn->set_button_icon(get_editor_theme_icon(SNAME("Remove")));
|
|
remove_btn->set_button_icon(get_editor_theme_icon(SNAME("Remove")));
|
|
|
remove_btn->set_disabled(is_read_only());
|
|
remove_btn->set_disabled(is_read_only());
|
|
|
|
|
+ remove_btn->set_theme_type_variation(SceneStringName(FlatButton));
|
|
|
remove_btn->connect(SceneStringName(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);
|
|
property_vbox->add_child(hbox);
|
|
|
|
|
|
|
@@ -342,6 +345,8 @@ void EditorPropertyArray::_create_new_property_slot() {
|
|
|
slot.object = object;
|
|
slot.object = object;
|
|
|
slot.container = hbox;
|
|
slot.container = hbox;
|
|
|
slot.reorder_button = reorder_button;
|
|
slot.reorder_button = reorder_button;
|
|
|
|
|
+ slot.edit_button = edit_btn;
|
|
|
|
|
+ slot.remove_button = remove_btn;
|
|
|
slot.set_index(idx + page_index * page_length);
|
|
slot.set_index(idx + page_index * page_length);
|
|
|
slots.push_back(slot);
|
|
slots.push_back(slot);
|
|
|
}
|
|
}
|
|
@@ -513,6 +518,17 @@ void EditorPropertyArray::update_property() {
|
|
|
new_prop->connect(SNAME("object_id_selected"), callable_mp(this, &EditorPropertyArray::_object_id_selected));
|
|
new_prop->connect(SNAME("object_id_selected"), callable_mp(this, &EditorPropertyArray::_object_id_selected));
|
|
|
new_prop->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
new_prop->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
new_prop->set_read_only(is_read_only());
|
|
new_prop->set_read_only(is_read_only());
|
|
|
|
|
+
|
|
|
|
|
+ if (slot.reorder_button) {
|
|
|
|
|
+ new_prop->add_inline_control(slot.reorder_button, INLINE_CONTROL_LEFT);
|
|
|
|
|
+ slot.reorder_button->get_parent()->move_child(slot.reorder_button, 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (slot.edit_button) {
|
|
|
|
|
+ new_prop->add_inline_control(slot.edit_button, INLINE_CONTROL_RIGHT);
|
|
|
|
|
+ } else if (slot.remove_button) {
|
|
|
|
|
+ new_prop->add_inline_control(slot.remove_button, INLINE_CONTROL_RIGHT);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
slot.prop->add_sibling(new_prop, false);
|
|
slot.prop->add_sibling(new_prop, false);
|
|
|
slot.prop->queue_free();
|
|
slot.prop->queue_free();
|
|
|
slot.prop = new_prop;
|
|
slot.prop = new_prop;
|
|
@@ -1047,33 +1063,34 @@ void EditorPropertyDictionary::_create_new_property_slot(int p_idx) {
|
|
|
EditorProperty *prop_key = nullptr;
|
|
EditorProperty *prop_key = nullptr;
|
|
|
if (p_idx != EditorPropertyDictionaryObject::NEW_KEY_INDEX && p_idx != EditorPropertyDictionaryObject::NEW_VALUE_INDEX) {
|
|
if (p_idx != EditorPropertyDictionaryObject::NEW_KEY_INDEX && p_idx != EditorPropertyDictionaryObject::NEW_VALUE_INDEX) {
|
|
|
prop_key = memnew(EditorPropertyNil);
|
|
prop_key = memnew(EditorPropertyNil);
|
|
|
- hbox->add_child(prop_key);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
EditorProperty *prop = memnew(EditorPropertyNil);
|
|
EditorProperty *prop = memnew(EditorPropertyNil);
|
|
|
prop->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
prop->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
- if (p_idx != EditorPropertyDictionaryObject::NEW_KEY_INDEX && p_idx != EditorPropertyDictionaryObject::NEW_VALUE_INDEX) {
|
|
|
|
|
- prop->set_draw_label(false);
|
|
|
|
|
- }
|
|
|
|
|
hbox->add_child(prop);
|
|
hbox->add_child(prop);
|
|
|
|
|
+ if (prop_key) {
|
|
|
|
|
+ prop->add_inline_control(prop_key, INLINE_CONTROL_LEFT);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
bool use_key = p_idx == EditorPropertyDictionaryObject::NEW_KEY_INDEX;
|
|
bool use_key = p_idx == EditorPropertyDictionaryObject::NEW_KEY_INDEX;
|
|
|
bool is_untyped_dict = (use_key ? key_subtype : value_subtype) == Variant::NIL;
|
|
bool is_untyped_dict = (use_key ? key_subtype : value_subtype) == Variant::NIL;
|
|
|
|
|
|
|
|
|
|
+ Button *edit_btn = nullptr;
|
|
|
|
|
+ Button *remove_btn = nullptr;
|
|
|
if (is_untyped_dict) {
|
|
if (is_untyped_dict) {
|
|
|
- Button *edit_btn = memnew(Button);
|
|
|
|
|
|
|
+ edit_btn = memnew(Button);
|
|
|
edit_btn->set_accessibility_name(TTRC("Edit"));
|
|
edit_btn->set_accessibility_name(TTRC("Edit"));
|
|
|
edit_btn->set_button_icon(get_editor_theme_icon(SNAME("Edit")));
|
|
edit_btn->set_button_icon(get_editor_theme_icon(SNAME("Edit")));
|
|
|
edit_btn->set_disabled(is_read_only());
|
|
edit_btn->set_disabled(is_read_only());
|
|
|
|
|
+ edit_btn->set_theme_type_variation(SceneStringName(FlatButton));
|
|
|
edit_btn->connect(SceneStringName(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);
|
|
|
|
|
} else if (p_idx >= 0) {
|
|
} else if (p_idx >= 0) {
|
|
|
- Button *remove_btn = memnew(Button);
|
|
|
|
|
|
|
+ remove_btn = memnew(Button);
|
|
|
remove_btn->set_accessibility_name(TTRC("Remove"));
|
|
remove_btn->set_accessibility_name(TTRC("Remove"));
|
|
|
remove_btn->set_button_icon(get_editor_theme_icon(SNAME("Remove")));
|
|
remove_btn->set_button_icon(get_editor_theme_icon(SNAME("Remove")));
|
|
|
remove_btn->set_disabled(is_read_only());
|
|
remove_btn->set_disabled(is_read_only());
|
|
|
|
|
+ remove_btn->set_theme_type_variation(SceneStringName(FlatButton));
|
|
|
remove_btn->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyDictionary::_remove_pressed).bind(slots.size()));
|
|
remove_btn->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyDictionary::_remove_pressed).bind(slots.size()));
|
|
|
- hbox->add_child(remove_btn);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (add_panel) {
|
|
if (add_panel) {
|
|
@@ -1087,6 +1104,8 @@ void EditorPropertyDictionary::_create_new_property_slot(int p_idx) {
|
|
|
slot.prop_key = prop_key;
|
|
slot.prop_key = prop_key;
|
|
|
slot.object = object;
|
|
slot.object = object;
|
|
|
slot.container = hbox;
|
|
slot.container = hbox;
|
|
|
|
|
+ slot.edit_button = edit_btn;
|
|
|
|
|
+ slot.remove_button = remove_btn;
|
|
|
int index = p_idx + (p_idx >= 0 ? page_index * page_length : 0);
|
|
int index = p_idx + (p_idx >= 0 ? page_index * page_length : 0);
|
|
|
slot.set_index(index);
|
|
slot.set_index(index);
|
|
|
slots.push_back(slot);
|
|
slots.push_back(slot);
|
|
@@ -1360,6 +1379,9 @@ void EditorPropertyDictionary::update_property() {
|
|
|
dict_prop->set_preview_value(true);
|
|
dict_prop->set_preview_value(true);
|
|
|
}
|
|
}
|
|
|
slot.set_key_prop(new_prop);
|
|
slot.set_key_prop(new_prop);
|
|
|
|
|
+ if (slot.prop) {
|
|
|
|
|
+ slot.prop->add_inline_control(new_prop, INLINE_CONTROL_LEFT);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1395,10 +1417,22 @@ void EditorPropertyDictionary::update_property() {
|
|
|
new_prop->connect(SNAME("object_id_selected"), callable_mp(this, &EditorPropertyDictionary::_object_id_selected));
|
|
new_prop->connect(SNAME("object_id_selected"), callable_mp(this, &EditorPropertyDictionary::_object_id_selected));
|
|
|
new_prop->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
new_prop->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
if (slot.index != EditorPropertyDictionaryObject::NEW_KEY_INDEX && slot.index != EditorPropertyDictionaryObject::NEW_VALUE_INDEX) {
|
|
if (slot.index != EditorPropertyDictionaryObject::NEW_KEY_INDEX && slot.index != EditorPropertyDictionaryObject::NEW_VALUE_INDEX) {
|
|
|
- new_prop->set_draw_label(false);
|
|
|
|
|
|
|
+ new_prop->set_label(" ");
|
|
|
|
|
+ new_prop->set_label_overlayed(true);
|
|
|
}
|
|
}
|
|
|
new_prop->set_read_only(is_read_only());
|
|
new_prop->set_read_only(is_read_only());
|
|
|
|
|
+ if (slot.remove_button) {
|
|
|
|
|
+ new_prop->add_inline_control(slot.remove_button, INLINE_CONTROL_RIGHT);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (slot.edit_button) {
|
|
|
|
|
+ new_prop->add_inline_control(slot.edit_button, INLINE_CONTROL_RIGHT);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (slot.prop_key) {
|
|
|
|
|
+ new_prop->add_inline_control(slot.prop_key, INLINE_CONTROL_LEFT);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
slot.set_prop(new_prop);
|
|
slot.set_prop(new_prop);
|
|
|
|
|
+
|
|
|
} else if (slot.index != EditorPropertyDictionaryObject::NEW_KEY_INDEX && slot.index != EditorPropertyDictionaryObject::NEW_VALUE_INDEX) {
|
|
} else if (slot.index != EditorPropertyDictionaryObject::NEW_KEY_INDEX && slot.index != EditorPropertyDictionaryObject::NEW_VALUE_INDEX) {
|
|
|
Variant key = dict.get_key_at_index(slot.index);
|
|
Variant key = dict.get_key_at_index(slot.index);
|
|
|
String cs = key.get_construct_string();
|
|
String cs = key.get_construct_string();
|