2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
19 * All rights reserved.
21 * Contributor(s): Joshua Leung
23 * ***** END GPL LICENSE BLOCK *****
26 /** \file blender/editors/animation/anim_channels_defines.c
27 * \ingroup edanimation
33 #include "MEM_guardedalloc.h"
35 #include "BLI_blenlib.h"
37 #include "BLI_utildefines.h"
39 #include "BLF_translation.h"
41 #include "DNA_anim_types.h"
42 #include "DNA_armature_types.h"
43 #include "DNA_camera_types.h"
44 #include "DNA_object_types.h"
45 #include "DNA_particle_types.h"
46 #include "DNA_screen_types.h"
47 #include "DNA_scene_types.h"
48 #include "DNA_space_types.h"
49 #include "DNA_key_types.h"
50 #include "DNA_lamp_types.h"
51 #include "DNA_lattice_types.h"
52 #include "DNA_linestyle_types.h"
53 #include "DNA_mesh_types.h"
54 #include "DNA_material_types.h"
55 #include "DNA_meta_types.h"
56 #include "DNA_node_types.h"
57 #include "DNA_world_types.h"
58 #include "DNA_gpencil_types.h"
59 #include "DNA_speaker_types.h"
60 #include "DNA_mask_types.h"
62 #include "RNA_access.h"
64 #include "BKE_curve.h"
67 #include "BKE_context.h"
69 #include "UI_interface.h"
70 #include "UI_interface_icons.h"
71 #include "UI_resources.h"
73 #include "ED_anim_api.h"
74 #include "ED_keyframing.h"
77 #include "BIF_glutil.h"
82 /* *********************************************** */
83 // XXX constant defines to be moved elsewhere?
85 /* extra padding for lengths (to go under scrollers) */
86 #define EXTRA_SCROLL_PAD 100.0f
88 /* size of indent steps */
89 #define INDENT_STEP_SIZE (0.35f * U.widget_unit)
91 /* size of string buffers used for animation channel displayed names */
92 #define ANIM_CHAN_NAME_SIZE 256
94 /* get the pointer used for some flag */
95 #define GET_ACF_FLAG_PTR(ptr, type) ((*(type) = sizeof((ptr))), &(ptr))
97 /* *********************************************** */
98 /* Generic Functions (Type independent) */
100 /* Draw Backdrop ---------------------------------- */
102 /* get backdrop color for top-level widgets (Scene and Object only) */
103 static void acf_generic_root_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), float r_color[3])
105 /* darker blue for top-level widgets */
106 UI_GetThemeColor3fv(TH_DOPESHEET_CHANNELOB, r_color);
109 /* backdrop for top-level widgets (Scene and Object only) */
110 static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
112 bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
113 View2D *v2d = &ac->ar->v2d;
114 short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
115 short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
118 /* set backdrop drawing color */
119 acf->get_backdrop_color(ac, ale, color);
122 /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
123 uiSetRoundBox((expanded) ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
124 uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8);
128 /* get backdrop color for data expanders under top-level Scene/Object */
129 static void acf_generic_dataexpand_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), float r_color[3])
131 /* lighter color than top-level widget */
132 UI_GetThemeColor3fv(TH_DOPESHEET_CHANNELSUBOB, r_color);
135 /* backdrop for data expanders under top-level Scene/Object */
136 static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
138 bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
139 View2D *v2d = &ac->ar->v2d;
140 short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
143 /* set backdrop drawing color */
144 acf->get_backdrop_color(ac, ale, color);
147 /* no rounded corner - just rectangular box */
148 glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
151 /* helper method to test if group colors should be drawn */
152 static bool acf_show_channel_colors(bAnimContext *ac)
154 bool showGroupColors = false;
157 switch (ac->spacetype) {
160 SpaceAction *saction = (SpaceAction *)ac->sl;
161 showGroupColors = !(saction->flag & SACTION_NODRAWGCOLORS);
166 SpaceIpo *sipo = (SpaceIpo *)ac->sl;
167 showGroupColors = !(sipo->flag & SIPO_NODRAWGCOLORS);
173 return showGroupColors;
176 /* get backdrop color for generic channels */
177 static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3])
179 bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
180 bActionGroup *grp = NULL;
181 short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0;
182 bool showGroupColors = acf_show_channel_colors(ac);
184 if (ale->type == ANIMTYPE_FCURVE) {
185 FCurve *fcu = (FCurve *)ale->data;
189 /* set color for normal channels
190 * - use 3 shades of color group/standard color for 3 indention level
191 * - only use group colors if allowed to, and if actually feasible
193 if (showGroupColors && (grp) && (grp->customCol)) {
197 copy_v3_v3_char((char *)cp, grp->cs.solid);
199 else if (indent == 1) {
200 copy_v3_v3_char((char *)cp, grp->cs.select);
203 copy_v3_v3_char((char *)cp, grp->cs.active);
206 /* copy the colors over, transforming from bytes to floats */
207 rgb_uchar_to_float(r_color, cp);
210 // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)?
211 int colOfs = 20 - 20 * indent;
212 UI_GetThemeColorShade3fv(TH_HEADER, colOfs, r_color);
216 /* backdrop for generic channels */
217 static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
219 bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
220 View2D *v2d = &ac->ar->v2d;
221 short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
224 /* set backdrop drawing color */
225 acf->get_backdrop_color(ac, ale, color);
228 /* no rounded corners - just rectangular box */
229 glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
232 /* Indention + Offset ------------------------------------------- */
234 /* indention level is always the value in the name */
235 static short acf_generic_indention_0(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale))
239 static short acf_generic_indention_1(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale))
243 #if 0 // XXX not used
244 static short acf_generic_indention_2(bAnimContext *ac, bAnimListElem *ale)
250 /* indention which varies with the grouping status */
251 static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListElem *ale)
255 /* grouped F-Curves need extra level of indention */
256 if (ale->type == ANIMTYPE_FCURVE) {
257 FCurve *fcu = (FCurve *)ale->data;
259 // TODO: we need some way of specifying that the indention color should be one less...
268 /* basic offset for channels derived from indention */
269 static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale)
271 bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
273 if (acf && acf->get_indent_level)
274 return acf->get_indent_level(ac, ale) * INDENT_STEP_SIZE;
279 /* offset based on nodetree type */
280 static short acf_nodetree_rootType_offset(bNodeTree *ntree)
283 switch (ntree->type) {
285 /* 1 additional level (i.e. is indented one level in from material,
286 * so shift all right by one step)
288 return INDENT_STEP_SIZE;
291 /* no additional levels needed */
295 /* 2 additional levels */
296 return INDENT_STEP_SIZE * 2;
304 /* offset for groups + grouped entities */
305 static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale)
307 short offset = acf_generic_basic_offset(ac, ale);
310 /* texture animdata */
311 if (GS(ale->id->name) == ID_TE) {
312 offset += U.widget_unit;
314 /* materials and particles animdata */
315 else if (ELEM(GS(ale->id->name), ID_MA, ID_PA))
316 offset += (short)(0.7f * U.widget_unit);
318 /* if not in Action Editor mode, action-groups (and their children) must carry some offset too... */
319 else if (ac->datatype != ANIMCONT_ACTION)
320 offset += (short)(0.7f * U.widget_unit);
322 /* nodetree animdata */
323 if (GS(ale->id->name) == ID_NT) {
324 offset += acf_nodetree_rootType_offset((bNodeTree *)ale->id);
328 /* offset is just the normal type - i.e. based on indention */
332 /* Name ------------------------------------------- */
334 /* name for ID block entries */
335 static void acf_generic_idblock_name(bAnimListElem *ale, char *name)
337 ID *id = (ID *)ale->data; /* data pointed to should be an ID block */
339 /* just copy the name... */
341 BLI_strncpy(name, id->name + 2, ANIM_CHAN_NAME_SIZE);
344 /* name property for ID block entries */
345 static bool acf_generic_idblock_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
347 RNA_id_pointer_create(ale->data, ptr);
348 *prop = RNA_struct_name_property(ptr->type);
350 return (*prop != NULL);
354 /* name property for ID block entries which are just subheading "fillers" */
355 static bool acf_generic_idfill_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
357 /* actual ID we're representing is stored in ale->data not ale->id, as id gives the owner */
358 RNA_id_pointer_create(ale->data, ptr);
359 *prop = RNA_struct_name_property(ptr->type);
361 return (*prop != NULL);
364 /* Settings ------------------------------------------- */
367 /* channel type has no settings */
368 static bool acf_generic_none_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
374 /* check if some setting exists for this object-based data-expander (datablock only) */
375 static bool acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
378 /* expand is always supported */
379 case ACHANNEL_SETTING_EXPAND:
382 /* mute is only supported for NLA */
383 case ACHANNEL_SETTING_MUTE:
384 return ((ac) && (ac->spacetype == SPACE_NLA));
386 /* select is ok for most "ds*" channels (e.g. dsmat) */
387 case ACHANNEL_SETTING_SELECT:
390 /* other flags are never supported */
396 /* *********************************************** */
397 /* Type Specific Functions + Defines */
399 /* Animation Summary ----------------------------------- */
401 /* get backdrop color for summary widget */
402 static void acf_summary_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), float r_color[3])
404 /* reddish color - same as the 'action' line in NLA */
405 UI_GetThemeColor3fv(TH_ANIM_ACTIVE, r_color);
408 /* backdrop for summary widget */
409 static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
411 bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
412 View2D *v2d = &ac->ar->v2d;
415 /* set backdrop drawing color */
416 acf->get_backdrop_color(ac, ale, color);
419 /* rounded corners on LHS only
421 * - special hack: make the top a bit higher, since we are first...
423 uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT);
424 uiDrawBox(GL_POLYGON, 0, yminc - 2, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8);
427 /* name for summary entries */
428 static void acf_summary_name(bAnimListElem *UNUSED(ale), char *name)
431 BLI_strncpy(name, IFACE_("Dope Sheet Summary"), ANIM_CHAN_NAME_SIZE);
434 // FIXME: this is really a temp icon I think
435 static int acf_summary_icon(bAnimListElem *UNUSED(ale))
437 return ICON_BORDERMOVE;
440 /* check if some setting exists for this channel */
441 static bool acf_summary_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
443 /* only expanded is supported, as it is used for hiding all stuff which the summary covers */
444 return (setting == ACHANNEL_SETTING_EXPAND);
447 /* get the appropriate flag(s) for the setting when it is valid */
448 static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
450 if (setting == ACHANNEL_SETTING_EXPAND) {
453 return ADS_FLAG_SUMMARY_COLLAPSED;
462 /* get pointer to the setting */
463 static void *acf_summary_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
465 bAnimContext *ac = (bAnimContext *)ale->data;
467 /* if data is valid, return pointer to active dopesheet's relevant flag
468 * - this is restricted to DopeSheet/Action Editor only
470 if ((ac->sl) && (ac->spacetype == SPACE_ACTION) && (setting == ACHANNEL_SETTING_EXPAND)) {
471 SpaceAction *saction = (SpaceAction *)ac->sl;
472 bDopeSheet *ads = &saction->ads;
474 /* return pointer to DopeSheet's flag */
475 return GET_ACF_FLAG_PTR(ads->flag, type);
478 /* can't return anything useful - unsupported */
484 /* all animation summary (DopeSheet only) type define */
485 static bAnimChannelType ACF_SUMMARY =
487 "Summary", /* type name */
488 ACHANNEL_ROLE_EXPANDER, /* role */
490 acf_summary_color, /* backdrop color */
491 acf_summary_backdrop, /* backdrop */
492 acf_generic_indention_0, /* indent level */
495 acf_summary_name, /* name */
496 NULL, /* name prop */
497 acf_summary_icon, /* icon */
499 acf_summary_setting_valid, /* has setting */
500 acf_summary_setting_flag, /* flag for setting */
501 acf_summary_setting_ptr /* pointer for setting */
504 /* Scene ------------------------------------------- */
506 // TODO: just get this from RNA?
507 static int acf_scene_icon(bAnimListElem *UNUSED(ale))
509 return ICON_SCENE_DATA;
512 /* check if some setting exists for this channel */
513 static bool acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
516 /* muted only in NLA */
517 case ACHANNEL_SETTING_MUTE:
518 return ((ac) && (ac->spacetype == SPACE_NLA));
520 /* visible only in Graph Editor */
521 case ACHANNEL_SETTING_VISIBLE:
522 return ((ac) && (ac->spacetype == SPACE_IPO));
524 /* only select and expand supported otherwise */
525 case ACHANNEL_SETTING_SELECT:
526 case ACHANNEL_SETTING_EXPAND:
534 /* get the appropriate flag(s) for the setting when it is valid */
535 static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
537 /* clear extra return data first */
541 case ACHANNEL_SETTING_SELECT: /* selected */
542 return SCE_DS_SELECTED;
544 case ACHANNEL_SETTING_EXPAND: /* expanded */
546 return SCE_DS_COLLAPSED;
548 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
549 return ADT_NLA_EVAL_OFF;
551 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
553 return ADT_CURVES_NOT_VISIBLE;
555 default: /* unsupported */
560 /* get pointer to the setting */
561 static void *acf_scene_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
563 Scene *scene = (Scene *)ale->data;
565 /* clear extra return data first */
569 case ACHANNEL_SETTING_SELECT: /* selected */
570 return GET_ACF_FLAG_PTR(scene->flag, type);
572 case ACHANNEL_SETTING_EXPAND: /* expanded */
573 return GET_ACF_FLAG_PTR(scene->flag, type);
575 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
576 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
578 return GET_ACF_FLAG_PTR(scene->adt->flag, type);
581 default: /* unsupported */
586 /* scene type define */
587 static bAnimChannelType ACF_SCENE =
589 "Scene", /* type name */
590 ACHANNEL_ROLE_EXPANDER, /* role */
592 acf_generic_root_color, /* backdrop color */
593 acf_generic_root_backdrop, /* backdrop */
594 acf_generic_indention_0, /* indent level */
597 acf_generic_idblock_name, /* name */
598 acf_generic_idblock_name_prop, /* name prop */
599 acf_scene_icon, /* icon */
601 acf_scene_setting_valid, /* has setting */
602 acf_scene_setting_flag, /* flag for setting */
603 acf_scene_setting_ptr /* pointer for setting */
606 /* Object ------------------------------------------- */
608 static int acf_object_icon(bAnimListElem *ale)
610 Base *base = (Base *)ale->data;
611 Object *ob = base->object;
613 /* icon depends on object-type */
616 return ICON_OUTLINER_OB_LAMP;
618 return ICON_OUTLINER_OB_MESH;
620 return ICON_OUTLINER_OB_CAMERA;
622 return ICON_OUTLINER_OB_CURVE;
624 return ICON_OUTLINER_OB_META;
626 return ICON_OUTLINER_OB_LATTICE;
628 return ICON_OUTLINER_OB_SPEAKER;
630 return ICON_OUTLINER_OB_ARMATURE;
632 return ICON_OUTLINER_OB_FONT;
634 return ICON_OUTLINER_OB_SURFACE;
636 return ICON_OUTLINER_OB_EMPTY;
638 return ICON_OBJECT_DATA;
642 /* name for object */
643 static void acf_object_name(bAnimListElem *ale, char *name)
645 Base *base = (Base *)ale->data;
646 Object *ob = base->object;
648 /* just copy the name... */
650 BLI_strncpy(name, ob->id.name + 2, ANIM_CHAN_NAME_SIZE);
653 /* name property for object */
654 static bool acf_object_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
656 RNA_id_pointer_create(ale->id, ptr);
657 *prop = RNA_struct_name_property(ptr->type);
659 return (*prop != NULL);
662 /* check if some setting exists for this channel */
663 static bool acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
665 Base *base = (Base *)ale->data;
666 Object *ob = base->object;
669 /* muted only in NLA */
670 case ACHANNEL_SETTING_MUTE:
671 return ((ac) && (ac->spacetype == SPACE_NLA));
673 /* visible only in Graph Editor */
674 case ACHANNEL_SETTING_VISIBLE:
675 return ((ac) && (ac->spacetype == SPACE_IPO) && (ob->adt));
677 /* only select and expand supported otherwise */
678 case ACHANNEL_SETTING_SELECT:
679 case ACHANNEL_SETTING_EXPAND:
687 /* get the appropriate flag(s) for the setting when it is valid */
688 static int acf_object_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
690 /* clear extra return data first */
694 case ACHANNEL_SETTING_SELECT: /* selected */
697 case ACHANNEL_SETTING_EXPAND: /* expanded */
699 return OB_ADS_COLLAPSED;
701 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
702 return ADT_NLA_EVAL_OFF;
704 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
706 return ADT_CURVES_NOT_VISIBLE;
708 default: /* unsupported */
713 /* get pointer to the setting */
714 static void *acf_object_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
716 Base *base = (Base *)ale->data;
717 Object *ob = base->object;
719 /* clear extra return data first */
723 case ACHANNEL_SETTING_SELECT: /* selected */
724 return GET_ACF_FLAG_PTR(ob->flag, type);
726 case ACHANNEL_SETTING_EXPAND: /* expanded */
727 return GET_ACF_FLAG_PTR(ob->nlaflag, type); // xxx
729 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
730 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
732 return GET_ACF_FLAG_PTR(ob->adt->flag, type);
735 default: /* unsupported */
740 /* object type define */
741 static bAnimChannelType ACF_OBJECT =
743 "Object", /* type name */
744 ACHANNEL_ROLE_EXPANDER, /* role */
746 acf_generic_root_color, /* backdrop color */
747 acf_generic_root_backdrop, /* backdrop */
748 acf_generic_indention_0, /* indent level */
751 acf_object_name, /* name */
752 acf_object_name_prop, /* name prop */
753 acf_object_icon, /* icon */
755 acf_object_setting_valid, /* has setting */
756 acf_object_setting_flag, /* flag for setting */
757 acf_object_setting_ptr /* pointer for setting */
760 /* Group ------------------------------------------- */
762 /* get backdrop color for group widget */
763 static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3])
765 bActionGroup *agrp = (bActionGroup *)ale->data;
766 bool showGroupColors = acf_show_channel_colors(ac);
768 if (showGroupColors && agrp->customCol) {
771 /* highlight only for active */
772 if (ale->flag & AGRP_ACTIVE)
773 copy_v3_v3_char((char *)cp, agrp->cs.select);
775 copy_v3_v3_char((char *)cp, agrp->cs.solid);
777 /* copy the colors over, transforming from bytes to floats */
778 rgb_uchar_to_float(r_color, cp);
781 /* highlight only for active */
782 if (ale->flag & AGRP_ACTIVE)
783 UI_GetThemeColorShade3fv(TH_GROUP_ACTIVE, 10, r_color);
785 UI_GetThemeColorShade3fv(TH_GROUP, 20, r_color);
789 /* backdrop for group widget */
790 static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
792 bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
793 View2D *v2d = &ac->ar->v2d;
794 short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
795 short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
798 /* set backdrop drawing color */
799 acf->get_backdrop_color(ac, ale, color);
802 /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
803 uiSetRoundBox(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
804 uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8);
807 /* name for group entries */
808 static void acf_group_name(bAnimListElem *ale, char *name)
810 bActionGroup *agrp = (bActionGroup *)ale->data;
812 /* just copy the name... */
814 BLI_strncpy(name, agrp->name, ANIM_CHAN_NAME_SIZE);
817 /* name property for group entries */
818 static bool acf_group_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
820 RNA_pointer_create(ale->id, &RNA_ActionGroup, ale->data, ptr);
821 *prop = RNA_struct_name_property(ptr->type);
823 return (*prop != NULL);
826 /* check if some setting exists for this channel */
827 static bool acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
829 /* for now, all settings are supported, though some are only conditionally */
832 case ACHANNEL_SETTING_SOLO: /* Only available in NLA Editor for tracks */
835 /* conditionally supported */
836 case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
837 return (ac->spacetype == SPACE_IPO);
839 default: /* always supported */
844 /* get the appropriate flag(s) for the setting when it is valid */
845 static int acf_group_setting_flag(bAnimContext *ac, eAnimChannel_Settings setting, bool *neg)
847 /* clear extra return data first */
851 case ACHANNEL_SETTING_SELECT: /* selected */
852 return AGRP_SELECTED;
854 case ACHANNEL_SETTING_EXPAND: /* expanded */
856 /* NOTE: Graph Editor uses a different flag to everywhere else for this,
857 * allowing different collapsing of groups there, since sharing the flag
858 * proved to be a hazard for workflows...
860 return (ac->spacetype == SPACE_IPO) ?
861 AGRP_EXPANDED_G : /* Graph Editor case */
862 AGRP_EXPANDED; /* DopeSheet and elsewhere */
865 case ACHANNEL_SETTING_MUTE: /* muted */
868 case ACHANNEL_SETTING_PROTECT: /* protected */
869 return AGRP_PROTECTED;
871 case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */
873 return AGRP_NOTVISIBLE;
876 /* this shouldn't happen */
881 /* get pointer to the setting */
882 static void *acf_group_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
884 bActionGroup *agrp = (bActionGroup *)ale->data;
886 /* all flags are just in agrp->flag for now... */
887 return GET_ACF_FLAG_PTR(agrp->flag, type);
890 /* group type define */
891 static bAnimChannelType ACF_GROUP =
893 "Group", /* type name */
894 ACHANNEL_ROLE_CHANNEL, /* role */
896 acf_group_color, /* backdrop color */
897 acf_group_backdrop, /* backdrop */
898 acf_generic_indention_0, /* indent level */
899 acf_generic_group_offset, /* offset */
901 acf_group_name, /* name */
902 acf_group_name_prop, /* name prop */
905 acf_group_setting_valid, /* has setting */
906 acf_group_setting_flag, /* flag for setting */
907 acf_group_setting_ptr /* pointer for setting */
910 /* F-Curve ------------------------------------------- */
912 /* name for fcurve entries */
913 static void acf_fcurve_name(bAnimListElem *ale, char *name)
915 getname_anim_fcurve(name, ale->id, ale->data);
918 /* "name" property for fcurve entries */
919 static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
921 FCurve *fcu = (FCurve *)ale->data;
923 /* Ctrl-Click Usability Convenience Hack:
924 * For disabled F-Curves, allow access to the RNA Path
925 * as our "name" so that user can perform quick fixes
927 if (fcu->flag & FCURVE_DISABLED) {
928 RNA_pointer_create(ale->id, &RNA_FCurve, ale->data, ptr);
929 *prop = RNA_struct_find_property(ptr, "data_path");
932 /* for "normal" F-Curves - no editable name, but *prop may not be set properly yet... */
936 return (*prop != NULL);
939 /* check if some setting exists for this channel */
940 static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
942 FCurve *fcu = (FCurve *)ale->data;
946 case ACHANNEL_SETTING_SOLO: /* Solo Flag is only for NLA */
947 case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */
950 /* conditionally available */
951 case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */
955 return false; // NOTE: in this special case, we need to draw ICON_ZOOMOUT
957 case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
958 return (ac->spacetype == SPACE_IPO);
960 /* always available */
966 /* get the appropriate flag(s) for the setting when it is valid */
967 static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
969 /* clear extra return data first */
973 case ACHANNEL_SETTING_SELECT: /* selected */
974 return FCURVE_SELECTED;
976 case ACHANNEL_SETTING_MUTE: /* muted */
979 case ACHANNEL_SETTING_PROTECT: /* protected */
980 return FCURVE_PROTECTED;
982 case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */
983 return FCURVE_VISIBLE;
985 default: /* unsupported */
990 /* get pointer to the setting */
991 static void *acf_fcurve_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
993 FCurve *fcu = (FCurve *)ale->data;
995 /* all flags are just in agrp->flag for now... */
996 return GET_ACF_FLAG_PTR(fcu->flag, type);
999 /* fcurve type define */
1000 static bAnimChannelType ACF_FCURVE =
1002 "F-Curve", /* type name */
1003 ACHANNEL_ROLE_CHANNEL, /* role */
1005 acf_generic_channel_color, /* backdrop color */
1006 acf_generic_channel_backdrop, /* backdrop */
1007 acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only?
1008 acf_generic_group_offset, /* offset */
1010 acf_fcurve_name, /* name */
1011 acf_fcurve_name_prop, /* name prop */
1014 acf_fcurve_setting_valid, /* has setting */
1015 acf_fcurve_setting_flag, /* flag for setting */
1016 acf_fcurve_setting_ptr /* pointer for setting */
1019 /* Object Action Expander ------------------------------------------- */
1021 // TODO: just get this from RNA?
1022 static int acf_fillactd_icon(bAnimListElem *UNUSED(ale))
1027 /* check if some setting exists for this channel */
1028 static bool acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
1031 /* only select and expand supported */
1032 case ACHANNEL_SETTING_SELECT:
1033 case ACHANNEL_SETTING_EXPAND:
1041 /* get the appropriate flag(s) for the setting when it is valid */
1042 static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1044 /* clear extra return data first */
1048 case ACHANNEL_SETTING_SELECT: /* selected */
1049 return ADT_UI_SELECTED;
1051 case ACHANNEL_SETTING_EXPAND: /* expanded */
1053 return ACT_COLLAPSED;
1055 default: /* unsupported */
1060 /* get pointer to the setting */
1061 static void *acf_fillactd_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
1063 bAction *act = (bAction *)ale->data;
1064 AnimData *adt = ale->adt;
1066 /* clear extra return data first */
1070 case ACHANNEL_SETTING_SELECT: /* selected */
1072 return GET_ACF_FLAG_PTR(adt->flag, type);
1076 case ACHANNEL_SETTING_EXPAND: /* expanded */
1077 return GET_ACF_FLAG_PTR(act->flag, type);
1079 default: /* unsupported */
1084 /* object action expander type define */
1085 static bAnimChannelType ACF_FILLACTD =
1087 "Ob-Action Filler", /* type name */
1088 ACHANNEL_ROLE_EXPANDER, /* role */
1090 acf_generic_dataexpand_color, /* backdrop color */
1091 acf_generic_dataexpand_backdrop, /* backdrop */
1092 acf_generic_indention_1, /* indent level */
1093 acf_generic_basic_offset, /* offset */
1095 acf_generic_idblock_name, /* name */
1096 acf_generic_idfill_name_prop, /* name prop */
1097 acf_fillactd_icon, /* icon */
1099 acf_fillactd_setting_valid, /* has setting */
1100 acf_fillactd_setting_flag, /* flag for setting */
1101 acf_fillactd_setting_ptr /* pointer for setting */
1104 /* Drivers Expander ------------------------------------------- */
1106 // TODO: just get this from RNA?
1107 static int acf_filldrivers_icon(bAnimListElem *UNUSED(ale))
1112 static void acf_filldrivers_name(bAnimListElem *UNUSED(ale), char *name)
1114 BLI_strncpy(name, IFACE_("Drivers"), ANIM_CHAN_NAME_SIZE);
1117 /* check if some setting exists for this channel */
1118 // TODO: this could be made more generic
1119 static bool acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
1122 /* only expand supported */
1123 case ACHANNEL_SETTING_EXPAND:
1131 /* get the appropriate flag(s) for the setting when it is valid */
1132 static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1134 /* clear extra return data first */
1138 case ACHANNEL_SETTING_EXPAND: /* expanded */
1140 return ADT_DRIVERS_COLLAPSED;
1142 default: /* unsupported */
1147 /* get pointer to the setting */
1148 static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
1150 AnimData *adt = (AnimData *)ale->data;
1152 /* clear extra return data first */
1156 case ACHANNEL_SETTING_EXPAND: /* expanded */
1157 return GET_ACF_FLAG_PTR(adt->flag, type);
1159 default: /* unsupported */
1164 /* drivers expander type define */
1165 static bAnimChannelType ACF_FILLDRIVERS =
1167 "Drivers Filler", /* type name */
1168 ACHANNEL_ROLE_EXPANDER, /* role */
1170 acf_generic_dataexpand_color, /* backdrop color */
1171 acf_generic_dataexpand_backdrop, /* backdrop */
1172 acf_generic_indention_1, /* indent level */
1173 acf_generic_basic_offset, /* offset */
1175 acf_filldrivers_name, /* name */
1176 NULL, /* name prop */
1177 acf_filldrivers_icon, /* icon */
1179 acf_filldrivers_setting_valid, /* has setting */
1180 acf_filldrivers_setting_flag, /* flag for setting */
1181 acf_filldrivers_setting_ptr /* pointer for setting */
1185 /* Material Expander ------------------------------------------- */
1187 // TODO: just get this from RNA?
1188 static int acf_dsmat_icon(bAnimListElem *UNUSED(ale))
1190 return ICON_MATERIAL_DATA;
1193 /* get the appropriate flag(s) for the setting when it is valid */
1194 static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1196 /* clear extra return data first */
1200 case ACHANNEL_SETTING_EXPAND: /* expanded */
1201 return MA_DS_EXPAND;
1203 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1204 return ADT_NLA_EVAL_OFF;
1206 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1208 return ADT_CURVES_NOT_VISIBLE;
1210 case ACHANNEL_SETTING_SELECT: /* selected */
1211 return ADT_UI_SELECTED;
1213 default: /* unsupported */
1218 /* get pointer to the setting */
1219 static void *acf_dsmat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
1221 Material *ma = (Material *)ale->data;
1223 /* clear extra return data first */
1227 case ACHANNEL_SETTING_EXPAND: /* expanded */
1228 return GET_ACF_FLAG_PTR(ma->flag, type);
1230 case ACHANNEL_SETTING_SELECT: /* selected */
1231 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1232 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1234 return GET_ACF_FLAG_PTR(ma->adt->flag, type);
1237 default: /* unsupported */
1242 /* material expander type define */
1243 static bAnimChannelType ACF_DSMAT =
1245 "Material Data Expander", /* type name */
1246 ACHANNEL_ROLE_EXPANDER, /* role */
1248 acf_generic_dataexpand_color, /* backdrop color */
1249 acf_generic_dataexpand_backdrop, /* backdrop */
1250 acf_generic_indention_1, /* indent level */
1251 acf_generic_basic_offset, /* offset */
1253 acf_generic_idblock_name, /* name */
1254 acf_generic_idblock_name_prop, /* name prop */
1255 acf_dsmat_icon, /* icon */
1257 acf_generic_dataexpand_setting_valid, /* has setting */
1258 acf_dsmat_setting_flag, /* flag for setting */
1259 acf_dsmat_setting_ptr /* pointer for setting */
1262 /* Lamp Expander ------------------------------------------- */
1264 // TODO: just get this from RNA?
1265 static int acf_dslam_icon(bAnimListElem *UNUSED(ale))
1267 return ICON_LAMP_DATA;
1270 /* get the appropriate flag(s) for the setting when it is valid */
1271 static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1273 /* clear extra return data first */
1277 case ACHANNEL_SETTING_EXPAND: /* expanded */
1278 return LA_DS_EXPAND;
1280 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1281 return ADT_NLA_EVAL_OFF;
1283 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1285 return ADT_CURVES_NOT_VISIBLE;
1287 case ACHANNEL_SETTING_SELECT: /* selected */
1288 return ADT_UI_SELECTED;
1290 default: /* unsupported */
1295 /* get pointer to the setting */
1296 static void *acf_dslam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
1298 Lamp *la = (Lamp *)ale->data;
1300 /* clear extra return data first */
1304 case ACHANNEL_SETTING_EXPAND: /* expanded */
1305 return GET_ACF_FLAG_PTR(la->flag, type);
1307 case ACHANNEL_SETTING_SELECT: /* selected */
1308 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1309 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1311 return GET_ACF_FLAG_PTR(la->adt->flag, type);
1314 default: /* unsupported */
1319 /* lamp expander type define */
1320 static bAnimChannelType ACF_DSLAM =
1322 "Lamp Expander", /* type name */
1323 ACHANNEL_ROLE_EXPANDER, /* role */
1325 acf_generic_dataexpand_color, /* backdrop color */
1326 acf_generic_dataexpand_backdrop, /* backdrop */
1327 acf_generic_indention_1, /* indent level */
1328 acf_generic_basic_offset, /* offset */
1330 acf_generic_idblock_name, /* name */
1331 acf_generic_idblock_name_prop, /* name prop */
1332 acf_dslam_icon, /* icon */
1334 acf_generic_dataexpand_setting_valid, /* has setting */
1335 acf_dslam_setting_flag, /* flag for setting */
1336 acf_dslam_setting_ptr /* pointer for setting */
1339 /* Texture Expander ------------------------------------------- */
1341 // TODO: just get this from RNA?
1342 static int acf_dstex_icon(bAnimListElem *UNUSED(ale))
1344 return ICON_TEXTURE_DATA;
1347 /* offset for texture expanders */
1348 // FIXME: soon to be obsolete?
1349 static short acf_dstex_offset(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale))
1351 return 14; // XXX: simply include this in indention instead?
1354 /* get the appropriate flag(s) for the setting when it is valid */
1355 static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1357 /* clear extra return data first */
1361 case ACHANNEL_SETTING_EXPAND: /* expanded */
1362 return TEX_DS_EXPAND;
1364 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1365 return ADT_NLA_EVAL_OFF;
1367 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1369 return ADT_CURVES_NOT_VISIBLE;
1371 case ACHANNEL_SETTING_SELECT: /* selected */
1372 return ADT_UI_SELECTED;
1374 default: /* unsupported */
1379 /* get pointer to the setting */
1380 static void *acf_dstex_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
1382 Tex *tex = (Tex *)ale->data;
1384 /* clear extra return data first */
1388 case ACHANNEL_SETTING_EXPAND: /* expanded */
1389 return GET_ACF_FLAG_PTR(tex->flag, type);
1391 case ACHANNEL_SETTING_SELECT: /* selected */
1392 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1393 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1395 return GET_ACF_FLAG_PTR(tex->adt->flag, type);
1398 default: /* unsupported */
1403 /* texture expander type define */
1404 static bAnimChannelType ACF_DSTEX =
1406 "Texture Data Expander", /* type name */
1407 ACHANNEL_ROLE_EXPANDER, /* role */
1409 acf_generic_dataexpand_color, /* backdrop color */
1410 acf_generic_dataexpand_backdrop, /* backdrop */
1411 acf_generic_indention_1, /* indent level */
1412 acf_dstex_offset, /* offset */
1414 acf_generic_idblock_name, /* name */
1415 acf_generic_idfill_name_prop, /* name prop */
1416 acf_dstex_icon, /* icon */
1418 acf_generic_dataexpand_setting_valid, /* has setting */
1419 acf_dstex_setting_flag, /* flag for setting */
1420 acf_dstex_setting_ptr /* pointer for setting */
1423 /* Camera Expander ------------------------------------------- */
1425 // TODO: just get this from RNA?
1426 static int acf_dscam_icon(bAnimListElem *UNUSED(ale))
1428 return ICON_CAMERA_DATA;
1431 /* get the appropriate flag(s) for the setting when it is valid */
1432 static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1434 /* clear extra return data first */
1438 case ACHANNEL_SETTING_EXPAND: /* expanded */
1439 return CAM_DS_EXPAND;
1441 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1442 return ADT_NLA_EVAL_OFF;
1444 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1446 return ADT_CURVES_NOT_VISIBLE;
1448 case ACHANNEL_SETTING_SELECT: /* selected */
1449 return ADT_UI_SELECTED;
1451 default: /* unsupported */
1456 /* get pointer to the setting */
1457 static void *acf_dscam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
1459 Camera *ca = (Camera *)ale->data;
1461 /* clear extra return data first */
1465 case ACHANNEL_SETTING_EXPAND: /* expanded */
1466 return GET_ACF_FLAG_PTR(ca->flag, type);
1468 case ACHANNEL_SETTING_SELECT: /* selected */
1469 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1470 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1472 return GET_ACF_FLAG_PTR(ca->adt->flag, type);
1475 default: /* unsupported */
1480 /* camera expander type define */
1481 static bAnimChannelType ACF_DSCAM =
1483 "Camera Expander", /* type name */
1484 ACHANNEL_ROLE_EXPANDER, /* role */
1486 acf_generic_dataexpand_color, /* backdrop color */
1487 acf_generic_dataexpand_backdrop, /* backdrop */
1488 acf_generic_indention_1, /* indent level */
1489 acf_generic_basic_offset, /* offset */
1491 acf_generic_idblock_name, /* name */
1492 acf_generic_idfill_name_prop, /* name prop */
1493 acf_dscam_icon, /* icon */
1495 acf_generic_dataexpand_setting_valid, /* has setting */
1496 acf_dscam_setting_flag, /* flag for setting */
1497 acf_dscam_setting_ptr /* pointer for setting */
1500 /* Curve Expander ------------------------------------------- */
1502 // TODO: just get this from RNA?
1503 static int acf_dscur_icon(bAnimListElem *ale)
1505 Curve *cu = (Curve *)ale->data;
1506 short obtype = BKE_curve_type_get(cu);
1510 return ICON_FONT_DATA;
1512 return ICON_SURFACE_DATA;
1514 return ICON_CURVE_DATA;
1518 /* get the appropriate flag(s) for the setting when it is valid */
1519 static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1521 /* clear extra return data first */
1525 case ACHANNEL_SETTING_EXPAND: /* expanded */
1526 return CU_DS_EXPAND;
1528 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1529 return ADT_NLA_EVAL_OFF;
1531 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1533 return ADT_CURVES_NOT_VISIBLE;
1535 case ACHANNEL_SETTING_SELECT: /* selected */
1536 return ADT_UI_SELECTED;
1538 default: /* unsupported */
1543 /* get pointer to the setting */
1544 static void *acf_dscur_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
1546 Curve *cu = (Curve *)ale->data;
1548 /* clear extra return data first */
1552 case ACHANNEL_SETTING_EXPAND: /* expanded */
1553 return GET_ACF_FLAG_PTR(cu->flag, type);
1555 case ACHANNEL_SETTING_SELECT: /* selected */
1556 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1557 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1559 return GET_ACF_FLAG_PTR(cu->adt->flag, type);
1562 default: /* unsupported */
1567 /* curve expander type define */
1568 static bAnimChannelType ACF_DSCUR =
1570 "Curve Expander", /* type name */
1571 ACHANNEL_ROLE_EXPANDER, /* role */
1573 acf_generic_dataexpand_color, /* backdrop color */
1574 acf_generic_dataexpand_backdrop, /* backdrop */
1575 acf_generic_indention_1, /* indent level */
1576 acf_generic_basic_offset, /* offset */
1578 acf_generic_idblock_name, /* name */
1579 acf_generic_idblock_name_prop, /* name prop */
1580 acf_dscur_icon, /* icon */
1582 acf_generic_dataexpand_setting_valid, /* has setting */
1583 acf_dscur_setting_flag, /* flag for setting */
1584 acf_dscur_setting_ptr /* pointer for setting */
1587 /* Shape Key Expander ------------------------------------------- */
1589 // TODO: just get this from RNA?
1590 static int acf_dsskey_icon(bAnimListElem *UNUSED(ale))
1592 return ICON_SHAPEKEY_DATA;
1595 /* get the appropriate flag(s) for the setting when it is valid */
1596 static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1598 /* clear extra return data first */
1602 case ACHANNEL_SETTING_EXPAND: /* expanded */
1603 return KEY_DS_EXPAND;
1605 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1606 return ADT_NLA_EVAL_OFF;
1608 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1610 return ADT_CURVES_NOT_VISIBLE;
1612 case ACHANNEL_SETTING_SELECT: /* selected */
1613 return ADT_UI_SELECTED;
1615 default: /* unsupported */
1620 /* get pointer to the setting */
1621 static void *acf_dsskey_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
1623 Key *key = (Key *)ale->data;
1625 /* clear extra return data first */
1629 case ACHANNEL_SETTING_EXPAND: /* expanded */
1630 return GET_ACF_FLAG_PTR(key->flag, type);
1632 case ACHANNEL_SETTING_SELECT: /* selected */
1633 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1634 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1636 return GET_ACF_FLAG_PTR(key->adt->flag, type);
1639 default: /* unsupported */
1644 /* shapekey expander type define */
1645 static bAnimChannelType ACF_DSSKEY =
1647 "Shape Key Expander", /* type name */
1648 ACHANNEL_ROLE_EXPANDER, /* role */
1650 acf_generic_dataexpand_color, /* backdrop color */
1651 acf_generic_dataexpand_backdrop, /* backdrop */
1652 acf_generic_indention_1, /* indent level */
1653 acf_generic_basic_offset, /* offset */
1655 acf_generic_idblock_name, /* name */
1656 acf_generic_idblock_name_prop, /* name prop */
1657 acf_dsskey_icon, /* icon */
1659 acf_generic_dataexpand_setting_valid, /* has setting */
1660 acf_dsskey_setting_flag, /* flag for setting */
1661 acf_dsskey_setting_ptr /* pointer for setting */
1664 /* World Expander ------------------------------------------- */
1666 // TODO: just get this from RNA?
1667 static int acf_dswor_icon(bAnimListElem *UNUSED(ale))
1669 return ICON_WORLD_DATA;
1672 /* get the appropriate flag(s) for the setting when it is valid */
1673 static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1675 /* clear extra return data first */
1679 case ACHANNEL_SETTING_EXPAND: /* expanded */
1680 return WO_DS_EXPAND;
1682 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1683 return ADT_NLA_EVAL_OFF;
1685 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1687 return ADT_CURVES_NOT_VISIBLE;
1689 case ACHANNEL_SETTING_SELECT: /* selected */
1690 return ADT_UI_SELECTED;
1692 default: /* unsupported */
1697 /* get pointer to the setting */
1698 static void *acf_dswor_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
1700 World *wo = (World *)ale->data;
1702 /* clear extra return data first */
1706 case ACHANNEL_SETTING_EXPAND: /* expanded */
1707 return GET_ACF_FLAG_PTR(wo->flag, type);
1709 case ACHANNEL_SETTING_SELECT: /* selected */
1710 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1711 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1713 return GET_ACF_FLAG_PTR(wo->adt->flag, type);
1716 default: /* unsupported */
1721 /* world expander type define */
1722 static bAnimChannelType ACF_DSWOR =
1724 "World Expander", /* type name */
1725 ACHANNEL_ROLE_EXPANDER, /* role */
1727 acf_generic_dataexpand_color, /* backdrop color */
1728 acf_generic_dataexpand_backdrop, /* backdrop */
1729 acf_generic_indention_1, /* indent level */
1730 acf_generic_basic_offset, /* offset */
1732 acf_generic_idblock_name, /* name */
1733 acf_generic_idfill_name_prop, /* name prop */
1734 acf_dswor_icon, /* icon */
1736 acf_generic_dataexpand_setting_valid, /* has setting */
1737 acf_dswor_setting_flag, /* flag for setting */
1738 acf_dswor_setting_ptr /* pointer for setting */
1741 /* Particle Expander ------------------------------------------- */
1743 // TODO: just get this from RNA?
1744 static int acf_dspart_icon(bAnimListElem *UNUSED(ale))
1746 return ICON_PARTICLE_DATA;
1749 /* get the appropriate flag(s) for the setting when it is valid */
1750 static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1752 /* clear extra return data first */
1756 case ACHANNEL_SETTING_EXPAND: /* expanded */
1757 return PART_DS_EXPAND;
1759 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1760 return ADT_NLA_EVAL_OFF;
1762 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1764 return ADT_CURVES_NOT_VISIBLE;
1766 case ACHANNEL_SETTING_SELECT: /* selected */
1767 return ADT_UI_SELECTED;
1769 default: /* unsupported */
1774 /* get pointer to the setting */
1775 static void *acf_dspart_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
1777 ParticleSettings *part = (ParticleSettings *)ale->data;
1779 /* clear extra return data first */
1783 case ACHANNEL_SETTING_EXPAND: /* expanded */
1784 return GET_ACF_FLAG_PTR(part->flag, type);
1786 case ACHANNEL_SETTING_SELECT: /* selected */
1787 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1788 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1790 return GET_ACF_FLAG_PTR(part->adt->flag, type);
1793 default: /* unsupported */
1798 /* particle expander type define */
1799 static bAnimChannelType ACF_DSPART =
1801 "Particle Data Expander", /* type name */
1802 ACHANNEL_ROLE_EXPANDER, /* role */
1804 acf_generic_dataexpand_color, /* backdrop color */
1805 acf_generic_dataexpand_backdrop, /* backdrop */
1806 acf_generic_indention_1, /* indent level */
1807 acf_generic_basic_offset, /* offset */
1809 acf_generic_idblock_name, /* name */
1810 acf_generic_idblock_name_prop, /* name prop */
1811 acf_dspart_icon, /* icon */
1813 acf_generic_dataexpand_setting_valid, /* has setting */
1814 acf_dspart_setting_flag, /* flag for setting */
1815 acf_dspart_setting_ptr /* pointer for setting */
1818 /* MetaBall Expander ------------------------------------------- */
1820 // TODO: just get this from RNA?
1821 static int acf_dsmball_icon(bAnimListElem *UNUSED(ale))
1823 return ICON_META_DATA;
1826 /* get the appropriate flag(s) for the setting when it is valid */
1827 static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1829 /* clear extra return data first */
1833 case ACHANNEL_SETTING_EXPAND: /* expanded */
1834 return MB_DS_EXPAND;
1836 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1837 return ADT_NLA_EVAL_OFF;
1839 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1841 return ADT_CURVES_NOT_VISIBLE;
1843 case ACHANNEL_SETTING_SELECT: /* selected */
1844 return ADT_UI_SELECTED;
1846 default: /* unsupported */
1851 /* get pointer to the setting */
1852 static void *acf_dsmball_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
1854 MetaBall *mb = (MetaBall *)ale->data;
1856 /* clear extra return data first */
1860 case ACHANNEL_SETTING_EXPAND: /* expanded */
1861 return GET_ACF_FLAG_PTR(mb->flag2, type);
1863 case ACHANNEL_SETTING_SELECT: /* selected */
1864 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1865 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1867 return GET_ACF_FLAG_PTR(mb->adt->flag, type);
1870 default: /* unsupported */
1875 /* metaball expander type define */
1876 static bAnimChannelType ACF_DSMBALL =
1878 "Metaball Expander", /* type name */
1879 ACHANNEL_ROLE_EXPANDER, /* role */
1881 acf_generic_dataexpand_color, /* backdrop color */
1882 acf_generic_dataexpand_backdrop, /* backdrop */
1883 acf_generic_indention_1, /* indent level */
1884 acf_generic_basic_offset, /* offset */
1886 acf_generic_idblock_name, /* name */
1887 acf_generic_idblock_name_prop, /* name prop */
1888 acf_dsmball_icon, /* icon */
1890 acf_generic_dataexpand_setting_valid, /* has setting */
1891 acf_dsmball_setting_flag, /* flag for setting */
1892 acf_dsmball_setting_ptr /* pointer for setting */
1895 /* Armature Expander ------------------------------------------- */
1897 // TODO: just get this from RNA?
1898 static int acf_dsarm_icon(bAnimListElem *UNUSED(ale))
1900 return ICON_ARMATURE_DATA;
1903 /* get the appropriate flag(s) for the setting when it is valid */
1904 static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1906 /* clear extra return data first */
1910 case ACHANNEL_SETTING_EXPAND: /* expanded */
1911 return ARM_DS_EXPAND;
1913 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1914 return ADT_NLA_EVAL_OFF;
1916 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1918 return ADT_CURVES_NOT_VISIBLE;
1920 case ACHANNEL_SETTING_SELECT: /* selected */
1921 return ADT_UI_SELECTED;
1923 default: /* unsupported */
1928 /* get pointer to the setting */
1929 static void *acf_dsarm_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
1931 bArmature *arm = (bArmature *)ale->data;
1933 /* clear extra return data first */
1937 case ACHANNEL_SETTING_EXPAND: /* expanded */
1938 return GET_ACF_FLAG_PTR(arm->flag, type);
1940 case ACHANNEL_SETTING_SELECT: /* selected */
1941 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1942 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1944 return GET_ACF_FLAG_PTR(arm->adt->flag, type);
1947 default: /* unsupported */
1952 /* metaball expander type define */
1953 static bAnimChannelType ACF_DSARM =
1955 "Armature Expander", /* type name */
1956 ACHANNEL_ROLE_EXPANDER, /* role */
1958 acf_generic_dataexpand_color, /* backdrop color */
1959 acf_generic_dataexpand_backdrop, /* backdrop */
1960 acf_generic_indention_1, /* indent level */
1961 acf_generic_basic_offset, /* offset */
1963 acf_generic_idblock_name, /* name */
1964 acf_generic_idblock_name_prop, /* name prop */
1965 acf_dsarm_icon, /* icon */
1967 acf_generic_dataexpand_setting_valid, /* has setting */
1968 acf_dsarm_setting_flag, /* flag for setting */
1969 acf_dsarm_setting_ptr /* pointer for setting */
1972 /* NodeTree Expander ------------------------------------------- */
1974 // TODO: just get this from RNA?
1975 static int acf_dsntree_icon(bAnimListElem *UNUSED(ale))
1977 return ICON_NODETREE;
1980 /* offset for nodetree expanders */
1981 static short acf_dsntree_offset(bAnimContext *ac, bAnimListElem *ale)
1983 bNodeTree *ntree = (bNodeTree *)ale->data;
1984 short offset = acf_generic_basic_offset(ac, ale);
1986 offset += acf_nodetree_rootType_offset(ntree);
1991 /* get the appropriate flag(s) for the setting when it is valid */
1992 static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
1994 /* clear extra return data first */
1998 case ACHANNEL_SETTING_EXPAND: /* expanded */
1999 return NTREE_DS_EXPAND;
2001 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
2002 return ADT_NLA_EVAL_OFF;
2004 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
2006 return ADT_CURVES_NOT_VISIBLE;
2008 case ACHANNEL_SETTING_SELECT: /* selected */
2009 return ADT_UI_SELECTED;
2011 default: /* unsupported */
2016 /* get pointer to the setting */
2017 static void *acf_dsntree_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
2019 bNodeTree *ntree = (bNodeTree *)ale->data;
2021 /* clear extra return data first */
2025 case ACHANNEL_SETTING_EXPAND: /* expanded */
2026 return GET_ACF_FLAG_PTR(ntree->flag, type);
2028 case ACHANNEL_SETTING_SELECT: /* selected */
2029 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
2030 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
2032 return GET_ACF_FLAG_PTR(ntree->adt->flag, type);
2035 default: /* unsupported */
2040 /* node tree expander type define */
2041 static bAnimChannelType ACF_DSNTREE =
2043 "Node Tree Expander", /* type name */
2044 ACHANNEL_ROLE_EXPANDER, /* role */
2046 acf_generic_dataexpand_color, /* backdrop color */
2047 acf_generic_dataexpand_backdrop, /* backdrop */
2048 acf_generic_indention_1, /* indent level */
2049 acf_dsntree_offset, /* offset */
2051 acf_generic_idblock_name, /* name */
2052 acf_generic_idblock_name_prop, /* name prop */
2053 acf_dsntree_icon, /* icon */
2055 acf_generic_dataexpand_setting_valid, /* has setting */
2056 acf_dsntree_setting_flag, /* flag for setting */
2057 acf_dsntree_setting_ptr /* pointer for setting */
2060 /* LineStyle Expander ------------------------------------------- */
2062 /* TODO: just get this from RNA? */
2063 static int acf_dslinestyle_icon(bAnimListElem *UNUSED(ale))
2065 return ICON_LINE_DATA;
2068 /* get the appropriate flag(s) for the setting when it is valid */
2069 static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
2071 /* clear extra return data first */
2075 case ACHANNEL_SETTING_EXPAND: /* expanded */
2076 return LS_DS_EXPAND;
2078 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
2079 return ADT_NLA_EVAL_OFF;
2081 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
2083 return ADT_CURVES_NOT_VISIBLE;
2085 case ACHANNEL_SETTING_SELECT: /* selected */
2086 return ADT_UI_SELECTED;
2088 default: /* unsupported */
2093 /* get pointer to the setting */
2094 static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
2096 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ale->data;
2098 /* clear extra return data first */
2102 case ACHANNEL_SETTING_EXPAND: /* expanded */
2103 return GET_ACF_FLAG_PTR(linestyle->flag, type);
2105 case ACHANNEL_SETTING_SELECT: /* selected */
2106 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
2107 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
2109 return GET_ACF_FLAG_PTR(linestyle->adt->flag, type);
2112 default: /* unsupported */
2117 /* node tree expander type define */
2118 static bAnimChannelType ACF_DSLINESTYLE =
2120 "Line Style Expander", /* type name */
2121 ACHANNEL_ROLE_EXPANDER, /* role */
2123 acf_generic_dataexpand_color, /* backdrop color */
2124 acf_generic_dataexpand_backdrop,/* backdrop */
2125 acf_generic_indention_1, /* indent level */
2126 acf_generic_basic_offset, /* offset */
2128 acf_generic_idblock_name, /* name */
2129 acf_generic_idblock_name_prop, /* name prop */
2130 acf_dslinestyle_icon, /* icon */
2132 acf_generic_dataexpand_setting_valid, /* has setting */
2133 acf_dslinestyle_setting_flag, /* flag for setting */
2134 acf_dslinestyle_setting_ptr /* pointer for setting */
2137 /* Mesh Expander ------------------------------------------- */
2139 // TODO: just get this from RNA?
2140 static int acf_dsmesh_icon(bAnimListElem *UNUSED(ale))
2142 return ICON_MESH_DATA;
2145 /* get the appropriate flag(s) for the setting when it is valid */
2146 static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
2148 /* clear extra return data first */
2152 case ACHANNEL_SETTING_EXPAND: /* expanded */
2153 return ME_DS_EXPAND;
2155 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
2156 return ADT_NLA_EVAL_OFF;
2158 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
2160 return ADT_CURVES_NOT_VISIBLE;
2162 case ACHANNEL_SETTING_SELECT: /* selected */
2163 return ADT_UI_SELECTED;
2165 default: /* unsupported */
2170 /* get pointer to the setting */
2171 static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
2173 Mesh *me = (Mesh *)ale->data;
2175 /* clear extra return data first */
2179 case ACHANNEL_SETTING_EXPAND: /* expanded */
2180 return GET_ACF_FLAG_PTR(me->flag, type);
2182 case ACHANNEL_SETTING_SELECT: /* selected */
2183 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
2184 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
2186 return GET_ACF_FLAG_PTR(me->adt->flag, type);
2189 default: /* unsupported */
2194 /* node tree expander type define */
2195 static bAnimChannelType ACF_DSMESH =
2197 "Mesh Expander", /* type name */
2198 ACHANNEL_ROLE_EXPANDER, /* role */
2200 acf_generic_dataexpand_color, /* backdrop color */
2201 acf_generic_dataexpand_backdrop, /* backdrop */
2202 acf_generic_indention_1, /* indent level */ // XXX this only works for compositing
2203 acf_generic_basic_offset, /* offset */
2205 acf_generic_idblock_name, /* name */
2206 acf_generic_idblock_name_prop, /* name prop */
2207 acf_dsmesh_icon, /* icon */
2209 acf_generic_dataexpand_setting_valid, /* has setting */
2210 acf_dsmesh_setting_flag, /* flag for setting */
2211 acf_dsmesh_setting_ptr /* pointer for setting */
2214 /* Lattice Expander ------------------------------------------- */
2216 // TODO: just get this from RNA?
2217 static int acf_dslat_icon(bAnimListElem *UNUSED(ale))
2219 return ICON_LATTICE_DATA;
2222 /* get the appropriate flag(s) for the setting when it is valid */
2223 static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
2225 /* clear extra return data first */
2229 case ACHANNEL_SETTING_EXPAND: /* expanded */
2230 return LT_DS_EXPAND;
2232 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
2233 return ADT_NLA_EVAL_OFF;
2235 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
2237 return ADT_CURVES_NOT_VISIBLE;
2239 case ACHANNEL_SETTING_SELECT: /* selected */
2240 return ADT_UI_SELECTED;
2242 default: /* unsupported */
2247 /* get pointer to the setting */
2248 static void *acf_dslat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
2250 Lattice *lt = (Lattice *)ale->data;
2252 /* clear extra return data first */
2256 case ACHANNEL_SETTING_EXPAND: /* expanded */
2257 return GET_ACF_FLAG_PTR(lt->flag, type);
2259 case ACHANNEL_SETTING_SELECT: /* selected */
2260 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
2261 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
2263 return GET_ACF_FLAG_PTR(lt->adt->flag, type);
2266 default: /* unsupported */
2271 /* node tree expander type define */
2272 static bAnimChannelType ACF_DSLAT =
2274 "Lattice Expander", /* type name */
2275 ACHANNEL_ROLE_EXPANDER, /* role */
2277 acf_generic_dataexpand_color, /* backdrop color */
2278 acf_generic_dataexpand_backdrop, /* backdrop */
2279 acf_generic_indention_1, /* indent level */ // XXX this only works for compositing
2280 acf_generic_basic_offset, /* offset */
2282 acf_generic_idblock_name, /* name */
2283 acf_generic_idblock_name_prop, /* name prop */
2284 acf_dslat_icon, /* icon */
2286 acf_generic_dataexpand_setting_valid, /* has setting */
2287 acf_dslat_setting_flag, /* flag for setting */
2288 acf_dslat_setting_ptr /* pointer for setting */
2291 /* Speaker Expander ------------------------------------------- */
2293 // TODO: just get this from RNA?
2294 static int acf_dsspk_icon(bAnimListElem *UNUSED(ale))
2296 return ICON_SPEAKER;
2299 /* get the appropriate flag(s) for the setting when it is valid */
2300 static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
2302 /* clear extra return data first */
2306 case ACHANNEL_SETTING_EXPAND: /* expanded */
2307 return SPK_DS_EXPAND;
2309 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
2310 return ADT_NLA_EVAL_OFF;
2312 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
2314 return ADT_CURVES_NOT_VISIBLE;
2316 case ACHANNEL_SETTING_SELECT: /* selected */
2317 return ADT_UI_SELECTED;
2319 default: /* unsupported */
2324 /* get pointer to the setting */
2325 static void *acf_dsspk_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
2327 Speaker *spk = (Speaker *)ale->data;
2329 /* clear extra return data first */
2333 case ACHANNEL_SETTING_EXPAND: /* expanded */
2334 return GET_ACF_FLAG_PTR(spk->flag, type);
2336 case ACHANNEL_SETTING_SELECT: /* selected */
2337 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
2338 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
2340 return GET_ACF_FLAG_PTR(spk->adt->flag, type);
2343 default: /* unsupported */
2348 /* speaker expander type define */
2349 static bAnimChannelType ACF_DSSPK =
2351 "Speaker Expander", /* type name */
2352 ACHANNEL_ROLE_EXPANDER, /* role */
2354 acf_generic_dataexpand_color, /* backdrop color */
2355 acf_generic_dataexpand_backdrop, /* backdrop */
2356 acf_generic_indention_1, /* indent level */
2357 acf_generic_basic_offset, /* offset */
2359 acf_generic_idblock_name, /* name */
2360 acf_generic_idblock_name_prop, /* name prop */
2361 acf_dsspk_icon, /* icon */
2363 acf_generic_dataexpand_setting_valid, /* has setting */
2364 acf_dsspk_setting_flag, /* flag for setting */
2365 acf_dsspk_setting_ptr /* pointer for setting */
2368 /* ShapeKey Entry ------------------------------------------- */
2370 /* name for ShapeKey */
2371 static void acf_shapekey_name(bAnimListElem *ale, char *name)
2373 KeyBlock *kb = (KeyBlock *)ale->data;
2375 /* just copy the name... */
2377 /* if the KeyBlock had a name, use it, otherwise use the index */
2379 BLI_strncpy(name, kb->name, ANIM_CHAN_NAME_SIZE);
2381 BLI_snprintf(name, ANIM_CHAN_NAME_SIZE, IFACE_("Key %d"), ale->index);
2385 /* name property for ShapeKey entries */
2386 static bool acf_shapekey_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
2388 KeyBlock *kb = (KeyBlock *)ale->data;
2390 /* if the KeyBlock had a name, use it, otherwise use the index */
2391 if (kb && kb->name[0]) {
2392 RNA_pointer_create(ale->id, &RNA_ShapeKey, kb, ptr);
2393 *prop = RNA_struct_name_property(ptr->type);
2395 return (*prop != NULL);
2401 /* check if some setting exists for this channel */
2402 static bool acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
2405 case ACHANNEL_SETTING_SELECT: /* selected */
2406 case ACHANNEL_SETTING_MUTE: /* muted */
2407 case ACHANNEL_SETTING_PROTECT: /* protected */
2410 /* nothing else is supported */
2416 /* get the appropriate flag(s) for the setting when it is valid */
2417 static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
2419 /* clear extra return data first */
2423 case ACHANNEL_SETTING_MUTE: /* mute */
2424 return KEYBLOCK_MUTE;
2426 case ACHANNEL_SETTING_SELECT: /* selected */
2427 return KEYBLOCK_SEL;
2429 case ACHANNEL_SETTING_PROTECT: /* locked */
2430 return KEYBLOCK_LOCKED;
2432 default: /* unsupported */
2437 /* get pointer to the setting */
2438 static void *acf_shapekey_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
2440 KeyBlock *kb = (KeyBlock *)ale->data;
2442 /* clear extra return data first */
2446 case ACHANNEL_SETTING_SELECT: /* selected */
2447 case ACHANNEL_SETTING_MUTE: /* muted */
2448 case ACHANNEL_SETTING_PROTECT: /* protected */
2449 return GET_ACF_FLAG_PTR(kb->flag, type);
2451 default: /* unsupported */
2456 /* shapekey expander type define */
2457 static bAnimChannelType ACF_SHAPEKEY =
2459 "Shape Key", /* type name */
2460 ACHANNEL_ROLE_CHANNEL, /* role */
2462 acf_generic_channel_color, /* backdrop color */
2463 acf_generic_channel_backdrop, /* backdrop */
2464 acf_generic_indention_0, /* indent level */
2465 acf_generic_basic_offset, /* offset */
2467 acf_shapekey_name, /* name */
2468 acf_shapekey_name_prop, /* name prop */
2471 acf_shapekey_setting_valid, /* has setting */
2472 acf_shapekey_setting_flag, /* flag for setting */
2473 acf_shapekey_setting_ptr /* pointer for setting */
2476 /* GPencil Datablock ------------------------------------------- */
2478 /* get backdrop color for gpencil datablock widget */
2479 static void acf_gpd_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), float r_color[3])
2481 /* these are ID-blocks, but not exactly standalone... */
2482 UI_GetThemeColorShade3fv(TH_DOPESHEET_CHANNELSUBOB, 20, r_color);
2485 // TODO: just get this from RNA?
2486 static int acf_gpd_icon(bAnimListElem *UNUSED(ale))
2488 return ICON_GREASEPENCIL;
2491 /* check if some setting exists for this channel */
2492 static bool acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
2495 /* only select and expand supported */
2496 case ACHANNEL_SETTING_SELECT:
2497 case ACHANNEL_SETTING_EXPAND:
2505 /* get the appropriate flag(s) for the setting when it is valid */
2506 static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
2508 /* clear extra return data first */
2512 case ACHANNEL_SETTING_SELECT: /* selected */
2513 return AGRP_SELECTED;
2515 case ACHANNEL_SETTING_EXPAND: /* expanded */
2516 return GP_DATA_EXPAND;
2519 /* these shouldn't happen */
2524 /* get pointer to the setting */
2525 static void *acf_gpd_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
2527 bGPdata *gpd = (bGPdata *)ale->data;
2529 /* all flags are just in gpd->flag for now... */
2530 return GET_ACF_FLAG_PTR(gpd->flag, type);
2533 /* gpencil datablock type define */
2534 static bAnimChannelType ACF_GPD =
2536 "GPencil Datablock", /* type name */
2537 ACHANNEL_ROLE_EXPANDER, /* role */
2539 acf_gpd_color, /* backdrop color */
2540 acf_group_backdrop, /* backdrop */
2541 acf_generic_indention_0, /* indent level */
2542 acf_generic_group_offset, /* offset */
2544 acf_generic_idblock_name, /* name */
2545 acf_generic_idfill_name_prop, /* name prop */
2546 acf_gpd_icon, /* icon */
2548 acf_gpd_setting_valid, /* has setting */
2549 acf_gpd_setting_flag, /* flag for setting */
2550 acf_gpd_setting_ptr /* pointer for setting */
2553 /* GPencil Layer ------------------------------------------- */
2555 /* name for grease pencil layer entries */
2556 static void acf_gpl_name(bAnimListElem *ale, char *name)
2558 bGPDlayer *gpl = (bGPDlayer *)ale->data;
2561 BLI_strncpy(name, gpl->info, ANIM_CHAN_NAME_SIZE);
2564 /* name property for grease pencil layer entries */
2565 static bool acf_gpl_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
2568 RNA_pointer_create(ale->id, &RNA_GPencilLayer, ale->data, ptr);
2569 *prop = RNA_struct_name_property(ptr->type);
2571 return (*prop != NULL);
2577 /* check if some setting exists for this channel */
2578 static bool acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
2582 case ACHANNEL_SETTING_EXPAND: /* gpencil layers are more like F-Curves than groups */
2583 case ACHANNEL_SETTING_VISIBLE: /* graph editor only */
2584 case ACHANNEL_SETTING_SOLO: /* nla editor only */
2587 /* always available */
2593 /* get the appropriate flag(s) for the setting when it is valid */
2594 static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
2596 /* clear extra return data first */
2600 case ACHANNEL_SETTING_SELECT: /* selected */
2601 return GP_LAYER_SELECT;
2603 case ACHANNEL_SETTING_MUTE: /* muted */
2604 return GP_LAYER_HIDE;
2606 case ACHANNEL_SETTING_PROTECT: /* protected */
2607 return GP_LAYER_LOCKED;
2609 default: /* unsupported */
2614 /* get pointer to the setting */
2615 static void *acf_gpl_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
2617 bGPDlayer *gpl = (bGPDlayer *)ale->data;
2619 /* all flags are just in gpl->flag for now... */
2620 return GET_ACF_FLAG_PTR(gpl->flag, type);
2623 /* grease pencil layer type define */
2624 static bAnimChannelType ACF_GPL =
2626 "GPencil Layer", /* type name */
2627 ACHANNEL_ROLE_CHANNEL, /* role */
2629 acf_generic_channel_color, /* backdrop color */
2630 acf_generic_channel_backdrop, /* backdrop */
2631 acf_generic_indention_flexible, /* indent level */
2632 acf_generic_group_offset, /* offset */
2634 acf_gpl_name, /* name */
2635 acf_gpl_name_prop, /* name prop */
2638 acf_gpl_setting_valid, /* has setting */
2639 acf_gpl_setting_flag, /* flag for setting */
2640 acf_gpl_setting_ptr /* pointer for setting */
2644 /* Mask Datablock ------------------------------------------- */
2646 /* get backdrop color for mask datablock widget */
2647 static void acf_mask_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), float r_color[3])
2649 /* these are ID-blocks, but not exactly standalone... */
2650 UI_GetThemeColorShade3fv(TH_DOPESHEET_CHANNELSUBOB, 20, r_color);
2653 // TODO: just get this from RNA?
2654 static int acf_mask_icon(bAnimListElem *UNUSED(ale))
2656 return ICON_MOD_MASK;
2659 /* check if some setting exists for this channel */
2660 static bool acf_mask_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
2663 /* only select and expand supported */
2664 case ACHANNEL_SETTING_SELECT:
2665 case ACHANNEL_SETTING_EXPAND:
2673 /* get the appropriate flag(s) for the setting when it is valid */
2674 static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
2676 /* clear extra return data first */
2680 case ACHANNEL_SETTING_SELECT: /* selected */
2681 return AGRP_SELECTED;
2683 case ACHANNEL_SETTING_EXPAND: /* expanded */
2684 return MASK_ANIMF_EXPAND;
2687 /* this shouldn't happen */
2692 /* get pointer to the setting */
2693 static void *acf_mask_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
2695 Mask *mask = (Mask *)ale->data;
2697 /* all flags are just in mask->flag for now... */
2698 return GET_ACF_FLAG_PTR(mask->flag, type);
2701 /* mask datablock type define */
2702 static bAnimChannelType ACF_MASKDATA =
2704 "Mask Datablock", /* type name */
2705 ACHANNEL_ROLE_EXPANDER, /* role */
2707 acf_mask_color, /* backdrop color */
2708 acf_group_backdrop, /* backdrop */
2709 acf_generic_indention_0, /* indent level */
2710 acf_generic_group_offset, /* offset */
2712 acf_generic_idblock_name, /* name */
2713 acf_generic_idfill_name_prop, /* name prop */
2714 acf_mask_icon, /* icon */
2716 acf_mask_setting_valid, /* has setting */
2717 acf_mask_setting_flag, /* flag for setting */
2718 acf_mask_setting_ptr /* pointer for setting */
2721 /* Mask Layer ------------------------------------------- */
2723 /* name for grease pencil layer entries */
2724 static void acf_masklay_name(bAnimListElem *ale, char *name)
2726 MaskLayer *masklay = (MaskLayer *)ale->data;
2728 if (masklay && name)
2729 BLI_strncpy(name, masklay->name, ANIM_CHAN_NAME_SIZE);
2732 /* name property for grease pencil layer entries */
2733 static bool acf_masklay_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
2736 RNA_pointer_create(ale->id, &RNA_MaskLayer, ale->data, ptr);
2737 *prop = RNA_struct_name_property(ptr->type);
2739 return (*prop != NULL);
2745 /* check if some setting exists for this channel */
2746 static bool acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), eAnimChannel_Settings setting)
2750 case ACHANNEL_SETTING_EXPAND: /* mask layers are more like F-Curves than groups */
2751 case ACHANNEL_SETTING_VISIBLE: /* graph editor only */
2752 case ACHANNEL_SETTING_SOLO: /* nla editor only */
2755 /* always available */
2761 /* get the appropriate flag(s) for the setting when it is valid */
2762 static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
2764 /* clear extra return data first */
2768 case ACHANNEL_SETTING_SELECT: /* selected */
2769 return MASK_LAYERFLAG_SELECT;
2771 case ACHANNEL_SETTING_PROTECT: /* protected */
2772 return MASK_LAYERFLAG_LOCKED;
2774 default: /* unsupported */
2779 /* get pointer to the setting */
2780 static void *acf_masklay_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
2782 MaskLayer *masklay = (MaskLayer *)ale->data;
2784 /* all flags are just in masklay->flag for now... */
2785 return GET_ACF_FLAG_PTR(masklay->flag, type);
2788 /* grease pencil layer type define */
2789 static bAnimChannelType ACF_MASKLAYER =
2791 "Mask Layer", /* type name */
2792 ACHANNEL_ROLE_CHANNEL, /* role */
2794 acf_generic_channel_color, /* backdrop color */
2795 acf_generic_channel_backdrop, /* backdrop */
2796 acf_generic_indention_flexible, /* indent level */
2797 acf_generic_group_offset, /* offset */
2799 acf_masklay_name, /* name */
2800 acf_masklay_name_prop, /* name prop */
2803 acf_masklay_setting_valid, /* has setting */
2804 acf_masklay_setting_flag, /* flag for setting */
2805 acf_masklay_setting_ptr /* pointer for setting */
2808 /* NLA Track ----------------------------------------------- */
2810 /* get backdrop color for nla track channels */
2811 static void acf_nlatrack_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, float r_color[3])
2813 NlaTrack *nlt = (NlaTrack *)ale->data;
2814 AnimData *adt = ale->adt;
2815 bool nonSolo = false;
2817 /* is track enabled for solo drawing? */
2818 if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) {
2819 if ((nlt->flag & NLATRACK_SOLO) == 0) {
2820 /* tag for special non-solo handling */
2825 /* set color for nla track */
2826 UI_GetThemeColorShade3fv(TH_HEADER, ((nonSolo == false) ? 20 : -20), r_color);
2829 /* name for nla track entries */
2830 static void acf_nlatrack_name(bAnimListElem *ale, char *name)
2832 NlaTrack *nlt = (NlaTrack *)ale->data;
2835 BLI_strncpy(name, nlt->name, ANIM_CHAN_NAME_SIZE);
2838 /* name property for nla track entries */
2839 static bool acf_nlatrack_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
2842 RNA_pointer_create(ale->id, &RNA_NlaTrack, ale->data, ptr);
2843 *prop = RNA_struct_name_property(ptr->type);
2845 return (*prop != NULL);
2851 /* check if some setting exists for this channel */
2852 static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *ale, eAnimChannel_Settings setting)
2854 NlaTrack *nlt = (NlaTrack *)ale->data;
2855 AnimData *adt = ale->adt;
2857 /* visibility of settings depends on various states... */
2859 /* always supported */
2860 case ACHANNEL_SETTING_SELECT:
2861 case ACHANNEL_SETTING_SOLO:
2864 /* conditionally supported... */
2865 case ACHANNEL_SETTING_PROTECT:
2866 case ACHANNEL_SETTING_MUTE:
2867 /* if this track is active and we're tweaking it, don't draw these toggles */
2868 if (((nlt->flag & NLATRACK_ACTIVE) && (nlt->flag & NLATRACK_DISABLED)) == 0) {
2869 /* is track enabled for solo drawing? */
2870 if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) {
2871 if (nlt->flag & NLATRACK_SOLO) {
2872 /* ok - we've got a solo track, and this is it */
2876 /* not ok - we've got a solo track, but this isn't it, so make it more obvious */
2882 /* ok - no tracks are solo'd, and this isn't being tweaked */
2886 /* unsupported - this track is being tweaked */
2896 /* get the appropriate flag(s) for the setting when it is valid */
2897 static int acf_nlatrack_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
2899 /* clear extra return data first */
2903 case ACHANNEL_SETTING_SELECT: /* selected */
2904 return NLATRACK_SELECTED;
2906 case ACHANNEL_SETTING_MUTE: /* muted */
2907 return NLATRACK_MUTED;
2909 case ACHANNEL_SETTING_PROTECT: /* protected */
2910 return NLATRACK_PROTECTED;
2912 case ACHANNEL_SETTING_SOLO: /* solo */
2913 return NLATRACK_SOLO;
2915 default: /* unsupported */
2920 /* get pointer to the setting */
2921 static void *acf_nlatrack_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
2923 NlaTrack *nlt = (NlaTrack *)ale->data;
2924 return GET_ACF_FLAG_PTR(nlt->flag, type);
2927 /* nla track type define */
2928 static bAnimChannelType ACF_NLATRACK =
2930 "NLA Track", /* type name */
2931 ACHANNEL_ROLE_CHANNEL, /* role */
2933 acf_nlatrack_color, /* backdrop color */
2934 acf_generic_channel_backdrop, /* backdrop */
2935 acf_generic_indention_flexible, /* indent level */
2936 acf_generic_group_offset, /* offset */ // XXX?
2938 acf_nlatrack_name, /* name */
2939 acf_nlatrack_name_prop, /* name prop */
2942 acf_nlatrack_setting_valid, /* has setting */
2943 acf_nlatrack_setting_flag, /* flag for setting */
2944 acf_nlatrack_setting_ptr /* pointer for setting */
2947 /* NLA Action ----------------------------------------------- */
2949 /* icon for action depends on whether it's in tweaking mode */
2950 static int acf_nlaaction_icon(bAnimListElem *ale)
2952 AnimData *adt = ale->adt;
2954 /* indicate tweaking-action state by changing the icon... */
2955 if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) {
2956 return ICON_ACTION_TWEAK;
2963 /* Backdrop color for nla action channel
2964 * Although this can't be used directly for NLA Action drawing,
2965 * it is still needed for use behind the RHS toggles
2967 static void acf_nlaaction_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, float r_color[3])
2972 * The alpha values action_get_color returns are only useful for drawing
2973 * strips backgrounds but here we're doing channel list backgrounds instead
2974 * so we ignore that and use our own when needed
2976 nla_action_get_color(ale->adt, (bAction *)ale->data, color);
2978 /* NOTE: since the return types only allow rgb, we cannot do the alpha-blending we'd
2979 * like for the solo-drawing case. Hence, this method isn't actually used for drawing
2980 * most of the channel...
2982 copy_v3_v3(r_color, color);
2985 /* backdrop for nla action channel */
2986 static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
2988 bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
2989 View2D *v2d = &ac->ar->v2d;
2990 AnimData *adt = ale->adt;
2991 short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
2995 * The alpha values action_get_color returns are only useful for drawing
2996 * strips backgrounds but here we're doing channel list backgrounds instead
2997 * so we ignore that and use our own when needed
2999 nla_action_get_color(adt, (bAction *)ale->data, color);
3001 if (adt && (adt->flag & ADT_NLA_EDIT_ON)) {
3002 /* Yes, the color vector has 4 components, BUT we only want to be using 3 of them! */
3006 float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f;
3007 glColor4f(color[0], color[1], color[2], alpha);
3010 /* only on top left corner, to show that this channel sits on top of the preceding ones
3011 * while still linking into the action line strip to the right
3013 uiSetRoundBox(UI_CNR_TOP_LEFT);
3015 /* draw slightly shifted up vertically to look like it has more separation from other channels,
3016 * but we then need to slightly shorten it so that it doesn't look like it overlaps
3018 uiDrawBox(GL_POLYGON, offset, yminc + NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc + NLACHANNEL_SKIP - 1, 8);
3021 /* name for nla action entries */
3022 static void acf_nlaaction_name(bAnimListElem *ale, char *name)
3024 bAction *act = (bAction *)ale->data;
3028 // TODO: add special decoration when doing this in tweaking mode?
3029 BLI_strncpy(name, act->id.name + 2, ANIM_CHAN_NAME_SIZE);
3032 BLI_strncpy(name, "<No Action>", ANIM_CHAN_NAME_SIZE);
3037 /* name property for nla action entries */
3038 static bool acf_nlaaction_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
3041 RNA_pointer_create(ale->id, &RNA_Action, ale->data, ptr);
3042 *prop = RNA_struct_name_property(ptr->type);
3044 return (*prop != NULL);
3050 /* check if some setting exists for this channel */
3051 static bool acf_nlaaction_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *ale, eAnimChannel_Settings setting)
3053 AnimData *adt = ale->adt;
3055 /* visibility of settings depends on various states... */
3057 /* conditionally supported */