summaryrefslogtreecommitdiff
path: root/editor/editor_inspector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_inspector.cpp')
-rw-r--r--editor/editor_inspector.cpp67
1 files changed, 43 insertions, 24 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 4ffa90777c..e1fae47057 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -571,7 +571,7 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) {
if (is_layout_rtl()) {
mpos.x = get_size().x - mpos.x;
}
- bool button_left = me->get_button_mask() & MOUSE_BUTTON_MASK_LEFT;
+ bool button_left = (me->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE;
bool new_keying_hover = keying_rect.has_point(mpos) && !button_left;
if (new_keying_hover != keying_hover) {
@@ -600,7 +600,7 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
Vector2 mpos = mb->get_position();
if (is_layout_rtl()) {
mpos.x = get_size().x - mpos.x;
@@ -647,10 +647,10 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) {
update();
emit_signal(SNAME("property_checked"), property, checked);
}
- } else if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
+ } else if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) {
_update_popup();
menu->set_position(get_screen_position() + get_local_mouse_position());
- menu->set_size(Vector2(1, 1));
+ menu->reset_size();
menu->popup();
select();
return;
@@ -1014,11 +1014,15 @@ bool EditorInspectorPlugin::can_handle(Object *p_object) {
}
void EditorInspectorPlugin::parse_begin(Object *p_object) {
- GDVIRTUAL_CALL(_parse_begin);
+ GDVIRTUAL_CALL(_parse_begin, p_object);
}
-void EditorInspectorPlugin::parse_category(Object *p_object, const String &p_parse_category) {
- GDVIRTUAL_CALL(_parse_category, p_object, p_parse_category);
+void EditorInspectorPlugin::parse_category(Object *p_object, const String &p_category) {
+ GDVIRTUAL_CALL(_parse_category, p_object, p_category);
+}
+
+void EditorInspectorPlugin::parse_group(Object *p_object, const String &p_group) {
+ GDVIRTUAL_CALL(_parse_group, p_object, p_group);
}
bool EditorInspectorPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
@@ -1029,8 +1033,8 @@ bool EditorInspectorPlugin::parse_property(Object *p_object, const Variant::Type
return false;
}
-void EditorInspectorPlugin::parse_end() {
- GDVIRTUAL_CALL(_parse_end);
+void EditorInspectorPlugin::parse_end(Object *p_object) {
+ GDVIRTUAL_CALL(_parse_end, p_object);
}
void EditorInspectorPlugin::_bind_methods() {
@@ -1039,10 +1043,11 @@ void EditorInspectorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_property_editor_for_multiple_properties", "label", "properties", "editor"), &EditorInspectorPlugin::add_property_editor_for_multiple_properties);
GDVIRTUAL_BIND(_can_handle, "object")
- GDVIRTUAL_BIND(_parse_begin)
+ GDVIRTUAL_BIND(_parse_begin, "object")
GDVIRTUAL_BIND(_parse_category, "object", "category")
+ GDVIRTUAL_BIND(_parse_group, "object", "group")
GDVIRTUAL_BIND(_parse_property, "object", "type", "name", "hint_type", "hint_string", "usage_flags", "wide");
- GDVIRTUAL_BIND(_parse_end)
+ GDVIRTUAL_BIND(_parse_end, "object")
}
////////////////////////////////////////////////
@@ -1217,7 +1222,7 @@ void EditorInspectorSection::_notification(int p_what) {
Color c = bg_color;
c.a *= 0.4;
if (foldable && header_rect.has_point(get_local_mouse_position())) {
- c = c.lightened(Input::get_singleton()->is_mouse_button_pressed(MOUSE_BUTTON_LEFT) ? -0.05 : 0.2);
+ c = c.lightened(Input::get_singleton()->is_mouse_button_pressed(MouseButton::LEFT) ? -0.05 : 0.2);
}
draw_rect(header_rect, c);
@@ -1335,7 +1340,7 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
}
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree"));
int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree"));
if (mb->get_position().y > font->get_height(font_size)) { //clicked outside
@@ -1538,7 +1543,7 @@ void EditorInspectorArray::_panel_gui_input(Ref<InputEvent> p_event, int p_index
if (key_ref.is_valid()) {
const InputEventKey &key = **key_ref;
- if (array_elements[p_index].panel->has_focus() && key.is_pressed() && key.get_keycode() == KEY_DELETE) {
+ if (array_elements[p_index].panel->has_focus() && key.is_pressed() && key.get_keycode() == Key::KEY_DELETE) {
_move_element(begin_array_index + p_index, -1);
array_elements[p_index].panel->accept_event();
}
@@ -1546,12 +1551,12 @@ void EditorInspectorArray::_panel_gui_input(Ref<InputEvent> p_event, int p_index
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
- if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
+ if (mb->get_button_index() == MouseButton::RIGHT) {
popup_array_index_pressed = begin_array_index + p_index;
rmb_popup->set_item_disabled(OPTION_MOVE_UP, popup_array_index_pressed == 0);
rmb_popup->set_item_disabled(OPTION_MOVE_DOWN, popup_array_index_pressed == count - 1);
rmb_popup->set_position(mb->get_global_position());
- rmb_popup->set_size(Vector2());
+ rmb_popup->reset_size();
rmb_popup->popup();
}
}
@@ -1603,11 +1608,11 @@ void EditorInspectorArray::_move_element(int p_element_index, int p_to_pos) {
properties_as_array.insert(p_to_pos < 0 ? properties_as_array.size() : p_to_pos, Dictionary());
} else if (p_to_pos < 0) {
// Delete the element.
- properties_as_array.remove(p_element_index);
+ properties_as_array.remove_at(p_element_index);
} else {
// Move the element.
properties_as_array.insert(p_to_pos, properties_as_array[p_element_index].duplicate());
- properties_as_array.remove(p_to_pos < p_element_index ? p_element_index + 1 : p_element_index);
+ properties_as_array.remove_at(p_to_pos < p_element_index ? p_element_index + 1 : p_element_index);
}
// Change the array size then set the properties.
@@ -2628,6 +2633,12 @@ void EditorInspector::update_tree() {
c.a /= level;
section->setup(acc_path, component, object, c, use_folding);
+ // Add editors at the start of a group.
+ for (Ref<EditorInspectorPlugin> &ped : valid_plugins) {
+ ped->parse_group(object, path);
+ _parse_added_editors(section->get_vbox(), ped);
+ }
+
vbox_per_path[root_vbox][acc_path] = section->get_vbox();
}
@@ -2837,7 +2848,7 @@ void EditorInspector::update_tree() {
// Get the lists of to add at the end.
for (Ref<EditorInspectorPlugin> &ped : valid_plugins) {
- ped->parse_end();
+ ped->parse_end(object);
_parse_added_editors(main_vbox, ped);
}
}
@@ -3075,12 +3086,20 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo
} else {
undo_redo->create_action(vformat(TTR("Set %s"), p_name), UndoRedo::MERGE_ENDS);
undo_redo->add_do_property(object, p_name, p_value);
- undo_redo->add_undo_property(object, p_name, object->get(p_name));
+ bool valid = false;
+ Variant value = object->get(p_name, &valid);
+ if (valid) {
+ undo_redo->add_undo_property(object, p_name, value);
+ }
PropertyInfo prop_info;
if (ClassDB::get_property_info(object->get_class_name(), p_name, &prop_info)) {
for (const String &linked_prop : prop_info.linked_properties) {
- undo_redo->add_undo_property(object, linked_prop, object->get(linked_prop));
+ valid = false;
+ value = object->get(linked_prop, &valid);
+ if (valid) {
+ undo_redo->add_undo_property(object, linked_prop, value);
+ }
}
}
@@ -3557,7 +3576,7 @@ EditorInspector::EditorInspector() {
refresh_countdown = 0.33;
}
- ED_SHORTCUT("property_editor/copy_property", TTR("Copy Property"), KEY_MASK_CMD | KEY_C);
- ED_SHORTCUT("property_editor/paste_property", TTR("Paste Property"), KEY_MASK_CMD | KEY_V);
- ED_SHORTCUT("property_editor/copy_property_path", TTR("Copy Property Path"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_C);
+ ED_SHORTCUT("property_editor/copy_property", TTR("Copy Property"), KeyModifierMask::CMD | Key::C);
+ ED_SHORTCUT("property_editor/paste_property", TTR("Paste Property"), KeyModifierMask::CMD | Key::V);
+ ED_SHORTCUT("property_editor/copy_property_path", TTR("Copy Property Path"), KeyModifierMask::CMD | KeyModifierMask::SHIFT | Key::C);
}