Graph Editor: Selecting F-Curve channels + keyframes now sets active F-Curve correctly.
authorJoshua Leung <aligorith@gmail.com>
Sun, 22 Feb 2009 05:34:47 +0000 (05:34 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sun, 22 Feb 2009 05:34:47 +0000 (05:34 +0000)
source/blender/editors/animation/anim_channels.c
source/blender/editors/space_graph/graph_select.c

index e0ba8d15a987c931f7680f0d3f8b1c57c8a4f859..6ba499fa25dd56d1b788c844da5d31ef8eccb7f6 100644 (file)
@@ -1220,7 +1220,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
                                }
                                
                                /* if group is selected now, make group the 'active' one in the visible list */
-                               if ((agrp->flag & AGRP_SELECTED) && (selectmode != SELECT_INVERT))
+                               if (agrp->flag & AGRP_SELECTED)
                                        ANIM_set_active_channel(ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
                        }
                }
@@ -1240,17 +1240,23 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
                        }
                        else if ((x < (offset+17)) && (ac->spacetype==SPACE_IPO)) {
                                /* toggle visibility */
-                               // XXX this is supposed to be button before name, though this sometimes fails
                                fcu->flag ^= FCURVE_VISIBLE;
                        }
                        else {
                                /* select/deselect */
-                               fcu->flag ^= FCURVE_SELECTED;
+                               if (selectmode == SELECT_INVERT) {
+                                       /* inverse selection status of this F-Curve only */
+                                       fcu->flag ^= FCURVE_SELECTED;
+                               }
+                               else {
+                                       /* select F-Curve by itself */
+                                       ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+                                       fcu->flag |= FCURVE_SELECTED;
+                               }
                                
+                               /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */
                                if (fcu->flag & FCURVE_SELECTED)
-                                       fcu->flag |= FCURVE_ACTIVE;
-                               else
-                                       fcu->flag &= ~FCURVE_ACTIVE;
+                                       ANIM_set_active_channel(ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE);
                        }
                }
                        break;
index be2f6dda0e079550ac8d184b058b753bc2bc2e14..e4cb2f64071061bad8aa016f4aaa2c382414ed7b 100644 (file)
@@ -661,6 +661,7 @@ static void mouse_graph_keys (bAnimContext *ac, int mval[], short selectmode)
        FCurve *fcu;
        BezTriple *bezt;
        short handle;
+       int filter;
        
        /* find the beztriple that we're selecting, and the handle that was clicked on */
        handle= findnearest_fcurve_vert(ac, mval, &fcu, &bezt);
@@ -719,16 +720,16 @@ static void mouse_graph_keys (bAnimContext *ac, int mval[], short selectmode)
        }
        
        /* select or deselect curve? */
-       if (selectmode == SELECT_INVERT) {
+       if (selectmode == SELECT_INVERT)
                fcu->flag ^= FCURVE_SELECTED;
+       else if (selectmode == SELECT_ADD)
+               fcu->flag |= FCURVE_SELECTED;
                
-               if (fcu->flag & FCURVE_SELECTED)
-                       fcu->flag |= FCURVE_ACTIVE;
-               else
-                       fcu->flag &= ~FCURVE_ACTIVE;
+       /* set active F-Curve (NOTE: sync the filter flags with findnearest_fcurve_vert) */
+       if (fcu->flag & FCURVE_SELECTED) {
+               filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY);
+               ANIM_set_active_channel(ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE);
        }
-       else if (selectmode == SELECT_ADD)
-               fcu->flag |= (FCURVE_ACTIVE|FCURVE_SELECTED);
 }
 
 /* Option 2) Selects all the keyframes on either side of the current frame (depends on which side the mouse is on) */
@@ -881,7 +882,6 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *ev
        else {
                /* select keyframe under mouse */
                mouse_graph_keys(&ac, mval, selectmode); // xxx curves only should become an arg
-               // XXX activate transform...
        }
        
        /* set notifier tha things have changed */