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.cpp40
1 files changed, 24 insertions, 16 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index c8baecaaaf..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;
@@ -1222,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);
@@ -1340,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
@@ -1543,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();
}
@@ -1551,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();
}
}
@@ -1608,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.
@@ -3086,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);
+ }
}
}
@@ -3568,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);
}