Revision: 17375
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17375
Author:   aligorith
Date:     2008-11-09 10:43:32 +0100 (Sun, 09 Nov 2008)

Log Message:
-----------
AnimSys2: More DopeSheet Improvements (ShapeKeys...)

* Added ShapeKeys to DopeSheet
* Sliders now work in the DopeSheet

Modified Paths:
--------------
    branches/animsys2/source/blender/include/BIF_editaction.h
    branches/animsys2/source/blender/makesdna/DNA_key_types.h
    branches/animsys2/source/blender/src/drawaction.c
    branches/animsys2/source/blender/src/editaction.c

Modified: branches/animsys2/source/blender/include/BIF_editaction.h
===================================================================
--- branches/animsys2/source/blender/include/BIF_editaction.h   2008-11-09 
06:28:37 UTC (rev 17374)
+++ branches/animsys2/source/blender/include/BIF_editaction.h   2008-11-09 
09:43:32 UTC (rev 17375)
@@ -53,6 +53,7 @@
        ACTTYPE_FILLACTD,
        ACTTYPE_FILLIPOD,
        ACTTYPE_FILLCOND,
+       ACTTYPE_FILLSKED,
        
        ACTTYPE_ACHAN,
        ACTTYPE_CONCHAN,
@@ -70,6 +71,7 @@
 #define EXPANDED_OBJC(ob) ((ob->nlaflag & OB_ADS_COLLAPSED)==0)
 #define FILTER_IPO_OBJC(ob) ((ob->nlaflag & OB_ADS_SHOWIPO))
 #define FILTER_CON_OBJC(ob) ((ob->nlaflag & OB_ADS_SHOWCONS)) 
+#define FILTER_SKE_OBJC(key) ((key->flag & KEYBLOCK_EXPAND))
 #define SEL_ACTC(actc) ((actc->flag & ACTC_SELECTED))
 #define EXPANDED_ACTC(actc) ((actc->flag & ACTC_EXPANDED))
 

Modified: branches/animsys2/source/blender/makesdna/DNA_key_types.h
===================================================================
--- branches/animsys2/source/blender/makesdna/DNA_key_types.h   2008-11-09 
06:28:37 UTC (rev 17374)
+++ branches/animsys2/source/blender/makesdna/DNA_key_types.h   2008-11-09 
09:43:32 UTC (rev 17375)
@@ -86,6 +86,7 @@
 
 /* keyblock->flag */
 #define KEYBLOCK_MUTE  1
+#define KEYBLOCK_EXPAND        2
 
 #endif
 

Modified: branches/animsys2/source/blender/src/drawaction.c
===================================================================
--- branches/animsys2/source/blender/src/drawaction.c   2008-11-09 06:28:37 UTC 
(rev 17374)
+++ branches/animsys2/source/blender/src/drawaction.c   2008-11-09 09:43:32 UTC 
(rev 17375)
@@ -300,7 +300,7 @@
     block= uiNewBlock (&curarea->uiblocks, str, 
                        UI_EMBOSS, UI_HELV, curarea->win);
 
-       x = NAMEWIDTH + 1;
+       x = (float)NAMEWIDTH + 1;
     y = 0.0f;
        
        uiBlockSetEmboss(block, UI_EMBOSSN);
@@ -336,8 +336,8 @@
                                                bActionChannel *achan = 
(bActionChannel *)ale->owner;
                                                IpoCurve *icu = (IpoCurve 
*)ale->key_data;
                                                
