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         sc->scopes.track_preview_height= 120;
100
101         /* header */
102         ar= MEM_callocN(sizeof(ARegion), "header for clip");
103
104         BLI_addtail(&sc->regionbase, ar);
105         ar->regiontype= RGN_TYPE_HEADER;
106         ar->alignment= RGN_ALIGN_BOTTOM;
107
108         /* tools view */
109         ar= MEM_callocN(sizeof(ARegion), "tools for logic");
110
111         BLI_addtail(&sc->regionbase, ar);
112         ar->regiontype= RGN_TYPE_TOOLS;
113         ar->alignment= RGN_ALIGN_LEFT;
114
115         /* properties view */
116         ar= MEM_callocN(sizeof(ARegion), "properties for logic");
117
118         BLI_addtail(&sc->regionbase, ar);
119         ar->regiontype= RGN_TYPE_UI;
120         ar->alignment= RGN_ALIGN_RIGHT;
121
122         /* main area */
123         ar= MEM_callocN(sizeof(ARegion), "main area for clip");
124
125         BLI_addtail(&sc->regionbase, ar);
126         ar->regiontype= RGN_TYPE_WINDOW;
127
128         return (SpaceLink *)sc;
129 }
130
131 /* not spacelink itself */
132 static void clip_free(SpaceLink *sl)
133 {
134         SpaceClip *sc= (SpaceClip*) sl;
135
136         sc->clip= NULL;
137
138         if(sc->scopes.track_preview)
139                 IMB_freeImBuf(sc->scopes.track_preview);
140 }
141
142 /* spacetype; init callback */
143 static void clip_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
144 {
145
146 }
147
148 static SpaceLink *clip_duplicate(SpaceLink *sl)
149 {
150         SpaceClip *scn= MEM_dupallocN(sl);
151
152         /* clear or remove stuff from old */
153         scn->scopes.track_preview= NULL;
154         scn->scopes.ok= 0;
155
156         return (SpaceLink *)scn;
157 }
158
159 static void clip_listener(ScrArea *sa, wmNotifier *wmn)
160 {
161         SpaceClip *sc= sa->spacedata.first;
162
163         (void)sc;
164
165         /* context changes */
166         switch(wmn->category) {
167                 case NC_SCENE:
168                         switch(wmn->data) {
169                                 case ND_FRAME:
170                                         clip_scopes_tag_refresh(sa);
171                                         /* no break! */
172
173                                 case ND_FRAME_RANGE:
174                                         ED_area_tag_refresh(sa);
175                                         ED_area_tag_redraw(sa);
176                                         break;
177                         }
178                         break;
179                 case NC_MOVIECLIP:
180                         switch(wmn->data) {
181                                 case ND_DISPLAY:
182                                 case ND_SELECT:
183                                         clip_scopes_tag_refresh(sa);
184                                         ED_area_tag_redraw(sa);
185                                         break;
186                         }
187                         switch(wmn->action) {
188                                 case NA_REMOVED:
189                                 case NA_SELECTED:
190                                 case NA_EDITED:
191                                 case NA_EVALUATED:
192                                         clip_scopes_tag_refresh(sa);
193                                         ED_area_tag_redraw(sa);
194                                         break;
195                         }
196                         break;
197                 case NC_GEOM:
198                         switch(wmn->data) {
199                                 case ND_SELECT:
200                                         ED_area_tag_redraw(sa);
201                                         clip_scopes_tag_refresh(sa);
202                                         break;
203                         }
204                         break;
205                 case NC_SPACE:
206                         if(wmn->data==ND_SPACE_CLIP) {
207                                 clip_scopes_tag_refresh(sa);
208                                 ED_area_tag_redraw(sa);
209                         }
210                         break;
211         }
212 }
213
214 static void clip_operatortypes(void)
215 {
216         WM_operatortype_append(CLIP_OT_open);
217         WM_operatortype_append(CLIP_OT_reload);
218         WM_operatortype_append(CLIP_OT_tools);
219          WM_operatortype_append(CLIP_OT_properties);
220         // WM_operatortype_append(CLIP_OT_unlink);
221         WM_operatortype_append(CLIP_OT_view_pan);
222         WM_operatortype_append(CLIP_OT_view_zoom);
223         WM_operatortype_append(CLIP_OT_view_zoom_in);
224         WM_operatortype_append(CLIP_OT_view_zoom_out);
225         WM_operatortype_append(CLIP_OT_view_zoom_ratio);
226         WM_operatortype_append(CLIP_OT_view_all);
227         WM_operatortype_append(CLIP_OT_view_selected);
228
229         WM_operatortype_append(CLIP_OT_select);
230         WM_operatortype_append(CLIP_OT_select_all);
231         WM_operatortype_append(CLIP_OT_select_border);
232         WM_operatortype_append(CLIP_OT_select_circle);
233
234         WM_operatortype_append(CLIP_OT_add_marker);
235         WM_operatortype_append(CLIP_OT_delete_track);
236         WM_operatortype_append(CLIP_OT_delete_marker);
237
238         WM_operatortype_append(CLIP_OT_track_markers);
239         WM_operatortype_append(CLIP_OT_solve_camera);
240         WM_operatortype_append(CLIP_OT_clear_reconstruction);
241
242         WM_operatortype_append(CLIP_OT_disable_markers);
243         WM_operatortype_append(CLIP_OT_hide_tracks);
244         WM_operatortype_append(CLIP_OT_hide_tracks_clear);
245
246         WM_operatortype_append(CLIP_OT_set_origin);
247         WM_operatortype_append(CLIP_OT_set_floor);
248         WM_operatortype_append(CLIP_OT_set_axis);
249         WM_operatortype_append(CLIP_OT_set_scale);
250
251         WM_operatortype_append(CLIP_OT_set_center_principal);
252
253         WM_operatortype_append(CLIP_OT_clear_track_path);
254
255         WM_operatortype_append(CLIP_OT_slide_marker);
256
257         WM_operatortype_append(CLIP_OT_detect_features);
258 }
259
260 static void clip_keymap(struct wmKeyConfig *keyconf)
261 {
262         wmKeyMap *keymap;
263         wmKeyMapItem *kmi;
264
265         keymap= WM_keymap_find(keyconf, "Clip", SPACE_CLIP, 0);
266
267         WM_keymap_add_item(keymap, "CLIP_OT_open", OKEY, KM_PRESS, KM_ALT, 0);
268
269         WM_keymap_add_item(keymap, "CLIP_OT_tools", TKEY, KM_PRESS, 0, 0);
270          WM_keymap_add_item(keymap, "CLIP_OT_properties", NKEY, KM_PRESS, 0, 0);
271
272         /* ********* View/navigation ******** */
273
274         WM_keymap_add_item(keymap, "CLIP_OT_view_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
275         WM_keymap_add_item(keymap, "CLIP_OT_view_pan", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
276         WM_keymap_add_item(keymap, "CLIP_OT_view_pan", MOUSEPAN, 0, 0, 0);
277
278         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
279         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom", MOUSEZOOM, 0, 0, 0);
280         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_in", WHEELINMOUSE, KM_PRESS, 0, 0);
281         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_out", WHEELOUTMOUSE, KM_PRESS, 0, 0);
282         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0);
283         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_out", PADMINUS, KM_PRESS, 0, 0);
284
285         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f);
286         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f);
287         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD2, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 2.0f);
288         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD1, KM_PRESS, 0, 0)->ptr, "ratio", 1.0f);
289         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD2, KM_PRESS, 0, 0)->ptr, "ratio", 0.5f);
290         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
291         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
292
293         WM_keymap_add_item(keymap, "CLIP_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
294
295         WM_keymap_add_item(keymap, "CLIP_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
296
297         WM_keymap_add_item(keymap, "CLIP_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
298         RNA_boolean_set(WM_keymap_add_item(keymap, "CLIP_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
299         WM_keymap_add_item(keymap, "CLIP_OT_select_all", AKEY, KM_PRESS, 0, 0);
300         RNA_enum_set(WM_keymap_add_item(keymap, "CLIP_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "action", SEL_INVERT);
301         WM_keymap_add_item(keymap, "CLIP_OT_select_border", BKEY, KM_PRESS, 0, 0);
302         WM_keymap_add_item(keymap, "CLIP_OT_select_circle", CKEY, KM_PRESS, 0, 0);
303
304         WM_keymap_add_item(keymap, "CLIP_OT_add_marker_slide", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
305
306         kmi= WM_keymap_add_item(keymap, "CLIP_OT_track_markers", LEFTARROWKEY, KM_PRESS, KM_ALT, 0);
307         RNA_boolean_set(kmi->ptr, "backwards", 1);
308         WM_keymap_add_item(keymap, "CLIP_OT_track_markers", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0);
309         kmi= WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_CTRL, 0);
310         RNA_boolean_set(kmi->ptr, "sequence", 1);
311         kmi= WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
312         RNA_boolean_set(kmi->ptr, "backwards", 1);
313         RNA_boolean_set(kmi->ptr, "sequence", 1);
314
315         kmi= WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT, 0);
316         RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_REMAINED);
317         kmi= WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_SHIFT, 0);
318         RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_UPTO);
319         kmi= WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0);
320         RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_ALL);
321
322         WM_keymap_add_item(keymap, "CLIP_OT_delete_track", DELKEY, KM_PRESS, 0, 0);
323         WM_keymap_add_item(keymap, "CLIP_OT_delete_track", XKEY, KM_PRESS, 0, 0);
324
325         WM_keymap_add_item(keymap, "CLIP_OT_delete_marker", DELKEY, KM_PRESS, KM_SHIFT, 0);
326
327         kmi= WM_keymap_add_item(keymap, "WM_OT_context_toggle", LKEY, KM_PRESS, 0, 0);
328         RNA_string_set(kmi->ptr, "data_path", "space_data.lock_selection");
329
330         WM_keymap_add_menu(keymap, "CLIP_MT_tracking_specials", WKEY, KM_PRESS, 0, 0);
331
332         WM_keymap_add_item(keymap, "CLIP_OT_slide_marker", LEFTMOUSE, KM_PRESS, 0, 0);
333
334         WM_keymap_add_item(keymap, "CLIP_OT_hide_tracks", HKEY, KM_PRESS, 0, 0);
335         kmi= WM_keymap_add_item(keymap, "CLIP_OT_hide_tracks", HKEY, KM_PRESS, KM_SHIFT, 0);
336         RNA_boolean_set(kmi->ptr, "unselected", 1);
337         WM_keymap_add_item(keymap, "CLIP_OT_hide_tracks_clear", HKEY, KM_PRESS, KM_ALT, 0);
338
339         kmi= WM_keymap_add_item(keymap, "CLIP_OT_disable_markers", DKEY, KM_PRESS, 0, 0);
340         RNA_enum_set(kmi->ptr, "action", 2);
341
342         transform_keymap_for_space(keyconf, keymap, SPACE_CLIP);
343 }
344
345 const char *clip_context_dir[]= {"edit_movieclip", NULL};
346
347 static int clip_context(const bContext *C, const char *member, bContextDataResult *result)
348 {
349         SpaceClip *sc= CTX_wm_space_clip(C);
350
351         if(CTX_data_dir(member)) {
352                 CTX_data_dir_set(result, clip_context_dir);
353                 return 1;
354         }
355         else if(CTX_data_equals(member, "edit_movieclip")) {
356                 CTX_data_id_pointer_set(result, &sc->clip->id);
357                 return 1;
358         }
359
360         return 0;
361 }
362
363 static void clip_refresh(const bContext *C, ScrArea *UNUSED(sa))
364 {
365         SpaceClip *sc= CTX_wm_space_clip(C);
366
367         BKE_movieclip_user_set_frame(&sc->user, CTX_data_scene(C)->r.cfra);
368 }
369
370 /********************* main region ********************/
371
372 /* sets up the fields of the View2D from zoom and offset */
373 static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
374 {
375         float x1, y1, w, h;
376         int width, height, winx, winy;
377
378         ED_space_clip_size(sc, &width, &height);
379
380         w= width;
381         h= height;
382
383         winx= ar->winrct.xmax - ar->winrct.xmin + 1;
384         winy= ar->winrct.ymax - ar->winrct.ymin + 1;
385
386         ar->v2d.tot.xmin= 0;
387         ar->v2d.tot.ymin= 0;
388         ar->v2d.tot.xmax= w;
389         ar->v2d.tot.ymax= h;
390
391         ar->v2d.mask.xmin= ar->v2d.mask.ymin= 0;
392         ar->v2d.mask.xmax= winx;
393         ar->v2d.mask.ymax= winy;
394
395         /* which part of the image space do we see? */
396         x1= ar->winrct.xmin+(winx-sc->zoom*w)/2.0f;
397         y1= ar->winrct.ymin+(winy-sc->zoom*h)/2.0f;
398
399         x1-= sc->zoom*sc->xof;
400         y1-= sc->zoom*sc->yof;
401
402         /* relative display right */
403         ar->v2d.cur.xmin= ((ar->winrct.xmin - (float)x1)/sc->zoom);
404         ar->v2d.cur.xmax= ar->v2d.cur.xmin + ((float)winx/sc->zoom);
405
406         /* relative display left */
407         ar->v2d.cur.ymin= ((ar->winrct.ymin-(float)y1)/sc->zoom);
408         ar->v2d.cur.ymax= ar->v2d.cur.ymin + ((float)winy/sc->zoom);
409
410         /* normalize 0.0..1.0 */
411         ar->v2d.cur.xmin /= w;
412         ar->v2d.cur.xmax /= w;
413         ar->v2d.cur.ymin /= h;
414         ar->v2d.cur.ymax /= h;
415 }
416
417 /* add handlers, stuff you only do once or on area/region changes */
418 static void clip_main_area_init(wmWindowManager *wm, ARegion *ar)
419 {
420         wmKeyMap *keymap;
421
422         UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
423
424         /* own keymap */
425         keymap= WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0);
426         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
427 }
428
429 static void clip_main_area_draw(const bContext *C, ARegion *ar)
430 {
431         /* draw entirely, view changes should be handled here */
432         SpaceClip *sc= CTX_wm_space_clip(C);
433         Scene *scene= CTX_data_scene(C);
434         MovieClip *clip= ED_space_clip(sc);
435
436         /* if trcking is in progress, we should sunchronize framenr from clipuser
437            so latest tracked frame would be shown */
438         if(clip && clip->tracking_context)
439                 BKE_tracking_sync_user(&sc->user, clip->tracking_context);
440
441         if(sc->flag&SC_LOCK_SELECTION)
442                 ED_clip_view_selection(sc, ar, 0);
443
444         /* clear and setup matrix */
445         UI_ThemeClearColor(TH_BACK);
446         glClear(GL_COLOR_BUFFER_BIT);
447
448         /* data... */
449         movieclip_main_area_set_view2d(sc, ar);
450         draw_clip_main(sc, ar, scene);
451
452         /* reset view matrix */
453         UI_view2d_view_restore(C);
454 }
455
456 /****************** header region ******************/
457
458 /* add handlers, stuff you only do once or on area/region changes */
459 static void clip_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
460 {
461         ED_region_header_init(ar);
462 }
463
464 static void clip_header_area_draw(const bContext *C, ARegion *ar)
465 {
466         ED_region_header(C, ar);
467 }
468
469 /****************** tools region ******************/
470
471 /* add handlers, stuff you only do once or on area/region changes */
472 static void clip_tools_area_init(wmWindowManager *wm, ARegion *ar)
473 {
474         ED_region_panels_init(wm, ar);
475 }
476
477 static void clip_tools_area_draw(const bContext *C, ARegion *ar)
478 {
479         ED_region_panels(C, ar, 1, NULL, -1);
480 }
481
482 /****************** properties region ******************/
483
484 /* add handlers, stuff you only do once or on area/region changes */
485 static void clip_properties_area_init(wmWindowManager *wm, ARegion *ar)
486 {
487         ED_region_panels_init(wm, ar);
488 }
489
490 static void clip_properties_area_draw(const bContext *C, ARegion *ar)
491 {
492         SpaceClip *sc= CTX_wm_space_clip(C);
493
494         BKE_movieclip_update_scopes(sc->clip, &sc->user, &sc->scopes);
495
496         ED_region_panels(C, ar, 1, NULL, -1);
497 }
498
499 /********************* registration ********************/
500
501 /* only called once, from space/spacetypes.c */
502 void ED_spacetype_clip(void)
503 {
504         SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype clip");
505         ARegionType *art;
506
507         st->spaceid= SPACE_CLIP;
508         strncpy(st->name, "Clip", BKE_ST_MAXNAME);
509
510         st->new= clip_new;
511         st->free= clip_free;
512         st->init= clip_init;
513         st->duplicate= clip_duplicate;
514         st->operatortypes= clip_operatortypes;
515         st->keymap= clip_keymap;
516         st->listener= clip_listener;
517         st->context= clip_context;
518         st->refresh= clip_refresh;
519
520         /* regions: main window */
521         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region");
522         art->regionid= RGN_TYPE_WINDOW;
523         art->init= clip_main_area_init;
524         art->draw= clip_main_area_draw;
525         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
526
527         BLI_addhead(&st->regiontypes, art);
528
529         /* regions: properties */
530         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region properties");
531         art->regionid= RGN_TYPE_UI;
532         art->prefsizex= UI_COMPACT_PANEL_WIDTH;
533         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
534         art->init= clip_properties_area_init;
535         art->draw= clip_properties_area_draw;
536         BLI_addhead(&st->regiontypes, art);
537         ED_clip_buttons_register(art);
538
539         /* regions: tools */
540         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region tools");
541         art->regionid= RGN_TYPE_TOOLS;
542         art->prefsizex= UI_COMPACT_PANEL_WIDTH;
543         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
544         art->init= clip_tools_area_init;
545         art->draw= clip_tools_area_draw;
546
547         BLI_addhead(&st->regiontypes, art);
548
549         /* regions: header */
550         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region");
551         art->regionid= RGN_TYPE_HEADER;
552         art->prefsizey= HEADERY;
553         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER;
554
555         art->init= clip_header_area_init;
556         art->draw= clip_header_area_draw;
557
558         BLI_addhead(&st->regiontypes, art);
559
560         BKE_spacetype_register(st);
561 }