summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2021-08-03 17:27:45 +0200
committerRémi Verschelde <rverschelde@gmail.com>2021-08-05 13:48:43 +0200
commitde2c2be19bed9f78be627045fb671367b2b93122 (patch)
treecacdc888b9e0afa64d2b80b0d1faf8480064bd57 /editor
parent1eff610e2bd71521db6d0f4fee25a641e1c7bdd6 (diff)
Shortcut: Rename `shortcut` property to `event`
Having a property which has the same name as its class leads to confusing situations (e.g. `BaseButton` has a `shortcut` property of type `Shortcut` which has a `shortcut` property of type `InputEvent`). Also renames `is_event` to `matches_event`, and `is_valid` to `has_valid_event` to better reflect what the methods check.
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_bezier_editor.cpp4
-rw-r--r--editor/animation_track_editor.cpp6
-rw-r--r--editor/editor_settings.cpp18
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp26
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp2
-rw-r--r--editor/settings_config_dialog.cpp10
6 files changed, 33 insertions, 33 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp
index 1e3140e202..6ef36f16f5 100644
--- a/editor/animation_bezier_editor.cpp
+++ b/editor/animation_bezier_editor.cpp
@@ -605,12 +605,12 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
if (p_event->is_pressed()) {
- if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->is_shortcut(p_event)) {
+ if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->matches_event(p_event)) {
duplicate_selection();
accept_event();
}
- if (ED_GET_SHORTCUT("animation_editor/delete_selection")->is_shortcut(p_event)) {
+ if (ED_GET_SHORTCUT("animation_editor/delete_selection")->matches_event(p_event)) {
delete_selection();
accept_event();
}
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 91835c1866..c9d3df9ce2 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -2555,17 +2555,17 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
if (p_event->is_pressed()) {
- if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->is_shortcut(p_event)) {
+ if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->matches_event(p_event)) {
emit_signal(SNAME("duplicate_request"));
accept_event();
}
- if (ED_GET_SHORTCUT("animation_editor/duplicate_selection_transposed")->is_shortcut(p_event)) {
+ if (ED_GET_SHORTCUT("animation_editor/duplicate_selection_transposed")->matches_event(p_event)) {
emit_signal(SNAME("duplicate_transpose_request"));
accept_event();
}
- if (ED_GET_SHORTCUT("animation_editor/delete_selection")->is_shortcut(p_event)) {
+ if (ED_GET_SHORTCUT("animation_editor/delete_selection")->matches_event(p_event)) {
emit_signal(SNAME("delete_request"));
accept_event();
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index df4469b6fe..29ac836834 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -80,7 +80,7 @@ bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value)
Ref<Shortcut> sc;
sc.instantiate();
- sc->set_shortcut(shortcut);
+ sc->set_event(shortcut);
add_shortcut(name, sc);
}
@@ -153,13 +153,13 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const {
}
Ref<InputEvent> original = sc->get_meta("original");
- if (sc->is_shortcut(original) || (original.is_null() && sc->get_shortcut().is_null())) {
+ if (sc->matches_event(original) || (original.is_null() && sc->get_event().is_null())) {
continue; //not changed from default, don't save
}
}
arr.push_back(E->key());
- arr.push_back(sc->get_shortcut());
+ arr.push_back(sc->get_event());
}
r_ret = arr;
return true;
@@ -1457,7 +1457,7 @@ bool EditorSettings::is_shortcut(const String &p_name, const Ref<InputEvent> &p_
const Map<String, Ref<Shortcut>>::Element *E = shortcuts.find(p_name);
ERR_FAIL_COND_V_MSG(!E, false, "Unknown Shortcut: " + p_name + ".");
- return E->get()->is_shortcut(p_event);
+ return E->get()->matches_event(p_event);
}
Ref<Shortcut> EditorSettings::get_shortcut(const String &p_name) const {
@@ -1473,7 +1473,7 @@ Ref<Shortcut> EditorSettings::get_shortcut(const String &p_name) const {
const Map<String, List<Ref<InputEvent>>>::Element *builtin_override = builtin_action_overrides.find(p_name);
if (builtin_override) {
sc.instantiate();
- sc->set_shortcut(builtin_override->get().front()->get());
+ sc->set_event(builtin_override->get().front()->get());
sc->set_name(InputMap::get_singleton()->get_builtin_display_name(p_name));
}
@@ -1482,7 +1482,7 @@ Ref<Shortcut> EditorSettings::get_shortcut(const String &p_name) const {
const OrderedHashMap<String, List<Ref<InputEvent>>>::ConstElement builtin_default = InputMap::get_singleton()->get_builtins().find(p_name);
if (builtin_default) {
sc.instantiate();
- sc->set_shortcut(builtin_default.get().front()->get());
+ sc->set_event(builtin_default.get().front()->get());
sc->set_name(InputMap::get_singleton()->get_builtin_display_name(p_name));
}
}
@@ -1538,7 +1538,7 @@ Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p
Ref<Shortcut> sc;
sc.instantiate();
sc->set_name(p_name);
- sc->set_shortcut(ie);
+ sc->set_event(ie);
sc->set_meta("original", ie);
return sc;
}
@@ -1552,7 +1552,7 @@ Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p
sc.instantiate();
sc->set_name(p_name);
- sc->set_shortcut(ie);
+ sc->set_event(ie);
sc->set_meta("original", ie); //to compare against changes
EditorSettings::get_singleton()->add_shortcut(p_path, sc);
@@ -1600,7 +1600,7 @@ void EditorSettings::set_builtin_action_override(const String &p_name, const Arr
// Update the shortcut (if it is used somewhere in the editor) to be the first event of the new list.
if (shortcuts.has(p_name)) {
- shortcuts[p_name]->set_shortcut(event_list.front()->get());
+ shortcuts[p_name]->set_event(event_list.front()->get());
}
}
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 16e224b105..c440064898 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -486,11 +486,11 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
}
if (k->is_pressed() && !k->is_ctrl_pressed() && !k->is_echo()) {
- if ((grid_snap_active || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->is_shortcut(p_ev)) {
+ if ((grid_snap_active || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->matches_event(p_ev)) {
// Multiply the grid size
grid_step_multiplier = MIN(grid_step_multiplier + 1, 12);
viewport->update();
- } else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) {
+ } else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->matches_event(p_ev)) {
// Divide the grid size
Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1);
if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) {
@@ -1192,30 +1192,30 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
if (k->is_pressed()) {
- if (ED_GET_SHORTCUT("canvas_item_editor/zoom_3.125_percent")->is_shortcut(p_event)) {
+ if (ED_GET_SHORTCUT("canvas_item_editor/zoom_3.125_percent")->matches_event(p_event)) {
_update_zoom((1.0 / 32.0) * MAX(1, EDSCALE));
- } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_6.25_percent")->is_shortcut(p_event)) {
+ } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_6.25_percent")->matches_event(p_event)) {
_update_zoom((1.0 / 16.0) * MAX(1, EDSCALE));
- } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_12.5_percent")->is_shortcut(p_event)) {
+ } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_12.5_percent")->matches_event(p_event)) {
_update_zoom((1.0 / 8.0) * MAX(1, EDSCALE));
- } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_25_percent")->is_shortcut(p_event)) {
+ } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_25_percent")->matches_event(p_event)) {
_update_zoom((1.0 / 4.0) * MAX(1, EDSCALE));
- } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_50_percent")->is_shortcut(p_event)) {
+ } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_50_percent")->matches_event(p_event)) {
_update_zoom((1.0 / 2.0) * MAX(1, EDSCALE));
- } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_100_percent")->is_shortcut(p_event)) {
+ } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_100_percent")->matches_event(p_event)) {
_update_zoom(1.0 * MAX(1, EDSCALE));
- } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_200_percent")->is_shortcut(p_event)) {
+ } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_200_percent")->matches_event(p_event)) {
_update_zoom(2.0 * MAX(1, EDSCALE));
- } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_400_percent")->is_shortcut(p_event)) {
+ } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_400_percent")->matches_event(p_event)) {
_update_zoom(4.0 * MAX(1, EDSCALE));
- } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_800_percent")->is_shortcut(p_event)) {
+ } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_800_percent")->matches_event(p_event)) {
_update_zoom(8.0 * MAX(1, EDSCALE));
- } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_1600_percent")->is_shortcut(p_event)) {
+ } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_1600_percent")->matches_event(p_event)) {
_update_zoom(16.0 * MAX(1, EDSCALE));
}
}
- bool is_pan_key = pan_view_shortcut.is_valid() && pan_view_shortcut->is_shortcut(p_event);
+ bool is_pan_key = pan_view_shortcut.is_valid() && pan_view_shortcut->matches_event(p_event);
if (is_pan_key && (EditorSettings::get_singleton()->get("editors/2d/simple_panning") || drag_type != DRAG_NONE)) {
if (!panning) {
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 5f12294e22..e982625e2b 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -2454,7 +2454,7 @@ static bool is_shortcut_pressed(const String &p_path) {
if (shortcut.is_null()) {
return false;
}
- InputEventKey *k = Object::cast_to<InputEventKey>(shortcut->get_shortcut().ptr());
+ InputEventKey *k = Object::cast_to<InputEventKey>(shortcut->get_event().ptr());
if (k == nullptr) {
return false;
}
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index b3ec0c96c4..e7ba3daccd 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -209,7 +209,7 @@ void EditorSettingsDialog::_event_config_confirmed() {
undo_redo->create_action(TTR("Change Shortcut") + " '" + shortcut_being_edited + "'");
undo_redo->add_do_method(current_sc.ptr(), "set_shortcut", k);
- undo_redo->add_undo_method(current_sc.ptr(), "set_shortcut", current_sc->get_shortcut());
+ undo_redo->add_undo_method(current_sc.ptr(), "set_shortcut", current_sc->get_event());
undo_redo->add_do_method(this, "_update_shortcuts");
undo_redo->add_undo_method(this, "_update_shortcuts");
undo_redo->add_do_method(this, "_settings_changed");
@@ -361,7 +361,7 @@ void EditorSettingsDialog::_update_shortcuts() {
item->set_text(0, sc->get_name());
item->set_text(1, sc->get_as_text());
- if (!sc->is_shortcut(original) && !(sc->get_shortcut().is_null() && original.is_null())) {
+ if (!sc->matches_event(original) && !(sc->get_event().is_null() && original.is_null())) {
item->add_button(1, shortcuts->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), 2);
}
@@ -444,7 +444,7 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column
switch (button_idx) {
case EditorSettingsDialog::SHORTCUT_EDIT:
- shortcut_editor->popup_and_configure(sc->get_shortcut());
+ shortcut_editor->popup_and_configure(sc->get_event());
shortcut_being_edited = item;
break;
case EditorSettingsDialog::SHORTCUT_ERASE: {
@@ -454,7 +454,7 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column
undo_redo->create_action(TTR("Erase Shortcut"));
undo_redo->add_do_method(sc.ptr(), "set_shortcut", Ref<InputEvent>());
- undo_redo->add_undo_method(sc.ptr(), "set_shortcut", sc->get_shortcut());
+ undo_redo->add_undo_method(sc.ptr(), "set_shortcut", sc->get_event());
undo_redo->add_do_method(this, "_update_shortcuts");
undo_redo->add_undo_method(this, "_update_shortcuts");
undo_redo->add_do_method(this, "_settings_changed");
@@ -470,7 +470,7 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column
undo_redo->create_action(TTR("Restore Shortcut"));
undo_redo->add_do_method(sc.ptr(), "set_shortcut", original);
- undo_redo->add_undo_method(sc.ptr(), "set_shortcut", sc->get_shortcut());
+ undo_redo->add_undo_method(sc.ptr(), "set_shortcut", sc->get_event());
undo_redo->add_do_method(this, "_update_shortcuts");
undo_redo->add_undo_method(this, "_update_shortcuts");
undo_redo->add_do_method(this, "_settings_changed");