-                                               /* only show if action channel 
is selected */
-                                               if (SEL_ACHAN(achan)) {
+                                               /* only show if owner is 
selected */
+                                               if ((ale->ownertype == 
ACTTYPE_OBJECT) || SEL_ACHAN(achan)) {
                                                        make_icu_slider(block, 
icu,
                                                                                
        (int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-2, 
                                                                                
        "Slider to control current value of Constraint Influence");
@@ -349,8 +349,8 @@
                                                bActionChannel *achan = 
(bActionChannel *)ale->owner;
                                                IpoCurve *icu = (IpoCurve 
*)ale->key_data;
                                                
-                                               /* only show if action channel 
is selected */
-                                               if (SEL_ACHAN(achan)) {
+                                               /* only show if owner is 
selected */
+                                               if ((ale->ownertype == 
ACTTYPE_OBJECT) || SEL_ACHAN(achan)) {
                                                        make_icu_slider(block, 
icu,
                                                                                
        (int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-2, 
                                                                                
        "Slider to control current value of IPO-Curve");
@@ -359,7 +359,19 @@
                                                break;
                                        case ACTTYPE_SHAPEKEY: /* shapekey 
channel */
                                        {
-                                               // TODO...
+                                               Object *ob= (Object *)ale->id;
+                                               IpoCurve *icu= (IpoCurve 
*)ale->key_data;
+                                               
+                                               // TODO: only show if object is 
active 
+                                               if (icu) {
+                                                       make_icu_slider(block, 
icu,
+                                                                               
(int)x, (int)y, SLIDERWIDTH-2, CHANNELHEIGHT-2, 
+                                                                               
"Slider to control ShapeKey");
+                                               }
+                                               else if (ob && ale->index) {
+                                                       make_rvk_slider(block, 
ob, ale->index, 
+                                                                       (int)x, 
(int)y, SLIDERWIDTH-2, CHANNELHEIGHT-1, "Slider to control Shape Keys");
+                                               }
                                        }
                                                break;
                                }
@@ -531,6 +543,23 @@
                                        sprintf(name, "IPO Curves");
                                }
                                        break;
+                               case ACTTYPE_FILLSKED: /* shapekeys (dopesheet) 
expand widget */
+                               {
+                                       Key *key= (Key *)ale->data;
+                                       
+                                       group = 4;
+                                       indent = 1;
+                                       special = ICON_EDIT;
+                                       
+                                       if (FILTER_SKE_OBJC(key))       
+                                               expand = ICON_TRIA_DOWN;
+                                       else
+                                               expand = ICON_TRIA_RIGHT;
+                                               
+                                       //sel = SEL_OBJC(base);
+                                       sprintf(name, "Shape Keys");
+                               }
+                                       break;
                                case ACTTYPE_FILLCOND: /* constraint channels 
(dopesheet) expand widget */
                                {
                                        Object *ob = (Object *)ale->data;
@@ -712,6 +741,8 @@
                                        indent = 0;
                                        special = -1;
                                        
+                                       offset= (ale->id) ? 21 : 0;
+                                       
                                        if (kb->name[0] == '\0')
                                                sprintf(name, "Key %d", 
ale->index);
                                        else
@@ -1490,7 +1521,7 @@
                draw_channel_names();
                
                if(sa->winx > 50 + NAMEWIDTH + SLIDERWIDTH) {
-                       if (act) {
+                       if (ELEM(G.saction->mode, SACTCONT_ACTION, 
SACTCONT_DOPESHEET)) {
                                /* if there is an action, draw sliders for its
                                 * ipo-curve channels in the action window
                                 */

Modified: branches/animsys2/source/blender/src/editaction.c
===================================================================
--- branches/animsys2/source/blender/src/editaction.c   2008-11-09 06:28:37 UTC 
(rev 17374)
+++ branches/animsys2/source/blender/src/editaction.c   2008-11-09 09:43:32 UTC 
(rev 17375)
@@ -239,6 +239,16 @@
                                ale->datatype= ALE_IPO;
                        }
                                break;
+                       case ACTTYPE_FILLSKED:
+                       {
+                               Key *key= (Key *)data;
+                               
+                               ale->flag = FILTER_SKE_OBJC(key);
+                               
+                               ale->key_data= key->ipo;
+                               ale->datatype= ALE_IPO;
+                       }
+                               break;
                        case ACTTYPE_FILLCOND:
                        {
                                Object *ob= (Object *)data;
@@ -537,11 +547,12 @@
        }
 }
 
-static void actdata_filter_shapekey (ListBase *act_data, Key *key, int 
filter_mode)
+static void actdata_filter_shapekey (ListBase *act_data, Key *key, int 
filter_mode, void *owner, short ownertype)
 {
        bActListElem *ale;
        KeyBlock *kb;
        IpoCurve *icu;
+       short owned= (owner && ownertype)? 1 : 0;
        int i;
        
        /* are we filtering for display or editing */
@@ -552,7 +563,7 @@
                /* loop through possible shapekeys, manually creating entries */
                for (i= 1; i < key->totkey; i++) {
                        ale= MEM_callocN(sizeof(bActListElem), "bActListElem");
-                       kb = kb->next;
+                       kb = kb->next; /* do this even on the first try, as the 
first is 'Basis' (which doesn't get included) */
                        
                        ale->data= kb;
                        ale->type= ACTTYPE_SHAPEKEY; /* 'abused' usage of this 
type */
@@ -571,6 +582,8 @@
                                }
                        }
                        
+                       if (owned) ale->id= owner;
+                       
                        BLI_addtail(act_data, ale);
                }
        }
@@ -579,12 +592,18 @@
                if (key->ipo) {
                        if (filter_mode & ACTFILTER_IPOKEYS) {
                                ale= make_new_actlistelem(key->ipo, 
ACTTYPE_IPO, key, ACTTYPE_SHAPEKEY);
-                               if (ale) BLI_addtail(act_data, ale);
+                               if (ale) {
+                                       if (owned) ale->id= owner;
+                                       BLI_addtail(act_data, ale);
+                               }
                        }
                        else {
                                for (icu= key->ipo->curve.first; icu; 
icu=icu->next) {
                                        ale= make_new_actlistelem(icu, 
ACTTYPE_ICU, key, ACTTYPE_SHAPEKEY);
-                                       if (ale) BLI_addtail(act_data, ale);
+                                       if (ale) {
+                                               if (owned) ale->id= owner;
+                                               BLI_addtail(act_data, ale);
+                                       }
                                }
                        }
                }
@@ -647,11 +666,12 @@
        bActListElem *ale=NULL;
        Scene *sce= (Scene *)ads->source;
        Object *ob= base->object;
+       Key *key= ob_get_key(ob);
        
        /* add this object as a channel first */
        if (!(filter_mode & ACTFILTER_ONLYICU) && !(filter_mode & 
ACTFILTER_IPOKEYS)) {
                /* check if filtering by selection */
-               if (!(filter_mode & ACTFILTER_SEL) || ((base->flag & SELECT) || 
(base == sce->basact)) {
+               if ( !(filter_mode & ACTFILTER_SEL) || ((base->flag & SELECT) 
|| (base == sce->basact)) ) {
                        ale= make_new_actlistelem(base, ACTTYPE_OBJECT, NULL, 
ACTTYPE_NONE);
                        if (ale) BLI_addtail(act_data, ale);
                }
@@ -701,6 +721,20 @@
                }
        }
        
+       /* ShapeKeys? */
+       if (key) {
+               /* include shapekey-expand widget? */
+               if ((filter_mode & ACTFILTER_CHANNELS) && !(filter_mode & 
(ACTFILTER_IPOKEYS|ACTFILTER_ONLYICU))) {
+                       ale= make_new_actlistelem(key, ACTTYPE_FILLSKED, base, 
ACTTYPE_OBJECT);
+                       if (ale) BLI_addtail(act_data, ale);
+               }
+               
+               /* add channels */
+               if (FILTER_SKE_OBJC(key) || (filter_mode & ACTFILTER_IPOKEYS) 
|| (filter_mode & ACTFILTER_ONLYICU)) {
+                       actdata_filter_shapekey (act_data, key, filter_mode, 
ob, ACTTYPE_OBJECT);
+               }
+       }
+       
        /* Constraint Channels? */
        if (ob->constraintChannels.first) {
                bConstraintChannel *conchan;
@@ -753,6 +787,7 @@
                /* check if there's an object (all the relevant checks are done 
in the ob-function) */
                if (base->object) {
                        Object *ob= base->object;
+                       Key *key= ob_get_key(ob);
                        
                        /* firstly, check if object can be included, by the 
following factors:
                         *      - if only visible, must check for layer and 
also viewport visibility
@@ -767,7 +802,7 @@
                                /* outliner restrict-flag */
                                if (ob->restrictflag & OB_RESTRICT_VIEW) 
continue;
                        }
-                       if (!(ob->ipo) && !(ob->action) && 
!(ob->constraintChannels.first)) {
+                       if (!(ob->ipo) && !(ob->action) && 
!(ob->constraintChannels.first) && !(key)) {
                                /* no animation data to show... */
                                continue;
                        }
@@ -796,7 +831,7 @@
                                actdata_filter_action(act_data, data, 
filter_mode, NULL, ACTTYPE_NONE);
                                break;
                        case ACTCONT_SHAPEKEY:
-                               actdata_filter_shapekey(act_data, data, 
filter_mode);
+                               actdata_filter_shapekey(act_data, data, 
filter_mode, NULL, ACTTYPE_NONE);
                                break;
                        case ACTCONT_GPENCIL:
                                actdata_filter_gpencil(act_data, data, 
filter_mode);
@@ -4405,6 +4440,12 @@
                                ob->nlaflag ^= OB_ADS_SHOWCONS;
                        }
                                break;
+               case ACTTYPE_FILLSKED:
+                       {
+                               Key *key= (Key *)act_channel;
+                               key->flag ^= KEYBLOCK_EXPAND;
+                       }
+                               break;
                        
                case ACTTYPE_GROUP: 
                        {
@@ -4575,6 +4616,9 @@
                                }
                        }
                                break;
+               case ACTTYPE_SHAPEKEY:
+                       /* TODO: shapekey channels cannot be selected atm... */
+                       break;
                default:
                        printf("Error: Invalid channel type in 
mouse_actionchannels \n");
                        return;


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to