Rename ShortCut to Shortcut which is more grammatically correct

See https://github.com/godotengine/godot/issues/16863#issuecomment-685236980.
This commit is contained in:
Hugo Locurcio 2020-09-09 21:53:24 +02:00
parent 7015c59e2e
commit 3e0226515e
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
17 changed files with 99 additions and 98 deletions

View file

@ -65,8 +65,8 @@
<member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false">
If [code]true[/code], the button's state is pressed. Means the button is pressed down or toggled (if [member toggle_mode] is active).
</member>
<member name="shortcut" type="ShortCut" setter="set_shortcut" getter="get_shortcut">
[ShortCut] associated to the button.
<member name="shortcut" type="Shortcut" setter="set_shortcut" getter="get_shortcut">
[Shortcut] associated to the button.
</member>
<member name="shortcut_in_tooltip" type="bool" setter="set_shortcut_in_tooltip" getter="is_shortcut_in_tooltip_enabled" default="true">
If [code]true[/code], the button will add information about its shortcut in the tooltip.

View file

@ -29,14 +29,14 @@
<method name="add_check_shortcut">
<return type="void">
</return>
<argument index="0" name="shortcut" type="ShortCut">
<argument index="0" name="shortcut" type="Shortcut">
</argument>
<argument index="1" name="id" type="int" default="-1">
</argument>
<argument index="2" name="global" type="bool" default="false">
</argument>
<description>
Adds a new checkable item and assigns the specified [ShortCut] to it. Sets the label of the checkbox to the [ShortCut]'s name.
Adds a new checkable item and assigns the specified [Shortcut] to it. Sets the label of the checkbox to the [Shortcut]'s name.
An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
[b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] for more info on how to control it.
</description>
@ -63,14 +63,14 @@
</return>
<argument index="0" name="texture" type="Texture2D">
</argument>
<argument index="1" name="shortcut" type="ShortCut">
<argument index="1" name="shortcut" type="Shortcut">
</argument>
<argument index="2" name="id" type="int" default="-1">
</argument>
<argument index="3" name="global" type="bool" default="false">
</argument>
<description>
Adds a new checkable item and assigns the specified [ShortCut] and icon [code]texture[/code] to it. Sets the label of the checkbox to the [ShortCut]'s name.
Adds a new checkable item and assigns the specified [Shortcut] and icon [code]texture[/code] to it. Sets the label of the checkbox to the [Shortcut]'s name.
An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
[b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] for more info on how to control it.
</description>
@ -111,7 +111,7 @@
</return>
<argument index="0" name="texture" type="Texture2D">
</argument>
<argument index="1" name="shortcut" type="ShortCut">
<argument index="1" name="shortcut" type="Shortcut">
</argument>
<argument index="2" name="id" type="int" default="-1">
</argument>
@ -126,14 +126,14 @@
</return>
<argument index="0" name="texture" type="Texture2D">
</argument>
<argument index="1" name="shortcut" type="ShortCut">
<argument index="1" name="shortcut" type="Shortcut">
</argument>
<argument index="2" name="id" type="int" default="-1">
</argument>
<argument index="3" name="global" type="bool" default="false">
</argument>
<description>
Adds a new item and assigns the specified [ShortCut] and icon [code]texture[/code] to it. Sets the label of the checkbox to the [ShortCut]'s name.
Adds a new item and assigns the specified [Shortcut] and icon [code]texture[/code] to it. Sets the label of the checkbox to the [Shortcut]'s name.
An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
</description>
</method>
@ -188,14 +188,14 @@
<method name="add_radio_check_shortcut">
<return type="void">
</return>
<argument index="0" name="shortcut" type="ShortCut">
<argument index="0" name="shortcut" type="Shortcut">
</argument>
<argument index="1" name="id" type="int" default="-1">
</argument>
<argument index="2" name="global" type="bool" default="false">
</argument>
<description>
Adds a new radio check button and assigns a [ShortCut] to it. Sets the label of the checkbox to the [ShortCut]'s name.
Adds a new radio check button and assigns a [Shortcut] to it. Sets the label of the checkbox to the [Shortcut]'s name.
An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
[b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] for more info on how to control it.
</description>
@ -212,14 +212,14 @@
<method name="add_shortcut">
<return type="void">
</return>
<argument index="0" name="shortcut" type="ShortCut">
<argument index="0" name="shortcut" type="Shortcut">
</argument>
<argument index="1" name="id" type="int" default="-1">
</argument>
<argument index="2" name="global" type="bool" default="false">
</argument>
<description>
Adds a [ShortCut].
Adds a [Shortcut].
An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
</description>
</method>
@ -303,12 +303,12 @@
</description>
</method>
<method name="get_item_shortcut" qualifiers="const">
<return type="ShortCut">
<return type="Shortcut">
</return>
<argument index="0" name="idx" type="int">
</argument>
<description>
Returns the [ShortCut] associated with the specified [code]idx[/code] item.
Returns the [Shortcut] associated with the specified [code]idx[/code] item.
</description>
</method>
<method name="get_item_submenu" qualifiers="const">
@ -521,12 +521,12 @@
</return>
<argument index="0" name="idx" type="int">
</argument>
<argument index="1" name="shortcut" type="ShortCut">
<argument index="1" name="shortcut" type="Shortcut">
</argument>
<argument index="2" name="global" type="bool" default="false">
</argument>
<description>
Sets a [ShortCut] for the specified item [code]idx[/code].
Sets a [Shortcut] for the specified item [code]idx[/code].
</description>
</method>
<method name="set_item_shortcut_disabled">
@ -537,7 +537,7 @@
<argument index="1" name="disabled" type="bool">
</argument>
<description>
Disables the [ShortCut] of the specified index [code]idx[/code].
Disables the [Shortcut] of the specified index [code]idx[/code].
</description>
</method>
<method name="set_item_submenu">

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="ShortCut" inherits="Resource" version="4.0">
<class name="Shortcut" inherits="Resource" version="4.0">
<brief_description>
A shortcut for binding input.
</brief_description>

