"Batch-Edit" Code cleanup: Renaming ED_operator_ipo_active to
[blender.git] / source / blender / editors / space_graph / space_graph.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) 2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include <string.h>
30 #include <stdio.h>
31
32 #include "DNA_anim_types.h"
33 #include "DNA_scene_types.h"
34
35 #include "MEM_guardedalloc.h"
36
37 #include "BLI_blenlib.h"
38 #include "BLI_math.h"
39 #include "BLI_rand.h"
40 #include "BLI_utildefines.h"
41
42 #include "BKE_context.h"
43 #include "BKE_global.h"
44 #include "BKE_main.h"
45 #include "BKE_fcurve.h"
46 #include "BKE_screen.h"
47
48 #include "ED_screen.h"
49 #include "ED_anim_api.h"
50 #include "ED_markers.h"
51
52 #include "BIF_gl.h"
53
54 #include "WM_api.h"
55 #include "WM_types.h"
56
57 #include "UI_resources.h"
58 #include "UI_view2d.h"
59
60 #include "graph_intern.h"       // own include
61
62 /* ******************** manage regions ********************* */
63
64 ARegion *graph_has_buttons_region(ScrArea *sa)
65 {
66         ARegion *ar, *arnew;
67         
68         for (ar= sa->regionbase.first; ar; ar= ar->next) {
69                 if (ar->regiontype==RGN_TYPE_UI)
70                         return ar;
71         }
72         
73         /* add subdiv level; after main */
74         for (ar= sa->regionbase.first; ar; ar= ar->next) {
75                 if (ar->regiontype==RGN_TYPE_WINDOW)
76                         break;
77         }
78         
79         /* is error! */
80         if (ar==NULL) return NULL;
81         
82         arnew= MEM_callocN(sizeof(ARegion), "buttons for graph");
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 /* ******************** default callbacks for ipo space ***************** */
95
96 static SpaceLink *graph_new(const bContext *C)
97 {
98         Scene *scene= CTX_data_scene(C);
99         ARegion *ar;
100         SpaceIpo *sipo;
101         
102         /* Graph Editor - general stuff */
103         sipo= MEM_callocN(sizeof(SpaceIpo), "init graphedit");
104         sipo->spacetype= SPACE_IPO;
105         
106         sipo->autosnap= SACTSNAP_FRAME;
107         
108         /* allocate DopeSheet data for Graph Editor */
109         sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
110         sipo->ads->source= (ID *)scene;
111         
112         /* header */
113         ar= MEM_callocN(sizeof(ARegion), "header for graphedit");
114         
115         BLI_addtail(&sipo->regionbase, ar);
116         ar->regiontype= RGN_TYPE_HEADER;
117         ar->alignment= RGN_ALIGN_BOTTOM;
118         
119         /* channels */
120         ar= MEM_callocN(sizeof(ARegion), "channels area for graphedit");
121         
122         BLI_addtail(&sipo->regionbase, ar);
123         ar->regiontype= RGN_TYPE_CHANNELS;
124         ar->alignment= RGN_ALIGN_LEFT;
125         
126         ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
127         
128         /* ui buttons */
129         ar= MEM_callocN(sizeof(ARegion), "buttons area for graphedit");
130         
131         BLI_addtail(&sipo->regionbase, ar);
132         ar->regiontype= RGN_TYPE_UI;
133         ar->alignment= RGN_ALIGN_RIGHT;
134         ar->flag = RGN_FLAG_HIDDEN;
135         
136         /* main area */
137         ar= MEM_callocN(sizeof(ARegion), "main area for graphedit");
138         
139         BLI_addtail(&sipo->regionbase, ar);
140         ar->regiontype= RGN_TYPE_WINDOW;
141         
142         ar->v2d.tot.xmin= 0.0f;
143         ar->v2d.tot.ymin= (float)scene->r.sfra - 10.0f;
144         ar->v2d.tot.xmax= (float)scene->r.efra;
145         ar->v2d.tot.ymax= 10.0f;
146         
147         ar->v2d.cur= ar->v2d.tot;
148         
149         ar->v2d.min[0]= FLT_MIN;
150         ar->v2d.min[1]= FLT_MIN;
151
152         ar->v2d.max[0]= MAXFRAMEF;
153         ar->v2d.max[1]= FLT_MAX;
154         
155         ar->v2d.scroll= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
156         ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
157         
158         ar->v2d.keeptot= 0;
159         
160         return (SpaceLink *)sipo;
161 }
162
163 /* not spacelink itself */
164 static void graph_free(SpaceLink *sl)
165 {       
166         SpaceIpo *si= (SpaceIpo *)sl;
167         
168         if (si->ads) {
169                 BLI_freelistN(&si->ads->chanbase);
170                 MEM_freeN(si->ads);
171         }
172         
173         if (si->ghostCurves.first)
174                 free_fcurves(&si->ghostCurves);
175 }
176
177
178 /* spacetype; init callback */
179 static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
180 {
181         SpaceIpo *sipo= (SpaceIpo *)sa->spacedata.first;
182         
183         /* init dopesheet data if non-existant (i.e. for old files) */
184         if (sipo->ads == NULL) {
185                 sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
186                 sipo->ads->source= (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now...
187         }
188
189         ED_area_tag_refresh(sa);
190 }
191
192 static SpaceLink *graph_duplicate(SpaceLink *sl)
193 {
194         SpaceIpo *sipon= MEM_dupallocN(sl);
195         
196         /* clear or remove stuff from old */
197         BLI_duplicatelist(&sipon->ghostCurves, &((SpaceIpo *)sl)->ghostCurves);
198         sipon->ads= MEM_dupallocN(sipon->ads);
199         
200         return (SpaceLink *)sipon;
201 }
202
203 /* add handlers, stuff you only do once or on area/region changes */
204 static void graph_main_area_init(wmWindowManager *wm, ARegion *ar)
205 {
206         wmKeyMap *keymap;
207         
208         UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
209         
210         /* own keymap */
211         keymap= WM_keymap_find(wm->defaultconf, "Graph Editor", SPACE_IPO, 0);
212         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
213         keymap= WM_keymap_find(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0);
214         WM_event_add_keymap_handler(&ar->handlers, keymap);
215 }
216
217 static void graph_main_area_draw(const bContext *C, ARegion *ar)
218 {
219         /* draw entirely, view changes should be handled here */
220         SpaceIpo *sipo= CTX_wm_space_graph(C);
221         bAnimContext ac;
222         View2D *v2d= &ar->v2d;
223         View2DGrid *grid;
224         View2DScrollers *scrollers;
225         float col[3];
226         short unitx=0, unity=V2D_UNIT_VALUES, flag=0;
227         
228         /* clear and setup matrix */
229         UI_GetThemeColor3fv(TH_BACK, col);
230         glClearColor(col[0], col[1], col[2], 0.0);
231         glClear(GL_COLOR_BUFFER_BIT);
232         
233         UI_view2d_view_ortho(v2d);
234         
235         /* grid */
236         unitx= (sipo->flag & SIPO_DRAWTIME)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE;
237         grid= UI_view2d_grid_calc(CTX_data_scene(C), v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy);
238         UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
239         
240         /* draw data */
241         if (ANIM_animdata_get_context(C, &ac)) {
242                 /* draw ghost curves */
243                 graph_draw_ghost_curves(&ac, sipo, ar);
244                 
245                 /* draw curves twice - unselected, then selected, so that the are fewer occlusion problems */
246                 graph_draw_curves(&ac, sipo, ar, grid, 0);
247                 graph_draw_curves(&ac, sipo, ar, grid, 1);
248                 
249                 /* XXX the slow way to set tot rect... but for nice sliders needed (ton) */
250                 get_graph_keyframe_extents(&ac, &v2d->tot.xmin, &v2d->tot.xmax, &v2d->tot.ymin, &v2d->tot.ymax);
251                 /* extra offset so that these items are visible */
252                 v2d->tot.xmin -= 10.0f;
253                 v2d->tot.xmax += 10.0f;
254         }
255         
256         /* only free grid after drawing data, as we need to use it to determine sampling rate */
257         UI_view2d_grid_free(grid);
258         
259         /* horizontal component of value-cursor (value line before the current frame line) */
260         if ((sipo->flag & SIPO_NODRAWCURSOR)==0) {
261                 float vec[2];
262                 
263                 /* Draw a green line to indicate the cursor value */
264                 vec[1]= sipo->cursorVal;
265                 
266                 UI_ThemeColorShadeAlpha(TH_CFRAME, -10, -50);
267                 glLineWidth(2.0);
268                 
269                 glEnable(GL_BLEND);
270                 glBegin(GL_LINE_STRIP);
271                         vec[0]= v2d->cur.xmin;
272                         glVertex2fv(vec);
273                         
274                         vec[0]= v2d->cur.xmax;
275                         glVertex2fv(vec);
276                 glEnd(); // GL_LINE_STRIP
277                 glDisable(GL_BLEND);
278         }
279         
280         /* current frame */
281         if (sipo->flag & SIPO_DRAWTIME)         flag |= DRAWCFRA_UNIT_SECONDS;
282         if ((sipo->flag & SIPO_NODRAWCFRANUM)==0)  flag |= DRAWCFRA_SHOW_NUMBOX;
283         ANIM_draw_cfra(C, v2d, flag);
284         
285         /* markers */
286         UI_view2d_view_orthoSpecial(ar, v2d, 1);
287         draw_markers_time(C, 0);
288         
289         /* preview range */
290         UI_view2d_view_ortho(v2d);
291         ANIM_draw_previewrange(C, v2d);
292         
293         /* reset view matrix */
294         UI_view2d_view_restore(C);
295         
296         /* scrollers */
297                 // FIXME: args for scrollers depend on the type of data being shown...
298         scrollers= UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
299         UI_view2d_scrollers_draw(C, v2d, scrollers);
300         UI_view2d_scrollers_free(scrollers);
301 }
302
303 static void graph_channel_area_init(wmWindowManager *wm, ARegion *ar)
304 {
305         wmKeyMap *keymap;
306         
307         UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
308         
309         /* own keymap */
310         keymap= WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0);
311         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
312         keymap= WM_keymap_find(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0);
313         WM_event_add_keymap_handler(&ar->handlers, keymap);
314 }
315
316 static void graph_channel_area_draw(const bContext *C, ARegion *ar)
317 {
318         bAnimContext ac;
319         View2D *v2d= &ar->v2d;
320         View2DScrollers *scrollers;
321         float col[3];
322         
323         /* clear and setup matrix */
324         UI_GetThemeColor3fv(TH_BACK, col);
325         glClearColor(col[0], col[1], col[2], 0.0);
326         glClear(GL_COLOR_BUFFER_BIT);
327         
328         UI_view2d_view_ortho(v2d);
329         
330         /* draw channels */
331         if (ANIM_animdata_get_context(C, &ac)) {
332                 graph_draw_channel_names((bContext*)C, &ac, ar);
333         }
334         
335         /* reset view matrix */
336         UI_view2d_view_restore(C);
337         
338         /* scrollers */
339         scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
340         UI_view2d_scrollers_draw(C, v2d, scrollers);
341         UI_view2d_scrollers_free(scrollers);
342 }
343
344 /* add handlers, stuff you only do once or on area/region changes */
345 static void graph_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
346 {
347         ED_region_header_init(ar);
348 }
349
350 static void graph_header_area_draw(const bContext *C, ARegion *ar)
351 {
352         ED_region_header(C, ar);
353 }
354
355 /* add handlers, stuff you only do once or on area/region changes */
356 static void graph_buttons_area_init(wmWindowManager *wm, ARegion *ar)
357 {
358         wmKeyMap *keymap;
359         
360         ED_region_panels_init(wm, ar);
361
362         keymap= WM_keymap_find(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0);
363         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
364 }
365
366 static void graph_buttons_area_draw(const bContext *C, ARegion *ar)
367 {
368         ED_region_panels(C, ar, 1, NULL, -1);
369 }
370
371 static void graph_region_listener(ARegion *ar, wmNotifier *wmn)
372 {
373         /* context changes */
374         switch(wmn->category) {
375                 case NC_ANIMATION:
376                         ED_region_tag_redraw(ar);
377                         break;
378                 case NC_SCENE:
379                         switch(wmn->data) {
380                                 case ND_RENDER_OPTIONS:
381                                 case ND_OB_ACTIVE:
382                                 case ND_FRAME:
383                                 case ND_MARKERS:
384                                         ED_region_tag_redraw(ar);
385                                         break;
386                                 case ND_SEQUENCER:
387                                         if (wmn->action == NA_SELECTED)
388                                                 ED_region_tag_redraw(ar);
389                                         break;
390                         }
391                         break;
392                 case NC_OBJECT:
393                         switch(wmn->data) {
394                                 case ND_BONE_ACTIVE:
395                                 case ND_BONE_SELECT:
396                                 case ND_KEYS:
397                                         ED_region_tag_redraw(ar);
398                                         break;
399                                 case ND_MODIFIER:
400                                         if(wmn->action == NA_RENAME)
401                                                 ED_region_tag_redraw(ar);
402                                         break;
403                         }
404                         break;
405                 case NC_NODE:
406                         switch(wmn->action) {
407                                 case NA_EDITED:
408                                 case NA_SELECTED:
409                                         ED_region_tag_redraw(ar);
410                                         break;
411                         }
412                         break;
413                 case NC_ID:
414                         if(wmn->action == NA_RENAME)
415                                 ED_region_tag_redraw(ar);
416                         break;
417                 default:
418                         if(wmn->data==ND_KEYS)
419                                 ED_region_tag_redraw(ar);
420                                 
421         }
422 }
423
424 /* editor level listener */
425 static void graph_listener(ScrArea *sa, wmNotifier *wmn)
426 {
427         SpaceIpo *sipo= (SpaceIpo *)sa->spacedata.first;
428         
429         /* context changes */
430         switch (wmn->category) {
431                 case NC_ANIMATION:
432                         /* for selection changes of animation data, we can just redraw... otherwise autocolor might need to be done again */
433                         if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED))
434                                 ED_area_tag_redraw(sa);
435                         else
436                                 ED_area_tag_refresh(sa);
437                         break;
438                 case NC_SCENE:
439                         switch (wmn->data) {    
440                                 case ND_OB_ACTIVE:      /* selection changed, so force refresh to flush (needs flag set to do syncing)  */
441                                 case ND_OB_SELECT:
442                                         sipo->flag |= SIPO_TEMP_NEEDCHANSYNC;
443                                         ED_area_tag_refresh(sa);
444                                         break;
445                                         
446                                 default: /* just redrawing the view will do */
447                                         ED_area_tag_redraw(sa);
448                                         break;
449                         }
450                         break;
451                 case NC_OBJECT:
452                         switch (wmn->data) {
453                                 case ND_BONE_SELECT:    /* selection changed, so force refresh to flush (needs flag set to do syncing) */
454                                 case ND_BONE_ACTIVE:
455                                         sipo->flag |= SIPO_TEMP_NEEDCHANSYNC;
456                                         ED_area_tag_refresh(sa);
457                                         break;
458                                 case ND_TRANSFORM:
459                                         break; /*do nothing*/                                   
460                                         
461                                 default: /* just redrawing the view will do */
462                                         ED_area_tag_redraw(sa);
463                                         break;
464                         }
465                         break;
466                 case NC_SPACE:
467                         if(wmn->data == ND_SPACE_GRAPH)
468                                 ED_area_tag_redraw(sa);
469                         break;
470                 
471                 // XXX: restore the case below if not enough updates occur...
472                 //default:
473                 //      if(wmn->data==ND_KEYS)
474                 //              ED_area_tag_redraw(sa);
475         }
476 }
477
478
479
480 static void graph_refresh(const bContext *C, ScrArea *sa)
481 {
482         SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first;
483         bAnimContext ac;
484         
485         /* updates to data needed depends on Graph Editor mode... */
486         switch (sipo->mode) {
487                 case SIPO_MODE_ANIMATION: /* all animation */
488                 {
489                         
490                 }
491                         break;
492                 
493                 case SIPO_MODE_DRIVERS: /* drivers only  */
494                 {
495                 
496                 }
497                         break; 
498         }
499         
500         /* region updates? */
501         // XXX resizing y-extents of tot should go here?
502         
503         /* update the state of the animchannels in response to changes from the data they represent 
504          * NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled
505          */
506         if (sipo->flag & SIPO_TEMP_NEEDCHANSYNC) {
507                 ANIM_sync_animchannels_to_data(C);
508                 sipo->flag &= ~SIPO_TEMP_NEEDCHANSYNC;
509         }
510         
511         /* init/adjust F-Curve colors */
512         if (ANIM_animdata_get_context(C, &ac)) {
513                 ListBase anim_data = {NULL, NULL};
514                 bAnimListElem *ale;
515                 int filter;
516                 int items, i;
517                 
518                 /* build list of F-Curves which will be visible as channels in channel-region
519                  *      - we don't include ANIMFILTER_CURVEVISIBLE filter, as that will result in a 
520                  *        mismatch between channel-colors and the drawn curves
521                  */
522                 filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CURVESONLY|ANIMFILTER_NODUPLIS);
523                 items= ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
524                 
525                 /* loop over F-Curves, assigning colors */
526                 for (ale=anim_data.first, i=0; ale; ale= ale->next, i++) {
527                         FCurve *fcu= (FCurve *)ale->data;
528                         
529                         /* set color of curve here */
530                         switch (fcu->color_mode) {
531                                 case FCURVE_COLOR_CUSTOM:
532                                         /* User has defined a custom color for this curve already (we assume it's not going to cause clashes with text colors),
533                                          * which should be left alone... Nothing needs to be done here.
534                                          */
535                                         break;
536                                         
537                                 case FCURVE_COLOR_AUTO_RGB:
538                                 {
539                                         /* F-Curve's array index is automatically mapped to RGB values. This works best of 3-value vectors. 
540                                          * TODO: find a way to module the hue so that not all curves have same color...
541                                          */
542                                         float *col= fcu->color;
543
544                                         switch(fcu->array_index) {
545                                         case 0:
546                                                 col[0]= 1.0f; col[1]= 0.0f; col[2]= 0.0f;
547                                                 break;
548                                         case 1:
549                                                 col[0]= 0.0f; col[1]= 1.0f; col[2]= 0.0f;
550                                                 break;
551                                         case 2:
552                                                 col[0]= 0.0f; col[1]= 0.0f; col[2]= 1.0f;
553                                                 break;
554                                         default:
555                                                 /* 'unknown' color - bluish so as to not conflict with handles */
556                                                 col[0]= 0.3f; col[1]= 0.8f; col[2]= 1.0f;
557                                                 break;
558                                         }
559                                 }
560                                         break;
561                                 
562                                 case FCURVE_COLOR_AUTO_RAINBOW:
563                                 default:
564                                 {
565                                         /* determine color 'automatically' using 'magic function' which uses the given args
566                                          * of current item index + total items to determine some RGB color
567                                          */
568                                         getcolor_fcurve_rainbow(i, items, fcu->color);
569                                 }
570                                         break;
571                         }
572                 }
573                 
574                 /* free temp list */
575                 BLI_freelistN(&anim_data);
576         }
577 }
578
579 /* only called once, from space/spacetypes.c */
580 void ED_spacetype_ipo(void)
581 {
582         SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype ipo");
583         ARegionType *art;
584         
585         st->spaceid= SPACE_IPO;
586         strncpy(st->name, "Graph", BKE_ST_MAXNAME);
587         
588         st->new= graph_new;
589         st->free= graph_free;
590         st->init= graph_init;
591         st->duplicate= graph_duplicate;
592         st->operatortypes= graphedit_operatortypes;
593         st->keymap= graphedit_keymap;
594         st->listener= graph_listener;
595         st->refresh= graph_refresh;
596         
597         /* regions: main window */
598         art= MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
599         art->regionid = RGN_TYPE_WINDOW;
600         art->init= graph_main_area_init;
601         art->draw= graph_main_area_draw;
602         art->listener= graph_region_listener;
603         art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES;
604
605         BLI_addhead(&st->regiontypes, art);
606         
607         /* regions: header */
608         art= MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
609         art->regionid = RGN_TYPE_HEADER;
610         art->prefsizey= HEADERY;
611         art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER;
612         art->listener= graph_region_listener;
613         art->init= graph_header_area_init;
614         art->draw= graph_header_area_draw;
615         
616         BLI_addhead(&st->regiontypes, art);
617         
618         /* regions: channels */
619         art= MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
620         art->regionid = RGN_TYPE_CHANNELS;
621         art->prefsizex= 200+V2D_SCROLL_WIDTH; /* 200 is the 'standard', but due to scrollers, we want a bit more to fit the lock icons in */
622         art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
623         art->listener= graph_region_listener;
624         art->init= graph_channel_area_init;
625         art->draw= graph_channel_area_draw;
626         
627         BLI_addhead(&st->regiontypes, art);
628         
629         /* regions: UI buttons */
630         art= MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
631         art->regionid = RGN_TYPE_UI;
632         art->prefsizex= 200;
633         art->keymapflag= ED_KEYMAP_UI;
634         art->listener= graph_region_listener;
635         art->init= graph_buttons_area_init;
636         art->draw= graph_buttons_area_draw;
637         
638         BLI_addhead(&st->regiontypes, art);
639
640         graph_buttons_register(art);
641         
642         BKE_spacetype_register(st);
643 }
644