Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-07-09 09:39:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-07-09 09:39:09 +0300
commit32396b316455c5b207b1103f03ddc4c8e81cfd00 (patch)
tree0ddd42d9674668a85e13e28a2c588fc5935d52d8 /source
parentac8aff2b28e93500d596a1fcdc2aa5089d4377c2 (diff)
WM: support for filtering modal keymap items
Modal keymap display often shows items which aren't used, add a poll funciton to hide these from the status bar.
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h2
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c12
2 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index bd2811d3306..80ad3840a8f 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -331,6 +331,8 @@ typedef struct wmKeyMap {
/* runtime */
/** Verify if enabled in the current context, use #WM_keymap_poll instead of direct calls. */
bool (*poll)(struct bContext *);
+ bool (*poll_modal_item)(const struct wmOperator *op, int value);
+
/** For modal, #EnumPropertyItem for now. */
const void *modal_items;
} wmKeyMap;
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 4f5578e452d..7e2198eed7a 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -4524,14 +4524,14 @@ bool WM_window_modal_keymap_status_draw(
uiLayout *layout)
{
wmKeyMap *keymap = NULL;
- wmOperatorType *ot = NULL;
+ wmOperator *op = NULL;
for (wmEventHandler *handler = win->modalhandlers.first; handler; handler = handler->next) {
if (handler->op) {
/* 'handler->keymap' could be checked too, seems not to be used. */
wmKeyMap *keymap_test = handler->op->type->modalkeymap;
if (keymap_test && keymap_test->modal_items) {
keymap = keymap_test;
- ot = handler->op->type;
+ op = handler->op;
break;
}
}
@@ -4546,6 +4546,11 @@ bool WM_window_modal_keymap_status_draw(
if (!items[i].identifier[0]) {
continue;
}
+ if ((keymap->poll_modal_item != NULL) &&
+ (keymap->poll_modal_item(op, items[i].value) == false))
+ {
+ continue;
+ }
bool show_text = true;
@@ -4577,7 +4582,8 @@ bool WM_window_modal_keymap_status_draw(
char buf[UI_MAX_DRAW_STR];
int available_len = sizeof(buf);
char *p = buf;
- WM_modalkeymap_operator_items_to_string_buf(ot, items[i].value, true, UI_MAX_SHORTCUT_STR, &available_len, &p);
+ WM_modalkeymap_operator_items_to_string_buf(
+ op->type, items[i].value, true, UI_MAX_SHORTCUT_STR, &available_len, &p);
p -= 1;
if (p > buf) {
BLI_snprintf(p, available_len, ": %s", items[i].name);