2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2007 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup wm
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
*/
|
|
|
|
|
|
2024-02-07 14:22:54 +01:00
|
|
|
#include <optional>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_windowmanager_types.h"
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "WM_types.hh"
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2025-03-26 14:14:35 +11:00
|
|
|
#ifdef hyper /* MSVC defines. */
|
|
|
|
|
# undef hyper
|
|
|
|
|
#endif
|
|
|
|
|
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
struct EnumPropertyItem;
|
|
|
|
|
|
2024-03-09 23:25:40 +11:00
|
|
|
/* Key Configuration. */
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2023-08-04 17:55:14 -04:00
|
|
|
void WM_keyconfig_init(bContext *C);
|
|
|
|
|
void WM_keyconfig_reload(bContext *C);
|
2018-11-13 19:02:12 +01:00
|
|
|
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname, bool user_defined);
|
2023-08-31 17:33:19 +10:00
|
|
|
wmKeyConfig *WM_keyconfig_ensure(wmWindowManager *wm, const char *idname, bool user_defined);
|
2023-09-13 14:49:58 +10:00
|
|
|
void WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf);
|
2023-08-04 17:55:14 -04:00
|
|
|
void WM_keyconfig_clear(wmKeyConfig *keyconf);
|
|
|
|
|
void WM_keyconfig_free(wmKeyConfig *keyconf);
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2023-08-04 17:55:14 -04:00
|
|
|
void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname);
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2023-10-13 14:20:30 +11:00
|
|
|
/**
|
|
|
|
|
* \param keep_properties: When true, the properties for operators which cannot be found are kept.
|
|
|
|
|
* This is needed for operator reloading that validates key-map items for operators that may have
|
|
|
|
|
* their operators loaded back in the future, see: #113309.
|
|
|
|
|
*/
|
|
|
|
|
void WM_keyconfig_update_ex(wmWindowManager *wm, bool keep_properties);
|
2023-08-04 17:55:14 -04:00
|
|
|
void WM_keyconfig_update(wmWindowManager *wm);
|
2025-08-06 08:09:50 +00:00
|
|
|
void WM_keyconfig_update_on_startup(wmWindowManager *wm);
|
2023-08-04 17:55:14 -04:00
|
|
|
void WM_keyconfig_update_tag(wmKeyMap *keymap, wmKeyMapItem *kmi);
|
2025-08-06 18:03:16 +10:00
|
|
|
void WM_keyconfig_update_operatortype_tag();
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2023-09-17 13:23:24 +10:00
|
|
|
void WM_keyconfig_update_suppress_begin();
|
|
|
|
|
void WM_keyconfig_update_suppress_end();
|
|
|
|
|
|
2023-10-24 23:20:29 +11:00
|
|
|
void WM_keyconfig_update_postpone_begin();
|
|
|
|
|
void WM_keyconfig_update_postpone_end();
|
|
|
|
|
|
2024-03-09 23:25:40 +11:00
|
|
|
/** Keymap. */
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2022-04-04 13:47:06 +10:00
|
|
|
/** Parameters for matching events, passed into functions that create key-map items. */
|
2023-08-04 17:55:14 -04:00
|
|
|
struct KeyMapItem_Params {
|
2024-03-09 23:25:40 +11:00
|
|
|
/** #wmKeyMapItem.type. */
|
2022-04-04 13:47:06 +10:00
|
|
|
int16_t type;
|
2024-03-09 23:25:40 +11:00
|
|
|
/** #wmKeyMapItem.val. */
|
2022-04-04 13:47:06 +10:00
|
|
|
int8_t value;
|
2025-03-26 12:36:07 +11:00
|
|
|
/**
|
2025-03-26 23:29:33 +00:00
|
|
|
* This value is used to initialize #wmKeyMapItem `ctrl, shift, alt, oskey, hyper`.
|
2025-03-26 12:36:07 +11:00
|
|
|
*
|
2025-03-26 23:29:33 +00:00
|
|
|
* Valid values:
|
|
|
|
|
*
|
|
|
|
|
* - Combinations of: #KM_SHIFT, #KM_CTRL, #KM_ALT, #KM_OSKEY, #KM_HYPER.
|
|
|
|
|
* Are mapped to #KM_MOD_HELD.
|
|
|
|
|
* - Combinations of the modifier flags bit-shifted using #KMI_PARAMS_MOD_TO_ANY.
|
|
|
|
|
* Are mapped to #KM_ANY.
|
|
|
|
|
* - The value #KM_ANY is represents all modifiers being set to #KM_ANY.
|
2025-03-26 12:36:07 +11:00
|
|
|
*/
|
|
|
|
|
int16_t modifier;
|
|
|
|
|
|
2024-03-09 23:25:40 +11:00
|
|
|
/** #wmKeyMapItem.keymodifier. */
|
2022-04-04 13:47:06 +10:00
|
|
|
int16_t keymodifier;
|
2024-03-09 23:25:40 +11:00
|
|
|
/** #wmKeyMapItem.direction. */
|
2022-04-04 13:47:06 +10:00
|
|
|
int8_t direction;
|
2023-08-04 17:55:14 -04:00
|
|
|
};
|
2022-04-04 13:47:06 +10:00
|
|
|
|
2025-03-26 23:29:33 +00:00
|
|
|
/**
|
|
|
|
|
* Use to assign modifiers to #KeyMapItem_Params::modifier
|
|
|
|
|
* which can have any state (held or released).
|
|
|
|
|
*/
|
|
|
|
|
#define KMI_PARAMS_MOD_TO_ANY(mod) ((mod) << 8)
|
|
|
|
|
/**
|
|
|
|
|
* Use to read modifiers from #KeyMapItem_Params::modifier
|
|
|
|
|
* which can have any state (held or released).
|
|
|
|
|
*/
|
|
|
|
|
#define KMI_PARAMS_MOD_FROM_ANY(mod) ((mod) >> 8)
|
|
|
|
|
|
2023-08-04 17:55:14 -04:00
|
|
|
void WM_keymap_clear(wmKeyMap *keymap);
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2021-12-08 17:12:41 +11:00
|
|
|
/**
|
|
|
|
|
* Always add item.
|
|
|
|
|
*/
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap,
|
2022-03-02 15:07:00 +11:00
|
|
|
const char *idname,
|
2022-04-04 13:47:06 +10:00
|
|
|
const KeyMapItem_Params *params);
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMapItem *WM_keymap_add_item_copy(wmKeyMap *keymap, wmKeyMapItem *kmi_src);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-13 14:49:58 +10:00
|
|
|
void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi);
|
2024-02-07 14:22:54 +01:00
|
|
|
std::optional<std::string> WM_keymap_item_to_string(const wmKeyMapItem *kmi, bool compact);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid);
|
2018-11-27 17:33:52 +11:00
|
|
|
wmKeyMap *WM_keymap_list_find_spaceid_or_empty(ListBase *lb,
|
|
|
|
|
const char *idname,
|
|
|
|
|
int spaceid,
|
|
|
|
|
int regionid);
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMap *WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid);
|
|
|
|
|
wmKeyMap *WM_keymap_find_all(wmWindowManager *wm, const char *idname, int spaceid, int regionid);
|
|
|
|
|
wmKeyMap *WM_keymap_find_all_spaceid_or_empty(wmWindowManager *wm,
|
2018-11-27 17:33:52 +11:00
|
|
|
const char *idname,
|
|
|
|
|
int spaceid,
|
|
|
|
|
int regionid);
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMap *WM_keymap_active(const wmWindowManager *wm, wmKeyMap *keymap);
|
2024-07-27 13:20:43 +10:00
|
|
|
void WM_keymap_remove(wmKeyConfig *keyconf, wmKeyMap *keymap);
|
2023-08-04 17:55:14 -04:00
|
|
|
bool WM_keymap_poll(bContext *C, wmKeyMap *keymap);
|
2018-06-07 16:43:52 +02:00
|
|
|
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMapItem *WM_keymap_item_find_id(wmKeyMap *keymap, int id);
|
|
|
|
|
bool WM_keymap_item_compare(const wmKeyMapItem *k1, const wmKeyMapItem *k2);
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2025-02-23 21:05:19 +11:00
|
|
|
/**
|
|
|
|
|
* Return the user key-map item from `km_base` based on `km_match` & `kmi_match`,
|
|
|
|
|
* currently the supported use case is looking up "User" key-map items from "Add-on" key-maps.
|
|
|
|
|
* Other lookups may be supported.
|
|
|
|
|
*/
|
|
|
|
|
wmKeyMapItem *WM_keymap_item_find_match(wmKeyMap *km_base,
|
|
|
|
|
wmKeyMap *km_match,
|
|
|
|
|
wmKeyMapItem *kmi_match,
|
|
|
|
|
ReportList *reports);
|
|
|
|
|
|
2024-03-09 23:25:40 +11:00
|
|
|
/* `wm_keymap_utils.cc`. */
|
2018-09-02 19:34:36 +10:00
|
|
|
|
2024-03-09 23:25:40 +11:00
|
|
|
/* Wrappers for #WM_keymap_add_item. */
|
2021-12-08 17:12:41 +11:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Menu wrapper for #WM_keymap_add_item.
|
|
|
|
|
*/
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMapItem *WM_keymap_add_menu(wmKeyMap *keymap,
|
2022-03-02 15:07:00 +11:00
|
|
|
const char *idname,
|
2022-04-04 13:47:06 +10:00
|
|
|
const KeyMapItem_Params *params);
|
2021-12-08 17:12:41 +11:00
|
|
|
/**
|
|
|
|
|
* Pie-menu wrapper for #WM_keymap_add_item.
|
|
|
|
|
*/
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMapItem *WM_keymap_add_menu_pie(wmKeyMap *keymap,
|
2022-03-02 15:07:00 +11:00
|
|
|
const char *idname,
|
2022-04-04 13:47:06 +10:00
|
|
|
const KeyMapItem_Params *params);
|
2021-12-08 17:12:41 +11:00
|
|
|
/**
|
|
|
|
|
* Panel (popover) wrapper for #WM_keymap_add_item.
|
|
|
|
|
*/
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMapItem *WM_keymap_add_panel(wmKeyMap *keymap,
|
2022-03-02 15:07:00 +11:00
|
|
|
const char *idname,
|
2022-04-04 13:47:06 +10:00
|
|
|
const KeyMapItem_Params *params);
|
2021-12-08 17:12:41 +11:00
|
|
|
/**
|
|
|
|
|
* Tool wrapper for #WM_keymap_add_item.
|
|
|
|
|
*/
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMapItem *WM_keymap_add_tool(wmKeyMap *keymap,
|
2022-03-02 15:07:00 +11:00
|
|
|
const char *idname,
|
2022-04-04 13:47:06 +10:00
|
|
|
const KeyMapItem_Params *params);
|
2018-09-02 19:42:29 +10:00
|
|
|
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMap *WM_keymap_guess_from_context(const bContext *C);
|
2021-12-08 17:12:41 +11:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Guess an appropriate key-map from the operator name.
|
|
|
|
|
*
|
|
|
|
|
* \note Needs to be kept up to date with Key-map and Operator naming.
|
|
|
|
|
*/
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname);
|
2018-09-02 19:34:36 +10:00
|
|
|
|
2022-01-07 11:38:08 +11:00
|
|
|
bool WM_keymap_uses_event_modifier(const wmKeyMap *keymap, int event_modifier);
|
2019-05-28 14:33:13 +10:00
|
|
|
|
2023-08-04 17:55:14 -04:00
|
|
|
void WM_keymap_fix_linking();
|
2018-11-08 15:59:51 +11:00
|
|
|
|
2024-03-09 23:25:40 +11:00
|
|
|
/* Modal Keymap. */
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2024-02-07 14:22:54 +01:00
|
|
|
std::optional<std::string> WM_modalkeymap_items_to_string(const wmKeyMap *km,
|
|
|
|
|
int propvalue,
|
|
|
|
|
bool compact);
|
|
|
|
|
std::optional<std::string> WM_modalkeymap_operator_items_to_string(wmOperatorType *ot,
|
|
|
|
|
int propvalue,
|
|
|
|
|
bool compact);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMap *WM_modalkeymap_ensure(wmKeyConfig *keyconf,
|
2020-03-27 10:58:00 +11:00
|
|
|
const char *idname,
|
2023-08-04 17:55:14 -04:00
|
|
|
const EnumPropertyItem *items);
|
|
|
|
|
wmKeyMap *WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname);
|
|
|
|
|
wmKeyMapItem *WM_modalkeymap_add_item(wmKeyMap *km, const KeyMapItem_Params *params, int value);
|
|
|
|
|
wmKeyMapItem *WM_modalkeymap_add_item_str(wmKeyMap *km,
|
2022-04-04 13:47:06 +10:00
|
|
|
const KeyMapItem_Params *params,
|
2022-03-02 15:07:00 +11:00
|
|
|
const char *value);
|
2022-01-07 11:38:08 +11:00
|
|
|
const wmKeyMapItem *WM_modalkeymap_find_propvalue(const wmKeyMap *km, int propvalue);
|
2023-08-04 17:55:14 -04:00
|
|
|
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname);
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2024-03-09 23:25:40 +11:00
|
|
|
/* Keymap Editor. */
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2023-08-04 17:55:14 -04:00
|
|
|
void WM_keymap_restore_to_default(wmKeyMap *keymap, wmWindowManager *wm);
|
2021-12-08 17:12:41 +11:00
|
|
|
/**
|
|
|
|
|
* Properties can be NULL, otherwise the arg passed is used and ownership is given to the `kmi`.
|
|
|
|
|
*/
|
2023-08-04 17:55:14 -04:00
|
|
|
void WM_keymap_item_properties_reset(wmKeyMapItem *kmi, IDProperty *properties);
|
|
|
|
|
void WM_keymap_item_restore_to_default(wmWindowManager *wm, wmKeyMap *keymap, wmKeyMapItem *kmi);
|
|
|
|
|
int WM_keymap_item_map_type_get(const wmKeyMapItem *kmi);
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2024-03-09 23:25:40 +11:00
|
|
|
/* Key Event. */
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2022-01-07 11:38:08 +11:00
|
|
|
const char *WM_key_event_string(short type, bool compact);
|
2025-03-25 10:17:32 +11:00
|
|
|
std::optional<std::string> WM_keymap_item_raw_to_string(int8_t shift,
|
|
|
|
|
int8_t ctrl,
|
|
|
|
|
int8_t alt,
|
|
|
|
|
int8_t oskey,
|
2025-03-25 23:32:41 +00:00
|
|
|
int8_t hyper,
|
2024-02-07 14:22:54 +01:00
|
|
|
short keymodifier,
|
|
|
|
|
short val,
|
|
|
|
|
short type,
|
|
|
|
|
bool compact);
|
2021-12-08 17:12:41 +11:00
|
|
|
/**
|
|
|
|
|
* \param include_mask, exclude_mask:
|
|
|
|
|
* Event types to include/exclude when looking up keys (#eEventType_Mask).
|
|
|
|
|
*/
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMapItem *WM_key_event_operator(const bContext *C,
|
2018-12-12 21:39:55 +11:00
|
|
|
const char *opname,
|
2025-07-15 03:08:04 +02:00
|
|
|
blender::wm::OpCallContext opcontext,
|
2023-08-04 17:55:14 -04:00
|
|
|
IDProperty *properties,
|
2022-01-07 11:38:08 +11:00
|
|
|
short include_mask,
|
|
|
|
|
short exclude_mask,
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMap **r_keymap);
|
2024-02-07 14:22:54 +01:00
|
|
|
std::optional<std::string> WM_key_event_operator_string(const bContext *C,
|
|
|
|
|
const char *opname,
|
2025-07-15 03:08:04 +02:00
|
|
|
blender::wm::OpCallContext opcontext,
|
2024-02-07 14:22:54 +01:00
|
|
|
IDProperty *properties,
|
|
|
|
|
bool is_strict);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-08-04 17:55:14 -04:00
|
|
|
wmKeyMapItem *WM_key_event_operator_from_keymap(wmKeyMap *keymap,
|
2019-01-09 12:26:10 +11:00
|
|
|
const char *opname,
|
2023-08-04 17:55:14 -04:00
|
|
|
IDProperty *properties,
|
2022-01-07 11:38:08 +11:00
|
|
|
short include_mask,
|
|
|
|
|
short exclude_mask);
|
2019-01-09 12:26:10 +11:00
|
|
|
|
2013-10-13 00:32:31 +00:00
|
|
|
const char *WM_bool_as_string(bool test);
|