Planar tracking support for motion tracking
[blender.git] / source / blender / editors / space_clip / space_clip.c
index 4543876ffe50f9edd866df2379d343777b3c1aae..54724881e37bc3044a122b208f3a481ae3d384b9 100644 (file)
@@ -33,7 +33,9 @@
 #include <stdio.h>
 
 #include "DNA_scene_types.h"
+#include "DNA_mask_types.h"
 #include "DNA_movieclip_types.h"
+#include "DNA_view3d_types.h"  /* for pivot point */
 
 #include "MEM_guardedalloc.h"
 
@@ -49,6 +51,8 @@
 
 #include "IMB_imbuf_types.h"
 
+#include "ED_mask.h"
+#include "ED_space_api.h"
 #include "ED_screen.h"
 #include "ED_clip.h"
 #include "ED_transform.h"
@@ -81,7 +85,7 @@ static void init_preview_region(const bContext *C, ARegion *ar)
 
        if (sc->view == SC_VIEW_DOPESHEET) {
                ar->v2d.tot.xmin = -10.0f;
-               ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f;
+               ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
                ar->v2d.tot.xmax = (float)(sa->winx);
                ar->v2d.tot.ymax = 0.0f;
 
@@ -95,7 +99,7 @@ static void init_preview_region(const bContext *C, ARegion *ar)
 
                ar->v2d.minzoom = 0.01f;
                ar->v2d.maxzoom = 50;
-               ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
+               ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
                ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
                ar->v2d.keepzoom = V2D_LOCKZOOM_Y;
                ar->v2d.keepofs = V2D_KEEPOFS_Y;
@@ -116,8 +120,8 @@ static void init_preview_region(const bContext *C, ARegion *ar)
                ar->v2d.max[0] = MAXFRAMEF;
                ar->v2d.max[1] = FLT_MAX;
 
-               ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
-               ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
+               ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
+               ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL);
 
                ar->v2d.minzoom = 0.0f;
                ar->v2d.maxzoom = 0.0f;
@@ -232,10 +236,12 @@ static SpaceLink *clip_new(const bContext *C)
 
        sc = MEM_callocN(sizeof(SpaceClip), "initclip");
        sc->spacetype = SPACE_CLIP;
-       sc->flag = SC_SHOW_MARKER_PATTERN|SC_SHOW_TRACK_PATH|SC_MANUAL_CALIBRATION|SC_SHOW_GRAPH_TRACKS|SC_SHOW_GRAPH_FRAMES;
+       sc->flag = SC_SHOW_MARKER_PATTERN | SC_SHOW_TRACK_PATH | SC_MANUAL_CALIBRATION |
+                  SC_SHOW_GRAPH_TRACKS | SC_SHOW_GRAPH_FRAMES;
        sc->zoom = 1.0f;
        sc->path_length = 20;
        sc->scopes.track_preview_height = 120;
+       sc->around = V3D_LOCAL;
 
        /* header */
        ar = MEM_callocN(sizeof(ARegion), "header for clip");
@@ -256,7 +262,7 @@ static SpaceLink *clip_new(const bContext *C)
 
        BLI_addtail(&sc->regionbase, ar);
        ar->regiontype = RGN_TYPE_TOOL_PROPS;
-       ar->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
+       ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
 
        /* properties view */
        ar = MEM_callocN(sizeof(ARegion), "properties for clip");
@@ -300,6 +306,9 @@ static void clip_free(SpaceLink *sl)
        if (sc->scopes.track_preview)
                IMB_freeImBuf(sc->scopes.track_preview);
 
+       if (sc->scopes.track_search)
+               IMB_freeImBuf(sc->scopes.track_search);
+
        ED_space_clip_free_texture_buffer(sc);
 }
 
@@ -317,6 +326,7 @@ static SpaceLink *clip_duplicate(SpaceLink *sl)
        SpaceClip *scn = MEM_dupallocN(sl);
 
        /* clear or remove stuff from old */
+       scn->scopes.track_search = NULL;
        scn->scopes.track_preview = NULL;
        scn->scopes.ok = FALSE;
        scn->draw_context = NULL;
@@ -360,6 +370,24 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
                                        break;
                        }
                        break;
+               case NC_MASK:
+                       switch (wmn->data) {
+                               case ND_SELECT:
+                               case ND_DATA:
+                               case ND_DRAW:
+                                       ED_area_tag_redraw(sa);
+                                       break;
+                       }
+                       switch (wmn->action) {
+                               case NA_SELECTED:
+                                       clip_scopes_tag_refresh(sa);
+                                       ED_area_tag_redraw(sa);
+                                       break;
+                               case NA_EDITED:
+                                       ED_area_tag_redraw(sa);
+                                       break;
+                       }
+                       break;
                case NC_GEOM:
                        switch (wmn->data) {
                                case ND_SELECT:
@@ -368,13 +396,16 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
                                        break;
                        }
                        break;
