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         WM_operatortype_append(CLIP_OT_lock_tracks);
246
247         WM_operatortype_append(CLIP_OT_set_origin);
248         WM_operatortype_append(CLIP_OT_set_floor);
249         WM_operatortype_append(CLIP_OT_set_axis);
250         WM_operatortype_append(CLIP_OT_set_scale);
251
252         WM_operatortype_append(CLIP_OT_set_center_principal);
253
254         WM_operatortype_append(CLIP_OT_clear_track_path);
255
256         WM_operatortype_append(CLIP_OT_slide_marker);
257
258         WM_operatortype_append(CLIP_OT_detect_features);
259 }
260
261 static void clip_keymap(struct wmKeyConfig *keyconf)
262 {
263         wmKeyMap *keymap;
264         wmKeyMapItem *kmi;
265
266         keymap= WM_keymap_find(keyconf, "Clip", SPACE_CLIP, 0);
267
268         WM_keymap_add_item(keymap, "CLIP_OT_open", OKEY, KM_PRESS, KM_ALT, 0);
269
270         WM_keymap_add_item(keymap, "CLIP_OT_tools", TKEY, KM_PRESS, 0, 0);
271          WM_keymap_add_item(keymap, "CLIP_OT_properties", NKEY, KM_PRESS, 0, 0);
272
273         /* ********* View/navigation ******** */
274
275         WM_keymap_add_item(keymap, "CLIP_OT_view_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
276         WM_keymap_add_item(keymap, "CLIP_OT_view_pan", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
277         WM_keymap_add_item(keymap, "CLIP_OT_view_pan", MOUSEPAN, 0, 0, 0);
278
279         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
280         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom", MOUSEZOOM, 0, 0, 0);
281         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_in", WHEELINMOUSE, KM_PRESS, 0, 0);
282         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_out", WHEELOUTMOUSE, KM_PRESS, 0, 0);
283         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0);
284         WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_out", PADMINUS, KM_PRESS, 0, 0);
285
286         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f);
287         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f);
288         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD2, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 2.0f);
289         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD1, KM_PRESS, 0, 0)->ptr, "ratio", 1.0f);
290         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD2, KM_PRESS, 0, 0)->ptr, "ratio", 0.5f);
291         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
292         RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
293
294         WM_keymap_add_item(keymap, "CLIP_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
295
296         WM_keymap_add_item(keymap, "CLIP_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
297
298         WM_keymap_add_item(keymap, "CLIP_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
299         RNA_boolean_set(WM_keymap_add_item(keymap, "CLIP_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
300         WM_keymap_add_item(keymap, "CLIP_OT_select_all", AKEY, KM_PRESS, 0, 0);
301         RNA_enum_set(WM_keymap_add_item(keymap, "CLIP_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "action", SEL_INVERT);
302         WM_keymap_add_item(keymap, "CLIP_OT_select_border", BKEY, KM_PRESS, 0, 0);
303         WM_keymap_add_item(keymap, "CLIP_OT_select_circle", CKEY, KM_PRESS, 0, 0);
304
305         WM_keymap_add_item(keymap, "CLIP_OT_add_marker_slide", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
306
307         kmi= WM_keymap_add_item(keymap, "CLIP_OT_track_markers", LEFTARROWKEY, KM_PRESS, KM_ALT, 0);
308         RNA_boolean_set(kmi->ptr, "backwards", 1);
309         WM_keymap_add_item(keymap, "CLIP_OT_track_markers", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0);
310         kmi= WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_CTRL, 0);
311         RNA_boolean_set(kmi->ptr, "sequence", 1);
312         kmi= WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
313         RNA_boolean_set(kmi->ptr, "backwards", 1);
314         RNA_boolean_set(kmi->ptr, "sequence", 1);
315
316         kmi= WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT, 0);
317         RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_REMAINED);
318         kmi= WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_SHIFT, 0);
319         RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_UPTO);
320         kmi= WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0);
321         RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_ALL);
322
323         WM_keymap_add_item(keymap, "CLIP_OT_delete_track", DELKEY, KM_PRESS, 0, 0);
324         WM_keymap_add_item(keymap, "CLIP_OT_delete_track", XKEY, KM_PRESS, 0, 0);
325
326         WM_keymap_add_item(keymap, "CLIP_OT_delete_marker", DELKEY, KM_PRESS, KM_SHIFT, 0);
327
328         kmi= WM_keymap_add_item(keymap, "WM_OT_context_toggle", LKEY, KM_PRESS, 0, 0);
329         RNA_string_set(kmi->ptr, "data_path", "space_data.lock_selection");
330
331         WM_keymap_add_menu(keymap, "CLIP_MT_tracking_specials", WKEY, KM_PRESS, 0, 0);
332
333         WM_keymap_add_item(keymap, "CLIP_OT_slide_marker", LEFTMOUSE, KM_PRESS, 0, 0);
334
335         WM_keymap_add_item(keymap, "CLIP_OT_hide_tracks", HKEY, KM_PRESS, 0, 0);
336         kmi= WM_keymap_add_item(keymap, "CLIP_OT_hide_tracks", HKEY, KM_PRESS, KM_SHIFT, 0);
337         RNA_boolean_set(kmi->ptr, "unselected", 1);
338         WM_keymap_add_item(keymap, "CLIP_OT_hide_tracks_clear", HKEY, KM_PRESS, KM_ALT, 0);
339
340         kmi= WM_keymap_add_item(keymap, "CLIP_OT_disable_markers", DKEY, KM_PRESS, 0, 0);
341         RNA_enum_set(kmi->ptr, "action", 2);
342
343         kmi= WM_keymap_add_item(keymap, "CLIP_OT_lock_tracks", LKEY, KM_PRESS, KM_CTRL, 0);
344         RNA_enum_set(kmi->ptr, "action", 2);
345
346         transform_keymap_for_space(keyconf, keymap, SPACE_CLIP);
347 }
348
349 const char *clip_context_dir[]= {"edit_movieclip", NULL};
350
351 static int clip_context(const bContext *C, const char *member, bContextDataResult *result)
352 {
353         SpaceClip *sc= CTX_wm_space_clip(C);
354
355         if(CTX_data_dir(member)) {
356                 CTX_data_dir_set(result, clip_context_dir);
357                 return 1;
358         }
359         else if(CTX_data_equals(member, "edit_movieclip")) {
360                 CTX_data_id_pointer_set(result, &sc->clip->id);
361                 return 1;
362         }
363
364         return 0;
365 }
366
367 static void clip_refresh(const bContext *C, ScrArea *UNUSED(sa))
368 {
369         SpaceClip *sc= CTX_wm_space_clip(C);
370
371         BKE_movieclip_user_set_frame(&sc->user, CTX_data_scene(C)->r.cfra);
372 }
373
374 /********************* main region ********************/
375
376 /* sets up the fields of the View2D from zoom and offset */
377 static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
378 {
379         float x1, y1, w, h;
380         int width, height, winx, winy;
381
382         ED_space_clip_size(sc, &width, &height);
383
384         w= width;
385         h= height;
386
387         winx= ar->winrct.xmax - ar->winrct.xmin + 1;
388         winy= ar->winrct.ymax - ar->winrct.ymin + 1;
389
390         ar->v2d.tot.xmin= 0;
391         ar->v2d.tot.ymin= 0;
392         ar->v2d.tot.xmax= w;
393         ar->v2d.tot.ymax= h;
394
395         ar->v2d.mask.xmin= ar->v2d.mask.ymin= 0;
396         ar->v2d.mask.xmax= winx;
397         ar->v2d.mask.ymax= winy;
398
399         /* which part of the image space do we see? */
400         x1= ar->winrct.xmin+(winx-sc->zoom*w)/2.0f;
401         y1= ar->winrct.ymin+(winy-sc->zoom*h)/2.0f;
402
403         x1-= sc->zoom*sc->xof;
404         y1-= sc->zoom*sc->yof;
405
406         /* relative display right */
407         ar->v2d.cur.xmin= ((ar->winrct.xmin - (float)x1)/sc->zoom);
408         ar->v2d.cur.xmax= ar->v2d.cur.xmin + ((float)winx/sc->zoom);
409
410         /* relative display left */
411         ar->v2d.cur.ymin= ((ar->winrct.ymin-(float)y1)/sc->zoom);
412         ar->v2d.cur.ymax= ar->v2d.cur.ymin + ((float)winy/sc->zoom);
413
414         /* normalize 0.0..1.0 */
415         ar->v2d.cur.xmin /= w;
416         ar->v2d.cur.xmax /= w;
417         ar->v2d.cur.ymin /= h;
418         ar->v2d.cur.ymax /= h;
419 }
420
421 /* add handlers, stuff you only do once or on area/region changes */
422 static void clip_main_area_init(wmWindowManager *wm, ARegion *ar)
423 {
424         wmKeyMap *keymap;
425
426         UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
427
428         /* own keymap */
429         keymap= WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0);
430         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
431 }
432
433 static void clip_main_area_draw(const bContext *C, ARegion *ar)
434 {
435         /* draw entirely, view changes should be handled here */
436         SpaceClip *sc= CTX_wm_space_clip(C);
437         Scene *scene= CTX_data_scene(C);
438         MovieClip *clip= ED_space_clip(sc);
439
440         /* if trcking is in progress, we should sunchronize framenr from clipuser
441            so latest tracked frame would be shown */
442         if(clip && clip->tracking_context)
443                 BKE_tracking_sync_user(&sc->user, clip->tracking_context);
444
445         if(sc->flag&SC_LOCK_SELECTION)
446                 ED_clip_view_selection(sc, ar, 0);
447
448         /* clear and setup matrix */
449         UI_ThemeClearColor(TH_BACK);
450         glClear(GL_COLOR_BUFFER_BIT);
451
452         /* data... */
453         movieclip_main_area_set_view2d(sc, ar);
454         draw_clip_main(sc, ar, scene);
455
456         /* reset view matrix */
457         UI_view2d_view_restore(C);
458 }
459
460 /****************** header region ******************/
461
462 /* add handlers, stuff you only do once or on area/region changes */
463 static void clip_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
464 {
465         ED_region_header_init(ar);
466 }
467
468 static void clip_header_area_draw(const bContext *C, ARegion *ar)
469 {
470         ED_region_header(C, ar);
471 }
472
473 /****************** tools region ******************/
474
475 /* add handlers, stuff you only do once or on area/region changes */
476 static void clip_tools_area_init(wmWindowManager *wm, ARegion *ar)
477 {
478         ED_region_panels_init(wm, ar);
479 }
480
481 static void clip_tools_area_draw(const bContext *C, ARegion *ar)
482 {
483         ED_region_panels(C, ar, 1, NULL, -1);
484 }
485
486 /****************** properties region ******************/
487
488 /* add handlers, stuff you only do once or on area/region changes */
489 static void clip_properties_area_init(wmWindowManager *wm, ARegion *ar)
490 {
491         ED_region_panels_init(wm, ar);
492 }
493
494 static void clip_properties_area_draw(const bContext *C, ARegion *ar)
495 {
496         SpaceClip *sc= CTX_wm_space_clip(C);
497
498         BKE_movieclip_update_scopes(sc->clip, &sc->user, &sc->scopes);
499
500         ED_region_panels(C, ar, 1, NULL, -1);
501 }
502
503 /********************* registration ********************/
504
505 /* only called once, from space/spacetypes.c */
506 void ED_spacetype_clip(void)
507 {
508         SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype clip");
509         ARegionType *art;
510
511         st->spaceid= SPACE_CLIP;
512         strncpy(st->name, "Clip", BKE_ST_MAXNAME);
513
514         st->new= clip_new;
515         st->free= clip_free;
516         st->init= clip_init;
517         st->duplicate= clip_duplicate;
518         st->operatortypes= clip_operatortypes;
519         st->keymap= clip_keymap;
520         st->listener= clip_listener;
521         st->context= clip_context;
522         st->refresh= clip_refresh;
523
524         /* regions: main window */
525         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region");
526         art->regionid= RGN_TYPE_WINDOW;
527         art->init= clip_main_area_init;
528         art->draw= clip_main_area_draw;
529         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
530
531         BLI_addhead(&st->regiontypes, art);
532
533         /* regions: properties */
534         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region properties");
535         art->regionid= RGN_TYPE_UI;
536         art->prefsizex= UI_COMPACT_PANEL_WIDTH;
537         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
538         art->init= clip_properties_area_init;
539         art->draw= clip_properties_area_draw;
540         BLI_addhead(&st->regiontypes, art);
541         ED_clip_buttons_register(art);
542
543         /* regions: tools */
544         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region tools");
545         art->regionid= RGN_TYPE_TOOLS;
546         art->prefsizex= UI_COMPACT_PANEL_WIDTH;
547         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
548         art->init= clip_tools_area_init;
549         art->draw= clip_tools_area_draw;
550
551         BLI_addhead(&st->regiontypes, art);
552
553         /* regions: header */
554         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region");
555         art->regionid= RGN_TYPE_HEADER;
556         art->prefsizey= HEADERY;
557         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER;
558
559         art->init= clip_header_area_init;
560         art->draw= clip_header_area_draw;
561
562         BLI_addhead(&st->regiontypes, art);
563
564         BKE_spacetype_register(st);
565 }