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