Merging r38516 through r38561 from trunk into soc-2011-tomato
[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", 0);
345
346         kmi= WM_keymap_add_item(keymap, "CLIP_OT_lock_tracks", LKEY, KM_PRESS, KM_ALT, 0);
347         RNA_enum_set(kmi->ptr, "action", 1);
348
349         transform_keymap_for_space(keyconf, keymap, SPACE_CLIP);
350 }
351
352 const char *clip_context_dir[]= {"edit_movieclip", NULL};
353
354 static int clip_context(const bContext *C, const char *member, bContextDataResult *result)
355 {
356         SpaceClip *sc= CTX_wm_space_clip(C);
357
358         if(CTX_data_dir(member)) {
359                 CTX_data_dir_set(result, clip_context_dir);
360                 return 1;
361         }
362         else if(CTX_data_equals(member, "edit_movieclip")) {
363                 CTX_data_id_pointer_set(result, &sc->clip->id);
364                 return 1;
365         }
366
367         return 0;
368 }
369
370 static void clip_refresh(const bContext *C, ScrArea *UNUSED(sa))
371 {
372         SpaceClip *sc= CTX_wm_space_clip(C);
373
374         BKE_movieclip_user_set_frame(&sc->user, CTX_data_scene(C)->r.cfra);
375 }
376
377 /********************* main region ********************/
378
379 /* sets up the fields of the View2D from zoom and offset */
380 static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
381 {
382         MovieClip *clip= ED_space_clip(sc);
383         float x1, y1, w, h;
384         int width, height, winx, winy;
385
386         ED_space_clip_size(sc, &width, &height);
387
388         w= width;
389         h= height;
390
391         if(clip)
392                 h*= clip->aspy/clip->aspx;
393
394         winx= ar->winrct.xmax - ar->winrct.xmin + 1;
395         winy= ar->winrct.ymax - ar->winrct.ymin + 1;
396
397         ar->v2d.tot.xmin= 0;
398         ar->v2d.tot.ymin= 0;
399         ar->v2d.tot.xmax= w;
400         ar->v2d.tot.ymax= h;
401
402         ar->v2d.mask.xmin= ar->v2d.mask.ymin= 0;
403         ar->v2d.mask.xmax= winx;
404         ar->v2d.mask.ymax= winy;
405
406         /* which part of the image space do we see? */
407         x1= ar->winrct.xmin+(winx-sc->zoom*w)/2.0f;
408         y1= ar->winrct.ymin+(winy-sc->zoom*h)/2.0f;
409
410         x1-= sc->zoom*sc->xof;
411         y1-= sc->zoom*sc->yof;
412
413         /* relative display right */
414         ar->v2d.cur.xmin= ((ar->winrct.xmin - (float)x1)/sc->zoom);
415         ar->v2d.cur.xmax= ar->v2d.cur.xmin + ((float)winx/sc->zoom);
416
417         /* relative display left */
418         ar->v2d.cur.ymin= ((ar->winrct.ymin-(float)y1)/sc->zoom);
419         ar->v2d.cur.ymax= ar->v2d.cur.ymin + ((float)winy/sc->zoom);
420
421         /* normalize 0.0..1.0 */
422         ar->v2d.cur.xmin /= w;
423         ar->v2d.cur.xmax /= w;
424         ar->v2d.cur.ymin /= h;
425         ar->v2d.cur.ymax /= h;
426 }
427
428 /* add handlers, stuff you only do once or on area/region changes */
429 static void clip_main_area_init(wmWindowManager *wm, ARegion *ar)
430 {
431         wmKeyMap *keymap;
432
433         UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
434
435         /* own keymap */
436         keymap= WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0);
437         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
438 }
439
440 static void clip_main_area_draw(const bContext *C, ARegion *ar)
441 {
442         /* draw entirely, view changes should be handled here */
443         SpaceClip *sc= CTX_wm_space_clip(C);
444         Scene *scene= CTX_data_scene(C);
445         MovieClip *clip= ED_space_clip(sc);
446
447         /* if trcking is in progress, we should sunchronize framenr from clipuser
448            so latest tracked frame would be shown */
449         if(clip && clip->tracking_context)
450                 BKE_tracking_sync_user(&sc->user, clip->tracking_context);
451
452         if(sc->flag&SC_LOCK_SELECTION)
453                 ED_clip_view_selection(sc, ar, 0);
454
455         /* clear and setup matrix */
456         UI_ThemeClearColor(TH_BACK);
457         glClear(GL_COLOR_BUFFER_BIT);
458
459         /* data... */
460         movieclip_main_area_set_view2d(sc, ar);
461         draw_clip_main(sc, ar, scene);
462
463         /* reset view matrix */
464         UI_view2d_view_restore(C);
465 }
466
467 /****************** header region ******************/
468
469 /* add handlers, stuff you only do once or on area/region changes */
470 static void clip_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
471 {
472         ED_region_header_init(ar);
473 }
474
475 static void clip_header_area_draw(const bContext *C, ARegion *ar)
476 {
477         ED_region_header(C, ar);
478 }
479
480 /****************** tools region ******************/
481
482 /* add handlers, stuff you only do once or on area/region changes */
483 static void clip_tools_area_init(wmWindowManager *wm, ARegion *ar)
484 {
485         ED_region_panels_init(wm, ar);
486 }
487
488 static void clip_tools_area_draw(const bContext *C, ARegion *ar)
489 {
490         ED_region_panels(C, ar, 1, NULL, -1);
491 }
492
493 /****************** properties region ******************/
494
495 /* add handlers, stuff you only do once or on area/region changes */
496 static void clip_properties_area_init(wmWindowManager *wm, ARegion *ar)
497 {
498         ED_region_panels_init(wm, ar);
499 }
500
501 static void clip_properties_area_draw(const bContext *C, ARegion *ar)
502 {
503         SpaceClip *sc= CTX_wm_space_clip(C);
504
505         BKE_movieclip_update_scopes(sc->clip, &sc->user, &sc->scopes);
506
507         ED_region_panels(C, ar, 1, NULL, -1);
508 }
509
510 /********************* registration ********************/
511
512 /* only called once, from space/spacetypes.c */
513 void ED_spacetype_clip(void)
514 {
515         SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype clip");
516         ARegionType *art;
517
518         st->spaceid= SPACE_CLIP;
519         strncpy(st->name, "Clip", BKE_ST_MAXNAME);
520
521         st->new= clip_new;
522         st->free= clip_free;
523         st->init= clip_init;
524         st->duplicate= clip_duplicate;
525         st->operatortypes= clip_operatortypes;
526         st->keymap= clip_keymap;
527         st->listener= clip_listener;
528         st->context= clip_context;
529         st->refresh= clip_refresh;
530
531         /* regions: main window */
532         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region");
533         art->regionid= RGN_TYPE_WINDOW;
534         art->init= clip_main_area_init;
535         art->draw= clip_main_area_draw;
536         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
537
538         BLI_addhead(&st->regiontypes, art);
539
540         /* regions: properties */
541         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region properties");
542         art->regionid= RGN_TYPE_UI;
543         art->prefsizex= UI_COMPACT_PANEL_WIDTH;
544         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
545         art->init= clip_properties_area_init;
546         art->draw= clip_properties_area_draw;
547         BLI_addhead(&st->regiontypes, art);
548         ED_clip_buttons_register(art);
549
550         /* regions: tools */
551         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region tools");
552         art->regionid= RGN_TYPE_TOOLS;
553         art->prefsizex= UI_COMPACT_PANEL_WIDTH;
554         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI;
555         art->init= clip_tools_area_init;
556         art->draw= clip_tools_area_draw;
557
558         BLI_addhead(&st->regiontypes, art);
559
560         /* regions: header */
561         art= MEM_callocN(sizeof(ARegionType), "spacetype clip region");
562         art->regionid= RGN_TYPE_HEADER;
563         art->prefsizey= HEADERY;
564         art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER;
565
566         art->init= clip_header_area_init;
567         art->draw= clip_header_area_draw;
568
569         BLI_addhead(&st->regiontypes, art);
570
571         BKE_spacetype_register(st);
572 }