diff options
author | Joshua Leung <aligorith@gmail.com> | 2015-03-22 11:41:45 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2015-03-28 15:39:56 +0300 |
commit | 67f983ac53e97f154b6710fea8f400a608e27550 (patch) | |
tree | b3561f2c576e9face32c872b9264cd1252cba434 /source/blender/editors/animation/anim_channels_defines.c | |
parent | 8f4c5ff0ecd81a95885939e2fa553f50f1f405fc (diff) |
Nla Strip Controls: Added special FCurve type (in the animfiltering code)
Using the standard "FCurve" animchannel type didn't work that well for
the control FCurves on NLA Strips, as the paths would not resolve correctly,
and the indentation was wrong. Also, there would likely be issues down the
track with applying NLA mapping. Hence, it's easier to just create a separate
type for this case, and adapt the rest of the code to also consider these (todo).
Diffstat (limited to 'source/blender/editors/animation/anim_channels_defines.c')
-rw-r--r-- | source/blender/editors/animation/anim_channels_defines.c | 231 |
1 files changed, 140 insertions, 91 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 11d68ed6f75..72aa0c18cb3 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -908,6 +908,115 @@ static bAnimChannelType ACF_GROUP = acf_group_setting_ptr /* pointer for setting */ }; +/* F-Curve ------------------------------------------- */ + +/* name for fcurve entries */ +static void acf_fcurve_name(bAnimListElem *ale, char *name) +{ + getname_anim_fcurve(name, ale->id, ale->data); +} + +/* "name" property for fcurve entries */ +static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) +{ + FCurve *fcu = (FCurve *)ale->data; + + /* Ctrl-Click Usability Convenience Hack: + * For disabled F-Curves, allow access to the RNA Path + * as our "name" so that user can perform quick fixes + */ + if (fcu->flag & FCURVE_DISABLED) { + RNA_pointer_create(ale->id, &RNA_FCurve, ale->data, ptr); + *prop = RNA_struct_find_property(ptr, "data_path"); + } + else { + /* for "normal" F-Curves - no editable name, but *prop may not be set properly yet... */ + *prop = NULL; + } + + return (*prop != NULL); +} + +/* check if some setting exists for this channel */ +static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting) +{ + FCurve *fcu = (FCurve *)ale->data; + + switch (setting) { + /* unsupported */ + case ACHANNEL_SETTING_SOLO: /* Solo Flag is only for NLA */ + case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */ + return false; + + /* conditionally available */ + case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */ + if (fcu->bezt) + return true; + else + return false; // NOTE: in this special case, we need to draw ICON_ZOOMOUT + + case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ + return (ac->spacetype == SPACE_IPO); + + /* always available */ + default: + return true; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg) +{ + /* clear extra return data first */ + *neg = false; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return FCURVE_SELECTED; + + case ACHANNEL_SETTING_MUTE: /* muted */ + return FCURVE_MUTED; + + case ACHANNEL_SETTING_PROTECT: /* protected */ + return FCURVE_PROTECTED; + + case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */ + return FCURVE_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_fcurve_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type) +{ + FCurve *fcu = (FCurve *)ale->data; + + /* all flags are just in agrp->flag for now... */ + return GET_ACF_FLAG_PTR(fcu->flag, type); +} + +/* fcurve type define */ +static bAnimChannelType ACF_FCURVE = +{ + "F-Curve", /* type name */ + ACHANNEL_ROLE_CHANNEL, /* role */ + + acf_generic_channel_color, /* backdrop color */ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only? + acf_generic_group_offset, /* offset */ + + acf_fcurve_name, /* name */ + acf_fcurve_name_prop, /* name prop */ + NULL, /* icon */ + + acf_fcurve_setting_valid, /* has setting */ + acf_fcurve_setting_flag, /* flag for setting */ + acf_fcurve_setting_ptr /* pointer for setting */ +}; + /* NLA Control FCurves Expander ----------------------- */ /* get backdrop color for nla controls widget */ @@ -1008,107 +1117,41 @@ static bAnimChannelType ACF_NLACONTROLS = acf_nla_controls_setting_ptr /* pointer for setting */ }; -/* F-Curve ------------------------------------------- */ -/* name for fcurve entries */ -static void acf_fcurve_name(bAnimListElem *ale, char *name) -{ - getname_anim_fcurve(name, ale->id, ale->data); -} +/* NLA Control F-Curve -------------------------------- */ -/* "name" property for fcurve entries */ -static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) +/* name for nla control fcurve entries */ +static void acf_nla_curve_name(bAnimListElem *ale, char *name) { - FCurve *fcu = (FCurve *)ale->data; + NlaStrip *strip = ale->owner; + FCurve *fcu = ale->data; + PropertyRNA *prop; - /* Ctrl-Click Usability Convenience Hack: - * For disabled F-Curves, allow access to the RNA Path - * as our "name" so that user can perform quick fixes - */ - if (fcu->flag & FCURVE_DISABLED) { - RNA_pointer_create(ale->id, &RNA_FCurve, ale->data, ptr); - *prop = RNA_struct_find_property(ptr, "data_path"); + /* try to get RNA property that this shortened path (relative to the strip) refers to */ + prop = RNA_struct_type_find_property(&RNA_NlaStrip, fcu->rna_path); + if (prop) { + /* "name" of this strip displays the UI identifier + the name of the NlaStrip */ + BLI_snprintf(name, 256, "%s (%s)", RNA_property_ui_name(prop), strip->name); } else { - /* for "normal" F-Curves - no editable name, but *prop may not be set properly yet... */ - *prop = NULL; - } - - return (*prop != NULL); -} - -/* check if some setting exists for this channel */ -static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting) -{ - FCurve *fcu = (FCurve *)ale->data; - - switch (setting) { - /* unsupported */ - case ACHANNEL_SETTING_SOLO: /* Solo Flag is only for NLA */ - case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */ - return false; - - /* conditionally available */ - case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */ - if (fcu->bezt) - return true; - else - return false; // NOTE: in this special case, we need to draw ICON_ZOOMOUT - - case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ - return (ac->spacetype == SPACE_IPO); - - /* always available */ - default: - return true; + /* unknown property... */ + BLI_snprintf(name, 256, "%s[%d]", fcu->rna_path, fcu->array_index); } } -/* get the appropriate flag(s) for the setting when it is valid */ -static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg) -{ - /* clear extra return data first */ - *neg = false; - - switch (setting) { - case ACHANNEL_SETTING_SELECT: /* selected */ - return FCURVE_SELECTED; - - case ACHANNEL_SETTING_MUTE: /* muted */ - return FCURVE_MUTED; - - case ACHANNEL_SETTING_PROTECT: /* protected */ - return FCURVE_PROTECTED; - - case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */ - return FCURVE_VISIBLE; - - default: /* unsupported */ - return 0; - } -} - -/* get pointer to the setting */ -static void *acf_fcurve_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type) -{ - FCurve *fcu = (FCurve *)ale->data; - - /* all flags are just in agrp->flag for now... */ - return GET_ACF_FLAG_PTR(fcu->flag, type); -} -/* fcurve type define */ -static bAnimChannelType ACF_FCURVE = +/* NLA Control F-Curve type define */ +static bAnimChannelType ACF_NLACURVE = { - "F-Curve", /* type name */ + "NLA Control F-Curve", /* type name */ ACHANNEL_ROLE_CHANNEL, /* role */ acf_generic_channel_color, /* backdrop color */ acf_generic_channel_backdrop, /* backdrop */ - acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only? + acf_generic_indention_1, /* indent level */ acf_generic_group_offset, /* offset */ - acf_fcurve_name, /* name */ + acf_nla_curve_name, /* name */ acf_fcurve_name_prop, /* name prop */ NULL, /* icon */ @@ -3323,6 +3366,7 @@ static void ANIM_init_channel_typeinfo_data(void) animchannelTypeInfo[type++] = &ACF_FCURVE; /* F-Curve */ animchannelTypeInfo[type++] = &ACF_NLACONTROLS; /* NLA Control FCurve Expander */ + animchannelTypeInfo[type++] = &ACF_NLACURVE; /* NLA Control FCurve Channel */ animchannelTypeInfo[type++] = &ACF_FILLACTD; /* Object Action Expander */ animchannelTypeInfo[type++] = &ACF_FILLDRIVERS; /* Drivers Expander */ @@ -3593,7 +3637,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float if (ac->sl) { if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { /* for F-Curves, draw color-preview of curve behind checkbox */ - if (ale->type == ANIMTYPE_FCURVE) { + if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { FCurve *fcu = (FCurve *)ale->data; /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever @@ -3639,7 +3683,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float UI_fontstyle_draw_simple(fstyle, offset, ytext, name); /* draw red underline if channel is disabled */ - if ((ale->type == ANIMTYPE_FCURVE) && (ale->flag & FCURVE_DISABLED)) { + if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE) && (ale->flag & FCURVE_DISABLED)) { /* FIXME: replace hardcoded color here, and check on extents! */ glColor3f(1.0f, 0.0f, 0.0f); glLineWidth(2.0); @@ -3706,7 +3750,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float * (only only F-Curves really can support them for now) * - slider should start before the toggles (if they're visible) to keep a clean line down the side */ - if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_SHAPEKEY)) { + if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY)) { /* adjust offset */ offset += SLIDER_WIDTH; } @@ -3895,7 +3939,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann //icon = ((enabled) ? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF); icon = ICON_VISIBLE_IPO_OFF; - if (ale->type == ANIMTYPE_FCURVE) + if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) tooltip = TIP_("F-Curve is visible in Graph Editor for editing"); else tooltip = TIP_("Channels are visible in Graph Editor for editing"); @@ -3930,7 +3974,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann //icon = ((enabled) ? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF); icon = ICON_MUTE_IPO_OFF; - if (ale->type == ANIMTYPE_FCURVE) { + if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { tooltip = TIP_("Does F-Curve contribute to result"); } else if ((ac) && (ac->spacetype == SPACE_NLA) && (ale->type != ANIMTYPE_NLATRACK)) { @@ -4199,7 +4243,7 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle * and wouldn't be able to auto-keyframe... * - slider should start before the toggles (if they're visible) to keep a clean line down the side */ - if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_SHAPEKEY)) { + if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY)) { /* adjust offset */ // TODO: make slider width dynamic, so that they can be easier to use when the view is wide enough offset += SLIDER_WIDTH; @@ -4207,7 +4251,12 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle /* need backdrop behind sliders... */ UI_block_emboss_set(block, UI_EMBOSS); - if (ale->id) { /* Slider using RNA Access -------------------- */ + if (ale->owner) { /* Slider using custom RNA Access ---------- */ + if (ale->type == ANIMTYPE_NLACURVE) { + // TODO... + } + } + else if (ale->id) { /* Slider using RNA Access --------------- */ PointerRNA id_ptr, ptr; PropertyRNA *prop; char *rna_path = NULL; |