-                case NC_SCREEN:
-                       if (wmn->data ==ND_ANIMPLAY) {
-                               ED_area_tag_redraw(sa);
+               case NC_SCREEN:
+                        switch (wmn->data) {
+                               case ND_ANIMPLAY:
+                               case ND_GPENCIL:
+                                       ED_area_tag_redraw(sa);
+                                       break;
                        }
                        break;
                case NC_SPACE:
-                       if (wmn->data ==ND_SPACE_CLIP) {
+                       if (wmn->data == ND_SPACE_CLIP) {
                                clip_scopes_tag_refresh(sa);
                                clip_stabilization_tag_refresh(sa);
                                ED_area_tag_redraw(sa);
@@ -415,6 +446,7 @@ static void clip_operatortypes(void)
        WM_operatortype_append(CLIP_OT_select);
        WM_operatortype_append(CLIP_OT_select_all);
        WM_operatortype_append(CLIP_OT_select_border);
+       WM_operatortype_append(CLIP_OT_select_lasso);
        WM_operatortype_append(CLIP_OT_select_circle);
        WM_operatortype_append(CLIP_OT_select_grouped);
 
@@ -512,7 +544,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
        kmi = WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_CTRL, 0);
        RNA_boolean_set(kmi->ptr, "backwards", FALSE);
        RNA_boolean_set(kmi->ptr, "sequence", TRUE);
-       kmi = WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
+       kmi = WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
        RNA_boolean_set(kmi->ptr, "backwards", TRUE);
        RNA_boolean_set(kmi->ptr, "sequence", TRUE);
 
@@ -530,7 +562,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
        /* ******** Hotkeys avalaible for main region only ******** */
 
        keymap = WM_keymap_find(keyconf, "Clip Editor", SPACE_CLIP, 0);
-
+//     keymap->poll = ED_space_clip_tracking_poll;
        /* ** View/navigation ** */
 
        WM_keymap_add_item(keymap, "CLIP_OT_view_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
@@ -560,16 +592,16 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "CLIP_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
 
        /* jump to special frame */
-       kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
+       kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
        RNA_enum_set(kmi->ptr, "position", 0);
 
-       kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
+       kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
        RNA_enum_set(kmi->ptr, "position", 1);
 
-       kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0);
+       kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
        RNA_enum_set(kmi->ptr, "position", 2);
 
-       kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0);
+       kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
        RNA_enum_set(kmi->ptr, "position", 3);
 
        /* "timeline" */
@@ -588,6 +620,11 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "CLIP_OT_select_circle", CKEY, KM_PRESS, 0, 0);
        WM_keymap_add_menu(keymap, "CLIP_MT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
 
+       kmi = WM_keymap_add_item(keymap, "CLIP_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_ALT, 0);
+       RNA_boolean_set(kmi->ptr, "deselect", FALSE);
+       kmi = WM_keymap_add_item(keymap, "CLIP_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT | KM_ALT, 0);
+       RNA_boolean_set(kmi->ptr, "deselect", TRUE);
+
        /* marker */
        WM_keymap_add_item(keymap, "CLIP_OT_add_marker_slide", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
 
@@ -645,7 +682,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
        kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_SHIFT, 0);
        RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_UPTO);
        RNA_boolean_set(kmi->ptr, "clear_active", FALSE);
-       kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0);
+       kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
        RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_ALL);
        RNA_boolean_set(kmi->ptr, "clear_active", FALSE);
 
@@ -690,7 +727,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
        kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_SHIFT, 0);
        RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_UPTO);
        RNA_boolean_set(kmi->ptr, "clear_active", TRUE);
-       kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0);
+       kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
        RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_ALL);
        RNA_boolean_set(kmi->ptr, "clear_active", TRUE);
 
@@ -708,7 +745,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
        RNA_boolean_set(kmi->ptr, "extend", TRUE);      /* toggle */
 }
 
