Blender V5.3
keyframes_draw.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors, Joshua Leung. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9/* System includes ----------------------------------------------------- */
10
11#include <cfloat>
12
13#include "MEM_guardedalloc.h"
14
15#include "BKE_grease_pencil.hh"
16#include "BKE_library.hh"
17
18#include "BLI_listbase.hh"
19#include "BLI_math_vector_c.hh"
20#include "BLI_rect.hh"
21
22#include "DNA_anim_types.h"
25#include "DNA_mask_types.h"
26
27#include "GPU_immediate.hh"
28#include "GPU_shader_shared.hh"
29#include "GPU_state.hh"
30
31#include "UI_interface.hh"
32#include "UI_resources.hh"
33#include "UI_view2d.hh"
34
35#include "ED_anim_api.hh"
36#include "ED_keyframes_draw.hh"
38
39#include "ANIM_action.hh"
40
41namespace blender {
42
43/* *************************** Keyframe Drawing *************************** */
44
45void draw_keyframe_shape(const float x,
46 const float y,
47 float size,
48 const bool sel,
49 const eBezTriple_KeyframeType key_type,
50 const eKeyframeShapeDrawOpts mode,
51 const float alpha,
52 const KeyframeShaderBindings *sh_bindings,
53 const short handle_type,
54 const short extreme_type)
55{
56 bool draw_fill = ELEM(mode, KEYFRAME_SHAPE_INSIDE, KEYFRAME_SHAPE_BOTH);
57 bool draw_outline = ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH);
58
59 BLI_assert(draw_fill || draw_outline);
60
61 /* Adjust size of keyframe shape according to type of keyframe. */
62 switch (key_type) {
64 break;
65
67 size *= 0.85f;
68 break;
69
71 size *= 0.925f;
72 break;
73
75 size *= 1.2f;
76 break;
77
79 size *= 0.8f;
80 break;
81
83 size *= 0.75;
84 break;
85 }
86
87 uchar fill_col[4];
88 uchar outline_col[4];
89 uint flags = 0;
90
91 /* draw! */
92 if (draw_fill) {
93 /* get interior colors from theme (for selected and unselected only) */
94 switch (key_type) {
97 fill_col);
98 break;
101 break;
104 break;
107 fill_col);
108 break;
111 fill_col);
112 break;
115 fill_col);
116 break;
117 }
118
119 /* For effects like graying out protected/muted channels. The theme RNA/UI doesn't allow users
120 * to set the alpha. */
121 fill_col[3] = 255.0f * alpha;
122
123 if (!draw_outline) {
124 /* force outline color to match */
125 outline_col[0] = fill_col[0];
126 outline_col[1] = fill_col[1];
127 outline_col[2] = fill_col[2];
128 outline_col[3] = fill_col[3];
129 }
130 }
131
132 if (draw_outline) {
133 /* exterior - black frame */
135 outline_col[3] *= alpha;
136
137 if (!draw_fill) {
138 /* fill color needs to be (outline.rgb, 0) */
139 fill_col[0] = outline_col[0];
140 fill_col[1] = outline_col[1];
141 fill_col[2] = outline_col[2];
142 fill_col[3] = 0;
143 }
144
145 /* Handle type to outline shape. */
146 switch (handle_type) {
149 break; /* circle */
152 break; /* circle with dot */
155 break; /* square */
158 break; /* clipped diamond */
159
161 default:
162 flags = GPU_KEYFRAME_SHAPE_DIAMOND; /* diamond */
163 }
164
165 /* Extreme type to arrow-like shading. */
166 if (extreme_type & KEYFRAME_EXTREME_MAX) {
168 }
169 if (extreme_type & KEYFRAME_EXTREME_MIN) {
171 }
172 if (extreme_type & GPU_KEYFRAME_SHAPE_ARROW_END_MIXED) {
173 flags |= 0x400;
174 }
175 }
176
177 immAttr1f(sh_bindings->size_id, size);
178 immAttr4ubv(sh_bindings->color_id, fill_col);
179 immAttr4ubv(sh_bindings->outline_color_id, outline_col);
180 immAttr1u(sh_bindings->flags_id, flags);
181 immVertex2f(sh_bindings->pos_id, x, y);
182}
183
184/* Common attributes shared between the draw calls. */
186 float alpha;
190 float ipo_size;
193 float sel_color[4];
194 float unsel_color[4];
195 float sel_mhcol[4];
196 float unsel_mhcol[4];
197
202
203 /* Show interpolation and handle type? */
205};
206
208 View2D *v2d,
209 float yscale_fac,
210 bool channel_locked,
211 eSAction_Flag saction_flag)
212{
213 /* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */
214 /* TODO: allow this opacity factor to be themed? */
215 ctx->alpha = channel_locked ? 0.25f : 1.0f;
216
217 ctx->icon_size = U.widget_unit * 0.5f * yscale_fac;
218 ctx->half_icon_size = 0.5f * ctx->icon_size;
219 ctx->smaller_size = 0.35f * ctx->icon_size;
220 ctx->ipo_size = 0.1f * ctx->icon_size;
221 ctx->gpencil_size = ctx->smaller_size * 0.8f;
223
224 ctx->show_ipo = (saction_flag & SACTION_SHOW_INTERPOLATION) != 0;
225
232
233 ctx->sel_color[3] *= ctx->alpha;
234 ctx->unsel_color[3] *= ctx->alpha;
235 ctx->ipo_color_linear[3] *= ctx->alpha;
236 ctx->ipo_color_constant[3] *= ctx->alpha;
237 ctx->ipo_color_other[3] *= ctx->alpha;
238 ctx->ipo_color_mix[3] *= ctx->alpha * 0.5f;
239
240 copy_v4_v4(ctx->sel_mhcol, ctx->sel_color);
241 ctx->sel_mhcol[3] *= 0.8f;
243 ctx->unsel_mhcol[3] *= 0.8f;
244}
245
247 const ActKeyColumn *ab,
248 float ypos)
249{
251 float size = 1.0f;
252 switch (ab->next->key_type) {
257 size *= 0.5f;
258 break;
260 size *= 0.8f;
261 break;
263 break;
264 }
265
266 rctf box;
267 box.xmin = ab->cfra;
268 box.xmax = min_ff(ab->next->cfra - (ctx->screenspace_margin * size), ab->next->cfra);
269 box.ymin = ypos - ctx->gpencil_size;
270 box.ymax = ypos + ctx->gpencil_size;
271
273 &box, true, 0.25f * float(UI_UNIT_X), (ab->block.sel) ? ctx->sel_mhcol : ctx->unsel_mhcol);
274}
275
277 const ActKeyColumn *ab,
278 float ypos)
279{
280 rctf box;
281 box.xmin = ab->cfra;
282 box.xmax = ab->next->cfra;
283 box.ymin = ypos - ctx->smaller_size;
284 box.ymax = ypos + ctx->smaller_size;
285
286 ui::draw_roundbox_4fv(&box, true, 3.0f, (ab->block.sel) ? ctx->sel_mhcol : ctx->unsel_mhcol);
287}
288
290 const ActKeyColumn *ab,
291 float ypos)
292{
293 /* The bar needs to be an odd number of pixels high for proper alignment. */
294 const int height = int(0.45f * (ctx->icon_size)) * 2 - 1;
295 rctf box;
296 box.xmin = ab->cfra;
297 box.xmax = ab->next->cfra;
298 box.ymin = round(ypos - (float(height) * 0.5f));
299 box.ymax = box.ymin + height;
300
301 ui::draw_roundbox_4fv(&box, true, 3.0f, (ab->block.sel) ? ctx->sel_color : ctx->unsel_color);
302}
303
305 const ActKeyColumn *ab,
306 float ypos)
307{
308 rctf box;
309 box.xmin = ab->cfra;
310 box.xmax = ab->next->cfra;
311 box.ymin = ypos - ctx->ipo_size;
312 box.ymax = ypos + ctx->ipo_size;
313
314 /* Color for interpolation lines based on their type */
315 const float *color = nullptr;
316
317 constexpr short IPO_FLAGS = ACTKEYBLOCK_FLAG_IPO_OTHER | ACTKEYBLOCK_FLAG_IPO_LINEAR |
319 if (ab->block.conflict & IPO_FLAGS) {
320 /* This is a summary line that combines multiple interpolation modes. */
321 color = ctx->ipo_color_mix;
322 }
323 else if (ab->block.flag & ACTKEYBLOCK_FLAG_IPO_OTHER) {
324 color = ctx->ipo_color_other;
325 }
326 else if (ab->block.flag & ACTKEYBLOCK_FLAG_IPO_LINEAR) {
327 color = ctx->ipo_color_linear;
328 }
331 }
332 else {
333 /* No line to draw. */
334 return;
335 }
336
337 ui::draw_roundbox_4fv(&box, true, 3.0f, color);
338}
339
340static void draw_keylist_block(const DrawKeylistUIData *ctx, const ActKeyColumn *ab, float ypos)
341{
342 /* Draw grease pencil bars between keyframes. */
343 if ((ab->next != nullptr) && (ab->block.flag & ACTKEYBLOCK_FLAG_GPENCIL)) {
344 draw_keylist_block_gpencil(ctx, ab, ypos);
345 }
346 else {
347 /* Draw other types. */
348 draw_roundbox_corner_set(ui::CNR_NONE);
349
350 int valid_hold = actkeyblock_get_valid_hold(ab);
351 if (valid_hold != 0) {
352 if ((valid_hold & ACTKEYBLOCK_FLAG_STATIC_HOLD) == 0) {
353 /* draw "moving hold" long-keyframe block - slightly smaller */
354 draw_keylist_block_moving_hold(ctx, ab, ypos);
355 }
356 else {
357 /* draw standard long-keyframe block */
358 draw_keylist_block_standard(ctx, ab, ypos);
359 }
360 }
361 if (ctx->show_ipo && actkeyblock_is_valid(ab) && (ab->block.flag)) {
362 /* draw an interpolation line */
364 }
365 }
366}
367
369 const ActKeyColumn *keys,
370 const int key_len,
371 float ypos)
372{
373 for (int i = 0; i < key_len; i++) {
374 const ActKeyColumn *ab = &keys[i];
375 draw_keylist_block(ctx, ab, ypos);
376 }
377}
378
379static bool draw_keylist_is_visible_key(const View2D *v2d, const ActKeyColumn *ak)
380{
381 return IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax);
382}
383
385 View2D *v2d,
386 const KeyframeShaderBindings *sh_bindings,
387 const ActKeyColumn *keys,
388 const int key_len,
389 float ypos,
390 eSAction_Flag saction_flag)
391{
392 short handle_type = KEYFRAME_HANDLE_NONE, extreme_type = KEYFRAME_EXTREME_NONE;
393
394 for (int i = 0; i < key_len; i++) {
395 const ActKeyColumn *ak = &keys[i];
396 if (draw_keylist_is_visible_key(v2d, ak)) {
397 if (ctx->show_ipo) {
398 handle_type = ak->handle_type;
399 }
400 if (saction_flag & SACTION_SHOW_EXTREMES) {
401 extreme_type = ak->extreme_type;
402 }
403
405 ypos,
406 ctx->icon_size,
407 (ak->sel & SELECT),
410 ctx->alpha,
411 sh_bindings,
412 handle_type,
413 extreme_type);
414 }
415 }
416}
417
418/* *************************** Drawing Stack *************************** */
434
439
441 float ypos;
444
445 /* Currently only used for F-Curve channels, because some should be nla
446 * remapped but not others. All other channel types ignore this, as it's clear
447 * from the type whether they should be nla remapped or not. */
449
450 /* TODO: check which of these can be put into a `union`: */
455 ID *animated_id; /* The ID that adt (below) belongs to. */
466};
467
469{
470 switch (elem->type) {
472 summary_to_keylist(elem->ac, elem->keylist, elem->saction_flag, range);
473 break;
474 }
475 case ChannelType::SCENE: {
476 scene_to_keylist(elem->ads, elem->sce, elem->keylist, elem->saction_flag, range);
477 break;
478 }
479 case ChannelType::OBJECT: {
480 ob_to_keylist(elem->ads, elem->ob, elem->keylist, elem->saction_flag, range);
481 break;
482 }
483 case ChannelType::FCURVE: {
485 elem->adt, elem->fcu, elem->keylist, elem->saction_flag, range, elem->use_nla_remapping);
486 break;
487 }
489 /* This is only called for action summaries in the Dope-sheet, *not* the
490 * Action Editor. Therefore despite the name `ACTION_LAYERED`, this is
491 * only used to show a *single slot* of the action: the slot used by the
492 * ID the action is listed under.
493 *
494 * Thus we use the same function as the `ChannelType::ACTION_SLOT` case
495 * below because in practice the only distinction between these cases is
496 * where they get the slot from. In this case, we get it from `elem`'s
497 * ADT. */
498 BLI_assert(elem->act);
499 BLI_assert(elem->adt);
501 elem->animated_id,
502 elem->act->wrap(),
503 elem->adt->slot_handle,
504 elem->keylist,
505 elem->saction_flag,
506 range);
507 break;
508 }
510 BLI_assert(elem->act);
511 BLI_assert(elem->action_slot);
513 elem->animated_id,
514 elem->act->wrap(),
515 elem->action_slot->handle,
516 elem->keylist,
517 elem->saction_flag,
518 range);
519 break;
520 }
522 action_to_keylist(elem->adt, elem->act, elem->keylist, elem->saction_flag, range);
523 break;
524 }
526 action_group_to_keylist(elem->adt, elem->agrp, elem->keylist, elem->saction_flag, range);
527 break;
528 }
531 elem->adt, elem->grease_pencil_layer, elem->keylist, elem->saction_flag);
532 break;
533 }
536 elem->adt, elem->grease_pencil_layer_group, elem->keylist, elem->saction_flag);
537 break;
538 }
540 if (elem->ac->datatype != ANIMCONT_GPENCIL && elem->adt) {
541 action_to_keylist(elem->adt, elem->adt->action, elem->keylist, elem->saction_flag, range);
542 }
544 elem->adt, elem->grease_pencil, elem->keylist, elem->saction_flag, false);
545 break;
546 }
548 gpl_to_keylist(elem->ads, elem->gpl, elem->keylist);
549 break;
550 }
552 mask_to_keylist(elem->ads, elem->masklay, elem->keylist);
553 break;
554 }
555 }
556}
557
559{
561 channel_ui_data_init(&ctx, v2d, elem->yscale_fac, elem->channel_locked, elem->saction_flag);
562
563 const int key_len = ED_keylist_array_len(elem->keylist);
564 const ActKeyColumn *keys = ED_keylist_array(elem->keylist);
565 draw_keylist_blocks(&ctx, keys, key_len, elem->ypos);
566}
567
569 View2D *v2d,
570 const KeyframeShaderBindings *sh_bindings)
571{
573 channel_ui_data_init(&ctx, v2d, elem->yscale_fac, elem->channel_locked, elem->saction_flag);
574
575 const int key_len = ED_keylist_array_len(elem->keylist);
576 const ActKeyColumn *keys = ED_keylist_array(elem->keylist);
577 draw_keylist_keys(&ctx, v2d, sh_bindings, keys, key_len, elem->ypos, elem->saction_flag);
578}
579
584
587 ListBaseT<ChannelListElement> channels;
588};
589
594
595static void channel_list_build_keylists(ChannelDrawList *channel_list, float2 range)
596{
597 for (ChannelListElement &elem : channel_list->channels) {
598 build_channel_keylist(&elem, range);
600 }
601}
602
603static void channel_list_draw_blocks(ChannelDrawList *channel_list, View2D *v2d)
604{
605 for (ChannelListElement &elem : channel_list->channels) {
606 draw_channel_blocks(&elem, v2d);
607 }
608}
609
610static int channel_visible_key_len(const View2D *v2d, const ListBaseT<ActKeyColumn> *keys)
611{
612 /* count keys */
613 uint len = 0;
614
615 for (ActKeyColumn &ak : *keys) {
616 /* Optimization: if keyframe doesn't appear within 5 units (screenspace)
617 * in visible area, don't draw.
618 * This might give some improvements,
619 * since we current have to flip between view/region matrices.
620 */
621 if (draw_keylist_is_visible_key(v2d, &ak)) {
622 len++;
623 }
624 }
625 return len;
626}
627
628static int channel_list_visible_key_len(const ChannelDrawList *channel_list, const View2D *v2d)
629{
630 uint len = 0;
631 for (ChannelListElement &elem : channel_list->channels) {
632 const ListBaseT<ActKeyColumn> *keys = ED_keylist_listbase(elem.keylist);
633 len += channel_visible_key_len(v2d, keys);
634 }
635 return len;
636}
637
638static void channel_list_draw_keys(ChannelDrawList *channel_list, View2D *v2d)
639{
640 const int visible_key_len = channel_list_visible_key_len(channel_list, v2d);
641 if (visible_key_len == 0) {
642 return;
643 }
644
646
647 GPUVertFormat *format = immVertexFormat();
648 KeyframeShaderBindings sh_bindings;
649
650 sh_bindings.pos_id = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
651 sh_bindings.size_id = GPU_vertformat_attr_add(format, "size", gpu::VertAttrType::SFLOAT_32);
652 sh_bindings.color_id = GPU_vertformat_attr_add(
653 format, "color", gpu::VertAttrType::UNORM_8_8_8_8);
655 format, "outlineColor", gpu::VertAttrType::UNORM_8_8_8_8);
656 sh_bindings.flags_id = GPU_vertformat_attr_add(format, "flags", gpu::VertAttrType::UINT_32);
657
660 immUniform1f("outline_scale", 1.0f);
661 immUniform2f("ViewportSize", BLI_rcti_size_x(&v2d->mask) + 1, BLI_rcti_size_y(&v2d->mask) + 1);
662 immBegin(GPU_PRIM_POINTS, visible_key_len);
663
664 for (ChannelListElement &elem : channel_list->channels) {
665 draw_channel_keys(&elem, v2d, &sh_bindings);
666 }
667
668 immEnd();
671
673}
674
675static void channel_list_draw(ChannelDrawList *channel_list, View2D *v2d)
676{
677 channel_list_draw_blocks(channel_list, v2d);
678 channel_list_draw_keys(channel_list, v2d);
679}
680
682{
683 channel_list_build_keylists(channel_list, {v2d->cur.xmin, v2d->cur.xmax});
684 channel_list_draw(channel_list, v2d);
685}
686
688{
689 for (ChannelListElement &elem : channel_list->channels) {
691 }
692 channel_list->channels.free_no_destruct();
693 MEM_delete(channel_list);
694}
695
697 ChannelType elem_type,
698 float ypos,
699 float yscale_fac,
700 eSAction_Flag saction_flag)
701{
703 BLI_addtail(&channel_list->channels, draw_elem);
704 draw_elem->type = elem_type;
705 draw_elem->keylist = ED_keylist_create();
706 draw_elem->ypos = ypos;
707 draw_elem->yscale_fac = yscale_fac;
708 draw_elem->saction_flag = saction_flag;
709 return draw_elem;
710}
711
712/* *************************** Channel Drawing Functions *************************** */
713
715 bAnimContext *ac,
716 float ypos,
717 float yscale_fac,
718 int saction_flag)
719{
720 saction_flag &= ~SACTION_SHOW_EXTREMES;
722 channel_list, ChannelType::SUMMARY, ypos, yscale_fac, eSAction_Flag(saction_flag));
723 draw_elem->ac = ac;
724}
725
727 bDopeSheet *ads,
728 Scene *sce,
729 float ypos,
730 float yscale_fac,
731 int saction_flag)
732{
733 saction_flag &= ~SACTION_SHOW_EXTREMES;
735 channel_list, ChannelType::SCENE, ypos, yscale_fac, eSAction_Flag(saction_flag));
736 draw_elem->ads = ads;
737 draw_elem->sce = sce;
738}
739
741 bDopeSheet *ads,
742 Object *ob,
743 float ypos,
744 float yscale_fac,
745 int saction_flag)
746{
747 saction_flag &= ~SACTION_SHOW_EXTREMES;
749 channel_list, ChannelType::OBJECT, ypos, yscale_fac, eSAction_Flag(saction_flag));
750 draw_elem->ads = ads;
751 draw_elem->ob = ob;
752}
753
755 bAnimListElem *ale,
756 FCurve *fcu,
757 float ypos,
758 float yscale_fac,
759 int saction_flag)
760{
761 const bool locked = (fcu->flag & FCURVE_PROTECTED) ||
762 ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ||
763 ((ale->adt && ale->adt->action) &&
764 (!ID_IS_EDITABLE(ale->adt->action) ||
766
768 channel_list, ChannelType::FCURVE, ypos, yscale_fac, eSAction_Flag(saction_flag));
769 draw_elem->animated_id = ale->id;
770 draw_elem->adt = ale->adt;
771 draw_elem->fcu = fcu;
772 draw_elem->channel_locked = locked;
774}
775
777 bAnimListElem *ale,
778 bActionGroup *agrp,
779 float ypos,
780 float yscale_fac,
781 int saction_flag)
782{
783 bool locked = (agrp->flag & AGRP_PROTECTED) ||
784 ((ale->adt && ale->adt->action) &&
786
788 channel_list, ChannelType::ACTION_GROUP, ypos, yscale_fac, eSAction_Flag(saction_flag));
789 draw_elem->animated_id = ale->id;
790 draw_elem->adt = ale->adt;
791 draw_elem->agrp = agrp;
792 draw_elem->channel_locked = locked;
793}
794
796 bAnimContext *ac,
797 bAnimListElem *ale,
798 bAction *action,
799 const float ypos,
800 const float yscale_fac,
801 int saction_flag)
802{
803 BLI_assert(action);
804
805 const bool locked = (!ID_IS_EDITABLE(action) || ID_IS_OVERRIDE_LIBRARY(action));
806 saction_flag &= ~SACTION_SHOW_EXTREMES;
807
809 channel_list, ChannelType::ACTION_LAYERED, ypos, yscale_fac, eSAction_Flag(saction_flag));
810 draw_elem->ac = ac;
811 draw_elem->animated_id = ale->id;
812 draw_elem->adt = ale->adt;
813 draw_elem->act = action;
814 draw_elem->channel_locked = locked;
815}
816
818 bAnimContext *ac,
819 bAnimListElem *ale,
820 animrig::Action &action,
821 animrig::Slot &slot,
822 const float ypos,
823 const float yscale_fac,
824 int saction_flag)
825{
826 const bool locked = (ID_IS_LINKED(&action) || ID_IS_OVERRIDE_LIBRARY(&action));
827 saction_flag &= ~SACTION_SHOW_EXTREMES;
828
830 channel_list, ChannelType::ACTION_SLOT, ypos, yscale_fac, eSAction_Flag(saction_flag));
831 draw_elem->ac = ac;
832 draw_elem->animated_id = ale->id;
833 draw_elem->adt = ale->adt;
834 draw_elem->act = &action;
835 draw_elem->action_slot = &slot;
836 draw_elem->channel_locked = locked;
837}
838
840 bAnimContext *ac,
841 bAnimListElem *ale,
843 const float ypos,
844 const float yscale_fac,
845 int saction_flag)
846{
847 ChannelListElement *draw_elem = channel_list_add_element(channel_list,
849 ypos,
850 yscale_fac,
851 eSAction_Flag(saction_flag));
852 /* GreasePencil properties can be animated via an Action, so the GP-related
853 * animation data is not limited to GP drawings. */
854 draw_elem->animated_id = ale->id;
855 draw_elem->adt = ale->adt;
856 draw_elem->act = ale->adt ? ale->adt->action : nullptr;
857 draw_elem->grease_pencil = grease_pencil;
858 draw_elem->ac = ac;
859}
860
862 bDopeSheet *ads,
864 const float ypos,
865 const float yscale_fac,
866 int saction_flag)
867{
868 ChannelListElement *draw_elem = channel_list_add_element(channel_list,
870 ypos,
871 yscale_fac,
872 eSAction_Flag(saction_flag));
873 draw_elem->ads = ads;
874 draw_elem->grease_pencil_layer = layer;
875 draw_elem->channel_locked = layer->wrap().is_locked();
876}
877
879 bDopeSheet *ads,
880 const GreasePencilLayerTreeGroup *layer_group,
881 const float ypos,
882 const float yscale_fac,
883 int saction_flag)
884{
885 ChannelListElement *draw_elem = channel_list_add_element(channel_list,
887 ypos,
888 yscale_fac,
889 eSAction_Flag(saction_flag));
890 draw_elem->ads = ads;
891 draw_elem->grease_pencil_layer_group = layer_group;
892 draw_elem->channel_locked = layer_group->wrap().is_locked();
893}
894
896 bDopeSheet *ads,
897 bGPDlayer *gpl,
898 float ypos,
899 float yscale_fac,
900 int saction_flag)
901{
902 bool locked = (gpl->flag & GP_LAYER_LOCKED) != 0;
903 ChannelListElement *draw_elem = channel_list_add_element(channel_list,
905 ypos,
906 yscale_fac,
907 eSAction_Flag(saction_flag));
908 draw_elem->ads = ads;
909 draw_elem->gpl = gpl;
910 draw_elem->channel_locked = locked;
911}
912
914 bDopeSheet *ads,
915 MaskLayer *masklay,
916 float ypos,
917 float yscale_fac,
918 int saction_flag)
919{
920 bool locked = (masklay->flag & MASK_LAYERFLAG_LOCKED) != 0;
922 channel_list, ChannelType::MASK_LAYER, ypos, yscale_fac, eSAction_Flag(saction_flag));
923 draw_elem->ads = ads;
924 draw_elem->masklay = masklay;
925 draw_elem->channel_locked = locked;
926}
927
928} // namespace blender
Functions and classes to work with Actions.
Low-level operations for grease pencil.
#define SELECT
Definition BKE_mask.hh:19
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
@ GPU_KEYFRAME_SHAPE_INNER_DOT
@ GPU_KEYFRAME_SHAPE_CIRCLE
@ GPU_KEYFRAME_SHAPE_SQUARE
@ GPU_KEYFRAME_SHAPE_ARROW_END_MIXED
@ GPU_KEYFRAME_SHAPE_DIAMOND
@ GPU_KEYFRAME_SHAPE_ARROW_END_MAX
@ GPU_KEYFRAME_SHAPE_ARROW_END_MIN
@ GPU_KEYFRAME_SHAPE_CLIPPED_VERTICAL
Read Blender memory allocation and freeing.
#define UI_UNIT_X
#define ELEM(...)
#define IN_RANGE_INCL(a, b, c)
#define layer
#define round
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
void get_color_4ubv(int colorid, unsigned char col[4])
void get_color_4fv(int colorid, float col[4])
void get_color_3ubv(int colorid, unsigned char col[3])
void draw_roundbox_corner_set(int type)
float view2d_scale_get_x(const View2D *v2d)
Definition view2d.cc:1902
void draw_roundbox_4fv(const rctf *rect, bool filled, float rad, const float col[4])
BMesh Iterators.
static void draw_keylist_keys(const DrawKeylistUIData *ctx, View2D *v2d, const KeyframeShaderBindings *sh_bindings, const ActKeyColumn *keys, const int key_len, float ypos, eSAction_Flag saction_flag)
MINLINE float min_ff(float a, float b)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ BEZT_KEYTYPE_MOVEHOLD
@ BEZT_KEYTYPE_GENERATED
@ BEZT_KEYTYPE_KEYFRAME
@ BEZT_KEYTYPE_BREAKDOWN
void action_to_keylist(AnimData *adt, bAction *dna_action, AnimKeylist *keylist, const int saction_flag, float2 range)
void grease_pencil_cels_to_keylist(AnimData *, const GreasePencilLayer *gpl, AnimKeylist *keylist, int)
static bool draw_keylist_is_visible_key(const View2D *v2d, const ActKeyColumn *ak)
void gpl_to_keylist(bDopeSheet *, bGPDlayer *gpl, AnimKeylist *keylist)
void ED_add_grease_pencil_datablock_channel(ChannelDrawList *channel_list, bAnimContext *ac, bAnimListElem *ale, const GreasePencil *grease_pencil, const float ypos, const float yscale_fac, int saction_flag)
void immEnd()
bool actkeyblock_is_valid(const ActKeyColumn *ac)
ChannelDrawList * ED_channel_draw_list_create()
unsigned int uint
Definition BKE_text.h:55
@ ANIMCONT_GPENCIL
void grease_pencil_layer_group_to_keylist(AnimData *adt, const GreasePencilLayerTreeGroup *layer_group, AnimKeylist *keylist, const int saction_flag)
void immAttr4ubv(uint attr_id, const unsigned char data[4])
static void draw_keylist_block_standard(const DrawKeylistUIData *ctx, const ActKeyColumn *ab, float ypos)
static void build_channel_keylist(ChannelListElement *elem, float2 range)
static void draw_keylist_block_moving_hold(const DrawKeylistUIData *ctx, const ActKeyColumn *ab, float ypos)
void draw_keyframe_shape(const float x, const float y, float size, const bool sel, const eBezTriple_KeyframeType key_type, const eKeyframeShapeDrawOpts mode, const float alpha, const KeyframeShaderBindings *sh_bindings, const short handle_type, const short extreme_type)
void immUniform2f(const char *name, float x, float y)
GPUVertFormat * immVertexFormat()
void immBegin(GPUPrimType, uint vertex_len)
void summary_to_keylist(bAnimContext *ac, AnimKeylist *keylist, const int saction_flag, float2 range)
static void draw_channel_blocks(ChannelListElement *elem, View2D *v2d)
@ TH_LONGKEY_SELECT
@ TH_KEYTYPE_GENERATED
@ TH_KEYTYPE_BREAKDOWN_SELECT
@ TH_KEYTYPE_JITTER_SELECT
@ TH_KEYTYPE_MOVEHOLD_SELECT
@ TH_DOPESHEET_IPOOTHER
@ TH_KEYTYPE_JITTER
@ TH_KEYTYPE_MOVEHOLD
@ TH_KEYTYPE_KEYFRAME_SELECT
@ TH_KEYBORDER_SELECT
@ TH_DOPESHEET_IPOCONST
@ TH_KEYTYPE_BREAKDOWN
@ TH_KEYTYPE_KEYFRAME
@ TH_DOPESHEET_IPOLINE
@ TH_KEYTYPE_EXTREME_SELECT
@ TH_KEYTYPE_GENERATED_SELECT
@ TH_KEYTYPE_EXTREME
bool ANIM_nla_mapping_allowed(const bAnimListElem *ale)
Definition anim_draw.cc:279
void ED_add_mask_layer_channel(ChannelDrawList *channel_list, bDopeSheet *ads, MaskLayer *masklay, float ypos, float yscale_fac, int saction_flag)
void immUnbindProgram()
const ActKeyColumn * ED_keylist_array(const AnimKeylist *keylist)
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
static void channel_list_draw_blocks(ChannelDrawList *channel_list, View2D *v2d)
static void draw_keylist_block(const DrawKeylistUIData *ctx, const ActKeyColumn *ab, float ypos)
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void ED_add_grease_pencil_layer_group_channel(ChannelDrawList *channel_list, bDopeSheet *ads, const GreasePencilLayerTreeGroup *layer_group, const float ypos, const float yscale_fac, int saction_flag)
void fcurve_to_keylist(AnimData *adt, FCurve *fcu, AnimKeylist *keylist, const int saction_flag, float2 range, const bool use_nla_remapping)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
void ED_add_fcurve_channel(ChannelDrawList *channel_list, bAnimListElem *ale, FCurve *fcu, float ypos, float yscale_fac, int saction_flag)
VecBase< float, 2 > float2
void immUniform1f(const char *name, float x)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void immVertex2f(uint attr_id, float x, float y)
unsigned char uchar
Definition BKE_text.h:58
void grease_pencil_data_block_to_keylist(AnimData *adt, const GreasePencil *grease_pencil, AnimKeylist *keylist, const int saction_flag, const bool active_layer_only)
static void channel_list_draw_keys(ChannelDrawList *channel_list, View2D *v2d)
static void draw_keylist_block_gpencil(const DrawKeylistUIData *ctx, const ActKeyColumn *ab, float ypos)
static void prepare_channel_for_drawing(ChannelListElement *elem)
void ED_add_scene_channel(ChannelDrawList *channel_list, bDopeSheet *ads, Scene *sce, float ypos, float yscale_fac, int saction_flag)
void ED_add_summary_channel(ChannelDrawList *channel_list, bAnimContext *ac, float ypos, float yscale_fac, int saction_flag)
void action_group_to_keylist(AnimData *adt, bActionGroup *agrp, AnimKeylist *keylist, const int saction_flag, float2 range)
void ED_keylist_prepare_for_direct_access(AnimKeylist *keylist)
void action_slot_summary_to_keylist(bAnimContext *ac, ID *animated_id, animrig::Action &action, const animrig::slot_handle_t slot_handle, AnimKeylist *keylist, const int saction_flag, float2 range)
void GPU_program_point_size(bool enable)
Definition gpu_state.cc:165
AnimKeylist * ED_keylist_create()
static int channel_visible_key_len(const View2D *v2d, const ListBaseT< ActKeyColumn > *keys)
int64_t ED_keylist_array_len(const AnimKeylist *keylist)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
void ob_to_keylist(bDopeSheet *ads, Object *ob, AnimKeylist *keylist, const int saction_flag, float2 range)
void ED_channel_list_free(ChannelDrawList *channel_list)
void scene_to_keylist(bDopeSheet *ads, Scene *sce, AnimKeylist *keylist, const int saction_flag, float2 range)
static void channel_list_build_keylists(ChannelDrawList *channel_list, float2 range)
static void draw_keylist_blocks(const DrawKeylistUIData *ctx, const ActKeyColumn *keys, const int key_len, float ypos)
static ChannelListElement * channel_list_add_element(ChannelDrawList *channel_list, ChannelType elem_type, float ypos, float yscale_fac, eSAction_Flag saction_flag)
void immAttr1f(uint attr_id, float x)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
static void draw_keylist_block_interpolation_line(const DrawKeylistUIData *ctx, const ActKeyColumn *ab, float ypos)
void ED_add_action_slot_channel(ChannelDrawList *channel_list, bAnimContext *ac, bAnimListElem *ale, animrig::Action &action, animrig::Slot &slot, const float ypos, const float yscale_fac, int saction_flag)
void ED_channel_list_flush(ChannelDrawList *channel_list, View2D *v2d)
@ MASK_LAYERFLAG_LOCKED
void ED_add_object_channel(ChannelDrawList *channel_list, bDopeSheet *ads, Object *ob, float ypos, float yscale_fac, int saction_flag)
static int channel_list_visible_key_len(const ChannelDrawList *channel_list, const View2D *v2d)
void mask_to_keylist(bDopeSheet *, MaskLayer *masklay, AnimKeylist *keylist)
void ED_keylist_free(AnimKeylist *keylist)
static void channel_list_draw(ChannelDrawList *channel_list, View2D *v2d)
MINLINE void copy_v4_v4(float r[4], const float a[4])
static void draw_channel_keys(ChannelListElement *elem, View2D *v2d, const KeyframeShaderBindings *sh_bindings)
void immAttr1u(uint attr_id, uint x)
@ SACTION_SHOW_INTERPOLATION
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
const ListBaseT< ActKeyColumn > * ED_keylist_listbase(const AnimKeylist *keylist)
void ED_add_action_layered_channel(ChannelDrawList *channel_list, bAnimContext *ac, bAnimListElem *ale, bAction *action, const float ypos, const float yscale_fac, int saction_flag)
static void channel_ui_data_init(DrawKeylistUIData *ctx, View2D *v2d, float yscale_fac, bool channel_locked, eSAction_Flag saction_flag)
void ED_add_action_group_channel(ChannelDrawList *channel_list, bAnimListElem *ale, bActionGroup *agrp, float ypos, float yscale_fac, int saction_flag)
void ED_add_grease_pencil_layer_legacy_channel(ChannelDrawList *channel_list, bDopeSheet *ads, bGPDlayer *gpl, float ypos, float yscale_fac, int saction_flag)
void ED_add_grease_pencil_cels_channel(ChannelDrawList *channel_list, bDopeSheet *ads, const GreasePencilLayer *layer, const float ypos, const float yscale_fac, int saction_flag)
int actkeyblock_get_valid_hold(const ActKeyColumn *ac)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eBezTriple_KeyframeType key_type
ListBaseT< ChannelListElement > channels
const GreasePencilLayerTreeGroup * grease_pencil_layer_group
ChannelListElement * prev
ChannelListElement * next
const GreasePencil * grease_pencil
const GreasePencilLayer * grease_pencil_layer
bActionGroup * grp
eFCurve_Flags flag
eAnimCont_Types datatype