Workbench: Cleaner Shadow edges own shadow
[blender.git] / source / blender / editors / space_nla / space_nla.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version. 
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2008 Blender Foundation.
19  * All rights reserved.
20  *
21  * 
22  * Contributor(s): Blender Foundation
23  *
24  * ***** END GPL LICENSE BLOCK *****
25  */
26
27 /** \file blender/editors/space_nla/space_nla.c
28  *  \ingroup spnla
29  */
30
31
32 #include <string.h>
33 #include <stdio.h>
34
35 #include "DNA_anim_types.h"
36 #include "DNA_group_types.h"
37 #include "DNA_scene_types.h"
38
39 #include "MEM_guardedalloc.h"
40
41 #include "BLI_blenlib.h"
42 #include "BLI_utildefines.h"
43
44 #include "BKE_context.h"
45 #include "BKE_global.h"
46 #include "BKE_main.h"
47 #include "BKE_screen.h"
48
49 #include "ED_space_api.h"
50 #include "ED_anim_api.h"
51 #include "ED_markers.h"
52 #include "ED_screen.h"
53
54 #include "BIF_gl.h"
55
56 #include "WM_api.h"
57 #include "WM_types.h"
58 #include "WM_message.h"
59
60 #include "RNA_access.h"
61
62 #include "UI_resources.h"
63 #include "UI_view2d.h"
64
65 #include "nla_intern.h" /* own include */
66
67 /* ******************** manage regions ********************* */
68
69 ARegion *nla_has_buttons_region(ScrArea *sa)
70 {
71         ARegion *ar, *arnew;
72
73         ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
74         if (ar) return ar;
75
76         /* add subdiv level; after main */
77         ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
78
79         /* is error! */
80         if (ar == NULL) return NULL;
81         
82         arnew = MEM_callocN(sizeof(ARegion), "buttons for nla");
83         
84         BLI_insertlinkafter(&sa->regionbase, ar, arnew);
85         arnew->regiontype = RGN_TYPE_UI;
86         arnew->alignment = RGN_ALIGN_RIGHT;
87         
88         arnew->flag = RGN_FLAG_HIDDEN;
89         
90         return arnew;
91 }
92
93
94
95 /* ******************** default callbacks for nla space ***************** */
96
97 static SpaceLink *nla_new(const ScrArea *sa, const Scene *scene)
98 {
99         ARegion *ar;
100         SpaceNla *snla;
101         
102         snla = MEM_callocN(sizeof(SpaceNla), "initnla");
103         snla->spacetype = SPACE_NLA;
104         
105         /* allocate DopeSheet data for NLA Editor */
106         snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
107         snla->ads->source = (ID *)scene;
108         
109         /* set auto-snapping settings */
110         snla->autosnap = SACTSNAP_FRAME;
111         
112         /* header */
113         ar = MEM_callocN(sizeof(ARegion), "header for nla");
114         
115         BLI_addtail(&snla->regionbase, ar);
116         ar->regiontype = RGN_TYPE_HEADER;
117         ar->alignment = RGN_ALIGN_BOTTOM;
118         
119         /* channel list region */
120         ar = MEM_callocN(sizeof(ARegion), "channel list for nla");
121         BLI_addtail(&snla->regionbase, ar);
122         ar->regiontype = RGN_TYPE_CHANNELS;
123         ar->alignment = RGN_ALIGN_LEFT;
124         
125         /* only need to set these settings since this will use the 'stack' configuration */
126         ar->v2d.scroll = V2D_SCROLL_BOTTOM;
127         ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
128         
129         /* ui buttons */
130         ar = MEM_callocN(sizeof(ARegion), "buttons region for nla");
131         
132         BLI_addtail(&snla->regionbase, ar);
133         ar->regiontype = RGN_TYPE_UI;
134         ar->alignment = RGN_ALIGN_RIGHT;
135         ar->flag = RGN_FLAG_HIDDEN;
136         
137         /* main region */
138         ar = MEM_callocN(sizeof(ARegion), "main region for nla");
139         
140         BLI_addtail(&snla->regionbase, ar);
141         ar->regiontype = RGN_TYPE_WINDOW;
142         
143         ar->v2d.tot.xmin = (float)(SFRA - 10);
144         ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
145         ar->v2d.tot.xmax = (float)(EFRA + 10);
146         ar->v2d.tot.ymax = 0.0f;
147         
148         ar->v2d.cur = ar->v2d.tot;
149         
150         ar->v2d.min[0] = 0.0f;
151         ar->v2d.min[1] = 0.0f;
152         
153         ar->v2d.max[0] = MAXFRAMEF;
154         ar->v2d.max[1] = 10000.0f;
155
156         ar->v2d.minzoom = 0.01f;
157         ar->v2d.maxzoom = 50;
158         ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
159         ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
160         ar->v2d.keepzoom = V2D_LOCKZOOM_Y;
161         ar->v2d.keepofs = V2D_KEEPOFS_Y;
162         ar->v2d.align = V2D_ALIGN_NO_POS_Y;
163         ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
164         
165         return (SpaceLink *)snla;
166 }
167
168 /* not spacelink itself */
169 static void nla_free(SpaceLink *sl)
170 {       
171         SpaceNla *snla = (SpaceNla *) sl;
172         
173         if (snla->ads) {
174                 BLI_freelistN(&snla->ads->chanbase);
175                 MEM_freeN(snla->ads);
176         }
177 }
178
179
180 /* spacetype; init callback */
181 static void nla_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
182 {
183         SpaceNla *snla = (SpaceNla *)sa->spacedata.first;
184         
185         /* init dopesheet data if non-existent (i.e. for old files) */
186         if (snla->ads == NULL) {
187                 snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
188                 snla->ads->source = (ID *)G.main->scene.first; // XXX this is bad, but we need this to be set correct
189         }
190
191         ED_area_tag_refresh(sa);
192 }
193
194 static SpaceLink *nla_duplicate(SpaceLink *sl)
195 {
196         SpaceNla *snlan = MEM_dupallocN(sl);
197         
198         /* clear or remove stuff from old */
199         snlan->ads = MEM_dupallocN(snlan->ads);
200         
201         return (SpaceLink *)snlan;
202 }
203
204 /* add handlers, stuff you only do once or on area/region changes */
205 static void nla_channel_region_init(wmWindowManager *wm, ARegion *ar)
206 {
207         wmKeyMap *keymap;
208         
209         /* ensure the 2d view sync works - main region has bottom scroller */
210         ar->v2d.scroll = V2D_SCROLL_BOTTOM;
211         
212         UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
213         
214         /* own keymap */
215         /* own channels map first to override some channel keymaps */
216         keymap = WM_keymap_find(wm->defaultconf, "NLA Channels", SPACE_NLA, 0);
217         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
218         /* now generic channels map for everything else that can apply */
219         keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0);
220         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
221         
222         keymap = WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0);
223         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
224 }
225
226 /* draw entirely, view changes should be handled here */
227 static void nla_channel_region_draw(const bContext *C, ARegion *ar)
228 {
229         bAnimContext ac;
230         View2D *v2d = &ar->v2d;
231         View2DScrollers *scrollers;
232         
233         /* clear and setup matrix */
234         UI_ThemeClearColor(TH_BACK);
235         glClear(GL_COLOR_BUFFER_BIT);
236         
237         UI_view2d_view_ortho(v2d);
238         
239         /* data */
240         if (ANIM_animdata_get_context(C, &ac)) {
241                 draw_nla_channel_list(C, &ac, ar);
242         }
243         
244         /* reset view matrix */
245         UI_view2d_view_restore(C);
246         
247         /* scrollers */
248         scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
249         UI_view2d_scrollers_draw(C, v2d, scrollers);
250         UI_view2d_scrollers_free(scrollers);
251 }
252
253
254 /* add handlers, stuff you only do once or on area/region changes */
255 static void nla_main_region_init(wmWindowManager *wm, ARegion *ar)
256 {
257         wmKeyMap *keymap;
258         
259         UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
260         
261         /* own keymap */
262         keymap = WM_keymap_find(wm->defaultconf, "NLA Editor", SPACE_NLA, 0);
263         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
264         keymap = WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0);
265         WM_event_add_keymap_handler(&ar->handlers, keymap);
266 }
267
268 static void nla_main_region_draw(const bContext *C, ARegion *ar)
269 {
270         /* draw entirely, view changes should be handled here */
271         SpaceNla *snla = CTX_wm_space_nla(C);
272         Scene *scene = CTX_data_scene(C);
273         bAnimContext ac;
274         View2D *v2d = &ar->v2d;
275         View2DGrid *grid;
276         View2DScrollers *scrollers;
277         short unit = 0, cfra_flag = 0;
278         
279         /* clear and setup matrix */
280         UI_ThemeClearColor(TH_BACK);
281         glClear(GL_COLOR_BUFFER_BIT);
282         
283         UI_view2d_view_ortho(v2d);
284         
285         /* time grid */
286         unit = (snla->flag & SNLA_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
287         grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
288         UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
289         UI_view2d_grid_free(grid);
290         
291         ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
292         
293         /* start and end frame */
294         ANIM_draw_framerange(scene, v2d);
295         
296         /* data */
297         if (ANIM_animdata_get_context(C, &ac)) {
298                 /* strips and backdrops */
299                 draw_nla_main_data(&ac, snla, ar);
300                 
301                 /* text draw cached, in pixelspace now */
302                 UI_view2d_text_cache_draw(ar);
303         }
304         
305         UI_view2d_view_ortho(v2d);
306         
307         /* current frame */
308         if (snla->flag & SNLA_DRAWTIME) cfra_flag |= DRAWCFRA_UNIT_SECONDS;
309         ANIM_draw_cfra(C, v2d, cfra_flag);
310         
311         /* markers */
312         UI_view2d_view_orthoSpecial(ar, v2d, 1);
313         ED_markers_draw(C, DRAW_MARKERS_MARGIN);
314         
315         /* preview range */
316         UI_view2d_view_ortho(v2d);
317         ANIM_draw_previewrange(C, v2d, 0);
318         
319         /* callback */
320         UI_view2d_view_ortho(v2d);
321         ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
322
323         /* reset view matrix */
324         UI_view2d_view_restore(C);
325         
326         /* scrollers */
327         scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
328         UI_view2d_scrollers_draw(C, v2d, scrollers);
329         UI_view2d_scrollers_free(scrollers);
330         
331         /* draw current frame number-indicator on top of scrollers */
332         if ((snla->flag & SNLA_NODRAWCFRANUM) == 0) {
333                 UI_view2d_view_orthoSpecial(ar, v2d, 1);
334                 ANIM_draw_cfra_number(C, v2d, cfra_flag);
335         }
336 }
337
338
339 /* add handlers, stuff you only do once or on area/region changes */
340 static void nla_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
341 {
342         ED_region_header_init(ar);
343 }
344
345 static void nla_header_region_draw(const bContext *C, ARegion *ar)
346 {
347         ED_region_header(C, ar);
348 }
349
350 /* add handlers, stuff you only do once or on area/region changes */
351 static void nla_buttons_region_init(wmWindowManager *wm, ARegion *ar)
352 {
353         wmKeyMap *keymap;
354         
355         ED_region_panels_init(wm, ar);
356         
357         keymap = WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0);
358         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
359 }
360
361 static void nla_buttons_region_draw(const bContext *C, ARegion *ar)
362 {
363         ED_region_panels(C, ar, NULL, -1, true);
364 }
365
366 static void nla_region_listener(
367         bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
368         wmNotifier *wmn, const Scene *UNUSED(scene))
369 {
370         /* context changes */
371         switch (wmn->category) {
372                 case NC_ANIMATION:
373                         ED_region_tag_redraw(ar);
374                         break;
375                 case NC_SCENE:
376                         switch (wmn->data) {
377                                 case ND_OB_ACTIVE:
378                                 case ND_FRAME:
379                                 case ND_MARKERS:
380                                         ED_region_tag_redraw(ar);
381                                         break;
382                         }
383                         break;
384                 case NC_OBJECT:
385                         switch (wmn->data) {
386                                 case ND_BONE_ACTIVE:
387                                 case ND_BONE_SELECT:
388                                 case ND_KEYS:
389                                         ED_region_tag_redraw(ar);
390                                         break;
391                         }
392                         break;
393                 default:
394                         if (wmn->data == ND_KEYS)
395                                 ED_region_tag_redraw(ar);
396                         break;
397         }
398 }
399
400
401 static void nla_main_region_listener(
402         bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
403         wmNotifier *wmn, const Scene *UNUSED(scene))
404 {
405         /* context changes */
406         switch (wmn->category) {
407                 case NC_ANIMATION:
408                         ED_region_tag_redraw(ar);
409                         break;
410                 case NC_SCENE:
411                         switch (wmn->data) {
412                                 case ND_RENDER_OPTIONS:
413                                 case ND_OB_ACTIVE:
414                                 case ND_FRAME:
415                                 case ND_FRAME_RANGE:
416                                 case ND_MARKERS:
417                                         ED_region_tag_redraw(ar);
418                                         break;
419                         }
420                         break;
421                 case NC_OBJECT:
422                         switch (wmn->data) {
423                                 case ND_BONE_ACTIVE:
424                                 case ND_BONE_SELECT:
425                                 case ND_KEYS:
426                                 case ND_TRANSFORM:
427                                         ED_region_tag_redraw(ar);
428                                         break;
429                         }
430                         break;
431                 case NC_NODE:
432                         switch (wmn->action) {
433                                 case NA_EDITED:
434                                         ED_region_tag_redraw(ar);
435                                         break;
436                         }
437                         break;
438                 case NC_ID:
439                         if (wmn->action == NA_RENAME)
440                                 ED_region_tag_redraw(ar);
441                         break;
442                 case NC_SCREEN:
443                         if (ELEM(wmn->data, ND_LAYER)) {
444                                 ED_region_tag_redraw(ar);
445                         }
446                         break;
447                 default:
448                         if (wmn->data == ND_KEYS)
449                                 ED_region_tag_redraw(ar);
450                         break;
451         }
452 }
453
454 static void nla_main_region_message_subscribe(
455         const struct bContext *UNUSED(C),
456         struct WorkSpace *UNUSED(workspace), struct Scene *scene,
457         struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar,
458         struct wmMsgBus *mbus)
459 {
460         PointerRNA ptr;
461         RNA_pointer_create(&screen->id, &RNA_SpaceNLA, sa->spacedata.first, &ptr);
462
463         wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
464                 .owner = ar,
465                 .user_data = ar,
466                 .notify = ED_region_do_msg_notify_tag_redraw,
467         };
468
469         /* Timeline depends on scene properties. */
470         {
471                 bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
472                 extern PropertyRNA rna_Scene_frame_start;
473                 extern PropertyRNA rna_Scene_frame_end;
474                 extern PropertyRNA rna_Scene_frame_preview_start;
475                 extern PropertyRNA rna_Scene_frame_preview_end;
476                 extern PropertyRNA rna_Scene_use_preview_range;
477                 extern PropertyRNA rna_Scene_frame_current;
478                 const PropertyRNA *props[] = {
479                         use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
480                         use_preview ? &rna_Scene_frame_preview_end   : &rna_Scene_frame_end,
481                         &rna_Scene_use_preview_range,
482                         &rna_Scene_frame_current,
483                 };
484
485                 PointerRNA idptr;
486                 RNA_id_pointer_create(&scene->id, &idptr);
487
488                 for (int i = 0; i < ARRAY_SIZE(props); i++) {
489                         WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
490                 }
491         }
492 }
493
494 static void nla_channel_region_listener(
495         bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
496         wmNotifier *wmn, const Scene *UNUSED(scene))
497 {
498         /* context changes */
499         switch (wmn->category) {
500                 case NC_ANIMATION:
501                         ED_region_tag_redraw(ar);
502                         break;
503                 case NC_SCENE:
504                         switch (wmn->data) {
505                                 case ND_OB_ACTIVE:
506                                         ED_region_tag_redraw(ar);
507                                         break;
508                         }
509                         break;
510                 case NC_OBJECT:
511                         switch (wmn->data) {
512                                 case ND_BONE_ACTIVE:
513                                 case ND_BONE_SELECT:
514                                 case ND_KEYS:
515                                         ED_region_tag_redraw(ar);
516                                         break;
517                         }
518                         break;
519                 case NC_ID:
520                         if (wmn->action == NA_RENAME)
521                                 ED_region_tag_redraw(ar);
522                         break;
523                 default:
524                         if (wmn->data == ND_KEYS)
525                                 ED_region_tag_redraw(ar);
526                         break;
527         }
528 }
529
530 /* editor level listener */
531 static void nla_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
532                          WorkSpace *UNUSED(workspace))
533 {
534         /* context changes */
535         switch (wmn->category) {
536                 case NC_ANIMATION:
537                         // TODO: filter specific types of changes?
538                         ED_area_tag_refresh(sa);
539                         break;
540                 case NC_SCENE:
541 #if 0
542                         switch (wmn->data) {
543                                 case ND_OB_ACTIVE:
544                                 case ND_OB_SELECT:
545                                         ED_area_tag_refresh(sa);
546                                         break;
547                         }
548 #endif
549                         ED_area_tag_refresh(sa);
550                         break;
551                 case NC_OBJECT:
552                         switch (wmn->data) {
553                                 case ND_TRANSFORM:
554                                         /* do nothing */
555                                         break;
556                                 default:
557                                         ED_area_tag_refresh(sa);
558                                         break;
559                         }
560                         break;
561                 case NC_SPACE:
562                         if (wmn->data == ND_SPACE_NLA)
563                                 ED_area_tag_redraw(sa);
564                         break;
565         }
566 }
567
568 static void nla_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
569 {
570         SpaceNla *snla = (SpaceNla *)slink;
571         
572         if (snla->ads) {
573                 if ((ID *)snla->ads->filter_grp == old_id) {
574                         snla->ads->filter_grp = (Group *)new_id;
575                 }
576                 if ((ID *)snla->ads->source == old_id) {
577                         snla->ads->source = new_id;
578                 }
579         }
580 }
581
582 /* only called once, from space/spacetypes.c */
583 void ED_spacetype_nla(void)
584 {
585         SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype nla");
586         ARegionType *art;
587         
588         st->spaceid = SPACE_NLA;
589         strncpy(st->name, "NLA", BKE_ST_MAXNAME);
590         
591         st->new = nla_new;
592         st->free = nla_free;
593         st->init = nla_init;
594         st->duplicate = nla_duplicate;
595         st->operatortypes = nla_operatortypes;
596         st->listener = nla_listener;
597         st->keymap = nla_keymap;
598         st->id_remap = nla_id_remap;
599
600         /* regions: main window */
601         art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
602         art->regionid = RGN_TYPE_WINDOW;
603         art->init = nla_main_region_init;
604         art->draw = nla_main_region_draw;
605         art->listener = nla_main_region_listener;
606         art->message_subscribe = nla_main_region_message_subscribe;
607         art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
608
609         BLI_addhead(&st->regiontypes, art);
610         
611         /* regions: header */
612         art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
613         art->regionid = RGN_TYPE_HEADER;
614         art->prefsizey = HEADERY;
615         art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
616         
617         art->init = nla_header_region_init;
618         art->draw = nla_header_region_draw;
619         
620         BLI_addhead(&st->regiontypes, art);
621         
622         /* regions: channels */
623         art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
624         art->regionid = RGN_TYPE_CHANNELS;
625         art->prefsizex = 200;
626         art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
627         
628         art->init = nla_channel_region_init;
629         art->draw = nla_channel_region_draw;
630         art->listener = nla_channel_region_listener;
631         
632         BLI_addhead(&st->regiontypes, art);
633         
634         /* regions: UI buttons */
635         art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
636         art->regionid = RGN_TYPE_UI;
637         art->prefsizex = 200;
638         art->keymapflag = ED_KEYMAP_UI;
639         art->listener = nla_region_listener;
640         art->init = nla_buttons_region_init;
641         art->draw = nla_buttons_region_draw;
642         
643         BLI_addhead(&st->regiontypes, art);
644
645         nla_buttons_register(art);
646         
647         
648         BKE_spacetype_register(st);
649 }