Camera tracking integration
[blender.git] / source / blender / editors / space_clip / space_clip.c
1 /*
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2011 Blender Foundation.
21  * All rights reserved.
22  *
23  *
24  * Contributor(s): Blender Foundation,
25  *                 Sergey Sharybin
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29
30 /** \file blender/editors/space_clip/space_clip.c
31  *  \ingroup spclip
32  */
33
34 #include <string.h>
35 #include <stdio.h>
36
37 #include "DNA_scene_types.h"
38 #include "DNA_movieclip_types.h"
39
40 #include "MEM_guardedalloc.h"
41
42 #include "BLI_blenlib.h"
43 #include "BLI_utildefines.h"
44
45 #include "BKE_main.h"
46 #include "BKE_context.h"
47 #include "BKE_screen.h"
48 #include "BKE_movieclip.h"
49 #include "BKE_tracking.h"
50
51 #include "IMB_imbuf_types.h"
52
53 #include "ED_screen.h"
54 #include "ED_clip.h"
55 #include "ED_transform.h"
56
57 #include "IMB_imbuf.h"
58
59 #include "BIF_gl.h"
60
61 #include "WM_api.h"
62 #include "WM_types.h"
63
64 #include "UI_interface.h"
65 #include "UI_resources.h"
66 #include "UI_view2d.h"
67
68 #include "RNA_access.h"
69
70
71 #include "clip_intern.h"        // own include
72
73 static void clip_scopes_tag_refresh(ScrArea *sa)
74 {
75         SpaceClip *sc= (SpaceClip *)sa->spacedata.first;
76         ARegion *ar;
77
78         /* only while proeprties are visible */
79         for (ar=sa->regionbase.first; ar; ar=ar->next) {
80                 if (ar->regiontype == RGN_TYPE_PREVIEW && ar->flag & RGN_FLAG_HIDDEN)
81                         return;
82         }
83
84         sc->scopes.ok=0;
85 }
86
87 /* ******************** default callbacks for clip space ***************** */
88
89 static SpaceLink *clip_new(const bContext *UNUSED(C))
90 {
91         ARegion *ar;
92         SpaceClip *sc;
93
94         sc= MEM_callocN(sizeof(SpaceClip), "initclip");
95         sc->spacetype= SPACE_CLIP;
96         sc->flag= SC_SHOW_MARKER_PATTERN|SC_SHOW_TRACK_PATH;
97         sc->zoom= 1.0f;
98         sc->path_length= 20;
99
100         /* header */
101         ar= MEM_callocN(sizeof(ARegion), "header for clip");
102
103         BLI_addtail(&sc->regionbase, ar);
104         ar->regiontype= RGN_TYPE_HEADER;
105         ar->alignment= RGN_ALIGN_BOTTOM;
106
107         /* tools view */
108         ar= MEM_callocN(sizeof(ARegion), "tools for logic");
109
110         BLI_addtail(&sc->regionbase, ar);
111         ar->regiontype= RGN_TYPE_TOOLS;
112         ar->alignment= RGN_ALIGN_LEFT;
113
114         /* properties view */
115         ar= MEM_callocN(sizeof(ARegion), "properties for logic");
116
117         BLI_addtail(&sc->regionbase, ar);
118         ar->regiontype= RGN_TYPE_UI;
119         ar->alignment= RGN_ALIGN_RIGHT;
120
121         /* main area */
122         ar= MEM_callocN(sizeof(ARegion), "main area for clip");
123
124         BLI_addtail(&sc->regionbase, ar);
125         ar->regiontype= RGN_TYPE_WINDOW;
126
127         return (SpaceLink *)sc;
128 }
129
130 /* not spacelink itself */
131 static void clip_free(SpaceLink *sl)
132 {
133         SpaceClip *sc= (SpaceClip*) sl;
134
135         sc->clip= NULL;
136
137         if(sc->scopes.track_preview)
138                 IMB_freeImBuf(sc->scopes.track_preview);
139 }
140
141 /* spacetype; init callback */
142 static void clip_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
143 {
144
145 }
146
147 static SpaceLink *clip_duplicate(SpaceLink *sl)
148 {
149         SpaceClip *sclipn= MEM_dupallocN(sl);
150
151         /* clear or remove stuff from old */
152
153         return (SpaceLink *)sclipn;
154 }
155
156 static void clip_listener(ScrArea *sa, wmNotifier *wmn)
157 {
158         SpaceClip *sc= sa->spacedata.first;
159
160         (void)sc;
161
162         /* context changes */
163         switch(wmn->category) {
164                 case NC_SCENE:
165                         switch(wmn->data) {
166                                 case ND_FRAME:
167                                         clip_scopes_tag_refresh(sa);
168                                         /* no break! */
169
170                                 case ND_FRAME_RANGE:
171                                         ED_area_tag_refresh(sa);
172                                         ED_area_tag_redraw(sa);
173                                         break;
174                         }
175                         break;
176                 case NC_MOVIECLIP:
177                         switch(wmn->data) {
178                                 case ND_DISPLAY:
179                                 case ND_SELECT:
180                                         clip_scopes_tag_refresh(sa);
181                                         ED_area_tag_redraw(sa);
182                                         break;
183                         }
184                         switch(wmn->action) {
185                                 case NA_REMOVED:
186                                 case NA_SELECTED:
187                                 case NA_EDITED:
188                                 case NA_EVALUATED:
189                                         clip_scopes_tag_refresh(sa);
190                                         ED_area_tag_redraw(sa);
191                                         break;
192                         }
193                         break;
194                 case NC_GEOM:
195                         switch(wmn->data) {
196                                 case ND_SELECT:
197                                         ED_area_tag_redraw(sa);
198                                         clip_scopes_tag_refresh(sa);
199                                         break;
200                         }
201                         break;
202                 case NC_SPACE:
203                         if(wmn->data==ND_SPACE_CLIP) {
204                                 clip_scopes_tag_refresh(sa);
205                                 ED_area_tag_redraw(sa);
206                         }
207                         break;
208         }
209 }
210
211 static void clip_operatortypes(void)
212 {
213         WM_operatortype_append(CLIP_OT_open);
214         WM_operatortype_append(CLIP_OT_reload);
215         WM_operatortype_append(CLIP_OT_tools);
216          WM_operatortype_append(CLIP_OT_properties);
217         // WM_operatortype_append(CLIP_OT_unlink);
218         WM_operatortype_append(CLIP_OT_view_pan);
219         WM_operatortype_append(CLIP_OT_view_zoom);
220         WM_operatortype_append(CLIP_OT_view_zoom_in);
221         WM_operatortype_append(CLIP_OT_view_zoom_out);
222         WM_operatortype_append(CLIP_OT_view_zoom_ratio);
223         WM_operatortype_append(CLIP_OT_view_all);
224         WM_operatortype_append(CLIP_OT_view_selected);
225
226         WM_operatortype_append(CLIP_OT_select);
227         WM_operatortype_append(CLIP_OT_select_all);
228         WM_operatortype_append(CLIP_OT_select_border);
229         WM_operatortype_append(CLIP_OT_select_circle);
230
231         WM_operatortype_append(CLIP_OT_add_marker);
232         WM_operatortype_append(CLIP_OT_delete_track);
233         WM_operatortype_append(CLIP_OT_delete_marker);
234
235         WM_operatortype_append(CLIP_OT_track_markers);
236         WM_operatortype_append(CLIP_OT_solve_camera);
237         WM_operatortype_append(CLIP_OT_clear_reconstruction);
238
239         WM_operatortype_append(CLIP_OT_disable_markers);
240         WM_operatortype_append(CLIP_OT_hide_tracks);
241         WM_operatortype_append(CLIP_OT_hide_tracks_clear);
242
243         WM_operatortype_append(CLIP_OT_set_origin);
244         WM_operatortype_append(CLIP_OT_set_floor);
245         WM_operatortype_append(CLIP_OT_set_axis);
246         WM_operatortype_append(CLIP_OT_set_scale);
247
248         WM_operatortype_append(CLIP_OT_set_center_principal);
249
250         WM_operatortype_append(CLIP_OT_clear_track_path);
251
252         WM_operatortype_append(CLIP_OT_slide_marker);
253
254         WM_operatortype_append(CLIP_OT_detect_features);
255 }
256
257 static void clip_keymap(struct wmKeyConfig *keyconf)
258 {
259         wmKeyMap *keymap;
260         wmKeyMapItem *kmi;
261
262         keymap= WM_keymap_find(keyconf, "Clip", SPACE_CLIP, 0);
263
264         WM_keymap_add_item(keymap, "CLIP_OT_open", OKEY, KM_PRESS, KM_ALT, 0);
265
266         WM_keymap_add_item(keymap, "CLIP_OT_tools", TKEY, KM_PRESS, 0, 0);
267          WM_keymap_add_item(keymap, "CLIP_OT_properties", NKEY, KM_PRESS, 0, 0);
268
269         /* ********* View/navigation ******** */
270
271         WM_keymap_add_item(keymap, "CLIP_OT_view_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
272         WM_keymap_add_item(keymap, "CLIP_OT_view_pan", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
273         WM_keymap_add_item(keymap, "CLIP_OT_view_pan", MOUSEPAN, 0, 0, 0);
274
275         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
276         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom", MOUSEZOOM, 0, 0, 0);
277         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_in", WHEELINMOUSE, KM_PRESS, 0, 0);
278         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_out", WHEELOUTMOUSE, KM_PRESS, 0, 0);
279         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0);
280         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_out", PADMINUS, KM_PRESS, 0, 0);
281
282         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f);
283         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f);
284         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD2, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 2.0f);
285         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD1, KM_PRESS, 0, 0)->ptr, "ratio", 1.0f);
286         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD2, KM_PRESS, 0, 0)->ptr, "ratio", 0.5f);
287         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
288         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
289
290         WM_keymap_add_item(keymap, "CLIP_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
291
292         WM_keymap_add_item(keymap, "CLIP_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
293
294         WM_keymap_add_item(keymap, "CLIP_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
295         RNA_boolean_set(WM_keymap_add_item(keymap, "CLIP_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
296         WM_keymap_add_item(keymap, "CLIP_OT_select_all", AKEY, KM_PRESS, 0, 0);
297         RNA_enum_set(WM_keymap_add_item(keymap, "CLIP_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "action", SEL_INVERT);
298         WM_keymap_add_item(keymap, "CLIP_OT_select_border", BKEY, KM_PRESS, 0, 0);
299         WM_keymap_add_item(keymap, "CLIP_OT_select_circle", CKEY, KM_PRESS, 0, 0);
300
301         WM_keymap_add_item(keymap, "CLIP_OT_add_marker_slide", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
302
303         kmi= WM_keymap_add_item(keymap, "CLIP_OT_track_markers", LEFTARROWKEY, KM_PRESS, KM_ALT, 0);
304         RNA_boolean_set(kmi->ptr, "backwards", 1);
305         WM_keymap_add_item(keymap, "CLIP_OT_track_markers", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0);
306         kmi= WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_CTRL, 0);
307         RNA_boolean_set(kmi->ptr, "sequence", 1);
308         kmi= WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
309         RNA_boolean_set(kmi->ptr, "backwards", 1);
310         RNA_boolean_set(kmi->ptr, "sequence", 1);
311
312         kmi= WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT, 0);
313         RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_REMAINED);
314         kmi= WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_SHIFT, 0);
315         RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_UPTO);
316         kmi= WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0);
317         RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_ALL);
318
319         WM_keymap_add_item(keymap, "CLIP_OT_delete_track", DELKEY, KM_PRESS, 0, 0);
320         WM_keymap_add_item(keymap, "CLIP_OT_delete_track", XKEY, KM_PRESS, 0, 0);
321
322         WM_keymap_add_item(keymap, "CLIP_OT_delete_marker", DELKEY, KM_PRESS, KM_SHIFT, 0);
323
324         kmi= WM_keymap_add_item(keymap, "WM_OT_context_toggle", LKEY, KM_PRESS, 0, 0);
325         RNA_string_set(kmi->ptr, "data_path", "space_data.lock_selection");
326
327         WM_keymap_add_menu(keymap, "CLIP_MT_tracking_specials", WKEY, KM_PRESS, 0, 0);
328
329         WM_keymap_add_item(keymap, "CLIP_OT_slide_marker", LEFTMOUSE, KM_PRESS, 0, 0);
330
331         WM_keymap_add_item(keymap, "CLIP_OT_hide_tracks", HKEY, KM_PRESS, 0, 0);
332         kmi= WM_keymap_add_item(keymap, "CLIP_OT_hide_tracks", HKEY, KM_PRESS, KM_SHIFT, 0);
333         RNA_boolean_set(kmi->ptr, "unselected", 1);
334         WM_keymap_add_item(keymap, "CLIP_OT_hide_tracks_clear", HKEY, KM_PRESS, KM_ALT, 0);
335
336         kmi= WM_keymap_add_item(keymap, "CLIP_OT_disable_markers", DKEY, KM_PRESS, 0, 0);
337         RNA_enum_set(kmi->ptr, "action", 2);
338
339         transform_keymap_for_space(keyconf, keymap, SPACE_CLIP);
340 }
341
342 const char *clip_context_dir[]= {"edit_movieclip", NULL};
343
344 static int clip_context(const bContext *C, const char *member, bContextDataResult *result)
345 {
346         SpaceClip *sc= CTX_wm_space_clip(C);
347
348         if(CTX_data_dir(member)) {
349                 CTX_data_dir_set(result, clip_context_dir);
350                 return 1;
351         }
352         else if(CTX_data_equals(member, "edit_movieclip")) {
353                 CTX_data_id_pointer_set(result, &sc->clip->id);
354                 return 1;
355         }
356
357         return 0;
358 }
359
360 static void clip_refresh(const bContext *C, ScrArea *UNUSED(sa))
361 {
362         SpaceClip *sc= CTX_wm_space_clip(C);
363
364         BKE_movieclip_user_set_frame(&sc->user, CTX_data_scene(C)->r.cfra);
365 }
366
367 /********************* main region ********************/
368
369 /* sets up the fields of the View2D from zoom and offset */
370 static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
371 {
372         float x1, y1, w, h;
373         int width, height, winx, winy;
374
375         ED_space_clip_size(sc, &width, &height);
376
377         w= width;
378         h= height;
379
380         winx= ar->winrct.xmax - ar->winrct.xmin + 1;
381         winy= ar->winrct.ymax - ar->winrct.ymin + 1;
382
383         ar->v2d.tot.xmin= 0;
384         ar->v2d.tot.ymin= 0;
385         ar->v2d.tot.xmax= w;
386         ar->v2d.tot.ymax= h;
387
388         ar->v2d.mask.xmin= ar->v2d.mask.ymin= 0;
389         ar->v2d.mask.xmax= winx;
390         ar->v2d.mask.ymax= winy;
391
392         /* which part of the image space do we see? */
393         x1= ar->winrct.xmin+(winx-sc->zoom*w)/2.0f;
394         y1= ar->winrct.ymin+(winy-sc->zoom*h)/2.0f;
395
396         x1-= sc->zoom*sc->xof;
397         y1-= sc->zoom*sc->yof;
398
399         /* relative display right */
400         ar->v2d.cur.xmin= ((ar->winrct.xmin - (float)x1)/sc->zoom);
401         ar->v2d.cur.xmax= ar->v2d.cur.xmin + ((float)winx/sc->zoom);
402
403         /* relative display left */
404         ar->v2d.cur.ymin= ((ar->winrct.ymin-(float)y1)/sc->zoom);
405         ar->v2d.cur.ymax= ar->v2d.cur.ymin + ((float)winy/sc->zoom);
406
407         /* normalize 0.0..1.0 */
408         ar->v2d.cur.xmin /= w;
409         ar->v2d.cur.xmax /= w;
410         ar->v2d.cur.ymin /= h;
411         ar->v2d.cur.ymax /= h;
412 }
413
414 /* add handlers, stuff you only do once or on area/region changes */
415 static void clip_main_area_init(wmWindowManager *wm, ARegion *ar)
416 {
417         wmKeyMap *keymap;
418
419         UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
420
421         /* own keymap */
422         keymap= WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0);
423         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
424 }
425
426 static void clip_main_area_draw(const bContext *C, ARegion *ar)
427 {
428         /* draw entirely, view changes should be handled here */
429         SpaceClip *sc= CTX_wm_space_clip(C);
430         Scene *scene= CTX_data_scene(C);
431         MovieClip *clip= ED_space_clip(sc);
432
433         /* if trcking is in progress, we should sunchronize framenr from clipuser
434            so latest tracked frame would be shown */
435         if(clip && clip->tracking_context)
436                 BKE_tracking_sync_user(&sc->user, clip->tracking_context);
437
438         if(sc->flag&SC_LOCK_SELECTION)
439                 ED_clip_view_selection(sc, ar, 0);
440
441         /* clear and setup matrix */
442         UI_ThemeClearColor(TH_BACK);
443         glClear(GL_COLOR_BUFFER_BIT);
444
445         /* data... */
446         movieclip_main_area_set_view2d(sc, ar);
447         draw_clip_main(sc, ar, scene);
448
449         /* reset view matrix */
450         UI_view2d_view_restore(C);
451 }
452
453 /****************** header region ******************/
454
455 /* add handlers, stuff you only do once or on area/region changes */
456 static void clip_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
457 {
458         ED_region_header_init(ar);
459 }
460
461 static void clip_header_area_draw(const bContext *C, ARegion *ar)
462 {
463         ED_region_header(C, ar);
464 }
465
466 /****************** tools region ******************/
467
468 /* add handlers, stuff you only do once or on area/region changes */
469 static void clip_tools_area_init(wmWindowManager *wm, ARegion *ar)
470 {
471         ED_region_panels_init(wm, ar);
472 }
473
474 static void clip_tools_area_draw(const bContext *C, ARegion *ar)
475 {
476         ED_region_panels(C, ar, 1, NULL, -1);
477 }
478
479 /****************** properties region ******************/
480
481 /* add handlers, stuff you only do once or on area/region changes */
482 static void clip_properties_area_init(wmWindowManager *wm, ARegion *ar)
483 {
484         ED_region_panels_init(wm, ar);
485 }
486
487 static void clip_properties_area_draw(const bContext *C, ARegion *ar)
488 {
489         SpaceClip *sc= CTX_wm_space_clip(C);
490
491         BKE_movieclip_update_scopes(sc->clip, &sc->user, &sc->scopes);
492
493         ED_region_panels(C, ar, 1, NULL, -1);
494 }
495
496 /********************* registration ********************/
497
498 /* only called once, from space/spacetypes.c */
499 void ED_spacetype_clip(void)
500 {
501         SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype clip");
502         ARegionType *art;
503
504         st->spaceid= SPACE_CLIP;
505         strncpy(st->name, "Clip", BKE_ST_MAXNAME);
506
507         st->new= clip_new;
508         st->free= clip_free;
509         st->init= clip_init;
510         st->duplicate= clip_duplicate;
511         st->operatortypes= clip_operatortypes;
512         st->keymap= clip_keymap;
513         st->listener= clip_listener;
514         st->context= clip_context;
515         st->refresh= clip_refresh;
516
517         /* regions: main window */
518         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region");
519         art->regionid= RGN_TYPE_WINDOW;
520         art->init= clip_main_area_init;
521         art->draw= clip_main_area_draw;
522         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
523
524         BLI_addhead(&st->regiontypes, art);
525
526         /* regions: properties */
527         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region properties");
528         art->regionid= RGN_TYPE_UI;
529         art->prefsizex= UI_COMPACT_PANEL_WIDTH;
530         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
531         art->init= clip_properties_area_init;
532         art->draw= clip_properties_area_draw;
533         BLI_addhead(&st->regiontypes, art);
534         ED_clip_buttons_register(art);
535
536         /* regions: tools */
537         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region tools");
538         art->regionid= RGN_TYPE_TOOLS;
539         art->prefsizex= UI_COMPACT_PANEL_WIDTH;
540         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
541         art->init= clip_tools_area_init;
542         art->draw= clip_tools_area_draw;
543
544         BLI_addhead(&st->regiontypes, art);
545
546         /* regions: header */
547         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region");
548         art->regionid= RGN_TYPE_HEADER;
549         art->prefsizey= HEADERY;
550         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER;
551
552         art->init= clip_header_area_init;
553         art->draw= clip_header_area_draw;
554
555         BLI_addhead(&st->regiontypes, art);
556
557         BKE_spacetype_register(st);
558 }