[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22736] branches/blender2.5/blender/source /blender: 2.5 - Sliders in Animation Editors

joe joeedh at gmail.com
Mon Aug 24 07:21:22 CEST 2009


Though in Maya, you have to set keys on the channel boxes explicitly,
unless autokey is enabled.  Not sure it matters though.

Joe

On Sun, Aug 23, 2009 at 10:31 PM, Joshua Leung<aligorith at gmail.com> wrote:
> Revision: 22736
>          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22736
> Author:   aligorith
> Date:     2009-08-24 06:31:13 +0200 (Mon, 24 Aug 2009)
>
> Log Message:
> -----------
> 2.5 - Sliders in Animation Editors
>
> The 'Show Sliders' option for DopeSheet and Graph Editors now works again. When this option is enabled (it is disabled by default), a slider (or combobox) is shown beside the mute/lock toggles for F-Curves. Editing the slider will result in a new keyframe being added on the current frame.
>
> So, for all the (ex)-Maya animators out there, you can now animate in a channelbox-like way. :)
>
> Also in this commit:
> * Fixed some warnings in modifier.c from previous commits there
> * Fixed some refresh problems with DopeSheet channel list (which were only obvious after adding back the sliders)
> * Removed the old/unrestored and nasty slider code used in the past by the Action Editor only.
>
> Modified Paths:
> --------------
>    branches/blender2.5/blender/source/blender/blenkernel/intern/modifier.c
>    branches/blender2.5/blender/source/blender/editors/animation/anim_channels_defines.c
>    branches/blender2.5/blender/source/blender/editors/animation/anim_ipo_utils.c
>    branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
>    branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c
>    branches/blender2.5/blender/source/blender/editors/space_action/space_action.c
>    branches/blender2.5/blender/source/blender/editors/space_graph/graph_header.c
>    branches/blender2.5/blender/source/blender/makesdna/DNA_space_types.h
>    branches/blender2.5/blender/source/blender/makesrna/intern/rna_space.c
>
> Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/modifier.c
> ===================================================================
> --- branches/blender2.5/blender/source/blender/blenkernel/intern/modifier.c     2009-08-24 02:51:59 UTC (rev 22735)
> +++ branches/blender2.5/blender/source/blender/blenkernel/intern/modifier.c     2009-08-24 04:31:13 UTC (rev 22736)
> @@ -78,6 +78,7 @@
>
>  #include "BKE_main.h"
>  #include "BKE_anim.h"
> +#include "BKE_action.h"
>  #include "BKE_bmesh.h"
>  // XXX #include "BKE_booleanops.h"
>  #include "BKE_cloth.h"
>
> Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_channels_defines.c
> ===================================================================
> --- branches/blender2.5/blender/source/blender/editors/animation/anim_channels_defines.c        2009-08-24 02:51:59 UTC (rev 22735)
> +++ branches/blender2.5/blender/source/blender/editors/animation/anim_channels_defines.c        2009-08-24 04:31:13 UTC (rev 22736)
> @@ -79,6 +79,7 @@
>  #include "UI_view2d.h"
>
>  #include "ED_anim_api.h"
> +#include "ED_keyframing.h"
>  #include "ED_keyframes_edit.h" // XXX move the select modes out of there!
>  #include "ED_screen.h"
>  #include "ED_space_api.h"
> @@ -1869,13 +1870,14 @@
>
>  // XXX hardcoded size of icons
>  #define ICON_WIDTH             17
> +// XXX hardcoded width of sliders
> +#define SLIDER_WIDTH   70
>
>  /* Draw the given channel */
>  // TODO: make this use UI controls for the buttons
>  void ANIM_channel_draw (bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
>  {
>        bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
> -       View2D *v2d= &ac->ar->v2d;
>        short selected, offset;
>        float y, ymid, ytext;
>
> @@ -1970,26 +1972,6 @@
>                offset += 3;
>                UI_DrawString(offset, ytext, name);
>        }
> -
> -       /* step 6) draw mute+protection toggles + (sliders) ....................... */
> -       /* reset offset - now goes from RHS of panel */
> -       offset = 0;
> -
> -       // TODO: we need a mechanism of drawing over (and hiding) stuff from here...
> -       // TODO: when drawing sliders, make those draw instead of these toggles if not enough space
> -
> -       if (v2d) {
> -               /* protect... */
> -               if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) {
> -                       /* just skip - drawn as widget now */
> -                       offset += ICON_WIDTH;
> -               }
> -               /* mute... */
> -               if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) {
> -                       /* just skip - drawn as widget now */
> -                       offset += ICON_WIDTH;
> -               }
> -       }
>  }
>
>  /* ------------------ */
> @@ -2000,6 +1982,44 @@
>        WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
>  }
>
> +/* callback for widget sliders - insert keyframes */
> +static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poin)
> +{
> +       ID *id= (ID *)id_poin;
> +       FCurve *fcu= (FCurve *)fcu_poin;
> +
> +       Scene *scene= CTX_data_scene(C);
> +       PointerRNA id_ptr, ptr;
> +       PropertyRNA *prop;
> +       short flag=0, done=0;
> +       float cfra;
> +
> +       /* get current frame */
> +       // NOTE: this will do for now...
> +       cfra= (float)CFRA;
> +
> +       /* get flags for keyframing */
> +       if (IS_AUTOKEY_FLAG(INSERTNEEDED))
> +               flag |= INSERTKEY_NEEDED;
> +       if (IS_AUTOKEY_FLAG(AUTOMATKEY))
> +               flag |= INSERTKEY_MATRIX;
> +
> +
> +       /* get RNA pointer, and resolve the path */
> +       RNA_id_pointer_create(id, &id_ptr);
> +
> +       /* try to resolve the path stored in the F-Curve */
> +       if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) {
> +               /* insert a keyframe for this F-Curve */
> +               done= insert_keyframe_direct(ptr, prop, fcu, cfra, flag);
> +
> +               if (done)
> +                       WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
> +       }
> +}
> +
> +
> +
>  /* Draw a widget for some setting */
>  static void draw_setting_widget (bAnimContext *ac, bAnimListElem *ale, bAnimChannelType *acf, uiBlock *block, int xpos, int ypos, int setting)
>  {
> @@ -2164,16 +2184,76 @@
>        // TODO: when drawing sliders, make those draw instead of these toggles if not enough space
>
>        if (v2d) {
> -               /* protect... */
> -               if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) {
> -                       offset += ICON_WIDTH;
> -                       draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_PROTECT);
> +               short draw_sliders = 0;
> +
> +               /* check if we need to show the sliders */
> +               if ((ac->sa) && ELEM(ac->spacetype, SPACE_ACTION, SPACE_IPO)) {
> +                       switch (ac->spacetype) {
> +                               case SPACE_ACTION:
> +                               {
> +                                       SpaceAction *saction= (SpaceAction *)ac->sa->spacedata.first;
> +                                       draw_sliders= (saction->flag & SACTION_SLIDERS);
> +                               }
> +                                       break;
> +                               case SPACE_IPO:
> +                               {
> +                                       SpaceIpo *sipo= (SpaceIpo *)ac->sa->spacedata.first;
> +                                       draw_sliders= (sipo->flag & SIPO_SLIDERS);
> +                               }
> +                                       break;
> +                       }
>                }
> -               /* mute... */
> -               if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) {
> -                       offset += ICON_WIDTH;
> -                       draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_MUTE);
> +
> +               /* check if there's enough space for the toggles if the sliders are drawn too */
> +               if ( !(draw_sliders) || ((v2d->mask.xmax-v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH/2) ) {
> +                       /* protect... */
> +                       if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) {
> +                               offset += ICON_WIDTH;
> +                               draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_PROTECT);
> +                       }
> +                       /* mute... */
> +                       if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) {
> +                               offset += ICON_WIDTH;
> +                               draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_MUTE);
> +                       }
>                }
> +
> +               /* draw slider
> +                *      - even if we can draw sliders for this view, we must also check that the channel-type supports them
> +                *        (only only F-Curves really can support them for now)
> +                *      - to make things easier, we use RNA-autobuts for this so that changes are reflected immediately,
> +                *        whereever they occurred. BUT, we don't use the layout engine, otherwise we'd get wrong alignment,
> +                *        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) && (ale->type == ANIMTYPE_FCURVE)) {
> +                       /* adjust offset */
> +                       offset += SLIDER_WIDTH;
> +
> +                       /* need backdrop behind sliders... */
> +                       uiBlockSetEmboss(block, UI_EMBOSS);
> +
> +                       if (ale->id) { /* Slider using RNA Access -------------------- */
> +                               FCurve *fcu= (FCurve *)ale->data;
> +                               PointerRNA id_ptr, ptr;
> +                               PropertyRNA *prop;
> +
> +                               /* get RNA pointer, and resolve the path */
> +                               RNA_id_pointer_create(ale->id, &id_ptr);
> +
> +                               /* try to resolve the path */
> +                               if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) {
> +                                       uiBut *but;
> +
> +                                       /* create the slider button, and assign relevant callback to ensure keyframes are inserted... */
> +                                       but= uiDefAutoButR(block, &ptr, prop, fcu->array_index, "", 0, (int)v2d->cur.xmax-offset, ymid, SLIDER_WIDTH, (int)ymaxc-yminc);
> +                                       uiButSetFunc(but, achannel_setting_slider_cb, ale->id, fcu);
> +                               }
> +                       }
> +                       else { /* Special Slider for stuff without RNA Access ---------- */
> +                               // TODO: only implement this case when we really need it...
> +                       }
> +               }
>        }
>  }
>
>
> Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_ipo_utils.c
> ===================================================================
> --- branches/blender2.5/blender/source/blender/editors/animation/anim_ipo_utils.c       2009-08-24 02:51:59 UTC (rev 22735)
> +++ branches/blender2.5/blender/source/blender/editors/animation/anim_ipo_utils.c       2009-08-24 04:31:13 UTC (rev 22736)
> @@ -93,9 +93,8 @@
>  }
>
>  /* Write into "name" buffer, the name of the property (retrieved using RNA from the curve's settings)
> - * WARNING: name buffer we're writing to cannot exceed 128 chars (check action_draw.c for details)
> + * WARNING: name buffer we're writing to cannot exceed 256 chars (check anim_channels_defines.c for details)
>  */
> -// TODO: have an extra var to indicate if prop was valid?
>  void getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
>  {
>        /* sanity checks */
>
> Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
> ===================================================================
> --- branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c    2009-08-24 02:51:59 UTC (rev 22735)
> +++ branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c    2009-08-24 04:31:13 UTC (rev 22736)
> @@ -2050,7 +2050,7 @@
>        widget_init(&wtb);
>
>        /* half rounded */
> -       round_box_edges(&wtb, roundboxalign, rect, 4.0f);
> +       round_box_edges(&wtb, roundboxalign, rect, 5.0f);
>
>        widgetbase_draw(&wtb, wcol);
>  }
>
> Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c
> ===================================================================
> --- branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c       2009-08-24 02:51:59 UTC (rev 22735)
> +++ branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c       2009-08-24 04:31:13 UTC (rev 22736)
> @@ -92,307 +92,7 @@
>  #include "ED_screen.h"
>  #include "ED_space_api.h"
>
> -#if 0 // XXX old includes for reference only
> -       #include "BIF_editaction.h"
> -       #include "BIF_editkey.h"
> -       #include "BIF_editnla.h"
> -       #include "BIF_drawgpencil.h"
> -       #include "BIF_keyframing.h"
> -       #include "BIF_language.h"
> -       #include "BIF_space.h"
> -
> -       #include "BDR_editcurve.h"
> -       #include "BDR_gpencil.h"
>
> -       #include "BSE_drawnla.h"
> -       #include "BSE_drawipo.h"
> -       #include "BSE_drawview.h"
> -       #include "BSE_editaction_types.h"
> -       #include "BSE_editipo.h"
> -       #include "BSE_headerbuttons.h"
> -       #include "BSE_time.h"
> -       #include "BSE_view.h"
> -#endif // XXX old defines for reference only
> -
> -/* XXX */
> -extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
> -
> -/********************************** Slider Stuff **************************** */
> -
> -#if 0 // XXX all of this slider stuff will need a rethink!
> -/* sliders for shapekeys */
> -static void meshactionbuts(SpaceAction *saction, Object *ob, Key *key)
> -{
> -       int           i;
> -       char          str[64];
> -       float         x, y;
> -       uiBlock       *block;
> -       uiBut             *but;
> -
> -       /* lets make the shapekey sliders */
> -
> -       /* reset the damn myortho2 or the sliders won't draw/redraw
> -        * correctly *grumble*
> -        */
> -       mywinset(curarea->win);
> -       myortho2(-0.375f, curarea->winx-0.375f, G.v2d->cur.ymin, G.v2d->cur.ymax);
> -
> -    sprintf(str, "actionbuttonswin %d", curarea->win);
> -    block= uiNewBlock (&curarea->uiblocks, str, UI_EMBOSS);
> -
> -       x = ACHANNEL_NAMEWIDTH + 1;
> -    y = 0.0f;
> -
> -       uiBlockSetEmboss(block, UI_EMBOSSN);
> -
> -       if (!(G.saction->flag & SACTION_SLIDERS)) {
> -               ACTWIDTH = ACHANNEL_NAMEWIDTH;
>
> @@ Diff output truncated at 10240 characters. @@
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>


More information about the Bf-committers mailing list