Blender  V2.93
space_graph.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2008 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include <stdio.h>
25 #include <string.h>
26 
27 #include "DNA_anim_types.h"
28 #include "DNA_collection_types.h"
29 #include "DNA_scene_types.h"
30 
31 #include "MEM_guardedalloc.h"
32 
33 #include "BLI_blenlib.h"
34 #include "BLI_math.h"
35 #include "BLI_utildefines.h"
36 
37 #include "BKE_context.h"
38 #include "BKE_fcurve.h"
39 #include "BKE_screen.h"
40 
41 #include "ED_anim_api.h"
42 #include "ED_markers.h"
43 #include "ED_screen.h"
44 #include "ED_space_api.h"
45 #include "ED_time_scrub_ui.h"
46 
47 #include "GPU_framebuffer.h"
48 #include "GPU_immediate.h"
49 #include "GPU_state.h"
50 
51 #include "WM_api.h"
52 #include "WM_message.h"
53 #include "WM_types.h"
54 
55 #include "RNA_access.h"
56 #include "RNA_define.h"
57 #include "RNA_enum_types.h"
58 
59 #include "UI_interface.h"
60 #include "UI_resources.h"
61 #include "UI_view2d.h"
62 
63 #include "graph_intern.h" /* own include */
64 
65 /* ******************** default callbacks for ipo space ***************** */
66 
68 {
69  ARegion *region;
70  SpaceGraph *sipo;
71 
72  /* Graph Editor - general stuff */
73  sipo = MEM_callocN(sizeof(SpaceGraph), "init graphedit");
74  sipo->spacetype = SPACE_GRAPH;
75 
76  sipo->autosnap = SACTSNAP_FRAME;
77 
78  /* allocate DopeSheet data for Graph Editor */
79  sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
80  sipo->ads->source = (ID *)scene;
81 
82  /* settings for making it easier by default to just see what you're interested in tweaking */
85 
86  /* header */
87  region = MEM_callocN(sizeof(ARegion), "header for graphedit");
88 
89  BLI_addtail(&sipo->regionbase, region);
90  region->regiontype = RGN_TYPE_HEADER;
92 
93  /* channels */
94  region = MEM_callocN(sizeof(ARegion), "channels region for graphedit");
95 
96  BLI_addtail(&sipo->regionbase, region);
97  region->regiontype = RGN_TYPE_CHANNELS;
98  region->alignment = RGN_ALIGN_LEFT;
99 
101 
102  /* ui buttons */
103  region = MEM_callocN(sizeof(ARegion), "buttons region for graphedit");
104 
105  BLI_addtail(&sipo->regionbase, region);
106  region->regiontype = RGN_TYPE_UI;
107  region->alignment = RGN_ALIGN_RIGHT;
108  region->flag = RGN_FLAG_HIDDEN;
109 
110  /* main region */
111  region = MEM_callocN(sizeof(ARegion), "main region for graphedit");
112 
113  BLI_addtail(&sipo->regionbase, region);
114  region->regiontype = RGN_TYPE_WINDOW;
115 
116  region->v2d.tot.xmin = 0.0f;
117  region->v2d.tot.ymin = (float)scene->r.sfra - 10.0f;
118  region->v2d.tot.xmax = (float)scene->r.efra;
119  region->v2d.tot.ymax = 10.0f;
120 
121  region->v2d.cur = region->v2d.tot;
122 
123  region->v2d.min[0] = FLT_MIN;
124  region->v2d.min[1] = FLT_MIN;
125 
126  region->v2d.max[0] = MAXFRAMEF;
127  region->v2d.max[1] = FLT_MAX;
128 
131 
132  region->v2d.keeptot = 0;
133 
134  return (SpaceLink *)sipo;
135 }
136 
137 /* not spacelink itself */
138 static void graph_free(SpaceLink *sl)
139 {
140  SpaceGraph *si = (SpaceGraph *)sl;
141 
142  if (si->ads) {
143  BLI_freelistN(&si->ads->chanbase);
144  MEM_freeN(si->ads);
145  }
146 
147  if (si->runtime.ghost_curves.first) {
149  }
150 }
151 
152 /* spacetype; init callback */
153 static void graph_init(struct wmWindowManager *wm, ScrArea *area)
154 {
155  SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first;
156 
157  /* init dopesheet data if non-existent (i.e. for old files) */
158  if (sipo->ads == NULL) {
159  sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
161  }
162 
163  /* force immediate init of any invalid F-Curve colors */
164  /* XXX: but, don't do SIPO_TEMP_NEEDCHANSYNC (i.e. channel select state sync)
165  * as this is run on each region resize; setting this here will cause selection
166  * state to be lost on area/region resizing. T35744.
167  */
169 }
170 
172 {
173  SpaceGraph *sipon = MEM_dupallocN(sl);
174 
175  /* clear or remove stuff from old */
176  BLI_duplicatelist(&sipon->runtime.ghost_curves, &((SpaceGraph *)sl)->runtime.ghost_curves);
177  sipon->ads = MEM_dupallocN(sipon->ads);
178 
179  return (SpaceLink *)sipon;
180 }
181 
182 /* add handlers, stuff you only do once or on area/region changes */
184 {
185  wmKeyMap *keymap;
186 
187  UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_CUSTOM, region->winx, region->winy);
188 
189  /* own keymap */
190  keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor", SPACE_GRAPH, 0);
192  keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, 0);
193  WM_event_add_keymap_handler(&region->handlers, keymap);
194 }
195 
196 static void graph_main_region_draw(const bContext *C, ARegion *region)
197 {
198  /* draw entirely, view changes should be handled here */
201  bAnimContext ac;
202  View2D *v2d = &region->v2d;
203 
204  /* clear and setup matrix */
206 
208 
209  /* grid */
210  bool display_seconds = (sipo->mode == SIPO_MODE_ANIMATION) && (sipo->flag & SIPO_DRAWTIME);
211  UI_view2d_draw_lines_x__frames_or_seconds(v2d, scene, display_seconds);
213 
215 
216  /* start and end frame (in F-Curve mode only) */
217  if (sipo->mode != SIPO_MODE_DRIVERS) {
219  }
220 
221  /* draw data */
222  if (ANIM_animdata_get_context(C, &ac)) {
223  /* draw ghost curves */
224  graph_draw_ghost_curves(&ac, sipo, region);
225 
226  /* draw curves twice - unselected, then selected, so that the are fewer occlusion problems */
227  graph_draw_curves(&ac, sipo, region, 0);
228  graph_draw_curves(&ac, sipo, region, 1);
229 
230  /* XXX the slow way to set tot rect... but for nice sliders needed (ton) */
232  &ac, &v2d->tot.xmin, &v2d->tot.xmax, &v2d->tot.ymin, &v2d->tot.ymax, false, true);
233  /* extra offset so that these items are visible */
234  v2d->tot.xmin -= 10.0f;
235  v2d->tot.xmax += 10.0f;
236  }
237 
238  if (((sipo->flag & SIPO_NODRAWCURSOR) == 0) || (sipo->mode == SIPO_MODE_DRIVERS)) {
240 
242 
243  /* horizontal component of value-cursor (value line before the current frame line) */
244  if ((sipo->flag & SIPO_NODRAWCURSOR) == 0) {
245  float y = sipo->cursorVal;
246 
247  /* Draw a green line to indicate the cursor value */
250  GPU_line_width(2.0);
251 
253  immVertex2f(pos, v2d->cur.xmin, y);
254  immVertex2f(pos, v2d->cur.xmax, y);
255  immEnd();
256 
258  }
259 
260  /* current frame or vertical component of vertical component of the cursor */
261  if (sipo->mode == SIPO_MODE_DRIVERS) {
262  /* cursor x-value */
263  float x = sipo->cursorTime;
264 
265  /* to help differentiate this from the current frame,
266  * draw slightly darker like the horizontal one */
269  GPU_line_width(2.0);
270 
272  immVertex2f(pos, x, v2d->cur.ymin);
273  immVertex2f(pos, x, v2d->cur.ymax);
274  immEnd();
275 
277  }
278 
280  }
281 
282  /* markers */
283  if (sipo->mode != SIPO_MODE_DRIVERS) {
284  UI_view2d_view_orthoSpecial(region, v2d, 1);
285  int marker_draw_flag = DRAW_MARKERS_MARGIN;
286  if (sipo->flag & SIPO_SHOW_MARKERS) {
287  ED_markers_draw(C, marker_draw_flag);
288  }
289  }
290 
291  /* preview range */
292  if (sipo->mode != SIPO_MODE_DRIVERS) {
294  ANIM_draw_previewrange(C, v2d, 0);
295  }
296 
297  /* callback */
300 
301  /* reset view matrix */
303 
304  /* time-scrubbing */
305  ED_time_scrub_draw(region, scene, display_seconds, false);
306 }
307 
308 static void graph_main_region_draw_overlay(const bContext *C, ARegion *region)
309 {
310  /* draw entirely, view changes should be handled here */
311  const SpaceGraph *sipo = CTX_wm_space_graph(C);
312  const Scene *scene = CTX_data_scene(C);
313  const bool draw_vert_line = sipo->mode != SIPO_MODE_DRIVERS;
314  View2D *v2d = &region->v2d;
315 
316  /* scrubbing region */
317  ED_time_scrub_draw_current_frame(region, scene, sipo->flag & SIPO_DRAWTIME, draw_vert_line);
318 
319  /* scrollers */
320  /* FIXME: args for scrollers depend on the type of data being shown. */
322 
323  /* scale numbers */
324  {
325  rcti rect;
327  &rect, 0, 15 * UI_DPI_FAC, 15 * UI_DPI_FAC, region->winy - UI_TIME_SCRUB_MARGIN_Y);
328  UI_view2d_draw_scale_y__values(region, v2d, &rect, TH_SCROLL_TEXT);
329  }
330 }
331 
333 {
334  wmKeyMap *keymap;
335 
336  /* make sure we keep the hide flags */
337  region->v2d.scroll |= V2D_SCROLL_RIGHT;
338 
339  /* prevent any noise of past */
341 
344 
345  UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_LIST, region->winx, region->winy);
346 
347  /* own keymap */
348  keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0);
350  keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, 0);
351  WM_event_add_keymap_handler(&region->handlers, keymap);
352 }
353 
354 static void graph_channel_region_draw(const bContext *C, ARegion *region)
355 {
356  bAnimContext ac;
357  View2D *v2d = &region->v2d;
358 
359  /* clear and setup matrix */
361 
363 
364  /* draw channels */
365  if (ANIM_animdata_get_context(C, &ac)) {
366  graph_draw_channel_names((bContext *)C, &ac, region);
367  }
368 
369  /* channel filter next to scrubbing area */
371 
372  /* reset view matrix */
374 
375  /* scrollers */
377 }
378 
379 /* add handlers, stuff you only do once or on area/region changes */
381 {
382  ED_region_header_init(region);
383 }
384 
385 static void graph_header_region_draw(const bContext *C, ARegion *region)
386 {
387  ED_region_header(C, region);
388 }
389 
390 /* add handlers, stuff you only do once or on area/region changes */
392 {
393  wmKeyMap *keymap;
394 
395  ED_region_panels_init(wm, region);
396 
397  keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, 0);
399 }
400 
401 static void graph_buttons_region_draw(const bContext *C, ARegion *region)
402 {
403  ED_region_panels(C, region);
404 }
405 
407 {
408  ARegion *region = params->region;
409  wmNotifier *wmn = params->notifier;
410 
411  /* context changes */
412  switch (wmn->category) {
413  case NC_ANIMATION:
414  ED_region_tag_redraw(region);
415  break;
416  case NC_SCENE:
417  switch (wmn->data) {
418  case ND_RENDER_OPTIONS:
419  case ND_OB_ACTIVE:
420  case ND_FRAME:
421  case ND_FRAME_RANGE:
422  case ND_MARKERS:
423  ED_region_tag_redraw(region);
424  break;
425  case ND_SEQUENCER:
426  if (wmn->action == NA_SELECTED) {
427  ED_region_tag_redraw(region);
428  }
429  break;
430  }
431  break;
432  case NC_OBJECT:
433  switch (wmn->data) {
434  case ND_BONE_ACTIVE:
435  case ND_BONE_SELECT:
436  case ND_KEYS:
437  ED_region_tag_redraw(region);
438  break;
439  case ND_MODIFIER:
440  if (wmn->action == NA_RENAME) {
441  ED_region_tag_redraw(region);
442  }
443  break;
444  }
445  break;
446  case NC_NODE:
447  switch (wmn->action) {
448  case NA_EDITED:
449  case NA_SELECTED:
450  ED_region_tag_redraw(region);
451  break;
452  }
453  break;
454  case NC_ID:
455  if (wmn->action == NA_RENAME) {
456  ED_region_tag_redraw(region);
457  }
458  break;
459  case NC_SCREEN:
460  if (ELEM(wmn->data, ND_LAYER)) {
461  ED_region_tag_redraw(region);
462  }
463  break;
464  default:
465  if (wmn->data == ND_KEYS) {
466  ED_region_tag_redraw(region);
467  }
468  break;
469  }
470 }
471 
473 {
474  struct wmMsgBus *mbus = params->message_bus;
475  Scene *scene = params->scene;
476  bScreen *screen = params->screen;
477  ScrArea *area = params->area;
478  ARegion *region = params->region;
479 
480  PointerRNA ptr;
481  RNA_pointer_create(&screen->id, &RNA_SpaceGraphEditor, area->spacedata.first, &ptr);
482 
483  wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
484  .owner = region,
485  .user_data = region,
487  };
488 
489  /* Timeline depends on scene properties. */
490  {
491  bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
492  extern PropertyRNA rna_Scene_frame_start;
493  extern PropertyRNA rna_Scene_frame_end;
494  extern PropertyRNA rna_Scene_frame_preview_start;
495  extern PropertyRNA rna_Scene_frame_preview_end;
496  extern PropertyRNA rna_Scene_use_preview_range;
497  extern PropertyRNA rna_Scene_frame_current;
498  const PropertyRNA *props[] = {
499  use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
500  use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,
501  &rna_Scene_use_preview_range,
502  &rna_Scene_frame_current,
503  };
504 
505  PointerRNA idptr;
506  RNA_id_pointer_create(&scene->id, &idptr);
507 
508  for (int i = 0; i < ARRAY_SIZE(props); i++) {
509  WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
510  }
511  }
512 
513  /* All dopesheet filter settings, etc. affect the drawing of this editor,
514  * also same applies for all animation-related datatypes that may appear here,
515  * so just whitelist the entire structs for updates
516  */
517  {
518  wmMsgParams_RNA msg_key_params = {{0}};
519  StructRNA *type_array[] = {
520  &RNA_DopeSheet, /* dopesheet filters */
521 
522  &RNA_ActionGroup, /* channel groups */
523  &RNA_FCurve, /* F-Curve */
524  &RNA_Keyframe,
526 
527  &RNA_FModifier, /* F-Modifiers (XXX: Why can't we just do all subclasses too?) */
537  };
538 
539  for (int i = 0; i < ARRAY_SIZE(type_array); i++) {
540  msg_key_params.ptr.type = type_array[i];
542  mbus, &msg_key_params, &msg_sub_value_region_tag_redraw, __func__);
543  }
544  }
545 }
546 
547 /* editor level listener */
549 {
550  ScrArea *area = params->area;
551  wmNotifier *wmn = params->notifier;
552  SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first;
553 
554  /* context changes */
555  switch (wmn->category) {
556  case NC_ANIMATION:
557  /* for selection changes of animation data, we can just redraw...
558  * otherwise autocolor might need to be done again */
559  if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED)) {
561  }
562  else {
564  }
565  break;
566  case NC_SCENE:
567  switch (wmn->data) {
568  case ND_OB_ACTIVE: /* Selection changed, so force refresh to flush
569  * (needs flag set to do syncing). */
570  case ND_OB_SELECT:
573  break;
574 
575  default: /* just redrawing the view will do */
577  break;
578  }
579  break;
580  case NC_OBJECT:
581  switch (wmn->data) {
582  case ND_BONE_SELECT: /* Selection changed, so force refresh to flush
583  * (needs flag set to do syncing). */
584  case ND_BONE_ACTIVE:
587  break;
588  case ND_TRANSFORM:
589  break; /*do nothing*/
590 
591  default: /* just redrawing the view will do */
593  break;
594  }
595  break;
596  case NC_NODE:
597  if (wmn->action == NA_SELECTED) {
598  /* selection changed, so force refresh to flush (needs flag set to do syncing) */
601  }
602  break;
603  case NC_SPACE:
604  if (wmn->data == ND_SPACE_GRAPH) {
606  }
607  break;
608  case NC_WINDOW:
609  if (sipo->runtime.flag &
611  /* force redraw/refresh after undo/redo - prevents "black curve" problem */
613  }
614  break;
615 
616 #if 0 /* XXX: restore the case below if not enough updates occur... */
617  default: {
618  if (wmn->data == ND_KEYS) {
620  }
621  }
622 #endif
623  }
624 }
625 
626 /* Update F-Curve colors */
628 {
629  bAnimContext ac;
630 
631  ListBase anim_data = {NULL, NULL};
632  bAnimListElem *ale;
633  size_t items;
634  int filter;
635  int i;
636 
637  if (ANIM_animdata_get_context(C, &ac) == false) {
638  return;
639  }
640 
642 
643  /* build list of F-Curves which will be visible as channels in channel-region
644  * - we don't include ANIMFILTER_CURVEVISIBLE filter, as that will result in a
645  * mismatch between channel-colors and the drawn curves
646  */
648  items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
649 
650  /* loop over F-Curves, assigning colors */
651  for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
652  FCurve *fcu = (FCurve *)ale->data;
653 
654  /* set color of curve here */
655  switch (fcu->color_mode) {
656  case FCURVE_COLOR_CUSTOM: {
657  /* User has defined a custom color for this curve already
658  * (we assume it's not going to cause clashes with text colors),
659  * which should be left alone... Nothing needs to be done here.
660  */
661  break;
662  }
663  case FCURVE_COLOR_AUTO_RGB: {
664  /* F-Curve's array index is automatically mapped to RGB values.
665  * This works best of 3-value vectors.
666  * TODO: find a way to module the hue so that not all curves have same color...
667  */
668  float *col = fcu->color;
669 
670  switch (fcu->array_index) {
671  case 0:
673  break;
674  case 1:
676  break;
677  case 2:
679  break;
680  default:
681  /* 'unknown' color - bluish so as to not conflict with handles */
682  col[0] = 0.3f;
683  col[1] = 0.8f;
684  col[2] = 1.0f;
685  break;
686  }
687  break;
688  }
689  case FCURVE_COLOR_AUTO_YRGB: {
690  /* Like FCURVE_COLOR_AUTO_RGB, except this is for quaternions... */
691  float *col = fcu->color;
692 
693  switch (fcu->array_index) {
694  case 1:
696  break;
697  case 2:
699  break;
700  case 3:
702  break;
703 
704  case 0: {
705  /* Special Case: "W" channel should be yellowish, so blend X and Y channel colors... */
706  float c1[3], c2[3];
707  float h1[3], h2[3];
708  float hresult[3];
709 
710  /* - get colors (rgb) */
713 
714  /* - perform blending in HSV space (to keep brightness similar) */
715  rgb_to_hsv_v(c1, h1);
716  rgb_to_hsv_v(c2, h2);
717 
718  interp_v3_v3v3(hresult, h1, h2, 0.5f);
719 
720  /* - convert back to RGB for display */
721  hsv_to_rgb_v(hresult, col);
722  break;
723  }
724 
725  default:
726  /* 'unknown' color - bluish so as to not conflict with handles */
727  col[0] = 0.3f;
728  col[1] = 0.8f;
729  col[2] = 1.0f;
730  break;
731  }
732  break;
733  }
735  default: {
736  /* determine color 'automatically' using 'magic function' which uses the given args
737  * of current item index + total items to determine some RGB color
738  */
739  getcolor_fcurve_rainbow(i, items, fcu->color);
740  break;
741  }
742  }
743  }
744 
745  /* free temp list */
746  ANIM_animdata_freelist(&anim_data);
747 }
748 
749 static void graph_refresh(const bContext *C, ScrArea *area)
750 {
751  SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first;
752 
753  /* updates to data needed depends on Graph Editor mode... */
754  switch (sipo->mode) {
755  case SIPO_MODE_ANIMATION: /* all animation */
756  {
757  break;
758  }
759 
760  case SIPO_MODE_DRIVERS: /* drivers only */
761  {
762  break;
763  }
764  }
765 
766  /* region updates? */
767  /* XXX re-sizing y-extents of tot should go here? */
768 
769  /* Update the state of the animchannels in response to changes from the data they represent
770  * NOTE: the temp flag is used to indicate when this needs to be done,
771  * and will be cleared once handled. */
776  }
777 
778  /* We could check 'SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR', but color is recalculated anyway. */
781 #if 0 /* Done below. */
783 #endif
785  }
786 
789 
790  /* init/adjust F-Curve colors */
792 }
793 
794 static void graph_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
795 {
796  SpaceGraph *sgraph = (SpaceGraph *)slink;
797 
798  if (sgraph->ads) {
799  if ((ID *)sgraph->ads->filter_grp == old_id) {
800  sgraph->ads->filter_grp = (Collection *)new_id;
801  }
802  if ((ID *)sgraph->ads->source == old_id) {
803  sgraph->ads->source = new_id;
804  }
805  }
806 }
807 
809 {
810  SpaceGraph *sgraph = area->spacedata.first;
811  return sgraph->mode;
812 }
813 
814 static void graph_space_subtype_set(ScrArea *area, int value)
815 {
816  SpaceGraph *sgraph = area->spacedata.first;
817  sgraph->mode = value;
818 }
819 
821  EnumPropertyItem **item,
822  int *totitem)
823 {
825 }
826 
827 /* only called once, from space/spacetypes.c */
829 {
830  SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype ipo");
831  ARegionType *art;
832 
833  st->spaceid = SPACE_GRAPH;
834  strncpy(st->name, "Graph", BKE_ST_MAXNAME);
835 
836  st->create = graph_create;
837  st->free = graph_free;
838  st->init = graph_init;
841  st->keymap = graphedit_keymap;
842  st->listener = graph_listener;
843  st->refresh = graph_refresh;
844  st->id_remap = graph_id_remap;
848 
849  /* regions: main window */
850  art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
851  art->regionid = RGN_TYPE_WINDOW;
858 
859  BLI_addhead(&st->regiontypes, art);
860 
861  /* regions: header */
862  art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
863  art->regionid = RGN_TYPE_HEADER;
864  art->prefsizey = HEADERY;
869 
870  BLI_addhead(&st->regiontypes, art);
871 
872  /* regions: channels */
873  art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
875  /* 200 is the 'standard', but due to scrollers, we want a bit more to fit the lock icons in */
876  art->prefsizex = 200 + V2D_SCROLL_WIDTH;
882 
883  BLI_addhead(&st->regiontypes, art);
884 
885  /* regions: UI buttons */
886  art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
887  art->regionid = RGN_TYPE_UI;
893 
894  BLI_addhead(&st->regiontypes, art);
895 
897 
898  art = ED_area_type_hud(st->spaceid);
899  BLI_addhead(&st->regiontypes, art);
900 
902 }
typedef float(TangentPoint)[2]
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct SpaceGraph * CTX_wm_space_graph(const bContext *C)
Definition: context.c:863
void BKE_fcurves_free(ListBase *list)
Definition: fcurve.c:103
#define BKE_ST_MAXNAME
Definition: BKE_screen.h:68
void BKE_spacetype_register(struct SpaceType *st)
Definition: screen.c:420
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:87
void void void void void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src) ATTR_NONNULL(1
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:547
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
Definition: math_color.c:68
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
Definition: math_color.c:254
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
Definition: math_vector.c:49
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition: rct.c:446
unsigned int uint
Definition: BLI_sys_types.h:83
#define ARRAY_SIZE(arr)
#define UNUSED(x)
#define ELEM(...)
@ ADS_FILTER_ONLYSEL
@ SACTSNAP_FRAME
@ FCURVE_COLOR_AUTO_RGB
@ FCURVE_COLOR_AUTO_RAINBOW
@ FCURVE_COLOR_CUSTOM
@ FCURVE_COLOR_AUTO_YRGB
Object groups, one object can be in many groups at once.
#define SCER_PRV_RANGE
#define MAXFRAMEF
#define HEADERY
@ RGN_ALIGN_BOTTOM
@ RGN_ALIGN_LEFT
@ RGN_ALIGN_TOP
@ RGN_ALIGN_RIGHT
@ RGN_FLAG_HIDDEN
@ RGN_TYPE_CHANNELS
@ RGN_TYPE_UI
@ RGN_TYPE_WINDOW
@ RGN_TYPE_HEADER
@ SPACE_GRAPH
@ SIPO_MODE_DRIVERS
@ SIPO_MODE_ANIMATION
@ SIPO_DRAWTIME
@ SIPO_NODRAWCURSOR
@ SIPO_SELVHANDLESONLY
@ SIPO_SHOW_MARKERS
@ SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC
@ SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR
@ SIPO_RUNTIME_FLAG_TWEAK_HANDLES_RIGHT
@ SIPO_RUNTIME_FLAG_TWEAK_HANDLES_LEFT
@ USER_HEADER_BOTTOM
@ V2D_SCROLL_LEFT
@ V2D_SCROLL_HORIZONTAL_HIDE
@ V2D_SCROLL_VERTICAL_HIDE
@ V2D_SCROLL_TOP
@ V2D_SCROLL_VERTICAL_HANDLES
@ V2D_SCROLL_RIGHT
@ V2D_SCROLL_BOTTOM
@ V2D_SCROLL_HORIZONTAL_HANDLES
@ ANIMFILTER_DATA_VISIBLE
Definition: ED_anim_api.h:295
@ ANIMFILTER_NODUPLIS
Definition: ED_anim_api.h:328
@ DRAW_MARKERS_MARGIN
Definition: ED_markers.h:42
void ED_area_tag_redraw(ScrArea *area)
Definition: area.c:745
void ED_region_header(const struct bContext *C, struct ARegion *region)
void ED_region_do_msg_notify_tag_redraw(struct bContext *C, struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val)
void ED_region_panels(const struct bContext *C, struct ARegion *region)
struct ARegionType * ED_area_type_hud(int space_type)
void ED_region_panels_init(struct wmWindowManager *wm, struct ARegion *region)
Definition: area.c:3090
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:667
void ED_region_header_init(struct ARegion *region)
Definition: area.c:3358
void ED_area_tag_refresh(ScrArea *area)
Definition: area.c:774
@ ED_KEYMAP_UI
Definition: ED_screen.h:440
@ ED_KEYMAP_ANIMATION
Definition: ED_screen.h:444
@ ED_KEYMAP_HEADER
Definition: ED_screen.h:446
@ ED_KEYMAP_VIEW2D
Definition: ED_screen.h:443
@ ED_KEYMAP_FRAMES
Definition: ED_screen.h:445
#define REGION_DRAW_POST_VIEW
Definition: ED_space_api.h:66
void ED_region_draw_cb_draw(const struct bContext *, struct ARegion *, int)
#define REGION_DRAW_PRE_VIEW
Definition: ED_space_api.h:68
void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
void immUnbindProgram(void)
void immVertex2f(uint attr_id, float x, float y)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
GPUVertFormat * immVertexFormat(void)
void immBegin(GPUPrimType, uint vertex_len)
void immEnd(void)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:36
@ GPU_SHADER_2D_UNIFORM_COLOR
Definition: GPU_shader.h:171
@ GPU_BLEND_NONE
Definition: GPU_state.h:55
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:57
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:55
void GPU_line_width(float width)
Definition: gpu_state.cc:173
@ GPU_FETCH_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
Read Guarded memory(de)allocation.
StructRNA RNA_FModifier
StructRNA RNA_FModifierEnvelopeControlPoint
StructRNA RNA_DopeSheet
StructRNA RNA_ActionGroup
StructRNA RNA_FModifierPython
StructRNA RNA_FModifierGenerator
StructRNA RNA_FCurveSample
StructRNA RNA_FModifierStepped
StructRNA RNA_FCurve
StructRNA RNA_Keyframe
StructRNA RNA_FModifierEnvelope
StructRNA RNA_FModifierNoise
StructRNA RNA_FModifierCycles
StructRNA RNA_FModifierLimits
StructRNA RNA_FModifierFunctionGenerator
StructRNA RNA_SpaceGraphEditor
#define C
Definition: RandGen.cpp:39
#define UI_SIDEBAR_PANEL_WIDTH
Definition: UI_interface.h:245
#define UI_DPI_FAC
Definition: UI_interface.h:309
void UI_GetThemeColor3fv(int colorid, float col[3])
Definition: resources.c:1191
@ TH_BACK
Definition: UI_resources.h:55
@ TH_CFRAME
Definition: UI_resources.h:113
@ TH_SCROLL_TEXT
Definition: UI_resources.h:295
@ TH_AXIS_Y
Definition: UI_resources.h:317
@ TH_AXIS_X
Definition: UI_resources.h:316
@ TH_AXIS_Z
Definition: UI_resources.h:318
void UI_ThemeClearColor(int colorid)
Definition: resources.c:1478
void UI_SetTheme(int spacetype, int regionid)
Definition: resources.c:1064
void UI_view2d_draw_lines_y__values(const struct View2D *v2d)
void UI_view2d_region_reinit(struct View2D *v2d, short type, int winx, int winy)
Definition: view2d.c:240
#define V2D_SCROLL_WIDTH
Definition: UI_view2d.h:68
void UI_view2d_view_restore(const struct bContext *C)
#define UI_TIME_SCRUB_MARGIN_Y
Definition: UI_view2d.h:283
void UI_view2d_view_ortho(const struct View2D *v2d)
void UI_view2d_draw_lines_x__frames_or_seconds(const struct View2D *v2d, const struct Scene *scene, bool display_seconds)
void UI_view2d_scrollers_draw(struct View2D *v2d, const struct rcti *mask_custom)
void UI_view2d_view_orthoSpecial(struct ARegion *region, struct View2D *v2d, const bool xaxis)
Definition: view2d.c:1159
@ V2D_COMMONVIEW_LIST
Definition: UI_view2d.h:53
@ V2D_COMMONVIEW_CUSTOM
Definition: UI_view2d.h:49
void UI_view2d_draw_scale_y__values(const struct ARegion *region, const struct View2D *v2d, const struct rcti *rect, int colorid)
#define ND_SEQUENCER
Definition: WM_types.h:337
#define NC_WINDOW
Definition: WM_types.h:277
#define NC_ID
Definition: WM_types.h:296
#define NC_NODE
Definition: WM_types.h:295
#define ND_OB_ACTIVE
Definition: WM_types.h:340
#define ND_RENDER_OPTIONS
Definition: WM_types.h:335
#define NC_ANIMATION
Definition: WM_types.h:289
#define NC_SCREEN
Definition: WM_types.h:278
#define ND_OB_SELECT
Definition: WM_types.h:342
#define NC_SCENE
Definition: WM_types.h:279
#define ND_MODIFIER
Definition: WM_types.h:363
#define NA_EDITED
Definition: WM_types.h:462
#define ND_SPACE_GRAPH
Definition: WM_types.h:427
#define ND_FRAME_RANGE
Definition: WM_types.h:351
#define ND_MARKERS
Definition: WM_types.h:333
#define ND_FRAME
Definition: WM_types.h:334
#define ND_BONE_ACTIVE
Definition: WM_types.h:360
#define ND_TRANSFORM
Definition: WM_types.h:357
#define ND_LAYER
Definition: WM_types.h:350
#define ND_KEYS
Definition: WM_types.h:364
#define NA_RENAME
Definition: WM_types.h:466
#define ND_BONE_SELECT
Definition: WM_types.h:361
#define ND_KEYFRAME
Definition: WM_types.h:394
#define NC_OBJECT
Definition: WM_types.h:280
#define ND_ANIMCHAN
Definition: WM_types.h:396
#define NC_SPACE
Definition: WM_types.h:293
#define NA_SELECTED
Definition: WM_types.h:467
void ANIM_animdata_freelist(ListBase *anim_data)
Definition: anim_deps.c:425
void ANIM_sync_animchannels_to_data(const bContext *C)
Definition: anim_deps.c:287
void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
Definition: anim_draw.c:95
void ANIM_draw_framerange(Scene *scene, View2D *v2d)
Definition: anim_draw.c:134
bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
Definition: anim_filter.c:405
size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_Flags filter_mode, void *data, eAnimCont_Types datatype)
Definition: anim_filter.c:3442
void getcolor_fcurve_rainbow(int cur, int tot, float out[3])
void ED_markers_draw(const bContext *C, int flag)
Definition: anim_markers.c:567
unsigned int U
Definition: btGjkEpa3.h:78
Scene scene
uint pos
uint col
void graph_buttons_register(ARegionType *art)
void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
Definition: graph_draw.c:1411
void graph_draw_ghost_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region)
Definition: graph_draw.c:1319
void graph_draw_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, short sel)
Definition: graph_draw.c:1369
void graphedit_keymap(struct wmKeyConfig *keyconf)
Definition: graph_ops.c:501
void graphedit_operatortypes(void)
Definition: graph_ops.c:418
void get_graph_keyframe_extents(struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, const bool do_sel_only, const bool include_handles)
Definition: graph_view.c:55
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:42
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static void area(int d1, int d2, int e1, int e2, float weights[2])
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:146
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:122
void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
Definition: rna_define.c:4448
const EnumPropertyItem rna_enum_space_graph_mode_items[]
Definition: rna_space.c:167
static void graph_channel_region_draw(const bContext *C, ARegion *region)
Definition: space_graph.c:354
static void graph_refresh(const bContext *C, ScrArea *area)
Definition: space_graph.c:749
static void graph_main_region_draw_overlay(const bContext *C, ARegion *region)
Definition: space_graph.c:308
static void graph_region_listener(const wmRegionListenerParams *params)
Definition: space_graph.c:406
static void graph_channel_region_init(wmWindowManager *wm, ARegion *region)
Definition: space_graph.c:332
void ED_spacetype_ipo(void)
Definition: space_graph.c:828
static void graph_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
Definition: space_graph.c:380
static SpaceLink * graph_duplicate(SpaceLink *sl)
Definition: space_graph.c:171
static int graph_space_subtype_get(ScrArea *area)
Definition: space_graph.c:808
static void graph_main_region_init(wmWindowManager *wm, ARegion *region)
Definition: space_graph.c:183
static void graph_header_region_draw(const bContext *C, ARegion *region)
Definition: space_graph.c:385
static void graph_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
Definition: space_graph.c:794
static void graph_space_subtype_item_extend(bContext *UNUSED(C), EnumPropertyItem **item, int *totitem)
Definition: space_graph.c:820
static void graph_listener(const wmSpaceTypeListenerParams *params)
Definition: space_graph.c:548
static void graph_free(SpaceLink *sl)
Definition: space_graph.c:138
static void graph_space_subtype_set(ScrArea *area, int value)
Definition: space_graph.c:814
static void graph_main_region_draw(const bContext *C, ARegion *region)
Definition: space_graph.c:196
static void graph_refresh_fcurve_colors(const bContext *C)
Definition: space_graph.c:627
static void graph_buttons_region_init(wmWindowManager *wm, ARegion *region)
Definition: space_graph.c:391
static void graph_buttons_region_draw(const bContext *C, ARegion *region)
Definition: space_graph.c:401
static void graph_init(struct wmWindowManager *wm, ScrArea *area)
Definition: space_graph.c:153
static SpaceLink * graph_create(const ScrArea *UNUSED(area), const Scene *scene)
Definition: space_graph.c:67
static void graph_region_message_subscribe(const wmRegionMessageSubscribeParams *params)
Definition: space_graph.c:472
void(* draw)(const struct bContext *C, struct ARegion *region)
Definition: BKE_screen.h:169
void(* message_subscribe)(const wmRegionMessageSubscribeParams *params)
Definition: BKE_screen.h:185
void(* draw_overlay)(const struct bContext *C, struct ARegion *region)
Definition: BKE_screen.h:177
void(* listener)(const wmRegionListenerParams *params)
Definition: BKE_screen.h:183
int keymapflag
Definition: BKE_screen.h:226
void(* init)(struct wmWindowManager *wm, struct ARegion *region)
Definition: BKE_screen.h:165
ListBase handlers
short alignment
short regiontype
int color_mode
float color[3]
int array_index
Definition: DNA_ID.h:273
void * first
Definition: DNA_listBase.h:47
struct StructRNA * type
Definition: RNA_types.h:51
struct RenderData r
struct bDopeSheet * ads
SpaceGraph_Runtime runtime
ListBase regionbase
struct SpaceLink *(* duplicate)(struct SpaceLink *sl)
Definition: BKE_screen.h:104
ListBase regiontypes
Definition: BKE_screen.h:130
void(* keymap)(struct wmKeyConfig *keyconf)
Definition: BKE_screen.h:109
void(* operatortypes)(void)
Definition: BKE_screen.h:107
void(* free)(struct SpaceLink *sl)
Definition: BKE_screen.h:88
void(* space_subtype_item_extend)(struct bContext *C, EnumPropertyItem **item, int *totitem)
Definition: BKE_screen.h:127
struct SpaceLink *(* create)(const struct ScrArea *area, const struct Scene *scene)
Definition: BKE_screen.h:86
void(* refresh)(const struct bContext *C, struct ScrArea *area)
Definition: BKE_screen.h:101
void(* listener)(const wmSpaceTypeListenerParams *params)
Definition: BKE_screen.h:95
void(* init)(struct wmWindowManager *wm, struct ScrArea *area)
Definition: BKE_screen.h:91
int spaceid
Definition: BKE_screen.h:81
void(* space_subtype_set)(struct ScrArea *area, int value)
Definition: BKE_screen.h:126
void(* id_remap)(struct ScrArea *area, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id)
Definition: BKE_screen.h:120
char name[BKE_ST_MAXNAME]
Definition: BKE_screen.h:80
int(* space_subtype_get)(struct ScrArea *area)
Definition: BKE_screen.h:125
short keeptot
float max[2]
float min[2]
short scroll
struct bDopeSheet * ads
Definition: ED_anim_api.h:92
short datatype
Definition: ED_anim_api.h:75
void * data
Definition: ED_anim_api.h:73
struct bAnimListElem * next
Definition: ED_anim_api.h:135
ListBase chanbase
struct Collection * filter_grp
float xmax
Definition: DNA_vec_types.h:85
float xmin
Definition: DNA_vec_types.h:85
float ymax
Definition: DNA_vec_types.h:86
float ymin
Definition: DNA_vec_types.h:86
unsigned int data
Definition: WM_types.h:260
unsigned int action
Definition: WM_types.h:260
unsigned int category
Definition: WM_types.h:260
struct wmKeyConfig * defaultconf
struct wmWindow * winactive
void ED_time_scrub_draw_current_frame(const ARegion *region, const Scene *scene, bool display_seconds, bool draw_line)
void ED_time_scrub_channel_search_draw(const bContext *C, ARegion *region, bDopeSheet *dopesheet)
void ED_time_scrub_draw(const ARegion *region, const Scene *scene, bool display_seconds, bool discrete_frames)
wmEventHandler_Keymap * WM_event_add_keymap_handler_v2d_mask(ListBase *handlers, wmKeyMap *keymap)
wmEventHandler_Keymap * WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap)
PointerRNA * ptr
Definition: wm_files.c:3157
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition: wm_keymap.c:852
void WM_msg_subscribe_rna_params(struct wmMsgBus *mbus, const wmMsgParams_RNA *msg_key_params, const wmMsgSubscribeValue *msg_val_params, const char *id_repr)
void WM_msg_subscribe_rna(struct wmMsgBus *mbus, PointerRNA *ptr, const PropertyRNA *prop, const wmMsgSubscribeValue *msg_val_params, const char *id_repr)
Scene * WM_window_get_active_scene(const wmWindow *win)
Definition: wm_window.c:2249