add mask keymap to image window.

debug prints for events when --debug-events is used to help track down why a key is/isnt used.
This commit is contained in:
Campbell Barton 2012-07-25 14:46:38 +00:00
parent d417cdc9f4
commit 071a1034d6
4 changed files with 65 additions and 7 deletions

@ -80,7 +80,7 @@ int ED_maskedit_mask_poll(bContext *C)
case SPACE_SEQ:
return ED_space_sequencer_maskedit_mask_poll(C);
case SPACE_IMAGE:
return ED_space_sequencer_maskedit_mask_poll(C);
return ED_space_image_maskedit_mask_poll(C);
}
}
return FALSE;

@ -1065,6 +1065,7 @@ static void clip_main_area_init(wmWindowManager *wm, ARegion *ar)
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
/* mask polls mode */
keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);

@ -557,6 +557,10 @@ static void image_main_area_init(wmWindowManager *wm, ARegion *ar)
// image space manages own v2d
// UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
/* mask polls mode */
keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
/* image paint polls for mode */
keymap = WM_keymap_find(wm->defaultconf, "Image Paint", 0, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);

@ -1664,12 +1664,24 @@ static int wm_action_not_handled(int action)
static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
{
#ifndef NDEBUG
const int do_debug_handler = (G.debug & G_DEBUG_EVENTS);
#endif
wmWindowManager *wm = CTX_wm_manager(C);
wmEventHandler *handler, *nexthandler;
int action = WM_HANDLER_CONTINUE;
int always_pass;
if (handlers == NULL) return action;
if (handlers == NULL) {
return action;
}
#ifndef NDEBUG
if (do_debug_handler) {
printf("%s: handling event\n", __func__);
WM_event_print(event);
}
#endif
/* modal handlers can get removed in this loop, we keep the loop this way */
for (handler = handlers->first; handler; handler = nexthandler) {
@ -1677,9 +1689,10 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
nexthandler = handler->next;
/* during this loop, ui handlers for nested menus can tag multiple handlers free */
if (handler->flag & WM_HANDLER_DO_FREE) ;
/* optional boundbox */
else if (handler_boundbox_test(handler, event)) {
if (handler->flag & WM_HANDLER_DO_FREE) {
/* pass */
}
else if (handler_boundbox_test(handler, event)) { /* optional boundbox */
/* in advance to avoid access to freed event on window close */
always_pass = wm_event_always_pass(event);
@ -1691,18 +1704,58 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
wmKeyMap *keymap = WM_keymap_active(wm, handler->keymap);
wmKeyMapItem *kmi;
#ifndef NDEBUG
if (do_debug_handler) {
printf("%s: checking '%s' ...", __func__, keymap->idname);
}
#endif
if (!keymap->poll || keymap->poll(C)) {
#ifndef NDEBUG
if (do_debug_handler) {
printf("pass\n");
}
#endif
for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (wm_eventmatch(event, kmi)) {
#ifndef NDEBUG
if (do_debug_handler) {
printf("%s: item matched '%s'\n", __func__, kmi->idname);
}
#endif
/* weak, but allows interactive callback to not use rawkey */
event->keymap_idname = kmi->idname;
action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr);
if (action & WM_HANDLER_BREAK) /* not always_pass here, it denotes removed handler */
if (action & WM_HANDLER_BREAK) {
/* not always_pass here, it denotes removed handler */
#ifndef NDEBUG
if (do_debug_handler) {
printf("%s: handled! '%s'...", __func__, kmi->idname);
}
#endif
break;
}
else {
#ifndef NDEBUG
if (do_debug_handler) {
printf("%s: un-handled '%s'...", __func__, kmi->idname);
}
#endif
}
}
}
}
else {
#ifndef NDEBUG
if (do_debug_handler) {
printf("fail\n");
}
#endif
}
}
else if (handler->ui_handle) {