-const char *clip_context_dir[]= {"edit_movieclip", NULL};
+const char *clip_context_dir[] = {"edit_movieclip", "edit_mask", NULL};
 
 static int clip_context(const bContext *C, const char *member, bContextDataResult *result)
 {
@@ -722,7 +759,11 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul
        else if (CTX_data_equals(member, "edit_movieclip")) {
                if (sc->clip)
                        CTX_data_id_pointer_set(result, &sc->clip->id);
-
+               return TRUE;
+       }
+       else if (CTX_data_equals(member, "edit_mask")) {
+               if (sc->mask)
+                       CTX_data_id_pointer_set(result, &sc->mask->id);
                return TRUE;
        }
 
@@ -879,8 +920,8 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
                        ar_tool_props->v2d.flag &= ~V2D_IS_INITIALISED;
                        view_changed = TRUE;
                }
-               if (ar_tool_props && (ar_tool_props->alignment != (RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV))) {
-                       ar_tool_props->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
+               if (ar_tool_props && (ar_tool_props->alignment != (RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV))) {
+                       ar_tool_props->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
                        view_changed = TRUE;
                }
        }
@@ -984,11 +1025,11 @@ static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
        ar->v2d.mask.ymax = winy;
 
        /* which part of the image space do we see? */
-       x1= ar->winrct.xmin + (winx-sc->zoom * w) / 2.0f;
-       y1= ar->winrct.ymin + (winy-sc->zoom * h) / 2.0f;
+       x1 = ar->winrct.xmin + (winx - sc->zoom * w) / 2.0f;
+       y1 = ar->winrct.ymin + (winy - sc->zoom * h) / 2.0f;
 
-       x1-= sc->zoom * sc->xof;
-       y1-= sc->zoom * sc->yof;
+       x1 -= sc->zoom * sc->xof;
+       y1 -= sc->zoom * sc->yof;
 
        /* relative display right */
        ar->v2d.cur.xmin = (ar->winrct.xmin - (float)x1) / sc->zoom;
@@ -1013,6 +1054,9 @@ static void clip_main_area_init(wmWindowManager *wm, ARegion *ar)
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
 
        /* own keymap */
+       keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0);
+       WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+
        keymap = WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 
@@ -1060,6 +1104,49 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
        /* Grease Pencil */
        clip_draw_grease_pencil((bContext *)C, 1);
 
+       if (sc->mode == SC_MODE_MASKEDIT) {
+               int x, y;
+               int width, height;
+               float zoomx, zoomy, aspx, aspy;
+
+               /* frame image */
+               float maxdim;
+               float xofs, yofs;
+
+               /* find window pixel coordinates of origin */
+               UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
+
+               ED_space_clip_size(sc, &width, &height);
+               ED_space_clip_zoom(sc, ar, &zoomx, &zoomy);
+               ED_space_clip_aspect(sc, &aspx, &aspy);
+
+               /* frame the image */
+               maxdim = maxf(width, height);
+               if (width == height) {
+                       xofs = yofs = 0;
+               }
+               else if (width < height) {
+                       xofs = ((height - width) / -2.0f) * zoomx;
+                       yofs = 0.0f;
+               }
+               else { /* (width > height) */
+                       xofs = 0.0f;
+                       yofs = ((width - height) / -2.0f) * zoomy;
+               }
+
+               /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */
+               glPushMatrix();
+               glTranslatef(x + xofs, y + yofs, 0);
+               glScalef(maxdim * zoomx, maxdim * zoomy, 0);
+               glMultMatrixf(sc->stabmat);
+
+               ED_mask_draw((bContext *)C, sc->mask_draw_flag, sc->mask_draw_type);
+
+               ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
+
+               glPopMatrix();
+       }
+
        /* reset view matrix */
        UI_view2d_view_restore(C);
 
@@ -1129,11 +1216,15 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar)
 {
        Scene *scene = CTX_data_scene(C);
        SpaceClip *sc = CTX_wm_space_clip(C);
+       MovieClip *clip = ED_space_clip(sc);
        View2D *v2d = &ar->v2d;
        View2DGrid *grid;
        View2DScrollers *scrollers;
        short unit = 0;
 
+       if (clip)
+               BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE);
+
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
        glClear(GL_COLOR_BUFFER_BIT);
@@ -1142,7 +1233,8 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar)
 
        /* time grid */
        unit = (sc->flag & SC_SHOW_SECONDS)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
-       grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
+       grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP,
+                                  V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
        UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
        UI_view2d_grid_free(grid);
 
@@ -1153,7 +1245,7 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar)
        UI_view2d_view_restore(C);
 
        /* scrollers */
-       scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
+       scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
        UI_view2d_scrollers_draw(C, v2d, scrollers);
        UI_view2d_scrollers_free(scrollers);
 }
