4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
21 * All rights reserved.
23 * Contributor(s): Joshua Leung
25 * ***** END GPL LICENSE BLOCK *****
30 #include "MEM_guardedalloc.h"
32 #include "BLI_blenlib.h"
35 #include "DNA_anim_types.h"
36 #include "DNA_armature_types.h"
37 #include "DNA_camera_types.h"
38 #include "DNA_object_types.h"
39 #include "DNA_particle_types.h"
40 #include "DNA_screen_types.h"
41 #include "DNA_scene_types.h"
42 #include "DNA_space_types.h"
43 #include "DNA_key_types.h"
44 #include "DNA_lamp_types.h"
45 #include "DNA_mesh_types.h"
46 #include "DNA_material_types.h"
47 #include "DNA_meta_types.h"
48 #include "DNA_node_types.h"
49 #include "DNA_world_types.h"
51 #include "RNA_access.h"
52 #include "BKE_curve.h"
54 #include "BKE_context.h"
56 #include "UI_interface.h"
57 #include "UI_interface_icons.h"
58 #include "UI_resources.h"
60 #include "ED_anim_api.h"
61 #include "ED_keyframing.h"
68 /* *********************************************** */
69 // XXX constant defines to be moved elsewhere?
71 /* extra padding for lengths (to go under scrollers) */
72 #define EXTRA_SCROLL_PAD 100.0f
74 /* size of indent steps */
75 #define INDENT_STEP_SIZE 7
77 /* macros used for type defines */
78 /* get the pointer used for some flag */
79 #define GET_ACF_FLAG_PTR(ptr) \
81 *type= sizeof((ptr)); \
86 /* *********************************************** */
87 /* Generic Functions (Type independent) */
89 /* Draw Backdrop ---------------------------------- */
91 /* get backdrop color for top-level widgets (Scene and Object only) */
92 static void acf_generic_root_color(bAnimContext *ac, bAnimListElem *ale, float *color)
94 /* darker blue for top-level widgets */
95 UI_GetThemeColor3fv(TH_DOPESHEET_CHANNELOB, color);
98 /* backdrop for top-level widgets (Scene and Object only) */
99 static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
101 bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
102 View2D *v2d= &ac->ar->v2d;
103 short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
104 short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
107 /* set backdrop drawing color */
108 acf->get_backdrop_color(ac, ale, color);
111 /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
112 uiSetRoundBox((expanded)? (1):(1|8));
113 uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8);
117 /* get backdrop color for data expanders under top-level Scene/Object */
118 static void acf_generic_dataexpand_color(bAnimContext *ac, bAnimListElem *ale, float *color)
120 /* lighter color than top-level widget */
121 UI_GetThemeColor3fv(TH_DOPESHEET_CHANNELSUBOB, color);
124 /* backdrop for data expanders under top-level Scene/Object */
125 static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
127 bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
128 View2D *v2d= &ac->ar->v2d;
129 short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
132 /* set backdrop drawing color */
133 acf->get_backdrop_color(ac, ale, color);
136 /* no rounded corner - just rectangular box */
137 glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc);
140 /* get backdrop color for generic channels */
141 static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, float *color)
143 bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
144 SpaceAction *saction = NULL;
145 bActionGroup *grp = NULL;
146 short indent= (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0;
148 /* get context info needed... */
149 if ((ac->sa) && (ac->sa->spacetype == SPACE_ACTION))
150 saction= (SpaceAction *)ac->sa->spacedata.first;
152 if (ale->type == ANIMTYPE_FCURVE) {
153 FCurve *fcu= (FCurve *)ale->data;
157 /* set color for normal channels
158 * - use 3 shades of color group/standard color for 3 indention level
159 * - only use group colors if allowed to, and if actually feasible
161 if ( (saction && !(saction->flag & SACTION_NODRAWGCOLORS)) &&
162 ((grp) && (grp->customCol)) )
167 VECCOPY(cp, grp->cs.solid);
169 else if (indent == 1) {
170 VECCOPY(cp, grp->cs.select);
173 VECCOPY(cp, grp->cs.active);
176 /* copy the colors over, transforming from bytes to floats */
177 rgb_byte_to_float(cp, color);
180 // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)?
181 int colOfs= 20 - 20*indent;
182 UI_GetThemeColorShade3fv(TH_HEADER, colOfs, color);
186 /* backdrop for generic channels */
187 static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
189 bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
190 View2D *v2d= &ac->ar->v2d;
191 short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
194 /* set backdrop drawing color */
195 acf->get_backdrop_color(ac, ale, color);
198 /* no rounded corners - just rectangular box */
199 glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc);
202 /* Indention + Offset ------------------------------------------- */
204 /* indention level is always the value in the name */
205 static short acf_generic_indention_0(bAnimContext *ac, bAnimListElem *ale)
209 static short acf_generic_indention_1(bAnimContext *ac, bAnimListElem *ale)
213 #if 0 // XXX not used
214 static short acf_generic_indention_2(bAnimContext *ac, bAnimListElem *ale)
220 /* indention which varies with the grouping status */
221 static short acf_generic_indention_flexible(bAnimContext *ac, bAnimListElem *ale)
226 /* special exception for materials, textures, and particles */
227 // xxx should tex use indention 2?
228 if (ELEM3(GS(ale->id->name),ID_MA,ID_PA,ID_TE))
232 /* grouped F-Curves need extra level of indention */
233 if (ale->type == ANIMTYPE_FCURVE) {
234 FCurve *fcu= (FCurve *)ale->data;
236 // TODO: we need some way of specifying that the indention color should be one less...
245 /* basic offset for channels derived from indention */
246 static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale)
248 bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
250 if (acf && acf->get_indent_level)
251 return acf->get_indent_level(ac, ale) * INDENT_STEP_SIZE;
256 /* offset for groups + grouped entities */
257 static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale)
259 short offset= acf_generic_basic_offset(ac, ale);
262 /* special exception for textures */
263 if (GS(ale->id->name) == ID_TE) {
267 /* special offset from owner type */
268 switch (ale->ownertype) {
279 /* special exception for materials and particles */
280 else if (ELEM(GS(ale->id->name),ID_MA,ID_PA))
283 /* if not in Action Editor mode, groupings must carry some offset too... */
284 else if (ac->datatype != ANIMCONT_ACTION)
288 /* offset is just the normal type - i.e. based on indention */
292 /* Name ------------------------------------------- */
294 /* name for ID block entries */
295 static void acf_generic_idblock_name(bAnimListElem *ale, char *name)
297 ID *id= (ID *)ale->data; /* data pointed to should be an ID block */
299 /* just copy the name... */
301 strcpy(name, id->name+2);
304 /* Settings ------------------------------------------- */
307 /* channel type has no settings */
308 static short acf_generic_none_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
314 /* check if some setting exists for this object-based data-expander (category only) */
315 static short acf_generic_dsexpand_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
318 /* only expand supported everywhere */
319 case ACHANNEL_SETTING_EXPAND:
323 * - only available in Graph Editor
324 * - NOT available for 'filler' channels
326 case ACHANNEL_SETTING_VISIBLE:
327 if (ELEM3(ale->type, ANIMTYPE_FILLMATD, ANIMTYPE_FILLPARTD, ANIMTYPE_FILLTEXD))
330 return ((ac) && (ac->spacetype == SPACE_IPO));
337 /* get pointer to the setting (category only) */
338 static void *acf_generic_dsexpand_setting_ptr(bAnimListElem *ale, int setting, short *type)
340 Object *ob= (Object *)ale->data;
342 /* clear extra return data first */
346 case ACHANNEL_SETTING_EXPAND: /* expanded */
347 GET_ACF_FLAG_PTR(ob->nlaflag); // XXX
349 default: /* unsupported */
354 /* check if some setting exists for this object-based data-expander (datablock only) */
355 static short acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
358 /* expand is always supported */
359 case ACHANNEL_SETTING_EXPAND:
362 /* mute is only supported for NLA */
363 case ACHANNEL_SETTING_MUTE:
364 return ((ac) && (ac->spacetype == SPACE_NLA));
366 /* other flags are never supported */
372 /* *********************************************** */
373 /* Type Specific Functions + Defines */
375 /* Animation Summary ----------------------------------- */
377 /* get backdrop color for summary widget */
378 static void acf_summary_color(bAnimContext *ac, bAnimListElem *ale, float *color)
380 // FIXME: hardcoded color - same as the 'action' line in NLA
387 /* backdrop for summary widget */
388 static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
390 bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
391 View2D *v2d= &ac->ar->v2d;
394 /* set backdrop drawing color */
395 acf->get_backdrop_color(ac, ale, color);
398 /* rounded corners on LHS only
400 * - special hack: make the top a bit higher, since we are first...
402 uiSetRoundBox((1|8));
403 uiDrawBox(GL_POLYGON, 0, yminc-2, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8);
406 /* name for summary entries */
407 static void acf_summary_name(bAnimListElem *ale, char *name)
410 strcpy(name, "DopeSheet Summary");
413 // TODO: this is really a temp icon I think
414 static int acf_summary_icon(bAnimListElem *ale)
416 return ICON_BORDERMOVE;
419 /* check if some setting exists for this channel */
420 static short acf_summary_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
422 /* only expanded is supported, as it is used for hiding all stuff which the summary covers */
423 return (setting == ACHANNEL_SETTING_EXPAND);
426 /* get the appropriate flag(s) for the setting when it is valid */
427 static int acf_summary_setting_flag(bAnimContext *ac, int setting, short *neg)
429 if (setting == ACHANNEL_SETTING_EXPAND) {
432 return ADS_FLAG_SUMMARY_COLLAPSED;
441 /* get pointer to the setting */
442 static void *acf_summary_setting_ptr(bAnimListElem *ale, int setting, short *type)
444 bAnimContext *ac= (bAnimContext *)ale->data;
446 /* if data is valid, return pointer to active dopesheet's relevant flag
447 * - this is restricted to DopeSheet/Action Editor only
449 if ((ac->sa) && (ac->spacetype == SPACE_ACTION) && (setting == ACHANNEL_SETTING_EXPAND)) {
450 SpaceAction *saction= (SpaceAction *)ac->sa->spacedata.first;
451 bDopeSheet *ads= &saction->ads;
453 /* return pointer to DopeSheet's flag */
454 GET_ACF_FLAG_PTR(ads->flag);
457 /* can't return anything useful - unsupported */
463 /* all animation summary (DopeSheet only) type define */
464 static bAnimChannelType ACF_SUMMARY =
466 "Summary", /* type name */
468 acf_summary_color, /* backdrop color */
469 acf_summary_backdrop, /* backdrop */
470 acf_generic_indention_0, /* indent level */
473 acf_summary_name, /* name */
474 acf_summary_icon, /* icon */
476 acf_summary_setting_valid, /* has setting */
477 acf_summary_setting_flag, /* flag for setting */
478 acf_summary_setting_ptr /* pointer for setting */
481 /* Scene ------------------------------------------- */
483 // TODO: just get this from RNA?
484 static int acf_scene_icon(bAnimListElem *ale)
486 return ICON_SCENE_DATA;
489 /* check if some setting exists for this channel */
490 static short acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
493 /* muted only in NLA */
494 case ACHANNEL_SETTING_MUTE:
495 return ((ac) && (ac->spacetype == SPACE_NLA));
497 /* visible only in Graph Editor */
498 case ACHANNEL_SETTING_VISIBLE:
499 return ((ac) && (ac->spacetype == SPACE_IPO));
501 /* only select and expand supported otherwise */
502 case ACHANNEL_SETTING_SELECT:
503 case ACHANNEL_SETTING_EXPAND:
511 /* get the appropriate flag(s) for the setting when it is valid */
512 static int acf_scene_setting_flag(bAnimContext *ac, int setting, short *neg)
514 /* clear extra return data first */
518 case ACHANNEL_SETTING_SELECT: /* selected */
519 return SCE_DS_SELECTED;
521 case ACHANNEL_SETTING_EXPAND: /* expanded */
523 return SCE_DS_COLLAPSED;
525 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
526 return ADT_NLA_EVAL_OFF;
528 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
530 return ADT_CURVES_NOT_VISIBLE;
532 default: /* unsupported */
537 /* get pointer to the setting */
538 static void *acf_scene_setting_ptr(bAnimListElem *ale, int setting, short *type)
540 Scene *scene= (Scene *)ale->data;
542 /* clear extra return data first */
546 case ACHANNEL_SETTING_SELECT: /* selected */
547 GET_ACF_FLAG_PTR(scene->flag);
549 case ACHANNEL_SETTING_EXPAND: /* expanded */
550 GET_ACF_FLAG_PTR(scene->flag);
552 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
553 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
555 GET_ACF_FLAG_PTR(scene->adt->flag)
559 default: /* unsupported */
564 /* scene type define */
565 static bAnimChannelType ACF_SCENE =
567 "Scene", /* type name */
569 acf_generic_root_color, /* backdrop color */
570 acf_generic_root_backdrop, /* backdrop */
571 acf_generic_indention_0, /* indent level */
574 acf_generic_idblock_name, /* name */
575 acf_scene_icon, /* icon */
577 acf_scene_setting_valid, /* has setting */
578 acf_scene_setting_flag, /* flag for setting */
579 acf_scene_setting_ptr /* pointer for setting */
582 /* Object ------------------------------------------- */
584 static int acf_object_icon(bAnimListElem *ale)
586 Base *base= (Base *)ale->data;
587 Object *ob= base->object;
589 /* icon depends on object-type */
593 return ICON_OUTLINER_OB_LAMP;
595 return ICON_OUTLINER_OB_MESH;
597 return ICON_OUTLINER_OB_CAMERA;
599 return ICON_OUTLINER_OB_CURVE;
601 return ICON_OUTLINER_OB_META;
603 return ICON_OUTLINER_OB_LATTICE;
605 return ICON_OUTLINER_OB_ARMATURE;
607 return ICON_OUTLINER_OB_FONT;
609 return ICON_OUTLINER_OB_SURFACE;
611 return ICON_OUTLINER_OB_EMPTY;
613 return ICON_OBJECT_DATA;
618 /* name for object */
619 static void acf_object_name(bAnimListElem *ale, char *name)
621 Base *base= (Base *)ale->data;
622 Object *ob= base->object;
624 /* just copy the name... */
626 strcpy(name, ob->id.name+2);
629 /* check if some setting exists for this channel */
630 static short acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
632 Base *base= (Base *)ale->data;
633 Object *ob= base->object;
636 /* muted only in NLA */
637 case ACHANNEL_SETTING_MUTE:
638 return ((ac) && (ac->spacetype == SPACE_NLA));
640 /* visible only in Graph Editor */
641 case ACHANNEL_SETTING_VISIBLE:
642 return ((ac) && (ac->spacetype == SPACE_IPO) && (ob->adt));
644 /* only select and expand supported otherwise */
645 case ACHANNEL_SETTING_SELECT:
646 case ACHANNEL_SETTING_EXPAND:
654 /* get the appropriate flag(s) for the setting when it is valid */
655 static int acf_object_setting_flag(bAnimContext *ac, int setting, short *neg)
657 /* clear extra return data first */
661 case ACHANNEL_SETTING_SELECT: /* selected */
664 case ACHANNEL_SETTING_EXPAND: /* expanded */
666 return OB_ADS_COLLAPSED;
668 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
669 return ADT_NLA_EVAL_OFF;
671 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
673 return ADT_CURVES_NOT_VISIBLE;
675 default: /* unsupported */
680 /* get pointer to the setting */
681 static void *acf_object_setting_ptr(bAnimListElem *ale, int setting, short *type)
683 Base *base= (Base *)ale->data;
684 Object *ob= base->object;
686 /* clear extra return data first */
690 case ACHANNEL_SETTING_SELECT: /* selected */
691 GET_ACF_FLAG_PTR(ob->flag);
693 case ACHANNEL_SETTING_EXPAND: /* expanded */
694 GET_ACF_FLAG_PTR(ob->nlaflag); // xxx
696 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
697 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
699 GET_ACF_FLAG_PTR(ob->adt->flag)
703 default: /* unsupported */
708 /* object type define */
709 static bAnimChannelType ACF_OBJECT =
711 "Object", /* type name */
713 acf_generic_root_color, /* backdrop color */
714 acf_generic_root_backdrop, /* backdrop */
715 acf_generic_indention_0, /* indent level */
718 acf_object_name, /* name */
719 acf_object_icon, /* icon */
721 acf_object_setting_valid, /* has setting */
722 acf_object_setting_flag, /* flag for setting */
723 acf_object_setting_ptr /* pointer for setting */
726 /* Group ------------------------------------------- */
728 /* get backdrop color for group widget */
729 static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float *color)
731 /* highlight only for action group channels */
732 if (ale->flag & AGRP_ACTIVE)
733 UI_GetThemeColorShade3fv(TH_GROUP_ACTIVE, 10, color);
735 UI_GetThemeColorShade3fv(TH_GROUP, 20, color);
738 /* backdrop for group widget */
739 static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
741 bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
742 View2D *v2d= &ac->ar->v2d;
743 short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
744 short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
747 /* set backdrop drawing color */
748 acf->get_backdrop_color(ac, ale, color);
751 /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
752 uiSetRoundBox((expanded)? (1):(1|8));
753 uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8);
756 /* name for group entries */
757 static void acf_group_name(bAnimListElem *ale, char *name)
759 bActionGroup *agrp= (bActionGroup *)ale->data;
761 /* just copy the name... */
763 strcpy(name, agrp->name);
766 /* check if some setting exists for this channel */
767 static short acf_group_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
769 /* for now, all settings are supported, though some are only conditionally */
771 case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
772 return ((ac->sa) && (ac->sa->spacetype==SPACE_IPO));
774 default: /* always supported */
779 /* get the appropriate flag(s) for the setting when it is valid */
780 static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg)
782 /* clear extra return data first */
786 case ACHANNEL_SETTING_SELECT: /* selected */
787 return AGRP_SELECTED;
789 case ACHANNEL_SETTING_EXPAND: /* expanded */
791 /* NOTE: Graph Editor uses a different flag to everywhere else for this,
792 * allowing different collapsing of groups there, since sharing the flag
793 * proved to be a hazard for workflows...
795 return (ac->spacetype == SPACE_IPO) ?
796 AGRP_EXPANDED_G : /* Graph Editor case */
797 AGRP_EXPANDED; /* DopeSheet and elsewhere */
800 case ACHANNEL_SETTING_MUTE: /* muted */
803 case ACHANNEL_SETTING_PROTECT: /* protected */
804 //*neg= 1; - if we change this to edtiability
805 return AGRP_PROTECTED;
807 case ACHANNEL_SETTING_VISIBLE: /* visiblity - graph editor */
809 return AGRP_NOTVISIBLE;
812 /* this shouldn't happen */
816 /* get pointer to the setting */
817 static void *acf_group_setting_ptr(bAnimListElem *ale, int setting, short *type)
819 bActionGroup *agrp= (bActionGroup *)ale->data;
821 /* all flags are just in agrp->flag for now... */
822 GET_ACF_FLAG_PTR(agrp->flag);
825 /* group type define */
826 static bAnimChannelType ACF_GROUP =
828 "Group", /* type name */
830 acf_group_color, /* backdrop color */
831 acf_group_backdrop, /* backdrop */
832 acf_generic_indention_0, /* indent level */
833 acf_generic_group_offset, /* offset */
835 acf_group_name, /* name */
838 acf_group_setting_valid, /* has setting */
839 acf_group_setting_flag, /* flag for setting */
840 acf_group_setting_ptr /* pointer for setting */
843 /* F-Curve ------------------------------------------- */
845 /* name for fcurve entries */
846 static void acf_fcurve_name(bAnimListElem *ale, char *name)
848 getname_anim_fcurve(name, ale->id, ale->data);
851 /* check if some setting exists for this channel */
852 static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
854 FCurve *fcu= (FCurve *)ale->data;
858 case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */
861 /* conditionally available */
862 case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */
866 return 0; // NOTE: in this special case, we need to draw ICON_ZOOMOUT
868 case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
869 return ((ac->sa) && (ac->sa->spacetype==SPACE_IPO));
871 /* always available */
877 /* get the appropriate flag(s) for the setting when it is valid */
878 static int acf_fcurve_setting_flag(bAnimContext *ac, int setting, short *neg)
880 /* clear extra return data first */
884 case ACHANNEL_SETTING_SELECT: /* selected */
885 return FCURVE_SELECTED;
887 case ACHANNEL_SETTING_MUTE: /* muted */
890 case ACHANNEL_SETTING_PROTECT: /* protected */
891 //*neg= 1; - if we change this to edtiability
892 return FCURVE_PROTECTED;
894 case ACHANNEL_SETTING_VISIBLE: /* visiblity - graph editor */
895 return FCURVE_VISIBLE;
897 default: /* unsupported */
902 /* get pointer to the setting */
903 static void *acf_fcurve_setting_ptr(bAnimListElem *ale, int setting, short *type)
905 FCurve *fcu= (FCurve *)ale->data;
907 /* all flags are just in agrp->flag for now... */
908 GET_ACF_FLAG_PTR(fcu->flag);
911 /* fcurve type define */
912 static bAnimChannelType ACF_FCURVE =
914 "F-Curve", /* type name */
916 acf_generic_channel_color, /* backdrop color */
917 acf_generic_channel_backdrop, /* backdrop */
918 acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only?
919 acf_generic_group_offset, /* offset */
921 acf_fcurve_name, /* name */
924 acf_fcurve_setting_valid, /* has setting */
925 acf_fcurve_setting_flag, /* flag for setting */
926 acf_fcurve_setting_ptr /* pointer for setting */
929 /* Object Action Expander ------------------------------------------- */
931 // TODO: just get this from RNA?
932 static int acf_fillactd_icon(bAnimListElem *ale)
937 /* check if some setting exists for this channel */
938 static short acf_fillactd_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
941 /* only select and expand supported */
942 case ACHANNEL_SETTING_SELECT:
943 case ACHANNEL_SETTING_EXPAND:
951 /* get the appropriate flag(s) for the setting when it is valid */
952 static int acf_fillactd_setting_flag(bAnimContext *ac, int setting, short *neg)
954 /* clear extra return data first */
958 case ACHANNEL_SETTING_SELECT: /* selected */
959 return ADT_UI_SELECTED;
961 case ACHANNEL_SETTING_EXPAND: /* expanded */
963 return ACT_COLLAPSED;
965 default: /* unsupported */
970 /* get pointer to the setting */
971 static void *acf_fillactd_setting_ptr(bAnimListElem *ale, int setting, short *type)
973 bAction *act= (bAction *)ale->data;
974 AnimData *adt= ale->adt;
976 /* clear extra return data first */
980 case ACHANNEL_SETTING_SELECT: /* selected */
982 GET_ACF_FLAG_PTR(adt->flag);
987 case ACHANNEL_SETTING_EXPAND: /* expanded */
988 GET_ACF_FLAG_PTR(act->flag);
990 default: /* unsupported */
995 /* object action expander type define */
996 static bAnimChannelType ACF_FILLACTD =
998 "Ob-Action Filler", /* type name */
1000 acf_generic_dataexpand_color, /* backdrop color */
1001 acf_generic_dataexpand_backdrop,/* backdrop */
1002 acf_generic_indention_1, /* indent level */
1003 acf_generic_basic_offset, /* offset */
1005 acf_generic_idblock_name, /* name */
1006 acf_fillactd_icon, /* icon */
1008 acf_fillactd_setting_valid, /* has setting */
1009 acf_fillactd_setting_flag, /* flag for setting */
1010 acf_fillactd_setting_ptr /* pointer for setting */
1013 /* Drivers Expander ------------------------------------------- */
1015 // TODO: just get this from RNA?
1016 static int acf_filldrivers_icon(bAnimListElem *ale)
1018 return ICON_ANIM_DATA;
1021 static void acf_filldrivers_name(bAnimListElem *ale, char *name)
1023 strcpy(name, "Drivers");
1026 /* check if some setting exists for this channel */
1027 // TODO: this could be made more generic
1028 static short acf_filldrivers_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
1031 /* only expand supported */
1032 case ACHANNEL_SETTING_EXPAND:
1040 /* get the appropriate flag(s) for the setting when it is valid */
1041 static int acf_filldrivers_setting_flag(bAnimContext *ac, int setting, short *neg)
1043 /* clear extra return data first */
1047 case ACHANNEL_SETTING_EXPAND: /* expanded */
1049 return ADT_DRIVERS_COLLAPSED;
1051 default: /* unsupported */
1056 /* get pointer to the setting */
1057 static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, int setting, short *type)
1059 AnimData *adt= (AnimData *)ale->data;
1061 /* clear extra return data first */
1065 case ACHANNEL_SETTING_EXPAND: /* expanded */
1066 GET_ACF_FLAG_PTR(adt->flag);
1068 default: /* unsupported */
1073 /* drivers expander type define */
1074 static bAnimChannelType ACF_FILLDRIVERS =
1076 "Drivers Filler", /* type name */
1078 acf_generic_dataexpand_color, /* backdrop color */
1079 acf_generic_dataexpand_backdrop,/* backdrop */
1080 acf_generic_indention_1, /* indent level */
1081 acf_generic_basic_offset, /* offset */
1083 acf_filldrivers_name, /* name */
1084 acf_filldrivers_icon, /* icon */
1086 acf_filldrivers_setting_valid, /* has setting */
1087 acf_filldrivers_setting_flag, /* flag for setting */
1088 acf_filldrivers_setting_ptr /* pointer for setting */
1091 /* Materials Expander ------------------------------------------- */
1093 // TODO: just get this from RNA?
1094 static int acf_fillmatd_icon(bAnimListElem *ale)
1096 return ICON_MATERIAL_DATA;
1099 static void acf_fillmatd_name(bAnimListElem *ale, char *name)
1101 strcpy(name, "Materials");
1104 /* get the appropriate flag(s) for the setting when it is valid */
1105 static int acf_fillmatd_setting_flag(bAnimContext *ac, int setting, short *neg)
1107 /* clear extra return data first */
1111 case ACHANNEL_SETTING_EXPAND: /* expanded */
1112 return OB_ADS_SHOWMATS;
1114 default: /* unsupported */
1119 /* materials expander type define */
1120 static bAnimChannelType ACF_FILLMATD=
1122 "Materials Filler", /* type name */
1124 acf_generic_dataexpand_color, /* backdrop color */
1125 acf_generic_dataexpand_backdrop,/* backdrop */
1126 acf_generic_indention_1, /* indent level */
1127 acf_generic_basic_offset, /* offset */
1129 acf_fillmatd_name, /* name */
1130 acf_fillmatd_icon, /* icon */
1132 acf_generic_dsexpand_setting_valid, /* has setting */
1133 acf_fillmatd_setting_flag, /* flag for setting */
1134 acf_generic_dsexpand_setting_ptr /* pointer for setting */
1137 /* Particles Expander ------------------------------------------- */
1139 // TODO: just get this from RNA?
1140 static int acf_fillpartd_icon(bAnimListElem *ale)
1142 return ICON_PARTICLE_DATA;
1145 static void acf_fillpartd_name(bAnimListElem *ale, char *name)
1147 strcpy(name, "Particles");
1150 /* get the appropriate flag(s) for the setting when it is valid */
1151 static int acf_fillpartd_setting_flag(bAnimContext *ac, int setting, short *neg)
1153 /* clear extra return data first */
1157 case ACHANNEL_SETTING_EXPAND: /* expanded */
1158 return OB_ADS_SHOWPARTS;
1160 default: /* unsupported */
1165 /* particles expander type define */
1166 static bAnimChannelType ACF_FILLPARTD=
1168 "Particles Filler", /* type name */
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_fillpartd_name, /* name */
1176 acf_fillpartd_icon, /* icon */
1178 acf_generic_dsexpand_setting_valid, /* has setting */
1179 acf_fillpartd_setting_flag, /* flag for setting */
1180 acf_generic_dsexpand_setting_ptr /* pointer for setting */
1183 /* Textures Expander ------------------------------------------- */
1185 /* offset for groups + grouped entities */
1186 static short acf_filltexd_offset(bAnimContext *ac, bAnimListElem *ale)
1188 short offset= acf_generic_basic_offset(ac, ale);
1192 switch (GS(ale->id->name)) {
1207 // TODO: just get this from RNA?
1208 static int acf_filltexd_icon(bAnimListElem *ale)
1210 return ICON_TEXTURE_DATA;
1213 static void acf_filltexd_name(bAnimListElem *ale, char *name)
1215 strcpy(name, "Textures");
1218 /* get pointer to the setting (category only) */
1219 static void *acf_filltexd_setting_ptr(bAnimListElem *ale, int setting, short *type)
1221 ID *id= (ID *)ale->data;
1223 /* clear extra return data first */
1227 case ACHANNEL_SETTING_EXPAND: /* expanded */
1229 switch (GS(id->name)) {
1232 Material *ma= (Material *)id;
1233 GET_ACF_FLAG_PTR(ma->flag);
1238 Lamp *la= (Lamp *)id;
1239 GET_ACF_FLAG_PTR(la->flag);
1244 World *wo= (World *)id;
1245 GET_ACF_FLAG_PTR(wo->flag);
1250 default: /* unsupported */
1255 /* get the appropriate flag(s) for the setting when it is valid */
1256 static int acf_filltexd_setting_flag(bAnimContext *ac, int setting, short *neg)
1258 /* clear extra return data first */
1262 case ACHANNEL_SETTING_EXPAND: /* expanded */
1263 /* NOTE: the exact same flag must be used for other texture stack types too! */
1264 return MA_DS_SHOW_TEXS;
1266 default: /* unsupported */
1271 /* particles expander type define */
1272 static bAnimChannelType ACF_FILLTEXD=
1274 "Textures Filler", /* type name */
1276 acf_generic_dataexpand_color, /* backdrop color */
1277 acf_generic_dataexpand_backdrop,/* backdrop */
1278 acf_generic_indention_flexible, /* indent level */
1279 acf_filltexd_offset, /* offset */
1281 acf_filltexd_name, /* name */
1282 acf_filltexd_icon, /* icon */
1284 acf_generic_dsexpand_setting_valid, /* has setting */
1285 acf_filltexd_setting_flag, /* flag for setting */
1286 acf_filltexd_setting_ptr /* pointer for setting */
1289 /* Material Expander ------------------------------------------- */
1291 // TODO: just get this from RNA?
1292 static int acf_dsmat_icon(bAnimListElem *ale)
1294 return ICON_MATERIAL_DATA;
1297 /* offset for material expanders */
1298 static short acf_dsmat_offset(bAnimContext *ac, bAnimListElem *ale)
1303 /* get the appropriate flag(s) for the setting when it is valid */
1304 static int acf_dsmat_setting_flag(bAnimContext *ac, int setting, short *neg)
1306 /* clear extra return data first */
1310 case ACHANNEL_SETTING_EXPAND: /* expanded */
1311 return MA_DS_EXPAND;
1313 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1314 return ADT_NLA_EVAL_OFF;
1316 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1318 return ADT_CURVES_NOT_VISIBLE;
1320 case ACHANNEL_SETTING_SELECT: /* selected */
1321 return ADT_UI_SELECTED;
1323 default: /* unsupported */
1328 /* get pointer to the setting */
1329 static void *acf_dsmat_setting_ptr(bAnimListElem *ale, int setting, short *type)
1331 Material *ma= (Material *)ale->data;
1333 /* clear extra return data first */
1337 case ACHANNEL_SETTING_EXPAND: /* expanded */
1338 GET_ACF_FLAG_PTR(ma->flag);
1340 case ACHANNEL_SETTING_SELECT: /* selected */
1341 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1342 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1344 GET_ACF_FLAG_PTR(ma->adt->flag)
1348 default: /* unsupported */
1353 /* material expander type define */
1354 static bAnimChannelType ACF_DSMAT=
1356 "Material Data Expander", /* type name */
1358 acf_generic_channel_color, /* backdrop color */
1359 acf_generic_channel_backdrop, /* backdrop */
1360 acf_generic_indention_0, /* indent level */
1361 acf_dsmat_offset, /* offset */
1363 acf_generic_idblock_name, /* name */
1364 acf_dsmat_icon, /* icon */
1366 acf_generic_dataexpand_setting_valid, /* has setting */
1367 acf_dsmat_setting_flag, /* flag for setting */
1368 acf_dsmat_setting_ptr /* pointer for setting */
1371 /* Lamp Expander ------------------------------------------- */
1373 // TODO: just get this from RNA?
1374 static int acf_dslam_icon(bAnimListElem *ale)
1376 return ICON_LAMP_DATA;
1379 /* get the appropriate flag(s) for the setting when it is valid */
1380 static int acf_dslam_setting_flag(bAnimContext *ac, int setting, short *neg)
1382 /* clear extra return data first */
1386 case ACHANNEL_SETTING_EXPAND: /* expanded */
1387 return LA_DS_EXPAND;
1389 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1390 return ADT_NLA_EVAL_OFF;
1392 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1394 return ADT_CURVES_NOT_VISIBLE;
1396 case ACHANNEL_SETTING_SELECT: /* selected */
1397 return ADT_UI_SELECTED;
1399 default: /* unsupported */
1404 /* get pointer to the setting */
1405 static void *acf_dslam_setting_ptr(bAnimListElem *ale, int setting, short *type)
1407 Lamp *la= (Lamp *)ale->data;
1409 /* clear extra return data first */
1413 case ACHANNEL_SETTING_EXPAND: /* expanded */
1414 GET_ACF_FLAG_PTR(la->flag);
1416 case ACHANNEL_SETTING_SELECT: /* selected */
1417 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1418 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1420 GET_ACF_FLAG_PTR(la->adt->flag)
1424 default: /* unsupported */
1429 /* lamp expander type define */
1430 static bAnimChannelType ACF_DSLAM=
1432 "Lamp Expander", /* type name */
1434 acf_generic_dataexpand_color, /* backdrop color */
1435 acf_generic_dataexpand_backdrop,/* backdrop */
1436 acf_generic_indention_1, /* indent level */
1437 acf_generic_basic_offset, /* offset */
1439 acf_generic_idblock_name, /* name */
1440 acf_dslam_icon, /* icon */
1442 acf_generic_dataexpand_setting_valid, /* has setting */
1443 acf_dslam_setting_flag, /* flag for setting */
1444 acf_dslam_setting_ptr /* pointer for setting */
1447 /* Texture Expander ------------------------------------------- */
1449 // TODO: just get this from RNA?
1450 static int acf_dstex_icon(bAnimListElem *ale)
1452 return ICON_TEXTURE_DATA;
1455 /* offset for texture expanders */
1456 static short acf_dstex_offset(bAnimContext *ac, bAnimListElem *ale)
1460 /* special offset from owner type */
1461 // FIXME: too much now!
1462 switch (ale->ownertype) {
1463 case ANIMTYPE_DSMAT:
1466 case ANIMTYPE_DSLAM:
1467 case ANIMTYPE_DSWOR:
1474 /* get the appropriate flag(s) for the setting when it is valid */
1475 static int acf_dstex_setting_flag(bAnimContext *ac, int setting, short *neg)
1477 /* clear extra return data first */
1481 case ACHANNEL_SETTING_EXPAND: /* expanded */
1482 return TEX_DS_EXPAND;
1484 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1485 return ADT_NLA_EVAL_OFF;
1487 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1489 return ADT_CURVES_NOT_VISIBLE;
1491 case ACHANNEL_SETTING_SELECT: /* selected */
1492 return ADT_UI_SELECTED;
1494 default: /* unsupported */
1499 /* get pointer to the setting */
1500 static void *acf_dstex_setting_ptr(bAnimListElem *ale, int setting, short *type)
1502 Tex *tex= (Tex *)ale->data;
1504 /* clear extra return data first */
1508 case ACHANNEL_SETTING_EXPAND: /* expanded */
1509 GET_ACF_FLAG_PTR(tex->flag);
1511 case ACHANNEL_SETTING_SELECT: /* selected */
1512 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1513 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1515 GET_ACF_FLAG_PTR(tex->adt->flag)
1519 default: /* unsupported */
1524 /* material expander type define */
1525 static bAnimChannelType ACF_DSTEX=
1527 "Texture Data Expander", /* type name */
1529 acf_generic_channel_color, /* backdrop color */
1530 acf_generic_channel_backdrop, /* backdrop */
1531 acf_generic_indention_0, /* indent level */
1532 acf_dstex_offset, /* offset */
1534 acf_generic_idblock_name, /* name */
1535 acf_dstex_icon, /* icon */
1537 acf_generic_dataexpand_setting_valid, /* has setting */
1538 acf_dstex_setting_flag, /* flag for setting */
1539 acf_dstex_setting_ptr /* pointer for setting */
1542 /* Camera Expander ------------------------------------------- */
1544 // TODO: just get this from RNA?
1545 static int acf_dscam_icon(bAnimListElem *ale)
1547 return ICON_CAMERA_DATA;
1550 /* get the appropriate flag(s) for the setting when it is valid */
1551 static int acf_dscam_setting_flag(bAnimContext *ac, int setting, short *neg)
1553 /* clear extra return data first */
1557 case ACHANNEL_SETTING_EXPAND: /* expanded */
1558 return CAM_DS_EXPAND;
1560 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1561 return ADT_NLA_EVAL_OFF;
1563 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1565 return ADT_CURVES_NOT_VISIBLE;
1567 case ACHANNEL_SETTING_SELECT: /* selected */
1568 return ADT_UI_SELECTED;
1570 default: /* unsupported */
1575 /* get pointer to the setting */
1576 static void *acf_dscam_setting_ptr(bAnimListElem *ale, int setting, short *type)
1578 Camera *ca= (Camera *)ale->data;
1580 /* clear extra return data first */
1584 case ACHANNEL_SETTING_EXPAND: /* expanded */
1585 GET_ACF_FLAG_PTR(ca->flag);
1587 case ACHANNEL_SETTING_SELECT: /* selected */
1588 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1589 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1591 GET_ACF_FLAG_PTR(ca->adt->flag)
1595 default: /* unsupported */
1600 /* camera expander type define */
1601 static bAnimChannelType ACF_DSCAM=
1603 "Camera Expander", /* type name */
1605 acf_generic_dataexpand_color, /* backdrop color */
1606 acf_generic_dataexpand_backdrop,/* backdrop */
1607 acf_generic_indention_1, /* indent level */
1608 acf_generic_basic_offset, /* offset */
1610 acf_generic_idblock_name, /* name */
1611 acf_dscam_icon, /* icon */
1613 acf_generic_dataexpand_setting_valid, /* has setting */
1614 acf_dscam_setting_flag, /* flag for setting */
1615 acf_dscam_setting_ptr /* pointer for setting */
1618 /* Curve Expander ------------------------------------------- */
1620 // TODO: just get this from RNA?
1621 static int acf_dscur_icon(bAnimListElem *ale)
1623 Curve *cu= (Curve *)ale->data;
1624 short obtype= curve_type(cu);
1628 return ICON_FONT_DATA;
1630 return ICON_SURFACE_DATA;
1632 return ICON_CURVE_DATA;
1636 /* get the appropriate flag(s) for the setting when it is valid */
1637 static int acf_dscur_setting_flag(bAnimContext *ac, int setting, short *neg)
1639 /* clear extra return data first */
1643 case ACHANNEL_SETTING_EXPAND: /* expanded */
1644 return CU_DS_EXPAND;
1646 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1647 return ADT_NLA_EVAL_OFF;
1649 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1651 return ADT_CURVES_NOT_VISIBLE;
1653 case ACHANNEL_SETTING_SELECT: /* selected */
1654 return ADT_UI_SELECTED;
1656 default: /* unsupported */
1661 /* get pointer to the setting */
1662 static void *acf_dscur_setting_ptr(bAnimListElem *ale, int setting, short *type)
1664 Curve *cu= (Curve *)ale->data;
1666 /* clear extra return data first */
1670 case ACHANNEL_SETTING_EXPAND: /* expanded */
1671 GET_ACF_FLAG_PTR(cu->flag);
1673 case ACHANNEL_SETTING_SELECT: /* selected */
1674 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1675 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1677 GET_ACF_FLAG_PTR(cu->adt->flag)
1681 default: /* unsupported */
1686 /* curve expander type define */
1687 static bAnimChannelType ACF_DSCUR=
1689 "Curve Expander", /* type name */
1691 acf_generic_dataexpand_color, /* backdrop color */
1692 acf_generic_dataexpand_backdrop,/* backdrop */
1693 acf_generic_indention_1, /* indent level */
1694 acf_generic_basic_offset, /* offset */
1696 acf_generic_idblock_name, /* name */
1697 acf_dscur_icon, /* icon */
1699 acf_generic_dataexpand_setting_valid, /* has setting */
1700 acf_dscur_setting_flag, /* flag for setting */
1701 acf_dscur_setting_ptr /* pointer for setting */
1704 /* Shape Key Expander ------------------------------------------- */
1706 // TODO: just get this from RNA?
1707 static int acf_dsskey_icon(bAnimListElem *ale)
1709 return ICON_SHAPEKEY_DATA;
1712 /* get the appropriate flag(s) for the setting when it is valid */
1713 static int acf_dsskey_setting_flag(bAnimContext *ac, int setting, short *neg)
1715 /* clear extra return data first */
1719 case ACHANNEL_SETTING_EXPAND: /* expanded */
1720 return KEY_DS_EXPAND;
1722 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1723 return ADT_NLA_EVAL_OFF;
1725 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1727 return ADT_CURVES_NOT_VISIBLE;
1729 case ACHANNEL_SETTING_SELECT: /* selected */
1730 return ADT_UI_SELECTED;
1732 default: /* unsupported */
1737 /* get pointer to the setting */
1738 static void *acf_dsskey_setting_ptr(bAnimListElem *ale, int setting, short *type)
1740 Key *key= (Key *)ale->data;
1742 /* clear extra return data first */
1746 case ACHANNEL_SETTING_EXPAND: /* expanded */
1747 GET_ACF_FLAG_PTR(key->flag);
1749 case ACHANNEL_SETTING_SELECT: /* selected */
1750 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1751 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1753 GET_ACF_FLAG_PTR(key->adt->flag)
1757 default: /* unsupported */
1762 /* shapekey expander type define */
1763 static bAnimChannelType ACF_DSSKEY=
1765 "Shape Key Expander", /* type name */
1767 acf_generic_dataexpand_color, /* backdrop color */
1768 acf_generic_dataexpand_backdrop,/* backdrop */
1769 acf_generic_indention_1, /* indent level */
1770 acf_generic_basic_offset, /* offset */
1772 acf_generic_idblock_name, /* name */
1773 acf_dsskey_icon, /* icon */
1775 acf_generic_dataexpand_setting_valid, /* has setting */
1776 acf_dsskey_setting_flag, /* flag for setting */
1777 acf_dsskey_setting_ptr /* pointer for setting */
1780 /* World Expander ------------------------------------------- */
1782 // TODO: just get this from RNA?
1783 static int acf_dswor_icon(bAnimListElem *ale)
1785 return ICON_WORLD_DATA;
1788 /* get the appropriate flag(s) for the setting when it is valid */
1789 static int acf_dswor_setting_flag(bAnimContext *ac, int setting, short *neg)
1791 /* clear extra return data first */
1795 case ACHANNEL_SETTING_EXPAND: /* expanded */
1796 return WO_DS_EXPAND;
1798 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1799 return ADT_NLA_EVAL_OFF;
1801 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1803 return ADT_CURVES_NOT_VISIBLE;
1805 case ACHANNEL_SETTING_SELECT: /* selected */
1806 return ADT_UI_SELECTED;
1808 default: /* unsupported */
1813 /* get pointer to the setting */
1814 static void *acf_dswor_setting_ptr(bAnimListElem *ale, int setting, short *type)
1816 World *wo= (World *)ale->data;
1818 /* clear extra return data first */
1822 case ACHANNEL_SETTING_EXPAND: /* expanded */
1823 GET_ACF_FLAG_PTR(wo->flag);
1825 case ACHANNEL_SETTING_SELECT: /* selected */
1826 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1827 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1829 GET_ACF_FLAG_PTR(wo->adt->flag)
1833 default: /* unsupported */
1838 /* world expander type define */
1839 static bAnimChannelType ACF_DSWOR=
1841 "World Expander", /* type name */
1843 acf_generic_dataexpand_color, /* backdrop color */
1844 acf_generic_dataexpand_backdrop,/* backdrop */
1845 acf_generic_indention_1, /* indent level */
1846 acf_generic_basic_offset, /* offset */
1848 acf_generic_idblock_name, /* name */
1849 acf_dswor_icon, /* icon */
1851 acf_generic_dataexpand_setting_valid, /* has setting */
1852 acf_dswor_setting_flag, /* flag for setting */
1853 acf_dswor_setting_ptr /* pointer for setting */
1856 /* Particle Expander ------------------------------------------- */
1858 // TODO: just get this from RNA?
1859 static int acf_dspart_icon(bAnimListElem *ale)
1861 return ICON_PARTICLE_DATA;
1864 /* get the appropriate flag(s) for the setting when it is valid */
1865 static int acf_dspart_setting_flag(bAnimContext *ac, int setting, short *neg)
1867 /* clear extra return data first */
1871 case ACHANNEL_SETTING_EXPAND: /* expanded */
1872 return PART_DS_EXPAND;
1874 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1875 return ADT_NLA_EVAL_OFF;
1877 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1879 return ADT_CURVES_NOT_VISIBLE;
1881 case ACHANNEL_SETTING_SELECT: /* selected */
1882 return ADT_UI_SELECTED;
1884 default: /* unsupported */
1889 /* get pointer to the setting */
1890 static void *acf_dspart_setting_ptr(bAnimListElem *ale, int setting, short *type)
1892 ParticleSettings *part= (ParticleSettings *)ale->data;
1894 /* clear extra return data first */
1898 case ACHANNEL_SETTING_EXPAND: /* expanded */
1899 GET_ACF_FLAG_PTR(part->flag);
1901 case ACHANNEL_SETTING_SELECT: /* selected */
1902 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1903 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1905 GET_ACF_FLAG_PTR(part->adt->flag)
1909 default: /* unsupported */
1914 /* particle expander type define */
1915 static bAnimChannelType ACF_DSPART=
1917 "Particle Data Expander", /* type name */
1919 acf_generic_dataexpand_color, /* backdrop color */
1920 acf_generic_dataexpand_backdrop,/* backdrop */
1921 acf_generic_indention_1, /* indent level */
1922 acf_generic_basic_offset, /* offset */
1924 acf_generic_idblock_name, /* name */
1925 acf_dspart_icon, /* icon */
1927 acf_generic_dataexpand_setting_valid, /* has setting */
1928 acf_dspart_setting_flag, /* flag for setting */
1929 acf_dspart_setting_ptr /* pointer for setting */
1932 /* MetaBall Expander ------------------------------------------- */
1934 // TODO: just get this from RNA?
1935 static int acf_dsmball_icon(bAnimListElem *ale)
1937 return ICON_META_DATA;
1940 /* get the appropriate flag(s) for the setting when it is valid */
1941 static int acf_dsmball_setting_flag(bAnimContext *ac, int setting, short *neg)
1943 /* clear extra return data first */
1947 case ACHANNEL_SETTING_EXPAND: /* expanded */
1948 return MB_DS_EXPAND;
1950 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
1951 return ADT_NLA_EVAL_OFF;
1953 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
1955 return ADT_CURVES_NOT_VISIBLE;
1957 case ACHANNEL_SETTING_SELECT: /* selected */
1958 return ADT_UI_SELECTED;
1960 default: /* unsupported */
1965 /* get pointer to the setting */
1966 static void *acf_dsmball_setting_ptr(bAnimListElem *ale, int setting, short *type)
1968 MetaBall *mb= (MetaBall *)ale->data;
1970 /* clear extra return data first */
1974 case ACHANNEL_SETTING_EXPAND: /* expanded */
1975 GET_ACF_FLAG_PTR(mb->flag);
1977 case ACHANNEL_SETTING_SELECT: /* selected */
1978 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
1979 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
1981 GET_ACF_FLAG_PTR(mb->adt->flag)
1985 default: /* unsupported */
1990 /* metaball expander type define */
1991 static bAnimChannelType ACF_DSMBALL=
1993 "Metaball Expander", /* type name */
1995 acf_generic_dataexpand_color, /* backdrop color */
1996 acf_generic_dataexpand_backdrop,/* backdrop */
1997 acf_generic_indention_1, /* indent level */
1998 acf_generic_basic_offset, /* offset */
2000 acf_generic_idblock_name, /* name */
2001 acf_dsmball_icon, /* icon */
2003 acf_generic_dataexpand_setting_valid, /* has setting */
2004 acf_dsmball_setting_flag, /* flag for setting */
2005 acf_dsmball_setting_ptr /* pointer for setting */
2008 /* Armature Expander ------------------------------------------- */
2010 // TODO: just get this from RNA?
2011 static int acf_dsarm_icon(bAnimListElem *ale)
2013 return ICON_ARMATURE_DATA;
2016 /* get the appropriate flag(s) for the setting when it is valid */
2017 static int acf_dsarm_setting_flag(bAnimContext *ac, int setting, short *neg)
2019 /* clear extra return data first */
2023 case ACHANNEL_SETTING_EXPAND: /* expanded */
2024 return ARM_DS_EXPAND;
2026 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
2027 return ADT_NLA_EVAL_OFF;
2029 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
2031 return ADT_CURVES_NOT_VISIBLE;
2033 case ACHANNEL_SETTING_SELECT: /* selected */
2034 return ADT_UI_SELECTED;
2036 default: /* unsupported */
2041 /* get pointer to the setting */
2042 static void *acf_dsarm_setting_ptr(bAnimListElem *ale, int setting, short *type)
2044 bArmature *arm= (bArmature *)ale->data;
2046 /* clear extra return data first */
2050 case ACHANNEL_SETTING_EXPAND: /* expanded */
2051 GET_ACF_FLAG_PTR(arm->flag);
2053 case ACHANNEL_SETTING_SELECT: /* selected */
2054 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
2055 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
2057 GET_ACF_FLAG_PTR(arm->adt->flag)
2061 default: /* unsupported */
2066 /* metaball expander type define */
2067 static bAnimChannelType ACF_DSARM=
2069 "Armature Expander", /* type name */
2071 acf_generic_dataexpand_color, /* backdrop color */
2072 acf_generic_dataexpand_backdrop,/* backdrop */
2073 acf_generic_indention_1, /* indent level */
2074 acf_generic_basic_offset, /* offset */
2076 acf_generic_idblock_name, /* name */
2077 acf_dsarm_icon, /* icon */
2079 acf_generic_dataexpand_setting_valid, /* has setting */
2080 acf_dsarm_setting_flag, /* flag for setting */
2081 acf_dsarm_setting_ptr /* pointer for setting */
2084 /* NodeTree Expander ------------------------------------------- */
2086 // TODO: just get this from RNA?
2087 static int acf_dsntree_icon(bAnimListElem *ale)
2089 return ICON_NODETREE;
2092 /* get the appropriate flag(s) for the setting when it is valid */
2093 static int acf_dsntree_setting_flag(bAnimContext *ac, int setting, short *neg)
2095 /* clear extra return data first */
2099 case ACHANNEL_SETTING_EXPAND: /* expanded */
2100 return NTREE_DS_EXPAND;
2102 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
2103 return ADT_NLA_EVAL_OFF;
2105 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
2107 return ADT_CURVES_NOT_VISIBLE;
2109 case ACHANNEL_SETTING_SELECT: /* selected */
2110 return ADT_UI_SELECTED;
2112 default: /* unsupported */
2117 /* get pointer to the setting */
2118 static void *acf_dsntree_setting_ptr(bAnimListElem *ale, int setting, short *type)
2120 bNodeTree *ntree= (bNodeTree *)ale->data;
2122 /* clear extra return data first */
2126 case ACHANNEL_SETTING_EXPAND: /* expanded */
2127 GET_ACF_FLAG_PTR(ntree->flag);
2129 case ACHANNEL_SETTING_SELECT: /* selected */
2130 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
2131 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
2133 GET_ACF_FLAG_PTR(ntree->adt->flag)
2137 default: /* unsupported */
2142 /* node tree expander type define */
2143 static bAnimChannelType ACF_DSNTREE=
2145 "Node Tree Expander", /* type name */
2147 acf_generic_dataexpand_color, /* backdrop color */
2148 acf_generic_dataexpand_backdrop,/* backdrop */
2149 acf_generic_indention_1, /* indent level */ // XXX this only works for compositing
2150 acf_generic_basic_offset, /* offset */
2152 acf_generic_idblock_name, /* name */
2153 acf_dsntree_icon, /* icon */
2155 acf_generic_dataexpand_setting_valid, /* has setting */
2156 acf_dsntree_setting_flag, /* flag for setting */
2157 acf_dsntree_setting_ptr /* pointer for setting */
2160 /* Mesh Expander ------------------------------------------- */
2162 // TODO: just get this from RNA?
2163 static int acf_dsmesh_icon(bAnimListElem *ale)
2165 return ICON_MESH_DATA;
2168 /* get the appropriate flag(s) for the setting when it is valid */
2169 static int acf_dsmesh_setting_flag(bAnimContext *ac, int setting, short *neg)
2171 /* clear extra return data first */
2175 case ACHANNEL_SETTING_EXPAND: /* expanded */
2176 return ME_DS_EXPAND;
2178 case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
2179 return ADT_NLA_EVAL_OFF;
2181 case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
2183 return ADT_CURVES_NOT_VISIBLE;
2185 case ACHANNEL_SETTING_SELECT: /* selected */
2186 return ADT_UI_SELECTED;
2188 default: /* unsupported */
2193 /* get pointer to the setting */
2194 static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, int setting, short *type)
2196 Mesh *me= (Mesh *)ale->data;
2198 /* clear extra return data first */
2202 case ACHANNEL_SETTING_EXPAND: /* expanded */
2203 GET_ACF_FLAG_PTR(me->flag);
2205 case ACHANNEL_SETTING_SELECT: /* selected */
2206 case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
2207 case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
2209 GET_ACF_FLAG_PTR(me->adt->flag)
2213 default: /* unsupported */
2218 /* node tree expander type define */
2219 static bAnimChannelType ACF_DSMESH=
2221 "Mesh Expander", /* type name */
2223 acf_generic_dataexpand_color, /* backdrop color */
2224 acf_generic_dataexpand_backdrop,/* backdrop */
2225 acf_generic_indention_1, /* indent level */ // XXX this only works for compositing
2226 acf_generic_basic_offset, /* offset */
2228 acf_generic_idblock_name, /* name */
2229 acf_dsmesh_icon, /* icon */
2231 acf_generic_dataexpand_setting_valid, /* has setting */
2232 acf_dsmesh_setting_flag, /* flag for setting */
2233 acf_dsmesh_setting_ptr /* pointer for setting */
2236 /* ShapeKey Entry ------------------------------------------- */
2238 /* name for ShapeKey */
2239 static void acf_shapekey_name(bAnimListElem *ale, char *name)
2241 KeyBlock *kb= (KeyBlock *)ale->data;
2243 /* just copy the name... */
2245 /* if the KeyBlock had a name, use it, otherwise use the index */
2247 strcpy(name, kb->name);
2249 sprintf(name, "Key %d", ale->index);
2253 /* check if some setting exists for this channel */
2254 static short acf_shapekey_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
2257 case ACHANNEL_SETTING_SELECT: /* selected */
2258 case ACHANNEL_SETTING_MUTE: /* muted */
2259 case ACHANNEL_SETTING_PROTECT: /* protected */
2262 /* nothing else is supported */
2268 /* get the appropriate flag(s) for the setting when it is valid */
2269 static int acf_shapekey_setting_flag(bAnimContext *ac, int setting, short *neg)
2271 /* clear extra return data first */
2275 case ACHANNEL_SETTING_MUTE: /* mute */
2276 return KEYBLOCK_MUTE;
2278 case ACHANNEL_SETTING_SELECT: /* selected */
2279 return KEYBLOCK_SEL;
2281 case ACHANNEL_SETTING_PROTECT: /* locked */
2282 return KEYBLOCK_LOCKED;
2284 default: /* unsupported */
2289 /* get pointer to the setting */
2290 static void *acf_shapekey_setting_ptr(bAnimListElem *ale, int setting, short *type)
2292 KeyBlock *kb= (KeyBlock *)ale->data;
2294 /* clear extra return data first */
2298 case ACHANNEL_SETTING_SELECT: /* selected */
2299 case ACHANNEL_SETTING_MUTE: /* muted */
2300 case ACHANNEL_SETTING_PROTECT: /* protected */
2301 GET_ACF_FLAG_PTR(kb->flag)
2303 default: /* unsupported */
2308 /* shapekey expander type define */
2309 static bAnimChannelType ACF_SHAPEKEY=
2311 "Shape Key", /* type name */
2313 acf_generic_channel_color, /* backdrop color */
2314 acf_generic_channel_backdrop, /* backdrop */
2315 acf_generic_indention_0, /* indent level */
2316 acf_generic_basic_offset, /* offset */
2318 acf_shapekey_name, /* name */
2321 acf_shapekey_setting_valid, /* has setting */
2322 acf_shapekey_setting_flag, /* flag for setting */
2323 acf_shapekey_setting_ptr /* pointer for setting */
2326 /* Grease Pencil entries ------------------------------------------- */
2327 // XXX ... this is currently not restored yet
2330 static void dummy_olddraw_gpencil ()
2332 /* determine what needs to be drawn */
2333 switch (ale->type) {
2334 case ANIMTYPE_GPDATABLOCK: /* gpencil datablock */
2336 bGPdata *gpd = (bGPdata *)ale->data;
2337 ScrArea *sa = (ScrArea *)ale->owner; // XXX depreceated...
2342 /* only show expand if there are any channels */
2343 if (gpd->layers.first) {
2344 if (gpd->flag & GP_DATA_EXPAND)
2345 expand = ICON_TRIA_DOWN;
2347 expand = ICON_TRIA_RIGHT;
2350 switch (sa->spacetype) {
2353 /* this shouldn't cause any overflow... */
2354 //sprintf(name, "View3D:%s", view3d_get_name(sa->spacedata.first)); // XXX missing func..
2355 strcpy(name, "View3D");
2356 special= ICON_VIEW3D;
2361 SpaceNode *snode= sa->spacedata.first;
2364 if (snode->treetype == 1)
2365 strcpy(treetype, "Composite");
2367 strcpy(treetype, "Material");
2368 sprintf(name, "Nodes:%s", treetype);
2370 special= ICON_NODETREE;
2375 SpaceSeq *sseq= sa->spacedata.first;
2376 char imgpreview[10];
2378 switch (sseq->mainb) {
2379 case 1: sprintf(imgpreview, "Image..."); break;
2380 case 2: sprintf(imgpreview, "Luma..."); break;
2381 case 3: sprintf(imgpreview, "Chroma..."); break;
2382 case 4: sprintf(imgpreview, "Histogram"); break;
2384 default: sprintf(imgpreview, "Sequence"); break;
2386 sprintf(name, "Sequencer:%s", imgpreview);
2388 special= ICON_SEQUENCE;
2393 SpaceImage *sima= sa->spacedata.first;
2396 sprintf(name, "Image:%s", sima->image->id.name+2);
2398 strcpy(name, "Image:<None>");
2400 special= ICON_IMAGE_COL;
2406 sprintf(name, "<Unknown GP-Data Source>");
2413 case ANIMTYPE_GPLAYER: /* gpencil layer */
2415 bGPDlayer *gpl = (bGPDlayer *)ale->data;
2422 if (EDITABLE_GPL(gpl))
2423 protect = ICON_UNLOCKED;
2425 protect = ICON_LOCKED;
2427 if (gpl->flag & GP_LAYER_HIDE)
2428 mute = ICON_MUTE_IPO_ON;
2430 mute = ICON_MUTE_IPO_OFF;
2433 BLI_snprintf(name, 32, gpl->info);
2439 /* only for gp-data channels */
2440 UI_ThemeColorShade(TH_GROUP, 20);
2441 uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8));
2442 gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8);
2447 /* *********************************************** */
2448 /* Type Registration and General Access */
2450 /* These globals only ever get directly accessed in this file */
2451 static bAnimChannelType *animchannelTypeInfo[ANIMTYPE_NUM_TYPES];
2452 static short ACF_INIT= 1; /* when non-zero, the list needs to be updated */
2454 /* Initialise type info definitions */
2455 void ANIM_init_channel_typeinfo_data (void)
2459 /* start initialising if necessary... */
2463 animchannelTypeInfo[type++]= NULL; /* None */
2464 animchannelTypeInfo[type++]= NULL; /* AnimData */
2465 animchannelTypeInfo[type++]= NULL; /* Special */
2467 animchannelTypeInfo[type++]= &ACF_SUMMARY; /* Motion Summary */
2469 animchannelTypeInfo[type++]= &ACF_SCENE; /* Scene */
2470 animchannelTypeInfo[type++]= &ACF_OBJECT; /* Object */
2471 animchannelTypeInfo[type++]= &ACF_GROUP; /* Group */
2472 animchannelTypeInfo[type++]= &ACF_FCURVE; /* F-Curve */
2474 animchannelTypeInfo[type++]= &ACF_FILLACTD; /* Object Action Expander */
2475 animchannelTypeInfo[type++]= &ACF_FILLDRIVERS; /* Drivers Expander */
2476 animchannelTypeInfo[type++]= &ACF_FILLMATD; /* Materials Expander */
2477 animchannelTypeInfo[type++]= &ACF_FILLPARTD; /* Particles Expander */
2478 animchannelTypeInfo[type++]= &ACF_FILLTEXD; /* Textures Expander */
2480 animchannelTypeInfo[type++]= &ACF_DSMAT; /* Material Channel */
2481 animchannelTypeInfo[type++]= &ACF_DSLAM; /* Lamp Channel */
2482 animchannelTypeInfo[type++]= &ACF_DSCAM; /* Camera Channel */
2483 animchannelTypeInfo[type++]= &ACF_DSCUR; /* Curve Channel */
2484 animchannelTypeInfo[type++]= &ACF_DSSKEY; /* ShapeKey Channel */
2485 animchannelTypeInfo[type++]= &ACF_DSWOR; /* World Channel */
2486 animchannelTypeInfo[type++]= &ACF_DSNTREE; /* NodeTree Channel */
2487 animchannelTypeInfo[type++]= &ACF_DSPART; /* Particle Channel */
2488 animchannelTypeInfo[type++]= &ACF_DSMBALL; /* MetaBall Channel */
2489 animchannelTypeInfo[type++]= &ACF_DSARM; /* Armature Channel */
2490 animchannelTypeInfo[type++]= &ACF_DSMESH; /* Mesh Channel */
2491 animchannelTypeInfo[type++]= &ACF_DSTEX; /* Texture Channel */
2493 animchannelTypeInfo[type++]= &ACF_SHAPEKEY; /* ShapeKey */
2495 // XXX not restored yet
2496 animchannelTypeInfo[type++]= NULL; /* Grease Pencil Datablock */
2497 animchannelTypeInfo[type++]= NULL; /* Grease Pencil Layer */
2499 // TODO: these types still need to be implemented!!!
2500 // probably need a few extra flags for these special cases...
2501 animchannelTypeInfo[type++]= NULL; /* NLA Track */
2502 animchannelTypeInfo[type++]= NULL; /* NLA Action */
2506 /* Get type info from given channel type */
2507 bAnimChannelType *ANIM_channel_get_typeinfo (bAnimListElem *ale)
2513 /* init the typeinfo if not available yet... */
2514 ANIM_init_channel_typeinfo_data();
2516 /* check if type is in bounds... */
2517 if ((ale->type >= 0) && (ale->type < ANIMTYPE_NUM_TYPES))
2518 return animchannelTypeInfo[ale->type];
2523 /* --------------------------- */
2525 /* Print debug info string for the given channel */
2526 void ANIM_channel_debug_print_info (bAnimListElem *ale, short indent_level)
2528 bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
2531 for (; indent_level > 0; indent_level--)
2536 char name[256]; /* hopefully this will be enough! */
2540 acf->name(ale, name);
2542 sprintf(name, "<No name>");
2544 /* print type name + ui name */
2545 printf("ChanType: <%s> Name: \"%s\"\n", acf->channel_type_name, name);
2548 printf("ChanType: <Unknown - %d>\n", ale->type);
2550 printf("<Invalid channel - NULL>\n");
2553 /* --------------------------- */
2555 /* Check if some setting for a channel is enabled
2556 * Returns: 1 = On, 0 = Off, -1 = Invalid
2558 short ANIM_channel_setting_get (bAnimContext *ac, bAnimListElem *ale, int setting)
2560 bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
2562 /* 1) check that the setting exists for the current context */
2563 if ( (acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting)) )
2565 /* 2) get pointer to check for flag in, and the flag to check for */
2566 short negflag, ptrsize;
2570 flag= acf->setting_flag(ac, setting, &negflag);
2571 ptr= acf->setting_ptr(ale, setting, &ptrsize);
2573 /* check if flag is enabled */
2576 case sizeof(int): /* integer pointer for setting */
2578 int *val= (int *)ptr;
2581 return ((*val) & flag) == 0;
2583 return ((*val) & flag) != 0;
2587 case sizeof(short): /* short pointer for setting */
2589 short *val= (short *)ptr;
2592 return ((*val) & flag) == 0;
2594 return ((*val) & flag) != 0;
2598 case sizeof(char): /* char pointer for setting */
2600 char *val= (char *)ptr;
2603 return ((*val) & flag) == 0;
2605 return ((*val) & flag) != 0;
2617 /* quick macro for use in ANIM_channel_setting_set - set flag for setting according the mode given */
2618 #define ACF_SETTING_SET(sval, sflag, smode) \
2621 if (smode == ACHANNEL_SETFLAG_INVERT) (sval) ^= (sflag); \
2622 else if (smode == ACHANNEL_SETFLAG_ADD) (sval) &= ~(sflag); \
2623 else (sval) |= (sflag); \
2626 if (smode == ACHANNEL_SETFLAG_INVERT) (sval) ^= (sflag); \
2627 else if (smode == ACHANNEL_SETFLAG_ADD) (sval) |= (sflag); \
2628 else (sval) &= ~(sflag); \
2632 /* Change value of some setting for a channel
2633 * - setting: eAnimChannel_Settings
2634 * - mode: eAnimChannels_SetFlag
2636 void ANIM_channel_setting_set (bAnimContext *ac, bAnimListElem *ale, int setting, short mode)
2638 bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
2640 /* 1) check that the setting exists for the current context */
2641 if ( (acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting)) )
2643 /* 2) get pointer to check for flag in, and the flag to check for */
2644 short negflag, ptrsize;
2648 flag= acf->setting_flag(ac, setting, &negflag);
2649 ptr= acf->setting_ptr(ale, setting, &ptrsize);
2651 /* check if flag is enabled */
2654 case sizeof(int): /* integer pointer for setting */
2656 int *val= (int *)ptr;
2657 ACF_SETTING_SET(*val, flag, mode);
2661 case sizeof(short): /* short pointer for setting */
2663 short *val= (short *)ptr;
2664 ACF_SETTING_SET(*val, flag, mode);
2668 case sizeof(char): /* char pointer for setting */
2670 char *val= (char *)ptr;
2671 ACF_SETTING_SET(*val, flag, mode);
2679 /* --------------------------- */
2681 // XXX hardcoded size of icons
2682 #define ICON_WIDTH 17
2683 // XXX hardcoded width of sliders
2684 #define SLIDER_WIDTH 80
2686 /* Draw the given channel */
2687 // TODO: make this use UI controls for the buttons
2688 void ANIM_channel_draw (bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
2690 bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
2691 View2D *v2d= &ac->ar->v2d;
2692 short selected, offset;
2693 float y, ymid, ytext;
2695 /* sanity checks - don't draw anything */
2696 if ELEM(NULL, acf, ale)
2699 /* get initial offset */
2700 if (acf->get_offset)
2701 offset= acf->get_offset(ac, ale);
2705 /* calculate appropriate y-coordinates for icon buttons
2706 * 7 is hardcoded factor for half-height of icons
2708 y= (ymaxc - yminc)/2 + yminc;
2710 /* y-coordinates for text is only 4 down from middle */
2713 /* check if channel is selected */
2714 if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT))
2715 selected= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT);
2719 /* set blending again, as may not be set in previous step */
2720 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2723 /* step 1) draw backdrop ........................................... */
2724 if (acf->draw_backdrop)
2725 acf->draw_backdrop(ac, ale, yminc, ymaxc);
2727 /* step 2) draw expand widget ....................................... */
2728 if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) {
2729 /* just skip - drawn as widget now */
2730 offset += ICON_WIDTH;
2733 /* step 3) draw icon ............................................... */
2735 UI_icon_draw(offset, ymid, acf->icon(ale));
2736 offset += ICON_WIDTH;
2739 /* turn off blending, since not needed anymore... */
2740 glDisable(GL_BLEND);
2742 /* step 4) draw special toggles .................................
2743 * - in Graph Editor, checkboxes for visibility in curves area
2744 * - in NLA Editor, glowing dots for solo/not solo...
2747 if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) {
2748 /* for F-Curves, draw color-preview of curve behind checkbox */
2749 if (ale->type == ANIMTYPE_FCURVE) {
2750 FCurve *fcu= (FCurve *)ale->data;
2752 /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever
2753 * color the curve has stored
2755 glColor3fv(fcu->color);
2757 /* just a solid color rect
2758 * hardcoded 17 pixels width is slightly wider than icon width, so that
2759 * there's a slight border around it
2761 glRectf(offset, yminc, offset+17, ymaxc);
2764 /* icon is drawn as widget now... */
2765 offset += ICON_WIDTH;
2767 else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) {
2768 /* just skip - drawn as widget now */
2769 offset += ICON_WIDTH;
2773 /* step 5) draw name ............................................... */
2775 char name[256]; /* hopefully this will be enough! */
2777 /* set text color */
2779 UI_ThemeColor(TH_TEXT_HI);
2781 UI_ThemeColor(TH_TEXT);
2784 acf->name(ale, name);
2787 UI_DrawString(offset, ytext, name);
2790 /* step 6) draw backdrops behidn mute+protection toggles + (sliders) ....................... */
2791 /* reset offset - now goes from RHS of panel */
2794 // TODO: when drawing sliders, make those draw instead of these toggles if not enough space
2797 short draw_sliders = 0;
2800 /* get and set backdrop color */
2801 acf->get_backdrop_color(ac, ale, color);
2804 /* check if we need to show the sliders */
2805 if ((ac->sa) && ELEM(ac->spacetype, SPACE_ACTION, SPACE_IPO)) {
2806 switch (ac->spacetype) {
2809 SpaceAction *saction= (SpaceAction *)ac->sa->spacedata.first;
2810 draw_sliders= (saction->flag & SACTION_SLIDERS);
2815 SpaceIpo *sipo= (SpaceIpo *)ac->sa->spacedata.first;
2816 draw_sliders= (sipo->flag & SIPO_SLIDERS);
2822 /* check if there's enough space for the toggles if the sliders are drawn too */
2823 if ( !(draw_sliders) || ((v2d->mask.xmax-v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH/2) ) {
2825 if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT))
2826 offset += ICON_WIDTH;
2828 if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE))
2829 offset += ICON_WIDTH;
2833 * - even if we can draw sliders for this view, we must also check that the channel-type supports them
2834 * (only only F-Curves really can support them for now)
2835 * - slider should start before the toggles (if they're visible) to keep a clean line down the side
2837 if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_SHAPEKEY)) {
2839 offset += SLIDER_WIDTH;
2843 /* finally draw a backdrop rect behind these
2844 * - starts from the point where the first toggle/slider starts,
2845 * - ends past the space that might be reserved for a scroller
2847 glRectf(v2d->cur.xmax-(float)offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc);
2851 /* ------------------ */
2853 /* callback for (normal) widget settings - send notifiers */
2854 static void achannel_setting_widget_cb(bContext *C, void *poin, void *poin2)
2856 WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
2859 /* callback for widget settings that need flushing */
2860 static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void *setting_wrap)
2862 bAnimListElem *ale_setting= (bAnimListElem *)ale_npoin;
2864 ListBase anim_data = {NULL, NULL};
2866 int setting = GET_INT_FROM_POINTER(setting_wrap);
2869 /* send notifiers before doing anything else... */
2870 WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
2872 /* verify animation context */
2873 if (ANIM_animdata_get_context(C, &ac) == 0)
2876 /* verify that we have a channel to operate on, and that it has all we need */
2878 /* check if the setting is on... */
2879 on= ANIM_channel_setting_get(&ac, ale_setting, setting);
2881 /* on == -1 means setting not found... */
2888 /* get all channels that can possibly be chosen
2889 * - therefore, the filter is simply ANIMFILTER_CHANNELS, since if we took VISIBLE too,
2890 * then the channels under closed expanders get ignored...
2892 filter= ANIMFILTER_CHANNELS;
2893 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
2895 /* call API method to flush the setting */
2896 ANIM_flush_setting_anim_channels(&ac, &anim_data, ale_setting, setting, on);
2898 /* free temp data */
2899 BLI_freelistN(&anim_data);
2902 /* callback for widget sliders - insert keyframes */
2903 static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poin)
2905 ID *id= (ID *)id_poin;
2906 FCurve *fcu= (FCurve *)fcu_poin;
2908 Scene *scene= CTX_data_scene(C);
2909 PointerRNA id_ptr, ptr;
2911 short flag=0, done=0;
2914 /* get current frame */
2915 // NOTE: this will do for now...
2918 /* get flags for keyframing */
2919 flag = ANIM_get_keyframing_flags(scene, 1);
2921 /* get RNA pointer, and resolve the path */
2922 RNA_id_pointer_create(id, &id_ptr);
2924 /* try to resolve the path stored in the F-Curve */
2925 if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) {
2926 /* set the special 'replace' flag if on a keyframe */