diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-12 10:47:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-12 10:51:14 +0300 |
commit | df6530594f02969e6fae25df38d1b947411a9a82 (patch) | |
tree | bb2743a2d9eb6cb6dc33dc6ee850471a6833ebf0 /source/blender/editors | |
parent | 5aeec318217729288bb16fd6ec0b09802f86f452 (diff) |
Fix T57527: GP draw takes events from gizmos
Add keymap flag to the gizmo handler so events can be handled
on the UI level and not get over-ridden by grease pencil.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 19 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 24 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 12 | ||||
-rw-r--r-- | source/blender/editors/space_node/space_node.c | 9 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 9 |
5 files changed, 33 insertions, 40 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 7c05bfd829d..a5660c43416 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -356,14 +356,17 @@ struct ARegionType *ED_area_type_hud(int space_type); void ED_area_type_hud_clear(struct wmWindowManager *wm, ScrArea *sa_keep); void ED_area_type_hud_ensure(struct bContext *C, struct ScrArea *sa); -/* default keymaps, bitflags */ -#define ED_KEYMAP_UI 1 -#define ED_KEYMAP_VIEW2D 2 -#define ED_KEYMAP_MARKERS 4 -#define ED_KEYMAP_ANIMATION 8 -#define ED_KEYMAP_FRAMES 16 -#define ED_KEYMAP_GPENCIL 32 -#define ED_KEYMAP_HEADER 64 +/* default keymaps, bitflags (matches order of evaluation). */ +enum { + ED_KEYMAP_UI = (1 << 1), + ED_KEYMAP_GIZMO = (1 << 2), + ED_KEYMAP_VIEW2D = (1 << 3), + ED_KEYMAP_MARKERS = (1 << 4), + ED_KEYMAP_ANIMATION = (1 << 5), + ED_KEYMAP_FRAMES = (1 << 6), + ED_KEYMAP_HEADER = (1 << 7), + ED_KEYMAP_GPENCIL = (1 << 8), +}; /* SCREEN_OT_space_context_cycle direction */ enum { diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 66044680f10..8163959f909 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1461,6 +1461,18 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand /* user interface widgets */ UI_region_handlers_add(handlers); } + if (flag & ED_KEYMAP_GIZMO) { + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (ar) { + /* Anything else is confusing, only allow this. */ + BLI_assert(&ar->handlers == handlers); + if (ar->gizmo_map == NULL) { + ar->gizmo_map = WM_gizmomap_new_from_type( + &(const struct wmGizmoMapType_Params){sa->spacetype, RGN_TYPE_WINDOW}); + } + WM_gizmomap_add_handlers(ar, ar->gizmo_map); + } + } if (flag & ED_KEYMAP_VIEW2D) { /* 2d-viewport handling+manipulation */ wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "View2D", 0, 0); @@ -1490,6 +1502,13 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Frames", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } + if (flag & ED_KEYMAP_HEADER) { + /* standard keymap for headers regions */ + wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Header", 0, 0); + WM_event_add_keymap_handler(handlers, keymap); + } + + /* Keep last because of LMB/RMB handling, see: T57527. */ if (flag & ED_KEYMAP_GPENCIL) { /* grease pencil */ /* NOTE: This is now 4 keymaps - One for basic functionality, @@ -1519,11 +1538,6 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand wmKeyMap *keymap_sculpt = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Sculpt Mode", 0, 0); WM_event_add_keymap_handler(handlers, keymap_sculpt); } - if (flag & ED_KEYMAP_HEADER) { - /* standard keymap for headers regions */ - wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Header", 0, 0); - WM_event_add_keymap_handler(handlers, keymap); - } } void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area) diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 8218216f9a6..01d2fc28c6b 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -576,16 +576,6 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar) // image space manages own v2d // UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); - /* gizmos */ - if (ar->gizmo_map == NULL) { - const struct wmGizmoMapType_Params wmap_params = { - .spaceid = SPACE_IMAGE, - .regionid = RGN_TYPE_WINDOW, - }; - ar->gizmo_map = WM_gizmomap_new_from_type(&wmap_params); - } - WM_gizmomap_add_handlers(ar, ar->gizmo_map); - /* mask polls mode */ keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -991,7 +981,7 @@ void ED_spacetype_image(void) /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype image region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL; + art->keymapflag = ED_KEYMAP_GIZMO | ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL; art->init = image_main_region_init; art->draw = image_main_region_draw; art->listener = image_main_region_listener; diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 38bc1b6da8d..ba5703946c3 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -646,14 +646,6 @@ static void node_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - /* gizmos stay in the background for now - quick patchjob to make sure nodes themselves work */ - if (ar->gizmo_map == NULL) { - ar->gizmo_map = WM_gizmomap_new_from_type( - &(const struct wmGizmoMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW}); - } - - WM_gizmomap_add_handlers(ar, ar->gizmo_map); - /* own keymaps */ keymap = WM_keymap_ensure(wm->defaultconf, "Node Generic", SPACE_NODE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -987,6 +979,7 @@ void ED_spacetype_node(void) /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype node region"); art->regionid = RGN_TYPE_WINDOW; + art->keymapflag = ED_KEYMAP_GIZMO; art->init = node_main_region_init; art->draw = node_main_region_draw; art->listener = node_region_listener; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 8fe4a95927d..044cb56d367 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -458,13 +458,6 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar) ListBase *lb; wmKeyMap *keymap; - if (ar->gizmo_map == NULL) { - ar->gizmo_map = WM_gizmomap_new_from_type( - &(const struct wmGizmoMapType_Params) {SPACE_VIEW3D, RGN_TYPE_WINDOW}); - } - - WM_gizmomap_add_handlers(ar, ar->gizmo_map); - /* object ops. */ /* important to be before Pose keymap since they can both be enabled at once */ @@ -1479,7 +1472,7 @@ void ED_spacetype_view3d(void) /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype view3d main region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag = ED_KEYMAP_GPENCIL; + art->keymapflag = ED_KEYMAP_GIZMO | ED_KEYMAP_GPENCIL; art->draw = view3d_main_region_draw; art->init = view3d_main_region_init; art->exit = view3d_main_region_exit; |