Revision: 18235
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18235
Author:   aligorith
Date:     2009-01-02 01:56:48 +0100 (Fri, 02 Jan 2009)

Log Message:
-----------
2.5 - Animation and View2D 

* Added back deselect all (and invert all) tools for Animation Channels (i.e. 
channel list in Action Editor).

* Resolved all MSVC warnings (I came across) in View2d code. Also, added a new 
API method to get the coordinates (in 'view' space) of a listview 'cell' given 
the row + column the cell is in.

* Tidied up a few comments here and there

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
    branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c
    branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
    branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c
    branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c
    
branches/blender2.5/blender/source/blender/editors/space_action/action_select.c
    
branches/blender2.5/blender/source/blender/editors/space_action/space_action.c

Modified: 
branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c     
2009-01-02 00:53:49 UTC (rev 18234)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c     
2009-01-02 00:56:48 UTC (rev 18235)
@@ -5264,9 +5264,9 @@
                        case SPACE_ACTION:
                        {
                                SpaceAction *saction= (SpaceAction *)sl;
-                               memcpy(&ar->v2d, &saction->v2d, sizeof(View2D));
                                
-                               ar->v2d.tot.xmin= -10.0f;
+                               /* we totally reinit the view for the Action 
Editor, as some old instances had some weird cruft set */
+                               ar->v2d.tot.xmin= -20.0f;
                                ar->v2d.tot.ymin= (float)(-sa->winy);
                                ar->v2d.tot.xmax= (float)(sa->winx);
                                ar->v2d.tot.ymax= 0.0f;

Modified: 
branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c    
    2009-01-02 00:53:49 UTC (rev 18234)
+++ 
branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c    
    2009-01-02 00:56:48 UTC (rev 18235)
@@ -86,19 +86,178 @@
 /* ************************************************************************** 
*/
 /* CHANNELS API */
 
-/* -------------------------- Internal Tools -------------------------------- 
*/
+/* -------------------------- Internal Macros ------------------------------- 
*/
 
+/* set/clear/toggle macro 
+ *     - channel - channel with a 'flag' member that we're setting
+ *     - smode - 0=clear, 1=set, 2=toggle
+ *     - sflag - bitflag to set
+ */
+#define ACHANNEL_SET_FLAG(channel, smode, sflag) \
+       { \
+               if (smode == ACHANNEL_SETFLAG_TOGGLE)   (channel)->flag ^= 
(sflag); \
+               else if (smode == ACHANNEL_SETFLAG_ADD) (channel)->flag |= 
(sflag); \
+               else                                                            
        (channel)->flag &= ~(sflag); \
+       }
 
+/* -------------------------- Internal Tools -------------------------------- 
*/
 
 /* -------------------------- Exposed API ----------------------------------- 
*/
 
+
+
+/* Deselect all animation channels 
+ *     - data: pointer to datatype, as contained in bAnimContext
+ *     - datatype: the type of data that 'data' represents (eAnim_ChannelType)
+ *     - test: check if deselecting instead of selecting
+ *     - sel: eAnimChannels_SetFlag;
+ */
+void ANIM_deselect_anim_channels (void *data, short datatype, short test, 
short sel)
+{
+       ListBase anim_data = {NULL, NULL};
+       bAnimListElem *ale;
+       int filter;
+       
+       /* filter data */
+       filter= ANIMFILTER_VISIBLE;
+       ANIM_animdata_filter(&anim_data, filter, data, datatype);
+       
+       /* See if we should be selecting or deselecting */
+       if (test) {
+               for (ale= anim_data.first; ale; ale= ale->next) {
+                       if (sel == 0) 
+                               break;
+                       
+                       switch (ale->type) {
+                               case ANIMTYPE_OBJECT:
+                                       if (ale->flag & SELECT)
+                                               sel= ACHANNEL_SETFLAG_CLEAR;
+                                       break;
+                               case ANIMTYPE_FILLACTD:
+                                       if (ale->flag & ACTC_SELECTED)
+                                               sel= ACHANNEL_SETFLAG_CLEAR;
+                                       break;
+                               case ANIMTYPE_GROUP:
+                                       if (ale->flag & AGRP_SELECTED)
+                                               sel= ACHANNEL_SETFLAG_CLEAR;
+                                       break;
+                               case ANIMTYPE_ACHAN:
+                                       if (ale->flag & ACHAN_SELECTED) 
+                                               sel= ACHANNEL_SETFLAG_CLEAR;
+                                       break;
+                               case ANIMTYPE_CONCHAN:
+                                       if (ale->flag & 
CONSTRAINT_CHANNEL_SELECT) 
+                                               sel= ACHANNEL_SETFLAG_CLEAR;
+                                       break;
+                               case ANIMTYPE_ICU:
+                                       if (ale->flag & IPO_SELECT)
+                                               sel= ACHANNEL_SETFLAG_CLEAR;
+                                       break;
+                       }
+               }
+       }
+               
+       /* Now set the flags */
+       for (ale= anim_data.first; ale; ale= ale->next) {
+               switch (ale->type) {
+                       case ANIMTYPE_OBJECT:
+                       {
+                               Base *base= (Base *)ale->data;
+                               Object *ob= base->object;
+                               
+                               ACHANNEL_SET_FLAG(base, sel, SELECT);
+                               ACHANNEL_SET_FLAG(ob, sel, SELECT);
+                       }
+                               break;
+                       case ANIMTYPE_FILLACTD:
+                       {
+                               bAction *act= (bAction *)ale->data;
+                               
+                               ACHANNEL_SET_FLAG(act, sel, ACTC_SELECTED);
+                       }
+                               break;
+                       case ANIMTYPE_GROUP:
+                       {
+                               bActionGroup *agrp= (bActionGroup *)ale->data;
+                               
+                               ACHANNEL_SET_FLAG(agrp, sel, AGRP_SELECTED);
+                               agrp->flag &= ~AGRP_ACTIVE;
+                       }
+                               break;
+                       case ANIMTYPE_ACHAN:
+                       {
+                               bActionChannel *achan= (bActionChannel 
*)ale->data;
+                               
+                               ACHANNEL_SET_FLAG(achan, sel, ACHAN_SELECTED);
+                               
+                               //select_poseelement_by_name(achan->name, sel); 
// XXX
+                               achan->flag &= ~ACHAN_HILIGHTED;
+                       }
+                               break;
+                       case ANIMTYPE_CONCHAN:
+                       {
+                               bConstraintChannel *conchan= 
(bConstraintChannel *)ale->data;
+                               
+                               ACHANNEL_SET_FLAG(conchan, sel, 
CONSTRAINT_CHANNEL_SELECT);
+                       }
+                               break;
+                       case ANIMTYPE_ICU:
+                       {
+                               IpoCurve *icu= (IpoCurve *)ale->data;
+                               
+                               ACHANNEL_SET_FLAG(icu, sel, IPO_SELECT);
+                               icu->flag &= ~IPO_ACTIVE;
+                       }
+                               break;
+               }
+       }
+       
+       /* Cleanup */
+       BLI_freelistN(&anim_data);
+}
+
 /* ************************************************************************** 
*/
 /* OPERATORS */
 
 /* ********************** Select All Operator *********************** */
 
+static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
+{
+       bAnimContext ac;
+       
+       /* get editor data */
+       if (ANIM_animdata_get_context(C, &ac) == 0)
+               return OPERATOR_CANCELLED;
+               
+       /* 'standard' behaviour - check if selected, then apply relevant 
selection */
+       if (RNA_boolean_get(op->ptr, "invert"))
+               ANIM_deselect_anim_channels(ac.data, ac.datatype, 0, 
ACHANNEL_SETFLAG_TOGGLE);
+       else
+               ANIM_deselect_anim_channels(ac.data, ac.datatype, 1, 
ACHANNEL_SETFLAG_ADD);
+       
+       /* set notifier tha things have changed */
+       ED_area_tag_redraw(CTX_wm_area(C)); // FIXME... should be updating 
'keyframes' data context or so instead!
+       
+       return OPERATOR_FINISHED;
+}
+ 
+void ANIM_OT_channels_deselectall (wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Select All";
+       ot->idname= "ANIM_OT_channels_deselectall";
+       
+       /* api callbacks */
+       ot->exec= animchannels_deselectall_exec;
+       ot->poll= ED_operator_areaactive;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+       
+       /* props */
+       RNA_def_property(ot->srna, "invert", PROP_BOOLEAN, PROP_NONE);
+}
 
-
 /* ******************** Mouse-Click Operator *********************** */
 /* Depending on the channel that was clicked on, the mouse click will activate 
whichever
  * part of the channel is relevant.
@@ -243,7 +402,7 @@
                                                /* inverse selection status of 
group */
                                                //select_action_group(act, 
agrp, SELECT_INVERT);
                                        }
