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
|
|
|
*/
|
|
|
|
|
|
2013-05-07 18:32:37 +00:00
|
|
|
#include "BLI_utildefines.h"
|
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
|
|
|
|
|
|
|
|
struct EnumPropertyItem;
|
|
|
|
|
|
|
|
|
|
/* Key Configuration */
|
|
|
|
|
|
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);
|
|
|
|
|
void WM_keyconfig_update_tag(wmKeyMap *keymap, wmKeyMapItem *kmi);
|
|
|
|
|
void WM_keyconfig_update_operatortype();
|
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();
|
|
|
|
|
|
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
|
|
|
/* Keymap */
|
|
|
|
|
|
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 {
|
2022-04-04 13:47:06 +10:00
|
|
|
/** #wmKeyMapItem.type */
|
|
|
|
|
int16_t type;
|
|
|
|
|
/** #wmKeyMapItem.val */
|
|
|
|
|
int8_t value;
|
|
|
|
|
/** #wmKeyMapItem `ctrl, shift, alt, oskey` */
|
|
|
|
|
int8_t modifier;
|
|
|
|
|
/** #wmKeyMapItem.keymodifier */
|
|
|
|
|
int16_t keymodifier;
|
|
|
|
|
/** #wmKeyMapItem.direction */
|
|
|
|
|
int8_t direction;
|
2023-08-04 17:55:14 -04:00
|
|
|
};
|
2022-04-04 13:47:06 +10:00
|
|
|
|
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);
|
2023-05-07 15:22:58 +10:00
|
|
|
int WM_keymap_item_to_string(const wmKeyMapItem *kmi,
|
|
|
|
|
bool compact,
|
|
|
|
|
char *result,
|
|
|
|
|
int result_maxncpy);
|
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);
|
2023-09-13 14:49:58 +10:00
|
|
|
void WM_keymap_remove(wmKeyConfig *keyconfig, 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
|
|
|
|
2018-09-02 19:34:36 +10:00
|
|
|
/* keymap_utils.c */
|
|
|
|
|
|
2021-12-08 17:12:41 +11:00
|
|
|
/* Wrappers for #WM_keymap_add_item */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
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
|
|
|
/* Modal Keymap */
|
|
|
|
|
|
2022-01-07 11:38:08 +11:00
|
|
|
int WM_modalkeymap_items_to_string(
|
2023-08-04 17:55:14 -04:00
|
|
|
const wmKeyMap *km, int propvalue, bool compact, char *result, int result_maxncpy);
|
2022-01-07 11:38:08 +11:00
|
|
|
int WM_modalkeymap_operator_items_to_string(
|
2023-08-04 17:55:14 -04:00
|
|
|
wmOperatorType *ot, int propvalue, bool compact, char *result, int result_maxncpy);
|
|
|
|
|
char *WM_modalkeymap_operator_items_to_string_buf(wmOperatorType *ot,
|
2022-01-07 11:38:08 +11:00
|
|
|
int propvalue,
|
|
|
|
|
bool compact,
|
2023-05-07 15:22:58 +10:00
|
|
|
int result_maxncpy,
|
2017-11-06 00:04:46 +11:00
|
|
|
int *r_available_len,
|
|
|
|
|
char **r_result);
|
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
|
|
|
|
|
|
|
|
/* Keymap Editor */
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
/* Key Event */
|
|
|
|
|
|
2022-01-07 11:38:08 +11:00
|
|
|
const char *WM_key_event_string(short type, bool compact);
|
|
|
|
|
int WM_keymap_item_raw_to_string(short shift,
|
|
|
|
|
short ctrl,
|
|
|
|
|
short alt,
|
|
|
|
|
short oskey,
|
|
|
|
|
short keymodifier,
|
|
|
|
|
short val,
|
|
|
|
|
short type,
|
|
|
|
|
bool compact,
|
2017-11-06 00:04:46 +11:00
|
|
|
char *result,
|
2023-05-07 15:22:58 +10:00
|
|
|
int result_maxncpy);
|
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,
|
2021-11-05 14:56:22 +01:00
|
|
|
wmOperatorCallContext 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);
|
|
|
|
|
char *WM_key_event_operator_string(const bContext *C,
|
2014-01-28 03:52:21 +11:00
|
|
|
const char *opname,
|
2021-11-05 14:56:22 +01:00
|
|
|
wmOperatorCallContext opcontext,
|
2023-08-04 17:55:14 -04:00
|
|
|
IDProperty *properties,
|
2022-01-07 11:38:08 +11:00
|
|
|
bool is_strict,
|
2017-11-06 00:04:46 +11:00
|
|
|
char *result,
|
2023-05-07 15:22:58 +10:00
|
|
|
int result_maxncpy);
|
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);
|