Revision: 19670
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19670
Author:   aligorith
Date:     2009-04-12 08:47:25 +0200 (Sun, 12 Apr 2009)

Log Message:
-----------
Action Editor: Selection tools cleanup

* Cleaned up the code for selecting keyframes
* Click-column-select (Alt-RMB) now works

* Also, moved a function used in both Action/DopeSheet and Graph editors to the 
Animation module

Modified Paths:
--------------
    
branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
    
branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
    
branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c
    
branches/blender2.5/blender/source/blender/editors/space_action/action_select.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_edit.c

Modified: 
branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c   
    2009-04-12 06:41:01 UTC (rev 19669)
+++ 
branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c   
    2009-04-12 06:47:25 UTC (rev 19670)
@@ -335,6 +335,24 @@
 }
 
 /* ******************************************* */
+/* Assorted Utility Functions */
+
+/* helper callback for <animeditor>_cfrasnap_exec() -> used to help get the 
average time of all selected beztriples */
+short bezt_calc_average(BeztEditData *bed, BezTriple *bezt)
+{
+       /* only if selected */
+       if (bezt->f2 & SELECT) {
+               /* store average time in float (only do rounding at last step */
+               bed->f1 += bezt->vec[1][0];
+               
+               /* increment number of items */
+               bed->i1++;
+       }
+       
+       return 0;
+}
+
+/* ******************************************* */
 /* Transform */
 
 static short snap_bezier_nearest(BeztEditData *bed, BezTriple *bezt)

Modified: 
branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h  
    2009-04-12 06:41:01 UTC (rev 19669)
+++ 
branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h  
    2009-04-12 06:47:25 UTC (rev 19670)
@@ -131,6 +131,10 @@
 BeztEditFunc ANIM_editkeyframes_handles(short mode);
 BeztEditFunc ANIM_editkeyframes_ipo(short mode);
 
+/* ----------- BezTriple Callback (Assorted Utilities) ---------- */
+
+short bezt_calc_average(BeztEditData *bed, struct BezTriple *bezt);
+
 /* ************************************************ */
 /* Destructive Editing API (keyframes_general.c) */
 

Modified: 
branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c   
    2009-04-12 06:41:01 UTC (rev 19669)
+++ 
branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c   
    2009-04-12 06:47:25 UTC (rev 19670)
@@ -1051,22 +1051,6 @@
 
 /* ***************** Snap Current Frame Operator *********************** */
 