-                                       else if (/*G.qual == 
(LR_CTRLKEY|LR_SHIFTKEY)*/0) {
+                                       else if (/*G.qual == 
(LR_CTRLKEY|LR_SHIFTKEY)*/selectmode == -1) {
                                                // FIXME: need a special case 
for this!
                                                /* select all in group (and 
deselect everthing else) */ 
                                                
//select_action_group_channels(act, agrp);
@@ -251,7 +410,7 @@
                                        }
                                        else {
                                                /* select group by itself */
-                                               //deselect_actionchannels(act, 
ANIMCONT_ACTION, 0);
+                                               
ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
                                                //select_action_group(act, 
agrp, SELECT_ADD);
                                        }
                                        
@@ -283,7 +442,7 @@
                                                //select_channel(act, achan, 
SELECT_INVERT);
                                        }
                                        else {
-                                               //deselect_actionchannels(act, 
ACTCONT_ACTION, 0);
+                                               
ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
                                                //select_channel(act, achan, 
SELECT_ADD);
                                        }
                                        
@@ -303,7 +462,7 @@
                                
                                if ((x > 24) && (achan->flag & ACHAN_SHOWIPO)) {
                                        /* select+make active achan */          
-                                       //deselect_actionchannels(act, 
ACTCONT_ACTION, 0);
+                                       ANIM_deselect_anim_channels(ac->data, 
ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
                                        //select_channel(act, achan, 
SELECT_ADD);
                                        
                                        /* messy... set active bone */
