diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-07-03 16:07:46 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-07-03 16:55:22 +0300 |
commit | 947cdb3acd296d8e2e849586d5a41cc0d0dcb28c (patch) | |
tree | 36eb74d8f0185c747e50dc21c7087420d83afa47 /source/blender/editors | |
parent | 36426c3ee2d957c1898555f51ec828b31c5f746c (diff) |
UI: add ability to access/generate 'shortcuts strings' of modal keymaps.
We already had that for global keymaps (used e.g. to generate shortcuts for menu entries),
but this wasn’t possible for modal keymaps yet (e.g. help message in header during
transforms and other modal operation).
This commit only adds needing background code, it does not change anything from user PoV.
Modal operators will be updated to use it in comming weeks.
Thanks to Campbell for revisions & suggestions. :)
Differential Revision: https://developer.blender.org/D780
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/armature/pose_lib.c | 2 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tree.c | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 4 |
7 files changed, 9 insertions, 8 deletions
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index d571fb374d9..3ced37dcfb2 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -1196,7 +1196,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con /* only accept 'press' event, and ignore 'release', so that we don't get double actions */ if (ELEM(event->val, KM_PRESS, KM_NOTHING) == 0) { - //printf("PoseLib: skipping event with type '%s' and val %d\n", WM_key_event_string(event->type), event->val); + //printf("PoseLib: skipping event with type '%s' and val %d\n", WM_key_event_string(event->type, false), event->val); return ret; } diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index b5e1b9f08b1..bb6c9a1cb52 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -86,6 +86,7 @@ typedef struct uiLayout uiLayout; /* names */ #define UI_MAX_DRAW_STR 400 #define UI_MAX_NAME_STR 128 +#define UI_MAX_SHORTCUT_STR 64 /* use for clamping popups within the screen */ #define UI_SCREEN_MARGIN 10 diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index e045db8fdd2..1a62fb4b3ae 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2825,7 +2825,7 @@ void ui_but_update(uiBut *but) } else { UI_GET_BUT_VALUE_INIT(but, value); - str = WM_key_event_string((short)value); + str = WM_key_event_string((short)value, false); } BLI_snprintf(but->drawstr, UI_MAX_DRAW_STR, "%s%s", but->str, str); break; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 58cf6b900b9..c51d9906fa5 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3651,7 +3651,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data if (event->val == KM_PRESS) { if (ISHOTKEY(event->type)) { - if (WM_key_event_string(event->type)[0]) + if (WM_key_event_string(event->type, false)[0]) ui_but_value_set(but, event->type); else data->cancel = true; @@ -3687,7 +3687,7 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, c } if (event->val == KM_PRESS) { - if (WM_key_event_string(event->type)[0]) + if (WM_key_event_string(event->type, false)[0]) ui_but_value_set(but, event->type); else data->cancel = true; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index a61b208278d..0e30ba54d1c 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -668,7 +668,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n if (RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) { char buf[128]; - WM_keymap_item_to_string(ptr->data, buf, sizeof(buf)); + WM_keymap_item_to_string(ptr->data, buf, sizeof(buf), false); but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, w, h, ptr, prop, 0, 0, 0, -1, -1, NULL); UI_but_func_set(but, ui_keymap_but_cb, but, NULL); diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 0c1d6318638..b86d670a28c 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1139,7 +1139,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i int a = 0; for (kmi = km->items.first; kmi; kmi = kmi->next, a++) { - const char *key = WM_key_event_string(kmi->type); + const char *key = WM_key_event_string(kmi->type, false); if (key[0]) { wmOperatorType *ot = NULL; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 66146ff1d71..0497967c04a 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4422,7 +4422,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) if (t->keymap) { wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_RESIZE); if (kmi) { - ofs += WM_keymap_item_to_string(kmi, str + ofs, MAX_INFO_LEN - ofs); + ofs += WM_keymap_item_to_string(kmi, str + ofs, MAX_INFO_LEN - ofs, false); } } BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Even Thickness %s"), @@ -7743,7 +7743,7 @@ static void headerSeqSlide(TransInfo *t, const float val[2], char str[MAX_INFO_L if (t->keymap) { wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_TRANSLATE); if (kmi) { - ofs += WM_keymap_item_to_string(kmi, str + ofs, MAX_INFO_LEN - ofs); + ofs += WM_keymap_item_to_string(kmi, str + ofs, MAX_INFO_LEN - ofs, false); } } ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Expand to fit %s"), |