-/* helper callback for actkeys_cfrasnap_exec() -> used to help get the average 
time of all selected beztriples */
-// TODO: if some other code somewhere needs this, it'll be time to port this 
over to keyframes_edit.c!!!
-static short bezt_calc_average(BeztEditData *bed, BezTriple *bezt)
-{
-       /* only if selected */
-       if (bezt->f2 & SELECT) {
-               /* store average time in float (only do rounding at last step */
-               bed->f1 += bezt->vec[1][0];
-               
-               /* increment number of items */
-               bed->i1++;
-       }
-       
-       return 0;
-}
-
 /* snap current-frame indicator to 'average time' of selected keyframe */
 static int actkeys_cfrasnap_exec(bContext *C, wmOperator *op)
 {

Modified: 
branches/blender2.5/blender/source/blender/editors/space_action/action_select.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_action/action_select.c 
    2009-04-12 06:41:01 UTC (rev 19669)
+++ 
branches/blender2.5/blender/source/blender/editors/space_action/action_select.c 
    2009-04-12 06:47:25 UTC (rev 19670)
@@ -83,154 +83,6 @@
 #include "action_intern.h"
 
 /* ************************************************************************** 
*/
-/* GENERAL STUFF */
-
-/* used only by mouse_action. It is used to find the location of the nearest 
- * keyframe to where the mouse clicked, 
- */
-// XXX just merge this into the existing code!
-static void *get_nearest_action_key (bAnimContext *ac, int mval[2], float 
*selx, short *sel, short *ret_type, bActionGroup **par)
-{
-       ListBase anim_data = {NULL, NULL};
-       ListBase anim_keys = {NULL, NULL};
-       bAnimListElem *ale;
-       ActKeyColumn *ak;
-       View2D *v2d= &ac->ar->v2d;
-       int filter;
-       
-       rctf rectf;
-       void *data = NULL;
-       float xmin, xmax, x, y;
-       int channel_index;
-       short found = 0;
-       
-       /* action-group */
-       *par= NULL;
-       
-       
-       UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
-       UI_view2d_listview_view_to_cell(v2d, 0, ACHANNEL_STEP, 0, 
(float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index);
-       
-       /* x-range to check is +/- 7 on either side of mouse click (size of 
keyframe icon) */
-       UI_view2d_region_to_view(v2d, mval[0]-7, mval[1], &rectf.xmin, 
&rectf.ymin);
-       UI_view2d_region_to_view(v2d, mval[0]+7, mval[1], &rectf.xmax, 
&rectf.ymax);
-       
-       /* filter data */
-       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS);
-       ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-       
-       /* get channel */
-       ale= BLI_findlink(&anim_data, channel_index);
-       if (ale == NULL) {
-               /* channel not found */
-               printf("Error: animation channel (index = %d) not found in 
mouse_action_keys() \n", channel_index);
-               
-               BLI_freelistN(&anim_data);
-               return NULL;
-       }
-       else {
-               /* found match - must return here... */
-               Object *nob= ANIM_nla_mapping_get(ac, ale);
-               ActKeysInc *aki= init_aki_data(ac, ale);
-               
-               /* apply NLA-scaling correction? */
-               if (nob) {
-                       xmin= get_action_frame(nob, rectf.xmin);
-                       xmax= get_action_frame(nob, rectf.xmax);
-               }
-               else {
-                       xmin= rectf.xmin;
-                       xmax= rectf.xmax;
-               }
-               
-               /* make list of keyframes */
-               if (ale->key_data) {
-                       switch (ale->datatype) {
-                               case ALE_OB:
-                               {
-                                       Object *ob= (Object *)ale->key_data;
-                                       ob_to_keylist(ob, &anim_keys, NULL, 
aki);
-                               }
-                                       break;
-                               case ALE_ACT:
-                               {
-                                       bAction *act= (bAction *)ale->key_data;
-                                       action_to_keylist(act, &anim_keys, 
NULL, aki);
-                               }
-                                       break;
-                               case ALE_FCURVE:
-                               {
-                                       FCurve *fcu= (FCurve *)ale->key_data;
-                                       fcurve_to_keylist(fcu, &anim_keys, 
NULL, aki);
-                               }
-                                       break;
-                       }
-               }
-               else if (ale->type == ANIMTYPE_GROUP) {
-                       bActionGroup *agrp= (bActionGroup *)ale->data;
-                       agroup_to_keylist(agrp, &anim_keys, NULL, aki);
-               }
-               else if (ale->type == ANIMTYPE_GPDATABLOCK) {
-                       /* cleanup */
-                       BLI_freelistN(&anim_data);
-                       
-                       /* this channel currently doens't have any keyframes... 
must ignore! */
-                       *ret_type= ANIMTYPE_NONE;
-                       return NULL;
-               }
-               else if (ale->type == ANIMTYPE_GPLAYER) {
-                       bGPDlayer *gpl= (bGPDlayer *)ale->data;
-                       gpl_to_keylist(gpl, &anim_keys, NULL, aki);
-               }
-               
-               /* loop through keyframes, finding one that was clicked on */
-               for (ak= anim_keys.first; ak; ak= ak->next) {
-                       if (IN_RANGE(ak->cfra, xmin, xmax)) {
-                               *selx= ak->cfra;
-                               found= 1;
-                               break;
-                       }
-               }
-               /* no matching keyframe found - set to mean frame value so it 
doesn't actually select anything */
-               if (found == 0)
-                       *selx= ((xmax+xmin) / 2);
-               
-               /* figure out what to return */
-               if (ac->datatype == ANIMCONT_ACTION) {
-                       *par= ale->owner; /* assume that this is an action 
group */
-                       *ret_type= ale->type;
-                       data = ale->data;
-               }
-               else if (ac->datatype == ANIMCONT_SHAPEKEY) {
-                       data = ale->key_data;
-                       *ret_type= ANIMTYPE_FCURVE;
-               }
-               else if (ac->datatype == ANIMCONT_DOPESHEET) {
-                       data = ale->data;
-                       *ret_type= ale->type;
-               }
-               else if (ac->datatype == ANIMCONT_GPENCIL) {
-                       data = ale->data;
-                       *ret_type= ANIMTYPE_GPLAYER;
-               }
-               
-               /* cleanup tempolary lists */
-               BLI_freelistN(&anim_keys);
-               anim_keys.first = anim_keys.last = NULL;
-               
-               BLI_freelistN(&anim_data);
-               
-               return data;
-       }
-       
-       /* cleanup */
-       BLI_freelistN(&anim_data);
-       
-       *ret_type= ANIMTYPE_NONE;
-       return NULL;
-}
-
-/* ************************************************************************** 
*/
 /* KEYFRAMES STUFF */
 
 /* ******************** Deselect All Operator ***************************** */
@@ -763,140 +615,26 @@
 /* ------------------- */
  
 /* option 1) select keyframe directly under mouse */
-static void mouse_action_keys (bAnimContext *ac, int mval[2], short selectmode)
+static void actkeys_select_single (bAnimContext *ac, bAnimListElem *ale, short 
select_mode, float selx)
 {
-       Scene *sce= NULL;
-       Object *ob= NULL;
-       bDopeSheet *ads= NULL;
-       bAction *act= NULL;
-       bActionGroup *agrp= NULL;
-       FCurve *fcu= NULL;
-       bGPdata *gpd = NULL;
-       bGPDlayer *gpl = NULL;
+       bDopeSheet *ads= (ac->datatype == ANIMCONT_DOPESHEET) ? ac->data : NULL;
+       int ds_filter = ((ads) ? (ads->filterflag) : (0));
        
        BeztEditData bed;
        BeztEditFunc select_cb, ok_cb;
-       void *anim_channel;
-       short sel, chan_type = 0, key_type = 0;
-       float selx = 0.0f;
        
-       /* determine what type of data we are operating on */
-       if (ac->datatype == ANIMCONT_ACTION) 
-               act= (bAction *)ac->data;
-       else if (ac->datatype == ANIMCONT_DOPESHEET) 
-               ads= (bDopeSheet *)ac->data;
-       else if (ac->datatype == ANIMCONT_GPENCIL) 
-               gpd= (bGPdata *)ac->data;
-       
-       /* get channel and selection info */
-       anim_channel= get_nearest_action_key(ac, mval, &selx, &sel, &chan_type, 
&agrp); // xxx...
-       if (anim_channel == NULL) 
-               return;
-       
-       switch (chan_type) {
-               case ANIMTYPE_FCURVE:
-                       fcu= (FCurve *)anim_channel;
-                       key_type= ALE_FCURVE;
-                       break;
-               case ANIMTYPE_GROUP:
-                       agrp= (bActionGroup *)anim_channel;
-                       key_type= ALE_GROUP;
-                       break;
-#if 0 // XXX fixme
-               case ANIMTYPE_DSMAT:
-                       ipo= ((Material *)anim_channel)->ipo;
-                       break;
-               case ANIMTYPE_DSLAM:
-                       ipo= ((Lamp *)anim_channel)->ipo;
-                       break;
-               case ANIMTYPE_DSCAM:
-                       ipo= ((Camera *)anim_channel)->ipo;
-                       break;
-               case ANIMTYPE_DSCUR:
-                       ipo= ((Curve *)anim_channel)->ipo;
-                       break;
-               case ANIMTYPE_DSSKEY:
-                       ipo= ((Key *)anim_channel)->ipo;
-                       break;
-#endif // XXX fixme
-               case ANIMTYPE_FILLACTD:
-                       act= (bAction *)anim_channel;
-                       key_type= ALE_ACT;
-                       break;
-               case ANIMTYPE_OBJECT:
-                       ob= ((Base *)anim_channel)->object;
-                       key_type= ALE_OB;
-                       break;
-               case ANIMTYPE_SCENE:
-                       sce= (Scene *)anim_channel;
-                       key_type= ALE_SCE;
-                       break;
-               case ANIMTYPE_GPLAYER:
-                       gpl= (bGPDlayer *)anim_channel;
-                       break;
-               default:
-                       return;
-       }
-       
-       /* for replacing selection, firstly need to clear existing selection */
-       if (selectmode == SELECT_REPLACE) {
-               selectmode = SELECT_ADD;
-               
-               deselect_action_keys(ac, 0, SELECT_SUBTRACT);
-               
-               if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET)) {
-                       int filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS); 
/* this should suffice for now */
-                       
-                       /* deselect all other channels first */
-                       ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, 
ACHANNEL_SETFLAG_CLEAR);
-                       
-                       /* Highlight Action-Group or F-Curve? */
-                       if (agrp) {

@@ 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