@@ -322,7 +481,7 @@
                                
                                if ((x > 24) && (achan->flag & ACHAN_SHOWCONS)) 
{
                                        /* select+make active achan */  
-                                       //deselect_actionchannels(act, 
ACTCONT_ACTION, 0);
+                                       ANIM_deselect_anim_channels(ac->data, 
ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
                                        //select_channel(act, achan, 
SELECT_ADD);
                                        
                                        /* messy... set active bone */
@@ -460,7 +619,7 @@
         *              ACHANNEL_HEIGHT_HALF.
         */
        UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
-       UI_view2d_listview_get_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP, 0, 
(float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index);
+       UI_view2d_listview_view_to_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP, 
0, (float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index);
        
        /* handle mouse-click in the relevant channel then */
        mouse_anim_channels(&ac, x, channel_index, selectmode);
@@ -490,6 +649,7 @@
 
 void ED_operatortypes_animchannels(void)
 {
+       WM_operatortype_append(ANIM_OT_channels_deselectall);
        WM_operatortype_append(ANIM_OT_channels_mouseclick);
 }
 
@@ -501,6 +661,10 @@
                // XXX for now, only leftmouse.... 
        WM_keymap_add_item(keymap, "ANIM_OT_channels_mouseclick", LEFTMOUSE, 
KM_PRESS, 0, 0);
        RNA_boolean_set(WM_keymap_add_item(keymap, 
"ANIM_OT_channels_mouseclick", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, 
"extend_select", 1);
+       
+       /* deselect all */
+       WM_keymap_add_item(keymap, "ANIM_OT_channels_deselectall", AKEY, 
KM_PRESS, 0, 0);
+       RNA_boolean_set(WM_keymap_add_item(keymap, 
"ANIM_OT_channels_deselectall", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
 }
 
 /* ************************************************************************** 
*/

Modified: 
branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c    
2009-01-02 00:53:49 UTC (rev 18234)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c    
2009-01-02 00:56:48 UTC (rev 18235)
@@ -79,7 +79,7 @@
        
        /* because the frame number text is subject to the same scaling as the 
contents of the view */
        UI_view2d_getscale(v2d, &xscale, &yscale);
-       glScalef(1.0/xscale, 1.0, 1.0);
+       glScalef(1.0f/xscale, 1.0f, 1.0f);
        
        if (time) 
                sprintf(str, "   %.2f", FRA2TIME(CFRA));
@@ -97,7 +97,7 @@
        
        /* draw current frame number - black text */
        UI_ThemeColor(TH_TEXT);
-       ui_rasterpos_safe(x-5, y+3, 1.0);
+       ui_rasterpos_safe(x-5, y+3, 1.0f);
        UI_DrawString(G.fonts, str, 0); // XXX may need to be updated for font 
stuff
        
        /* restore view transform */
@@ -168,8 +168,8 @@
                
                /* only draw two separate 'curtains' if there's no overlap 
between them */
                if (PSFRA < PEFRA) {
-                       glRectf(v2d->cur.xmin, v2d->cur.ymin, PSFRA, 
v2d->cur.ymax);
-                       glRectf(PEFRA, v2d->cur.ymin, v2d->cur.xmax, 
v2d->cur.ymax);    

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to