View file

@ -2819,9 +2819,9 @@ void EditorNode::_discard_changes(const String &p_str) {
}
void EditorNode::_update_file_menu_opened() {
Ref<ShortCut> close_scene_sc = ED_GET_SHORTCUT("editor/close_scene");
Ref<Shortcut> close_scene_sc = ED_GET_SHORTCUT("editor/close_scene");
close_scene_sc->set_name(TTR("Close Scene"));
Ref<ShortCut> reopen_closed_scene_sc = ED_GET_SHORTCUT("editor/reopen_closed_scene");
Ref<Shortcut> reopen_closed_scene_sc = ED_GET_SHORTCUT("editor/reopen_closed_scene");
reopen_closed_scene_sc->set_name(TTR("Reopen Closed Scene"));
PopupMenu *pop = file_menu->get_popup();
pop->set_item_disabled(pop->get_item_index(FILE_OPEN_PREV), previous_scenes.empty());
@ -4714,10 +4714,10 @@ void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) {
scene_tabs_context_menu->add_item(TTR("Play This Scene"), RUN_PLAY_SCENE);
scene_tabs_context_menu->add_separator();
Ref<ShortCut> close_tab_sc = ED_GET_SHORTCUT("editor/close_scene");
Ref<Shortcut> close_tab_sc = ED_GET_SHORTCUT("editor/close_scene");
close_tab_sc->set_name(TTR("Close Tab"));
scene_tabs_context_menu->add_shortcut(close_tab_sc, FILE_CLOSE);
Ref<ShortCut> undo_close_tab_sc = ED_GET_SHORTCUT("editor/reopen_closed_scene");
Ref<Shortcut> undo_close_tab_sc = ED_GET_SHORTCUT("editor/reopen_closed_scene");
undo_close_tab_sc->set_name(TTR("Undo Close Tab"));
scene_tabs_context_menu->add_shortcut(undo_close_tab_sc, FILE_OPEN_PREV);
if (previous_scenes.empty()) {

View file

@ -77,7 +77,7 @@ bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value)
String name = arr[i];
Ref<InputEvent> shortcut = arr[i + 1];
Ref<ShortCut> sc;
Ref<Shortcut> sc;
sc.instance();
sc->set_shortcut(shortcut);
add_shortcut(name, sc);
@ -120,8 +120,8 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name.operator String() == "shortcuts") {
Array arr;
for (const Map<String, Ref<ShortCut>>::Element *E = shortcuts.front(); E; E = E->next()) {
Ref<ShortCut> sc = E->get();
for (const Map<String, Ref<Shortcut>>::Element *E = shortcuts.front(); E; E = E->next()) {
Ref<Shortcut> sc = E->get();
if (optimize_save) {
if (!sc->has_meta("original")) {
@ -1481,50 +1481,50 @@ String EditorSettings::get_editor_layouts_config() const {
// Shortcuts
void EditorSettings::add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcut) {
void EditorSettings::add_shortcut(const String &p_name, Ref<Shortcut> &p_shortcut) {
shortcuts[p_name] = p_shortcut;
}
bool EditorSettings::is_shortcut(const String &p_name, const Ref<InputEvent> &p_event) const {
const Map<String, Ref<ShortCut>>::Element *E = shortcuts.find(p_name);
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);
}
Ref<ShortCut> EditorSettings::get_shortcut(const String &p_name) const {
const Map<String, Ref<ShortCut>>::Element *E = shortcuts.find(p_name);
Ref<Shortcut> EditorSettings::get_shortcut(const String &p_name) const {
const Map<String, Ref<Shortcut>>::Element *E = shortcuts.find(p_name);
if (!E) {
return Ref<ShortCut>();
return Ref<Shortcut>();
}
return E->get();
}
void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) {
for (const Map<String, Ref<ShortCut>>::Element *E = shortcuts.front(); E; E = E->next()) {
for (const Map<String, Ref<Shortcut>>::Element *E = shortcuts.front(); E; E = E->next()) {
r_shortcuts->push_back(E->key());
}
}
Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) {
Ref<Shortcut> ED_GET_SHORTCUT(const String &p_path) {
if (!EditorSettings::get_singleton()) {
return nullptr;
}
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
ERR_FAIL_COND_V_MSG(!sc.is_valid(), sc, "Used ED_GET_SHORTCUT with invalid shortcut: " + p_path + ".");
return sc;
}
struct ShortCutMapping {
struct ShortcutMapping {
const char *path;
uint32_t keycode;
};
Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode) {
Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode) {
#ifdef OSX_ENABLED
// Use Cmd+Backspace as a general replacement for Delete shortcuts on macOS
if (p_keycode == KEY_DELETE) {
@ -1545,7 +1545,7 @@ Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p
}
if (!EditorSettings::get_singleton()) {
Ref<ShortCut> sc;
Ref<Shortcut> sc;
sc.instance();
sc->set_name(p_name);
sc->set_shortcut(ie);
@ -1553,7 +1553,7 @@ Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p
return sc;
}
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
if (sc.is_valid()) {
sc->set_name(p_name); //keep name (the ones that come from disk have no name)
sc->set_meta("original", ie); //to compare against changes

View file

@ -85,7 +85,7 @@ private:
int last_order;
Ref<Resource> clipboard;
Map<String, Ref<ShortCut>> shortcuts;
Map<String, Ref<Shortcut>> shortcuts;
String resource_path;
String settings_dir;
@ -182,9 +182,9 @@ public:
Vector<String> get_script_templates(const String &p_extension, const String &p_custom_path = String());
String get_editor_layouts_config() const;
void add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcut);
void add_shortcut(const String &p_name, Ref<Shortcut> &p_shortcut);
bool is_shortcut(const String &p_name, const Ref<InputEvent> &p_event) const;
Ref<ShortCut> get_shortcut(const String &p_name) const;
Ref<Shortcut> get_shortcut(const String &p_name) const;
void get_shortcut_list(List<String> *r_shortcuts);
void notify_changes();
@ -203,7 +203,7 @@ Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default, bool p_re
Variant _EDITOR_GET(const String &p_setting);
#define ED_IS_SHORTCUT(p_name, p_ev) (EditorSettings::get_singleton()->is_shortcut(p_name, p_ev))
Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode = 0);
Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path);
Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode = 0);
Ref<Shortcut> ED_GET_SHORTCUT(const String &p_path);
#endif // EDITOR_SETTINGS_H

View file

Before

Width:  |  Height:  |  Size: 382 B

After

Width:  |  Height:  |  Size: 382 B

View file

@ -400,11 +400,11 @@ private:
Ref<Texture2D> select_handle;
Ref<Texture2D> anchor_handle;
Ref<ShortCut> drag_pivot_shortcut;
Ref<ShortCut> set_pivot_shortcut;
Ref<ShortCut> multiply_grid_step_shortcut;
Ref<ShortCut> divide_grid_step_shortcut;
Ref<ShortCut> pan_view_shortcut;
Ref<Shortcut> drag_pivot_shortcut;
Ref<Shortcut> set_pivot_shortcut;
Ref<Shortcut> multiply_grid_step_shortcut;
Ref<Shortcut> divide_grid_step_shortcut;
Ref<Shortcut> pan_view_shortcut;
bool _is_node_locked(const Node *p_node);
bool _is_node_movable(const Node *p_node, bool p_popup_warning = false);

View file

@ -2246,7 +2246,7 @@ Point2i Node3DEditorViewport::_get_warped_mouse_motion(const Ref<InputEventMouse
}
static bool is_shortcut_pressed(const String &p_path) {
Ref<ShortCut> shortcut = ED_GET_SHORTCUT(p_path);
Ref<Shortcut> shortcut = ED_GET_SHORTCUT(p_path);
if (shortcut.is_null()) {
return false;
}

View file

@ -202,7 +202,7 @@ void EditorSettingsDialog::_update_shortcuts() {
Map<String, TreeItem *> sections;
for (List<String>::Element *E = slist.front(); E; E = E->next()) {
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(E->get());
Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(E->get());
if (!sc->has_meta("original")) {
continue;
}
@ -268,7 +268,7 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column
ERR_FAIL_COND(!ti);
String item = ti->get_metadata(0);
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(item);
Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(item);
if (p_idx == 0) {
press_a_key_label->set_text(TTR("Press a Key..."));
@ -335,7 +335,7 @@ void EditorSettingsDialog::_press_a_key_confirm() {
ie->set_alt(last_wait_for_key->get_alt());
ie->set_metakey(last_wait_for_key->get_metakey());
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(shortcut_configured);
Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(shortcut_configured);
undo_redo->create_action(TTR("Change Shortcut") + " '" + shortcut_configured + "'");
undo_redo->add_do_method(sc.ptr(), "set_shortcut", ie);

View file

@ -326,12 +326,12 @@ bool BaseButton::is_keep_pressed_outside() const {
return keep_pressed_outside;
}
void BaseButton::set_shortcut(const Ref<ShortCut> &p_shortcut) {
void BaseButton::set_shortcut(const Ref<Shortcut> &p_shortcut) {
shortcut = p_shortcut;
set_process_unhandled_input(shortcut.is_valid());
}
Ref<ShortCut> BaseButton::get_shortcut() const {
Ref<Shortcut> BaseButton::get_shortcut() const {
return shortcut;
}
@ -414,7 +414,7 @@ void BaseButton::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "button_mask", PROPERTY_HINT_FLAGS, "Mouse Left, Mouse Right, Mouse Middle"), "set_button_mask", "get_button_mask");
ADD_PROPERTY(PropertyInfo(Variant::INT, "enabled_focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), "set_enabled_focus_mode", "get_enabled_focus_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_pressed_outside"), "set_keep_pressed_outside", "is_keep_pressed_outside");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shortcut", PROPERTY_HINT_RESOURCE_TYPE, "ShortCut"), "set_shortcut", "get_shortcut");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shortcut", PROPERTY_HINT_RESOURCE_TYPE, "Shortcut"), "set_shortcut", "get_shortcut");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "group", PROPERTY_HINT_RESOURCE_TYPE, "ButtonGroup"), "set_button_group", "get_button_group");
BIND_ENUM_CONSTANT(DRAW_NORMAL);

View file

@ -50,7 +50,7 @@ private:
bool shortcut_in_tooltip;
bool keep_pressed_outside;
FocusMode enabled_focus_mode;
Ref<ShortCut> shortcut;
Ref<Shortcut> shortcut;
ActionMode action_mode;
struct Status {
@ -118,8 +118,8 @@ public:
void set_enabled_focus_mode(FocusMode p_mode);
FocusMode get_enabled_focus_mode() const;
void set_shortcut(const Ref<ShortCut> &p_shortcut);
Ref<ShortCut> get_shortcut() const;
void set_shortcut(const Ref<Shortcut> &p_shortcut);
Ref<Shortcut> get_shortcut() const;
virtual String get_tooltip(const Point2 &p_pos) const override;

View file

@ -717,7 +717,7 @@ void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int
}
#define ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global) \
ERR_FAIL_COND_MSG(p_shortcut.is_null(), "Cannot add item with invalid ShortCut."); \
ERR_FAIL_COND_MSG(p_shortcut.is_null(), "Cannot add item with invalid Shortcut."); \
_ref_shortcut(p_shortcut); \
item.text = p_shortcut->get_name(); \
item.xl_text = tr(item.text); \
@ -725,7 +725,7 @@ void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int
item.shortcut = p_shortcut; \
item.shortcut_is_global = p_global;
void PopupMenu::add_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
void PopupMenu::add_shortcut(const Ref<Shortcut> &p_shortcut, int p_id, bool p_global) {
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
items.push_back(item);
@ -733,7 +733,7 @@ void PopupMenu::add_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_g
child_controls_changed();
}
void PopupMenu::add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
void PopupMenu::add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id, bool p_global) {
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.icon = p_icon;
@ -742,7 +742,7 @@ void PopupMenu::add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortC
child_controls_changed();
}
void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
void PopupMenu::add_check_shortcut(const Ref<Shortcut> &p_shortcut, int p_id, bool p_global) {
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
@ -751,7 +751,7 @@ void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bo
child_controls_changed();
}
void PopupMenu::add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
void PopupMenu::add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id, bool p_global) {
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.icon = p_icon;
@ -761,7 +761,7 @@ void PopupMenu::add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<
child_controls_changed();
}
void PopupMenu::add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
void PopupMenu::add_radio_check_shortcut(const Ref<Shortcut> &p_shortcut, int p_id, bool p_global) {
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
@ -770,7 +770,7 @@ void PopupMenu::add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_
child_controls_changed();
}
void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id, bool p_global) {
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.icon = p_icon;
@ -931,8 +931,8 @@ String PopupMenu::get_item_tooltip(int p_idx) const {
return items[p_idx].tooltip;
}
Ref<ShortCut> PopupMenu::get_item_shortcut(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<ShortCut>());
Ref<Shortcut> PopupMenu::get_item_shortcut(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Shortcut>());
return items[p_idx].shortcut;
}
@ -970,7 +970,7 @@ void PopupMenu::set_item_tooltip(int p_idx, const String &p_tooltip) {
control->update();
}
void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut> &p_shortcut, bool p_global) {
void PopupMenu::set_item_shortcut(int p_idx, const Ref<Shortcut> &p_shortcut, bool p_global) {
ERR_FAIL_INDEX(p_idx, items.size());
if (items[p_idx].shortcut.is_valid()) {
_unref_shortcut(items[p_idx].shortcut);
@ -1209,7 +1209,7 @@ Array PopupMenu::_get_items() const {
return items;
}
void PopupMenu::_ref_shortcut(Ref<ShortCut> p_sc) {
void PopupMenu::_ref_shortcut(Ref<Shortcut> p_sc) {
if (!shortcut_refcount.has(p_sc)) {
shortcut_refcount[p_sc] = 1;
p_sc->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update));
@ -1218,7 +1218,7 @@ void PopupMenu::_ref_shortcut(Ref<ShortCut> p_sc) {
}
}
void PopupMenu::_unref_shortcut(Ref<ShortCut> p_sc) {
void PopupMenu::_unref_shortcut(Ref<Shortcut> p_sc) {
ERR_FAIL_COND(!shortcut_refcount.has(p_sc));
shortcut_refcount[p_sc]--;
if (shortcut_refcount[p_sc] == 0) {

View file

@ -61,7 +61,7 @@ class PopupMenu : public Popup {
int _ofs_cache;
int _height_cache;
int h_ofs;
Ref<ShortCut> shortcut;
Ref<Shortcut> shortcut;
bool shortcut_is_global;
bool shortcut_is_disabled;
@ -114,10 +114,10 @@ class PopupMenu : public Popup {
Array _get_items() const;
void _set_items(const Array &p_items);
Map<Ref<ShortCut>, int> shortcut_refcount;
Map<Ref<Shortcut>, int> shortcut_refcount;
void _ref_shortcut(Ref<ShortCut> p_sc);
void _unref_shortcut(Ref<ShortCut> p_sc);
void _ref_shortcut(Ref<Shortcut> p_sc);
void _unref_shortcut(Ref<Shortcut> p_sc);
bool allow_search;
uint64_t search_time_msec;
@ -145,12 +145,12 @@ public:
void add_multistate_item(const String &p_label, int p_max_states, int p_default_state = 0, int p_id = -1, uint32_t p_accel = 0);
void add_shortcut(const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false);
void add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false);
void add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false);
void add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false);
void add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false);
void add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false);
void add_shortcut(const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false);
void add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false);
void add_check_shortcut(const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false);
void add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false);
void add_radio_check_shortcut(const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false);
void add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false);
void add_submenu_item(const String &p_label, const String &p_submenu, int p_id = -1);
@ -166,7 +166,7 @@ public:
void set_item_as_checkable(int p_idx, bool p_checkable);
void set_item_as_radio_checkable(int p_idx, bool p_radio_checkable);
void set_item_tooltip(int p_idx, const String &p_tooltip);
void set_item_shortcut(int p_idx, const Ref<ShortCut> &p_shortcut, bool p_global = false);
void set_item_shortcut(int p_idx, const Ref<Shortcut> &p_shortcut, bool p_global = false);
void set_item_h_offset(int p_idx, int p_offset);
void set_item_multistate(int p_idx, int p_state);
void toggle_item_multistate(int p_idx);
@ -189,7 +189,7 @@ public:
bool is_item_radio_checkable(int p_idx) const;
bool is_item_shortcut_disabled(int p_idx) const;
String get_item_tooltip(int p_idx) const;
Ref<ShortCut> get_item_shortcut(int p_idx) const;
Ref<Shortcut> get_item_shortcut(int p_idx) const;
int get_item_state(int p_idx) const;
int get_current_index() const;

View file

@ -32,20 +32,20 @@
#include "core/os/keyboard.h"
void ShortCut::set_shortcut(const Ref<InputEvent> &p_shortcut) {
void Shortcut::set_shortcut(const Ref<InputEvent> &p_shortcut) {
shortcut = p_shortcut;
emit_changed();
}
Ref<InputEvent> ShortCut::get_shortcut() const {
Ref<InputEvent> Shortcut::get_shortcut() const {
return shortcut;
}
bool ShortCut::is_shortcut(const Ref<InputEvent> &p_event) const {
bool Shortcut::is_shortcut(const Ref<InputEvent> &p_event) const {
return shortcut.is_valid() && shortcut->shortcut_match(p_event);
}
String ShortCut::get_as_text() const {
String Shortcut::get_as_text() const {
if (shortcut.is_valid()) {
return shortcut->as_text();
} else {
@ -53,21 +53,21 @@ String ShortCut::get_as_text() const {
}
}
bool ShortCut::is_valid() const {
bool Shortcut::is_valid() const {
return shortcut.is_valid();
}
void ShortCut::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_shortcut", "event"), &ShortCut::set_shortcut);
ClassDB::bind_method(D_METHOD("get_shortcut"), &ShortCut::get_shortcut);
void Shortcut::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_shortcut", "event"), &Shortcut::set_shortcut);
ClassDB::bind_method(D_METHOD("get_shortcut"), &Shortcut::get_shortcut);
ClassDB::bind_method(D_METHOD("is_valid"), &ShortCut::is_valid);
ClassDB::bind_method(D_METHOD("is_valid"), &Shortcut::is_valid);
ClassDB::bind_method(D_METHOD("is_shortcut", "event"), &ShortCut::is_shortcut);
ClassDB::bind_method(D_METHOD("get_as_text"), &ShortCut::get_as_text);
ClassDB::bind_method(D_METHOD("is_shortcut", "event"), &Shortcut::is_shortcut);
ClassDB::bind_method(D_METHOD("get_as_text"), &Shortcut::get_as_text);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shortcut", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), "set_shortcut", "get_shortcut");
}
ShortCut::ShortCut() {
Shortcut::Shortcut() {
}

View file

@ -34,8 +34,8 @@
#include "core/input/input_event.h"
#include "core/resource.h"
class ShortCut : public Resource {
GDCLASS(ShortCut, Resource);
class Shortcut : public Resource {
GDCLASS(Shortcut, Resource);
Ref<InputEvent> shortcut;
@ -50,7 +50,7 @@ public:
String get_as_text() const;
ShortCut();
Shortcut();
};
#endif // SHORTCUT_H

View file

@ -295,7 +295,7 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
ClassDB::register_class<ShortCut>();
ClassDB::register_class<Shortcut>();
ClassDB::register_class<Control>();
ClassDB::register_class<Button>();
ClassDB::register_class<Label>();
@ -871,6 +871,7 @@ void register_scene_types() {
ClassDB::add_compatibility_class("RemoteTransform", "RemoteTransform3D");
ClassDB::add_compatibility_class("RigidBody", "RigidBody3D");
ClassDB::add_compatibility_class("Shape", "Shape3D");
ClassDB::add_compatibility_class("ShortCut", "Shortcut");
ClassDB::add_compatibility_class("Skeleton", "Skeleton3D");
ClassDB::add_compatibility_class("SkeletonIK", "SkeletonIK3D");
ClassDB::add_compatibility_class("SliderJoint", "SliderJoint3D");