Blender V5.3
space_action.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdio>
10#include <cstring>
11
12#include "DNA_action_types.h"
14#include "DNA_scene_types.h"
15
16#include "DNA_screen_types.h"
17#include "MEM_guardedalloc.h"
18
19#include "BLI_listbase.hh"
20#include "BLI_math_base_c.hh"
21#include "BLI_string_utf8.hh"
22#include "BLI_utildefines.hh"
23
24#include "BKE_context.hh"
25#include "BKE_lib_query.hh"
26#include "BKE_lib_remap.hh"
27#include "BKE_screen.hh"
28
29#include "RNA_access.hh"
30#include "RNA_define.hh"
31#include "RNA_enum_types.hh"
32
33#include "WM_api.hh"
34#include "WM_message.hh"
35#include "WM_types.hh"
36
37#include "UI_interface.hh"
38#include "UI_resources.hh"
39#include "UI_view2d.hh"
40
41#include "ED_anim_api.hh"
42#include "ED_markers.hh"
43#include "ED_screen.hh"
44#include "ED_space_api.hh"
45#include "ED_time_scrub_ui.hh"
46
47#include "BLO_read_write.hh"
48
49#include "GPU_matrix.hh"
50
51#include "action_intern.hh" /* own include */
52
53namespace blender {
54
55/* -------------------------------------------------------------------- */
58
59static SpaceLink *action_create(const ScrArea *area, const Scene *scene)
60{
61 SpaceAction *saction;
62 ARegion *region;
63
64 saction = MEM_new<SpaceAction>("initaction");
65 saction->spacetype = SPACE_ACTION;
66
67 const eAnimEdit_Context desired_mode = area ? eAnimEdit_Context(area->butspacetype_subtype) :
69 const bool is_timeline = (desired_mode == SACTCONT_TIMELINE);
70
71 /* This should always set to SACTCONT_DOPESHEET, regardless of what the desired_mode is set to.
72 * Not for fundamental reasons, but to make it safe to call this function with an invalid value
73 * in desired_mode. I (Sybren) have no idea if that's ever going to happen, but in this case I'm
74 * sticking as close as possible to what Blender 4.5 was already doing. Once this function
75 * returns, ED_area_newspace() will call action_space_subtype_set() to set the sub-type. */
76 saction->mode = SACTCONT_DOPESHEET;
79
81 if (is_timeline) {
83 }
84
89
91
92 /* header */
93 region = BKE_area_region_new();
94
95 BLI_addtail(&saction->regionbase, region);
98
99 /* footer */
100 region = BKE_area_region_new();
101
102 BLI_addtail(&saction->regionbase, region);
103 region->regiontype = RGN_TYPE_FOOTER;
105
106 /* channel list region */
107 region = BKE_area_region_new();
108 BLI_addtail(&saction->regionbase, region);
110 region->alignment = RGN_ALIGN_LEFT;
111 /* Channel list is hidden by default in timeline mode, and visible in other modes. */
112 if (is_timeline) {
113 region->flag |= RGN_FLAG_HIDDEN;
114 }
115
116 /* Only need to set scroll settings, as this will use `listview` v2d configuration. */
117 region->v2d.scroll = V2D_SCROLL_BOTTOM;
119
120 /* ui buttons */
121 region = BKE_area_region_new();
122
123 BLI_addtail(&saction->regionbase, region);
124 region->regiontype = RGN_TYPE_UI;
125 region->alignment = RGN_ALIGN_RIGHT;
126
127 /* main region */
128 region = BKE_area_region_new();
129
130 BLI_addtail(&saction->regionbase, region);
131 region->regiontype = RGN_TYPE_WINDOW;
132
133 region->v2d.tot.xmin = float(scene->r.sfra - 10);
134 region->v2d.tot.ymin = float(-area->winy) / 3.0f;
135 region->v2d.tot.xmax = float(scene->r.efra + 10);
136 region->v2d.tot.ymax = 0.0f;
137
138 region->v2d.cur = region->v2d.tot;
139
140 region->v2d.min[0] = 0.0f;
141 region->v2d.min[1] = 0.0f;
142
143 region->v2d.max[0] = MAXFRAMEF;
144 region->v2d.max[1] = FLT_MAX;
145
146 region->v2d.minzoom = 0.01f;
147 region->v2d.maxzoom = 50;
150 region->v2d.keepzoom = V2D_LOCKZOOM_Y;
151 region->v2d.keepofs = V2D_KEEPOFS_Y;
152 region->v2d.align = V2D_ALIGN_NO_POS_Y;
154
155 return reinterpret_cast<SpaceLink *>(saction);
156}
157
158/* Doesn't free the space-link itself. */
159static void action_free(SpaceLink * /*sl*/)
160{
161 // SpaceAction *saction = (SpaceAction *) sl;
162}
163
164/* spacetype; init callback */
165static void action_init(wmWindowManager * /*wm*/, ScrArea *area)
166{
167 SpaceAction *saction = area->spacedata.first_as<SpaceAction>();
169}
170
172{
173 SpaceAction *sactionn = MEM_dupalloc(reinterpret_cast<SpaceAction *>(sl));
174
175 sactionn->runtime = SpaceAction_Runtime{};
176
177 /* clear or remove stuff from old */
178
179 return reinterpret_cast<SpaceLink *>(sactionn);
180}
181
182/* add handlers, stuff you only do once or on area/region changes */
184{
185 wmKeyMap *keymap;
186
187 view2d_region_reinit(&region->v2d, ui::V2D_COMMONVIEW_CUSTOM, region->winx, region->winy);
188
189 /* own keymap */
190 keymap = WM_keymap_ensure(wm->runtime->defaultconf, "Dopesheet", SPACE_ACTION, RGN_TYPE_WINDOW);
193
194 keymap = WM_keymap_ensure(
195 wm->runtime->defaultconf, "Dopesheet Generic", SPACE_ACTION, RGN_TYPE_WINDOW);
197}
198
199static void set_v2d_height(View2D *v2d, const size_t item_count, const bool add_marker_padding)
200{
201 const int height = ANIM_UI_get_channels_total_height(v2d, item_count);
202 float pad_bottom = add_marker_padding ? UI_MARKER_MARGIN_Y : 0;
203 /* Add padding for the collapsed redo panel. */
204 pad_bottom += HEADERY;
205 v2d->tot.ymin = -(height + pad_bottom);
207}
208
209static void action_main_region_draw(const bContext *C, ARegion *region)
210{
211 /* draw entirely, view changes should be handled here */
213 Scene *scene = CTX_data_scene(C);
214 bAnimContext ac;
215 View2D *v2d = &region->v2d;
216 short marker_flag = 0;
217
218 const int min_height = UI_ANIM_MINY;
219
220 /* scrollers */
221 if (region->winy >= UI_ANIM_MINY) {
222 region->v2d.scroll |= V2D_SCROLL_BOTTOM;
223 }
224 else {
225 region->v2d.scroll &= ~V2D_SCROLL_BOTTOM;
226 }
227
228 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
229 const bool has_anim_context = ANIM_animdata_get_context(C, &ac);
230 if (has_anim_context) {
231 /* Build list of channels to draw. */
234 const size_t items = ANIM_animdata_filter(
235 &ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
236 /* The View2D's height needs to be set before calling view2d_view_ortho because the latter
237 * uses the View2D's `cur` rect which might be modified when setting the height. */
238 set_v2d_height(v2d, items, !ac.markers->is_empty());
239 }
240
242
243 /* clear and setup matrix */
245
247
248 /* time grid */
249 if (region->winy > min_height) {
250 ui::view2d_draw_lines_x_frames(v2d, scene, saction->flag & SACTION_DRAWTIME, false, true);
251 }
252
254
255 /* start and end frame */
256 if (region->winy > min_height) {
257 ANIM_draw_framerange(scene, v2d);
258 }
259
260 /* Draw the manually set intended playback frame range highlight in the Action editor. */
261 if (ac.active_action) {
264 }
265
266 /* data */
267 if (has_anim_context) {
268 draw_channel_strips(&ac, saction, region, &anim_data);
269 }
270
271 /* markers */
272 ui::view2d_view_orthoSpecial(region, v2d, true);
273
274 marker_flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) |
276
278 ED_markers_draw(C, marker_flag);
279 }
280
281 /* preview range */
283 ANIM_draw_previewrange(scene, v2d, 0);
284
286
287 /* callback */
290
291 /* reset view matrix */
293
294 /* gizmos */
296
297 /* scrubbing region */
298 const int fps = round_db_to_int(scene->frames_per_second());
299 ED_time_scrub_draw(region, scene, saction->flag & SACTION_DRAWTIME, true, fps);
300}
301
303{
304 /* draw entirely, view changes should be handled here */
305 const SpaceAction *saction = CTX_wm_space_action(C);
306 const Scene *scene = CTX_data_scene(C);
307 const Object *obact = CTX_data_active_object(C);
308 View2D *v2d = &region->v2d;
309
310 /* caches */
312 ui::view2d_view_orthoSpecial(region, v2d, true);
313 timeline_draw_cache(saction, obact, scene);
315
316 /* scrubbing region */
318 region, scene, saction->flag & SACTION_DRAWTIME, region->winy >= UI_ANIM_MINY);
319
320 /* scrollers */
321 const rcti scroller_mask = ED_time_scrub_clamp_scroller_mask(v2d->mask);
322 ui::view2d_scrollers_draw(v2d, &scroller_mask);
323}
324
325/* add handlers, stuff you only do once or on area/region changes */
327{
328 wmKeyMap *keymap;
329
330 /* ensure the 2d view sync works - main region has bottom scroller */
331 region->v2d.scroll = V2D_SCROLL_BOTTOM;
332
333 view2d_region_reinit(&region->v2d, ui::V2D_COMMONVIEW_LIST, region->winx, region->winy);
334
335 /* own keymap */
336 keymap = WM_keymap_ensure(
337 wm->runtime->defaultconf, "Animation Channels", SPACE_EMPTY, RGN_TYPE_WINDOW);
339
340 keymap = WM_keymap_ensure(
341 wm->runtime->defaultconf, "Dopesheet Generic", SPACE_ACTION, RGN_TYPE_WINDOW);
343}
344
345static void action_channel_region_draw(const bContext *C, ARegion *region)
346{
347 /* draw entirely, view changes should be handled here */
348 bAnimContext ac;
349 const bool has_valid_animcontext = ANIM_animdata_get_context(C, &ac);
350
351 /* clear and setup matrix */
353
354 if (!has_valid_animcontext) {
355 return;
356 }
357
358 View2D *v2d = &region->v2d;
359
360 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
361 /* Build list of channels to draw. */
364 const size_t item_count = ANIM_animdata_filter(
365 &ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
366 /* The View2D's height needs to be set before calling view2d_view_ortho because the latter
367 * uses the View2D's `cur` rect which might be modified when setting the height. */
368 set_v2d_height(v2d, item_count, !ac.markers->is_empty());
369
371 draw_channel_names(const_cast<bContext *>(C), &ac, region, anim_data);
372
373 /* channel filter next to scrubbing area */
375
376 /* reset view matrix */
378
379 /* no scrollers here */
380 ANIM_animdata_freelist(&anim_data);
381}
382
383/* add handlers, stuff you only do once or on area/region changes */
385{
386 ED_region_header_init(region);
387}
388
389static void action_header_region_draw(const bContext *C, ARegion *region)
390{
391 /* The anim context is not actually used, but this makes sure the action being displayed is up to
392 * date. */
393 bAnimContext ac;
395
396 ED_region_header(C, region);
397}
398
400{
401 ARegion *region = params->region;
402 const wmNotifier *wmn = params->notifier;
403
404 /* context changes */
405 switch (wmn->category) {
406 case NC_ANIMATION:
407 ED_region_tag_redraw(region);
408 break;
409 case NC_SCENE:
410 switch (wmn->data) {
411 case ND_OB_ACTIVE:
412 case ND_FRAME:
413 ED_region_tag_redraw(region);
414 break;
415 }
416 break;
417 case NC_OBJECT:
418 switch (wmn->data) {
419 case ND_BONE_ACTIVE:
420 case ND_BONE_SELECT:
421 case ND_KEYS:
422 ED_region_tag_redraw(region);
423 break;
424 case ND_MODIFIER:
425 if (wmn->action == NA_RENAME) {
426 ED_region_tag_redraw(region);
427 }
428 break;
429 }
430 break;
431 case NC_GPENCIL:
433 ED_region_tag_redraw(region);
434 }
435 break;
436 case NC_ID:
437 if (wmn->action == NA_RENAME) {
438 ED_region_tag_redraw(region);
439 }
440 break;
441 default:
442 if (wmn->data == ND_KEYS) {
443 ED_region_tag_redraw(region);
444 }
445 break;
446 }
447}
448
450{
451 wmMsgBus *mbus = params->message_bus;
452 ARegion *region = params->region;
453
454 wmMsgSubscribeValue msg_sub_value_region_tag_redraw{};
455 msg_sub_value_region_tag_redraw.owner = region;
456 msg_sub_value_region_tag_redraw.user_data = region;
457 msg_sub_value_region_tag_redraw.notify = ED_region_do_msg_notify_tag_redraw;
458
459 /* All dope-sheet filter settings, etc. affect the drawing of this editor,
460 * also same applies for all animation-related data-types that may appear here,
461 * so just whitelist the entire structs for updates. */
462 {
463 wmMsgParams_RNA msg_key_params = {{}};
464 StructRNA *type_array[] = {
465 RNA_DopeSheet, /* Dope-sheet filters. */
466
467 RNA_ActionGroup, /* channel groups */
468
469 RNA_FCurve, /* F-Curve */
470 RNA_Keyframe,
471 RNA_FCurveSample,
472
473 RNA_Annotation, /* Grease Pencil */
474 RNA_AnnotationLayer,
475 RNA_AnnotationFrame,
476 };
477
478 for (int i = 0; i < ARRAY_SIZE(type_array); i++) {
479 msg_key_params.ptr.type = type_array[i];
481 mbus, &msg_key_params, &msg_sub_value_region_tag_redraw, __func__);
482 }
483 }
484}
485
487{
488 ARegion *region = params->region;
489 const wmNotifier *wmn = params->notifier;
490
491 /* context changes */
492 switch (wmn->category) {
493 case NC_ANIMATION:
494 ED_region_tag_redraw(region);
495 break;
496 case NC_SCENE:
497 switch (wmn->data) {
499 case ND_OB_ACTIVE:
500 case ND_FRAME:
501 case ND_FRAME_RANGE:
502 case ND_MARKERS:
503 ED_region_tag_redraw(region);
504 break;
505 }
506 break;
507 case NC_OBJECT:
508 switch (wmn->data) {
509 case ND_TRANSFORM:
510 /* moving object shouldn't need to redraw action */
511 break;
512 case ND_BONE_ACTIVE:
513 case ND_BONE_SELECT:
515 case ND_KEYS:
516 ED_region_tag_redraw(region);
517 break;
518 }
519 break;
520 case NC_NODE:
521 switch (wmn->action) {
522 case NA_EDITED:
523 ED_region_tag_redraw(region);
524 break;
525 }
526 break;
527 case NC_ID:
528 if (wmn->action == NA_RENAME) {
529 ED_region_tag_redraw(region);
530 }
531 break;
532 case NC_SCREEN:
533 if (ELEM(wmn->data, ND_LAYER)) {
534 ED_region_tag_redraw(region);
535 }
536 break;
537 default:
538 if (wmn->data == ND_KEYS) {
539 ED_region_tag_redraw(region);
540 }
541 break;
542 }
543}
544
546{
547 wmMsgBus *mbus = params->message_bus;
548 Scene *scene = params->scene;
549 ARegion *region = params->region;
550
551 wmMsgSubscribeValue msg_sub_value_region_tag_redraw{};
552 msg_sub_value_region_tag_redraw.owner = region;
553 msg_sub_value_region_tag_redraw.user_data = region;
554 msg_sub_value_region_tag_redraw.notify = ED_region_do_msg_notify_tag_redraw;
555
556 /* Timeline depends on scene properties. */
557 {
558 bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
559 const PropertyRNA *props[] = {
560 use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
561 use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,
562 &rna_Scene_use_preview_range,
563 &rna_Scene_frame_current,
564 };
565
566 PointerRNA idptr = RNA_id_pointer_create(&scene->id);
567
568 for (int i = 0; i < ARRAY_SIZE(props); i++) {
569 WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
570 }
571 }
572
573 /* Now run the general "channels region" one - since channels and main should be in sync */
575}
576
577/* editor level listener */
579{
580 ScrArea *area = params->area;
581 const wmNotifier *wmn = params->notifier;
582 SpaceAction *saction = area->spacedata.first_as<SpaceAction>();
583
584 /* context changes */
585 switch (wmn->category) {
586 case NC_GPENCIL:
587 /* only handle these events for containers in which GPencil frames are displayed */
589 if (wmn->action == NA_EDITED) {
590 ED_area_tag_redraw(area);
591 }
592 else if (wmn->action == NA_SELECTED) {
595 }
596 }
597 break;
598 case NC_ANIMATION:
599 /* For NLA tweak-mode enter/exit, need complete refresh. */
600 if (wmn->data == ND_NLA_ACTCHANGE) {
603 }
604 /* Auto-color only really needs to change when channels are added/removed,
605 * or previously hidden stuff appears
606 * (assume for now that if just adding these works, that will be fine).
607 */
608 else if (((wmn->data == ND_KEYFRAME) && ELEM(wmn->action, NA_ADDED, NA_REMOVED)) ||
609 ((wmn->data == ND_ANIMCHAN) && (wmn->action != NA_SELECTED)))
610 {
612 }
613 /* for simple edits to the curve data though (or just plain selections),
614 * a simple redraw should work
615 * (see #39851 for an example of how this can go wrong)
616 */
617 else {
618 ED_area_tag_redraw(area);
619 }
620 break;
621 case NC_SCENE:
622 switch (wmn->data) {
623 case ND_SEQUENCER:
624 if (wmn->action == NA_SELECTED) {
627 }
628 break;
629 case ND_OB_ACTIVE:
630 case ND_OB_SELECT:
631 /* Selection changed, so force refresh to flush
632 * (needs flag set to do syncing). */
635 break;
636 case ND_RENDER_RESULT:
637 ED_area_tag_redraw(area);
638 break;
639 case ND_FRAME_RANGE:
640 for (ARegion &region : area->regionbase) {
641 if (region.regiontype == RGN_TYPE_WINDOW) {
642 Scene *scene = static_cast<Scene *>(wmn->reference);
643 region.v2d.tot.xmin = float(scene->r.sfra - 4);
644 region.v2d.tot.xmax = float(scene->r.efra + 4);
645 break;
646 }
647 }
648 break;
649 default:
650 /* Just redrawing the view will do. */
651 ED_area_tag_redraw(area);
652 break;
653 }
654 break;
655 case NC_OBJECT:
656 switch (wmn->data) {
657 case ND_BONE_SELECT: /* Selection changed, so force refresh to flush
658 * (needs flag set to do syncing). */
659 case ND_BONE_ACTIVE:
662 break;
663 case ND_TRANSFORM:
664 /* moving object shouldn't need to redraw action */
665 break;
666 case ND_POINTCACHE:
667 case ND_MODIFIER:
668 case ND_PARTICLE:
669 break;
670 default: /* just redrawing the view will do */
671 ED_area_tag_redraw(area);
672 break;
673 }
674 break;
675 case NC_MASK:
676 if (saction->mode == SACTCONT_MASK) {
677 switch (wmn->data) {
678 case ND_DATA:
680 ED_area_tag_redraw(area);
681 break;
682 default: /* just redrawing the view will do */
683 ED_area_tag_redraw(area);
684 break;
685 }
686 }
687 break;
688 case NC_NODE:
689 if (wmn->action == NA_SELECTED) {
690 /* selection changed, so force refresh to flush (needs flag set to do syncing) */
693 }
694 break;
695 case NC_SPACE:
696 switch (wmn->data) {
698 ED_area_tag_redraw(area);
699 break;
700 case ND_SPACE_TIME:
701 ED_area_tag_redraw(area);
702 break;
703 case ND_SPACE_CHANGED:
706 break;
707 }
708 break;
709 case NC_WINDOW:
711 /* force redraw/refresh after undo/redo, see: #28962. */
713 }
714 break;
715 case NC_WM:
716 switch (wmn->data) {
717 case ND_FILEREAD:
719 break;
720 }
721 break;
722 }
723}
724
726{
727 ARegion *region = params->region;
728 const wmNotifier *wmn = params->notifier;
729
730 /* context changes */
731 switch (wmn->category) {
732 case NC_SCREEN:
733 break;
734 case NC_SCENE:
735 switch (wmn->data) {
736 case ND_OB_ACTIVE:
737 ED_region_tag_redraw(region);
738 break;
739 }
740 break;
741 case NC_ID:
742 if (wmn->action == NA_RENAME) {
743 ED_region_tag_redraw(region);
744 }
745 break;
746 case NC_ANIMATION:
747 switch (wmn->data) {
748 case ND_ANIMCHAN: /* set of visible animchannels changed */
749 /* NOTE: for now, this should usually just mean that the filters changed
750 * It may be better if we had a dedicated flag for that though
751 */
752 ED_region_tag_redraw(region);
753 break;
754
755 case ND_KEYFRAME: /* new keyframed added -> active action may have changed */
756 // saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
757 ED_region_tag_redraw(region);
758 break;
759 }
760 break;
761 }
762}
763
765{
766 ARegion *region = params->region;
767 const wmNotifier *wmn = params->notifier;
768
769 /* context changes */
770 switch (wmn->category) {
771 case NC_SCREEN:
772 if (wmn->data == ND_ANIMPLAY) {
773 ED_region_tag_redraw(region);
774 }
775 break;
776 case NC_SCENE:
777 switch (wmn->data) {
778 case ND_FRAME:
779 ED_region_tag_redraw(region);
780 break;
781 }
782 break;
783 }
784}
785
787{
789 const SpaceAction *saction = params->area->spacedata.first_as<SpaceAction>();
790 return saction->mode != SACTCONT_TIMELINE;
791}
792
793/* add handlers, stuff you only do once or on area/region changes */
795{
796 wmKeyMap *keymap;
797
798 ED_region_panels_init(wm, region);
799
800 keymap = WM_keymap_ensure(
801 wm->runtime->defaultconf, "Dopesheet Generic", SPACE_ACTION, RGN_TYPE_WINDOW);
803}
804
805static void action_buttons_area_draw(const bContext *C, ARegion *region)
806{
807 ED_region_panels(C, region);
808}
809
811{
812 ARegion *region = params->region;
813 const wmNotifier *wmn = params->notifier;
814
815 /* context changes */
816 switch (wmn->category) {
817 case NC_ANIMATION:
818 ED_region_tag_redraw(region);
819 break;
820 case NC_SCENE:
821 switch (wmn->data) {
822 case ND_OB_ACTIVE:
823 case ND_FRAME:
824 case ND_MARKERS:
825 ED_region_tag_redraw(region);
826 break;
827 }
828 break;
829 case NC_OBJECT:
830 switch (wmn->data) {
831 case ND_BONE_ACTIVE:
832 case ND_BONE_SELECT:
833 case ND_KEYS:
834 ED_region_tag_redraw(region);
835 break;
836 }
837 break;
838 default:
839 if (wmn->data == ND_KEYS) {
840 ED_region_tag_redraw(region);
841 }
842 break;
843 }
844}
845
846static void action_refresh(const bContext *C, ScrArea *area)
847{
848 SpaceAction *saction = area->spacedata.first_as<SpaceAction>();
849
850 /* Update the state of the animchannels in response to changes from the data they represent
851 * NOTE: the temp flag is used to indicate when this needs to be done,
852 * and will be cleared once handled. */
854 /* Perform syncing of channel state incl. selection
855 * Active action setting also occurs here
856 * (as part of anim channel filtering in `anim_filter.cc`). */
859
860 /* Tag everything for redraw
861 * - Regions (such as header) need to be manually tagged for redraw too
862 * or else they don't update #28962.
863 */
864 ED_area_tag_redraw(area);
865 for (ARegion &region : area->regionbase) {
866 ED_region_tag_redraw(&region);
867 }
868 }
869
870 /* region updates? */
871 /* XXX re-sizing y-extents of tot should go here? */
872}
873
874static void action_id_remap(ScrArea * /*area*/,
875 SpaceLink *slink,
876 const bke::id::IDRemapper &mappings)
877{
878 SpaceAction *sact = reinterpret_cast<SpaceAction *>(slink);
879
880 mappings.apply(reinterpret_cast<ID **>(&sact->ads.filter_grp), ID_REMAP_APPLY_DEFAULT);
881 mappings.apply(&sact->ads.source, ID_REMAP_APPLY_DEFAULT);
882}
883
885{
886 SpaceAction *sact = reinterpret_cast<SpaceAction *>(space_link);
887 const int data_flags = BKE_lib_query_foreachid_process_flags_get(data);
888 const bool is_readonly = (data_flags & IDWALK_READONLY) != 0;
889
890 /* NOTE: Could be deduplicated with the #bDopeSheet handling of #SpaceNla and #SpaceGraph. */
893
894 if (!is_readonly) {
895 /* Force recalc of list of channels, potentially updating the active action while we're
896 * at it (as it can only be updated that way) #28962. */
898 }
899}
900
902{
903 SpaceAction *sact = area->spacedata.first_as<SpaceAction>();
905}
906
907static void action_space_subtype_set(ScrArea *area, int value)
908{
909 SpaceAction *sact = area->spacedata.first_as<SpaceAction>();
910 if (value == SACTCONT_TIMELINE) {
911 /* Switching to the timeline. Remember what the current mode of the dope sheet is. */
912 if (sact->mode != SACTCONT_TIMELINE) {
913 sact->mode_prev = sact->mode;
914 }
915 sact->mode = SACTCONT_TIMELINE;
916 }
917 else {
918 /* Switching to the 'Dope Sheet' editor, so switch to the last-used mode. Unless that was
919 * Timeline, don't use the 'subtype' switch to go back to that; if the user wanted that, we'd
920 * be in the `if` case above. */
923 }
924}
925
927 EnumPropertyItem **item,
928 int *totitem)
929{
931}
932
934{
935 SpaceAction *sact = area->spacedata.first_as<SpaceAction>();
938 return item.name;
939}
940
941static int action_space_icon_get(const ScrArea *area)
942{
943 SpaceAction *sact = area->spacedata.first_as<SpaceAction>();
946 return item.icon;
947}
948
950{
951 SpaceAction *saction = reinterpret_cast<SpaceAction *>(sl);
952 saction->runtime = SpaceAction_Runtime{};
953}
954
956{
957 writer->write_struct_cast<SpaceAction>(sl, [](BlendStructWriter<SpaceAction> &struct_writer) {
958 struct_writer.shallow_data.runtime = {};
959 });
960}
961
963{
964 std::unique_ptr<SpaceType> st = std::make_unique<SpaceType>();
965 ARegionType *art;
966
967 st->spaceid = SPACE_ACTION;
968 STRNCPY_UTF8(st->name, "Action");
969 st->struct_size = sizeof(SpaceAction);
970
971 st->create = action_create;
972 st->free = action_free;
973 st->init = action_init;
974 st->duplicate = action_duplicate;
975 st->operatortypes = action_operatortypes;
976 st->keymap = action_keymap;
977 st->listener = action_listener;
978 st->refresh = action_refresh;
979 st->id_remap = action_id_remap;
980 st->foreach_id = action_foreach_id;
981 st->space_subtype_item_extend = action_space_subtype_item_extend;
982 st->space_subtype_get = action_space_subtype_get;
983 st->space_subtype_set = action_space_subtype_set;
984 st->space_name_get = action_space_name_get;
985 st->space_icon_get = action_space_icon_get;
986 st->blend_read_data = action_space_blend_read_data;
987 st->blend_read_after_liblink = nullptr;
988 st->blend_write = action_space_blend_write;
989
990 /* regions: main window */
991 art = MEM_new_zeroed<ARegionType>("spacetype action region");
999
1000 BLI_addhead(&st->regiontypes, art);
1001
1002 /* regions: header */
1003 art = MEM_new_zeroed<ARegionType>("spacetype action region");
1005 art->prefsizey = HEADERY;
1007
1011
1012 BLI_addhead(&st->regiontypes, art);
1013
1014 /* regions: footer */
1015 art = MEM_new_zeroed<ARegionType>("spacetype action region");
1017 art->prefsizey = HEADERY;
1023
1024 BLI_addhead(&st->regiontypes, art);
1025
1026 /* regions: channels */
1027 art = MEM_new_zeroed<ARegionType>("spacetype action region");
1029 art->prefsizex = 200;
1031
1036
1037 BLI_addhead(&st->regiontypes, art);
1038
1039 /* regions: UI buttons */
1040 art = MEM_new_zeroed<ARegionType>("spacetype action region");
1041 art->regionid = RGN_TYPE_UI;
1049
1050 BLI_addhead(&st->regiontypes, art);
1051
1053
1054 art = ui::ED_area_type_hud(st->spaceid);
1055 BLI_addhead(&st->regiontypes, art);
1056
1057 BKE_spacetype_register(std::move(st));
1058}
1059
1061
1062} // namespace blender
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
#define BKE_LIB_FOREACHID_PROCESS_ID(data_, id_, cb_flag_)
#define STRNCPY_UTF8(dst, src)
Object groups, one object can be in many groups at once.
#define MAXFRAMEF
#define HEADERY
#define REGION_DRAW_POST_VIEW
#define REGION_DRAW_PRE_VIEW
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_SIDEBAR_PANEL_WIDTH
#define UI_ANIM_MINY
Definition UI_view2d.hh:495
#define UI_MARKER_MARGIN_Y
Definition UI_view2d.hh:492
#define ND_SEQUENCER
Definition WM_types.hh:456
#define NC_WINDOW
Definition WM_types.hh:388
#define NC_ID
Definition WM_types.hh:408
#define NC_NODE
Definition WM_types.hh:407
#define ND_FILEREAD
Definition WM_types.hh:428
#define ND_NLA_ACTCHANGE
Definition WM_types.hh:541
#define ND_SPACE_CHANGED
Definition WM_types.hh:581
#define ND_OB_ACTIVE
Definition WM_types.hh:459
#define ND_RENDER_RESULT
Definition WM_types.hh:465
#define NC_WM
Definition WM_types.hh:387
#define ND_DATA
Definition WM_types.hh:552
#define ND_RENDER_OPTIONS
Definition WM_types.hh:454
#define ND_SPACE_DOPESHEET
Definition WM_types.hh:576
#define NC_ANIMATION
Definition WM_types.hh:401
#define NC_SCREEN
Definition WM_types.hh:390
#define ND_OB_SELECT
Definition WM_types.hh:461
#define ND_ANIMPLAY
Definition WM_types.hh:441
#define NC_SCENE
Definition WM_types.hh:391
#define NA_ADDED
Definition WM_types.hh:636
#define ND_MODIFIER
Definition WM_types.hh:503
#define NA_EDITED
Definition WM_types.hh:634
#define ND_PARTICLE
Definition WM_types.hh:506
#define ND_FRAME_RANGE
Definition WM_types.hh:470
#define ND_MARKERS
Definition WM_types.hh:452
#define ND_FRAME
Definition WM_types.hh:453
#define ND_SPACE_TIME
Definition WM_types.hh:574
#define NA_REMOVED
Definition WM_types.hh:637
#define NC_GPENCIL
Definition WM_types.hh:412
#define ND_BONE_ACTIVE
Definition WM_types.hh:483
#define ND_TRANSFORM
Definition WM_types.hh:475
#define ND_LAYER
Definition WM_types.hh:469
#define ND_BONE_COLLECTION
Definition WM_types.hh:515
#define NC_MASK
Definition WM_types.hh:411
#define ND_KEYS
Definition WM_types.hh:504
#define NA_RENAME
Definition WM_types.hh:638
#define ND_POINTCACHE
Definition WM_types.hh:507
#define ND_BONE_SELECT
Definition WM_types.hh:491
#define ND_KEYFRAME
Definition WM_types.hh:537
#define NC_OBJECT
Definition WM_types.hh:392
#define ND_ANIMCHAN
Definition WM_types.hh:539
#define NC_SPACE
Definition WM_types.hh:405
#define NA_SELECTED
Definition WM_types.hh:639
#define ELEM(...)
IDRemapperApplyResult apply(ID **r_id_ptr, IDRemapperApplyOptions options, ID *id_self=nullptr) const
#define FLT_MAX
void frame_buffer_clear(int colorid)
void view2d_view_ortho(const View2D *v2d)
Definition view2d.cc:1080
void view2d_view_restore(const bContext *C)
Definition view2d.cc:1147
ARegionType * ED_area_type_hud(int space_type)
void view2d_scrollers_draw(View2D *v2d, const rcti *mask_custom)
Definition view2d.cc:1487
void view2d_curRect_clamp_y(View2D *v2d)
Definition view2d.cc:829
@ V2D_COMMONVIEW_LIST
Definition UI_view2d.hh:60
@ V2D_COMMONVIEW_CUSTOM
Definition UI_view2d.hh:56
void view2d_draw_lines_x_frames(const View2D *v2d, const Scene *scene, bool display_seconds, bool show_fractions, bool draw_minor_lines)
void view2d_view_orthoSpecial(ARegion *region, View2D *v2d, bool xaxis)
Definition view2d.cc:1121
BMesh Iterators.
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static SpaceLink * action_create(const ScrArea *area, const Scene *scene)
void ED_time_scrub_draw_current_frame(const ARegion *region, const Scene *scene, bool display_seconds, bool display_stalk, bool clamp_playhead)
static void action_footer_region_listener(const wmRegionListenerParams *params)
void ANIM_draw_framerange(Scene *scene, View2D *v2d)
Definition anim_draw.cc:176
ScrArea * CTX_wm_area(const bContext *C)
void ED_time_scrub_draw(const ARegion *region, const Scene *scene, bool display_seconds, bool discrete_frames, const int base)
void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region, const ListBaseT< bAnimListElem > &anim_data)
void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
SpaceAction * CTX_wm_space_action(const bContext *C)
@ ADS_FLAG_SUMMARY_COLLAPSED
static void action_refresh(const bContext *C, ScrArea *area)
@ V2D_VIEWSYNC_AREA_VERTICAL
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:98
void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region, ListBaseT< bAnimListElem > *anim_data)
static void action_space_subtype_set(ScrArea *area, int value)
static void action_space_blend_write(BlendWriter *writer, SpaceLink *sl)
void ANIM_draw_action_framerange(AnimData *adt, bAction *action, View2D *v2d, float ymin, float ymax)
Definition anim_draw.cc:212
PointerRNA RNA_id_pointer_create(ID *id)
void action_keymap(wmKeyConfig *keyconf)
Definition action_ops.cc:95
static void action_init(wmWindowManager *, ScrArea *area)
bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
void ED_markers_draw(const bContext *C, int flag)
bool ED_markers_region_visible(const ScrArea *area, const ARegion *region)
static SpaceLink * action_duplicate(SpaceLink *sl)
MINLINE int max_ii(int a, int b)
void WM_msg_subscribe_rna_params(wmMsgBus *mbus, const wmMsgParams_RNA *msg_key_params, const wmMsgSubscribeValue *msg_val_params, const char *id_repr)
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
LibraryForeachIDFlag BKE_lib_query_foreachid_process_flags_get(const LibraryForeachIDData *data)
Definition lib_query.cc:133
int RNA_enum_from_value(const EnumPropertyItem *item, const int value)
static void action_buttons_area_init(wmWindowManager *wm, ARegion *region)
const EnumPropertyItem rna_enum_space_action_mode_items[]
Definition rna_space.cc:294
static void action_space_blend_read_data(BlendDataReader *, SpaceLink *sl)
@ ADS_OVERLAY_SHOW_OVERLAYS
@ ADS_SHOW_SCENE_STRIP_FRAME_RANGE
static void action_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data)
@ TIME_CACHE_DYNAMICPAINT
@ TIME_CACHE_SIMULATION_NODES
static void action_id_remap(ScrArea *, SpaceLink *slink, const bke::id::IDRemapper &mappings)
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:93
static int action_space_icon_get(const ScrArea *area)
static void action_channel_region_init(wmWindowManager *wm, ARegion *region)
static StringRefNull action_space_name_get(const ScrArea *area)
size_t ANIM_animdata_filter(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const eAnimFilter_Flags filter_mode, void *data, const eAnimCont_Types datatype)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
@ ANIMFILTER_LIST_VISIBLE
@ ANIMFILTER_DATA_VISIBLE
@ ANIMFILTER_LIST_CHANNELS
void action_buttons_register(ARegionType *)
void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
BMesh const char void * data
wmEventHandler_Keymap * WM_event_add_keymap_handler_v2d_mask(ListBaseT< wmEventHandler > *handlers, wmKeyMap *keymap)
static void action_listener(const wmSpaceTypeListenerParams *params)
void ED_spacetype_action()
void ED_region_panels(const bContext *C, ARegion *region)
Definition area.cc:3999
static int action_space_subtype_get(ScrArea *area)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition wm_keymap.cc:935
rcti ED_time_scrub_clamp_scroller_mask(const rcti &scroller_mask)
bool WM_event_handler_region_v2d_mask_no_marker_poll(const wmWindow *win, const ScrArea *area, const ARegion *region, const wmEvent *event)
static void saction_main_region_message_subscribe(const wmRegionMessageSubscribeParams *params)
void ANIM_draw_previewrange(const Scene *scene, View2D *v2d, int end_frame_width)
Definition anim_draw.cc:88
wmEventHandler_Keymap * WM_event_add_keymap_handler(ListBaseT< wmEventHandler > *handlers, wmKeyMap *keymap)
@ DRAW_MARKERS_MARGIN
Definition ED_markers.hh:35
@ DRAW_MARKERS_LOCAL
Definition ED_markers.hh:34
ARegion * BKE_area_region_new()
Definition screen.cc:522
static void action_header_region_listener(const wmRegionListenerParams *params)
@ ED_KEYMAP_UI
Definition ED_screen.hh:852
@ ED_KEYMAP_FOOTER
Definition ED_screen.hh:859
@ ED_KEYMAP_HEADER
Definition ED_screen.hh:858
@ ED_KEYMAP_ANIMATION
Definition ED_screen.hh:856
@ ED_KEYMAP_VIEW2D
Definition ED_screen.hh:855
@ ED_KEYMAP_FRAMES
Definition ED_screen.hh:857
@ ED_KEYMAP_GIZMO
Definition ED_screen.hh:853
static void action_main_region_init(wmWindowManager *wm, ARegion *region)
wmEventHandler_Keymap * WM_event_add_keymap_handler_poll(ListBaseT< wmEventHandler > *handlers, wmKeyMap *keymap, EventHandlerPoll poll)
void WM_msg_subscribe_rna(wmMsgBus *mbus, PointerRNA *ptr, const PropertyRNA *prop, const wmMsgSubscribeValue *msg_val_params, const char *id_repr)
@ V2D_SCROLL_VERTICAL_HIDE
@ V2D_SCROLL_HORIZONTAL_HANDLES
static void set_v2d_height(View2D *v2d, const size_t item_count, const bool add_marker_padding)
static void action_channel_region_draw(const bContext *C, ARegion *region)
static void saction_channel_region_message_subscribe(const wmRegionMessageSubscribeParams *params)
static void action_header_region_draw(const bContext *C, ARegion *region)
float ANIM_UI_get_channels_total_height(View2D *v2d, const int item_count)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
void ANIM_sync_animchannels_to_data(const bContext *C)
Definition anim_deps.cc:270
static void action_main_region_draw_overlay(const bContext *C, ARegion *region)
void GPU_matrix_pop_projection()
void BKE_spacetype_register(std::unique_ptr< SpaceType > st)
Definition screen.cc:379
void ANIM_animdata_freelist(ListBaseT< bAnimListElem > *anim_data)
Definition anim_deps.cc:472
void WM_gizmomap_draw(wmGizmoMap *gzmap, const bContext *C, const eWM_GizmoFlagMapDrawStep drawstep)
void ED_region_header_init(ARegion *region)
Definition area.cc:4406
static void action_region_listener(const wmRegionListenerParams *params)
static void action_main_region_listener(const wmRegionListenerParams *params)
static void action_channel_region_listener(const wmRegionListenerParams *params)
static bool action_region_poll_hide_in_timeline(const RegionPollParams *params)
Scene * CTX_data_scene(const bContext *C)
@ SACTION_SHOW_INTERPOLATION
void ED_area_tag_refresh(ScrArea *area)
Definition area.cc:813
@ ID_REMAP_APPLY_DEFAULT
@ IDWALK_CB_DIRECT_WEAK_LINK
void ED_region_do_msg_notify_tag_redraw(bContext *C, wmMsgSubscribeKey *msg_key, wmMsgSubscribeValue *msg_val)
Definition area.cc:394
static void action_header_region_init(wmWindowManager *, ARegion *region)
@ SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC
void timeline_draw_cache(const SpaceAction *saction, const Object *ob, const Scene *scene)
void ED_time_scrub_channel_search_draw(const bContext *C, ARegion *region, bDopeSheet *dopesheet)
void GPU_matrix_push_projection()
void ED_region_header(const bContext *C, ARegion *region)
Definition area.cc:4391
void action_operatortypes()
Definition action_ops.cc:27
Object * CTX_data_active_object(const bContext *C)
static void action_buttons_area_draw(const bContext *C, ARegion *region)
void ED_region_panels_init(wmWindowManager *wm, ARegion *region)
Definition area.cc:4006
void ANIM_draw_scene_strip_range(const bContext *C, View2D *v2d)
Definition anim_draw.cc:119
static void action_free(SpaceLink *)
MINLINE int round_db_to_int(double a)
static void action_main_region_draw(const bContext *C, ARegion *region)
@ WM_GIZMOMAP_DRAWSTEP_2D
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:784
static void action_space_subtype_item_extend(bContext *, EnumPropertyItem **item, int *totitem)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
void(*) draw_overlay(const bContext *C, ARegion *region)
ARegionTypeFlag flag
void(*) message_subscribe(const wmRegionMessageSubscribeParams *params)
void(*) draw(const bContext *C, ARegion *region)
void(*) listener(const wmRegionListenerParams *params)
bool(*) poll(const RegionPollParams *params)
void(*) init(wmWindowManager *wm, ARegion *region)
bke::ARegionRuntime * runtime
eRegion_Alignment alignment
eRegion_Type regiontype
void write_struct_cast(const void *data, BlendStructWriterTypedFn< T > fn=nullptr)
StructRNA * type
Definition RNA_types.hh:63
ListBaseT< TimeMarker > markers
struct RenderData r
ListBaseT< ARegion > regionbase
ListBaseT< SpaceLink > spacedata
SpaceActionOverlays_Flag flag
SpaceActionOverlays overlays
eAnimEdit_Context mode
SpaceAction_Runtime runtime
ListBaseT< struct ARegion > regionbase
eTimeline_Cache_Flag cache_display
eView2D_KeepOfs keepofs
eView2D_KeepZoom keepzoom
eView2D_Scroll scroll
eView2D_Align align
ListBaseT< TimeMarker > * markers
eAnimCont_Types datatype
eDopeSheet_FilterFlag filterflag
struct Collection * filter_grp
ListBaseT< wmEventHandler > handlers
unsigned int action
Definition WM_types.hh:371
unsigned int category
Definition WM_types.hh:371
unsigned int data
Definition WM_types.hh:371