@@ -1186,9 +1278,14 @@ static void clip_channels_area_init(wmWindowManager *wm, ARegion *ar)
 
 static void clip_channels_area_draw(const bContext *C, ARegion *ar)
 {
+       SpaceClip *sc = CTX_wm_space_clip(C);
+       MovieClip *clip = ED_space_clip(sc);
        View2D *v2d = &ar->v2d;
        View2DScrollers *scrollers;
 
+       if (clip)
+               BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE);
+
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
        glClear(GL_COLOR_BUFFER_BIT);
@@ -1224,6 +1321,26 @@ static void clip_header_area_draw(const bContext *C, ARegion *ar)
        ED_region_header(C, ar);
 }
 
+static void clip_header_area_listener(ARegion *ar, wmNotifier *wmn)
+{
+       /* context changes */
+       switch (wmn->category) {
+               case NC_SCENE:
+                       switch (wmn->data) {
+                               /* for proportional editmode only */
+                               case ND_TOOLSETTINGS:
+                                       /* TODO - should do this when in mask mode only but no datas available */
+                                       // if (sc->mode == SC_MODE_MASKEDIT)
+                                       {
+                                               ED_region_tag_redraw(ar);
+                                       }
+                                       break;
+                       }
+                       break;
+       }
+}
+
+
 /****************** tools region ******************/
 
 /* add handlers, stuff you only do once or on area/region changes */
@@ -1289,11 +1406,11 @@ static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn)
        /* context changes */
        switch (wmn->category) {
                case NC_SCREEN:
-                       if (wmn->data ==ND_GPENCIL)
+                       if (wmn->data == ND_GPENCIL)
                                ED_region_tag_redraw(ar);
                        break;
                case NC_BRUSH:
-                       if (wmn->action ==NA_EDITED)
+                       if (wmn->action == NA_EDITED)
                                ED_region_tag_redraw(ar);
                        break;
        }
@@ -1327,7 +1444,7 @@ void ED_spacetype_clip(void)
        art->init = clip_main_area_init;
        art->draw = clip_main_area_draw;
        art->listener = clip_main_area_listener;
-       art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_GPENCIL;
+       art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_GPENCIL;
 
        BLI_addhead(&st->regiontypes, art);
 
@@ -1338,7 +1455,7 @@ void ED_spacetype_clip(void)
        art->init = clip_preview_area_init;
        art->draw = clip_preview_area_draw;
        art->listener = clip_preview_area_listener;
-       art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
+       art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
 
        BLI_addhead(&st->regiontypes, art);
 
@@ -1346,7 +1463,7 @@ void ED_spacetype_clip(void)
        art = MEM_callocN(sizeof(ARegionType), "spacetype clip region properties");
        art->regionid = RGN_TYPE_UI;
        art->prefsizex = UI_COMPACT_PANEL_WIDTH;
-       art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
+       art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI;
        art->init = clip_properties_area_init;
        art->draw = clip_properties_area_draw;
        art->listener = clip_properties_area_listener;
@@ -1357,7 +1474,7 @@ void ED_spacetype_clip(void)
        art = MEM_callocN(sizeof(ARegionType), "spacetype clip region tools");
        art->regionid = RGN_TYPE_TOOLS;
        art->prefsizex = UI_COMPACT_PANEL_WIDTH;
-       art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
+       art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI;
        art->listener = clip_props_area_listener;
        art->init = clip_tools_area_init;
        art->draw = clip_tools_area_draw;
@@ -1369,7 +1486,7 @@ void ED_spacetype_clip(void)
        art->regionid = RGN_TYPE_TOOL_PROPS;
        art->prefsizex = 0;
        art->prefsizey = 120;
-       art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
+       art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI;
        art->listener = clip_props_area_listener;
        art->init = clip_tools_area_init;
        art->draw = clip_tools_area_draw;
@@ -1381,10 +1498,11 @@ void ED_spacetype_clip(void)
        art = MEM_callocN(sizeof(ARegionType), "spacetype clip region");
        art->regionid = RGN_TYPE_HEADER;
        art->prefsizey = HEADERY;
-       art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER;
+       art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
 
        art->init = clip_header_area_init;
        art->draw = clip_header_area_draw;
+       art->listener = clip_header_area_listener;
 
        BLI_addhead(&st->regiontypes, art);
 
@@ -1394,7 +1512,7 @@ void ED_spacetype_clip(void)
        art = MEM_callocN(sizeof(ARegionType), "spacetype clip channels region");
        art->regionid = RGN_TYPE_CHANNELS;
        art->prefsizex = UI_COMPACT_PANEL_WIDTH;
-       art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
+       art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI;
        art->listener = clip_channels_area_listener;
        art->init = clip_channels_area_init;
        art->draw = clip_channels_area_draw;