diff options
author | Joshua Leung <aligorith@gmail.com> | 2014-05-04 19:32:23 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2014-05-05 06:16:38 +0400 |
commit | da6b1ca27dff4e9b85506417a557cded85ef39ed (patch) | |
tree | 0b0caa4c109b0e89adf9c9fdcfecb6f24d28da34 | |
parent | b2784d33ce6a6ae20344afa469b1425bdde9f90e (diff) |
NLA Editor: Second part of porting NLA Action channel to standard drawing system
This now works (barring one or two minor glitches and the operator on the pushdown
button being a bit of a hack). The old drawing code is still in place though, and
will be kept around for a little while yet while the last kinks are ironed out.
-rw-r--r-- | source/blender/editors/animation/anim_channels_defines.c | 37 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_draw.c | 20 |
2 files changed, 51 insertions, 6 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index ca13b6c118d..4106d210e06 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -2923,6 +2923,28 @@ static int acf_nlaaction_icon(bAnimListElem *ale) } } +/* Backdrop color for nla action channel + * Although this can't be used directly for NLA Action drawing, + * it is still needed for use behind the RHS toggles + */ +static void acf_nlaaction_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3]) +{ + float color[4]; + + /* Action Line + * The alpha values action_get_color returns are only useful for drawing + * strips backgrounds but here we're doing channel list backgrounds instead + * so we ignore that and use our own when needed + */ + nla_action_get_color(ale->adt, (bAction *)ale->data, color); + + /* NOTE: since the return types only allow rgb, we cannot do the alpha-blending we'd + * like for the solo-drawing case. Hence, this method isn't actually used for drawing + * most of the channel... + */ + copy_v3_v3(r_color, color); +} + /* backdrop for nla action channel */ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { @@ -2968,7 +2990,7 @@ static void acf_nlaaction_name(bAnimListElem *ale, char *name) BLI_strncpy(name, act->id.name + 2, ANIM_CHAN_NAME_SIZE); } else { - BLI_strncpy(name, "<No Action>", sizeof(name)); + BLI_strncpy(name, "<No Action>", ANIM_CHAN_NAME_SIZE); } } } @@ -3037,7 +3059,7 @@ static bAnimChannelType ACF_NLAACTION = { "NLA Active Action", /* type name */ - NULL, /* backdrop color (NOTE: the backdrop handles this too, since it needs special hacks) */ + acf_nlaaction_color, /* backdrop color (NOTE: the backdrop handles this too, since it needs special hacks) */ acf_nlaaction_backdrop, /* backdrop */ acf_generic_indention_flexible, /* indent level */ acf_generic_group_offset, /* offset */ // XXX? @@ -3440,6 +3462,11 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* mute... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) offset += ICON_WIDTH; + /* pinned... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PINNED)) + offset += ICON_WIDTH; + + /* NOTE: technically, NLA Action "pushdown" should be here too, but there are no sliders there */ } /* draw slider @@ -3896,16 +3923,18 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale } /* NLA Action "pushdown" */ - if ((ale->type == ANIMTYPE_NLAACTION) && (ale->adt) && (ale->adt->flag & ADT_NLA_EDIT_ON) == 0) { + if ((ale->type == ANIMTYPE_NLAACTION) && (ale->adt && ale->adt->action) && !(ale->adt->flag & ADT_NLA_EDIT_ON)) { //const char *opname = "NLA_OT_action_pushdown"; // XXX: this is the real one //const char *opname = "NLA_OT_channels_click"; // FIXME: this needs to hook up to an operator uiBlockSetEmboss(block, UI_EMBOSS); + offset += UI_UNIT_X; uiDefIconButO(block, BUT, "NLA_OT_channels_click", WM_OP_INVOKE_DEFAULT, ICON_NLA_PUSHDOWN, - (int)v2d->cur.xmax - offset, yminc, ICON_WIDTH, ICON_WIDTH, + (int)v2d->cur.xmax - offset, ymid, UI_UNIT_X, UI_UNIT_X, "Push action on to the top of the NLA stack as a new NLA Strip"); + // TODO: pass channel index uiBlockSetEmboss(block, UI_EMBOSSN); } diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 6a943f45ac2..a6f5cf1f5c5 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -646,6 +646,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View /* determine what needs to be drawn */ switch (ale->type) { +#if 0 case ANIMTYPE_NLAACTION: /* NLA Action-Line */ { bAction *act = (bAction *)ale->data; @@ -664,6 +665,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View do_draw = true; break; } +#endif default: /* handled by standard channel-drawing API */ /* (draw backdrops only...) */ ANIM_channel_draw(ac, ale, yminc, ymaxc); @@ -841,10 +843,24 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar) UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); /* draw channels */ - { /* first pass: backdrops + oldstyle drawing */ + { /* first pass: just the standard GL-drawing for backdrop + text */ y = (float)(-NLACHANNEL_HEIGHT(snla)); - draw_nla_channel_list_gl(ac, &anim_data, v2d, y); + for (ale = anim_data.first; ale; ale = ale->next) { + float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); + float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); + + /* check if visible */ + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw(ac, ale, yminc, ymaxc); + } + + /* adjust y-position for next one */ + y -= NLACHANNEL_STEP(snla); + } } { /* second pass: UI widgets */ uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); |