Graph Editor: Visibility toggles
authorJoshua Leung <aligorith@gmail.com>
Tue, 10 Feb 2009 11:37:14 +0000 (11:37 +0000)
committerJoshua Leung <aligorith@gmail.com>
Tue, 10 Feb 2009 11:37:14 +0000 (11:37 +0000)
F-Curves can now be hidden/shown in the Graph Editor in one of 3 ways:
* Specialised VKEY toggle hotkey, which alters the visibility of all selected F-Curves
* The setting toggle operators (Shift-W, Alt-W, Ctrl-Shift-W)
* Checkmark (*1) boxes in front of names of F-Curves

This allows irrelevant curves to be hidden from the keyframes area only if you want them hidden. By default, all curves are visible. Also note that a separate hotkey is used now for toggling visibility (VKEY) instead of lumping it under select-all (AKEY) as in the past, which was a major cause of confusion.

Notes:
1) I've used the ICON_BLANK011 and ICON_BLANK012 icons, which in the current icon set are two states for a checkbox type thing. These defines should probably get renamed sometime, but I'll leave that up to Matt.

source/blender/editors/animation/anim_channels.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/space_graph/graph_draw.c

index a697580d674914acf1369f1e7883495039aafed8..c0025a1b0f541437e457e6448912438c9df934de 100644 (file)
@@ -608,12 +608,70 @@ void ANIM_OT_channels_move_bottom (wmOperatorType *ot)
 
 #endif // XXX old animation system - needs to be updated for new system...
 
+
+/* ******************** Toggle Channel Visibility Operator *********************** */
+
+static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *op)
+{
+       bAnimContext ac;
+       ListBase anim_data = {NULL, NULL};
+       bAnimListElem *ale;
+       int filter;
+       short vis= ACHANNEL_SETFLAG_ADD;
+       
+       /* get editor data */
+       if (ANIM_animdata_get_context(C, &ac) == 0)
+               return OPERATOR_CANCELLED;
+               
+       /* filter data */
+       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY);
+       ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+       
+       /* See if we should be making showing all selected or hiding */
+       for (ale= anim_data.first; ale; ale= ale->next) {
+               if (vis == ACHANNEL_SETFLAG_CLEAR) 
+                       break;
+               
+               if (ale->flag & FCURVE_VISIBLE)
+                       vis= ACHANNEL_SETFLAG_CLEAR;
+       }
+               
+       /* Now set the flags */
+       for (ale= anim_data.first; ale; ale= ale->next) {
+               FCurve *fcu= (FCurve *)ale->data;
+               ACHANNEL_SET_FLAG(fcu, vis, FCURVE_VISIBLE);
+       }
+       
+       /* cleanup */
+       BLI_freelistN(&anim_data);
+       
+       /* set notifier tha things have changed */
+       ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_CHANNELS);
+       
+       return OPERATOR_FINISHED;
+}
+void ANIM_OT_channels_visibility_toggle (wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Toggle Visibility";
+       ot->idname= "ANIM_OT_channels_visibility_toggle";
+       
+       /* api callbacks */
+       ot->exec= animchannels_visibility_toggle_exec;
+       ot->poll= ED_operator_ipo_active;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 /* ********************** Set Flags Operator *********************** */
 
 enum {
 //     ACHANNEL_SETTING_SELECT = 0,
        ACHANNEL_SETTING_PROTECT = 1,
        ACHANNEL_SETTING_MUTE,
+       ACHANNEL_SETTING_VISIBLE,
 } eAnimChannel_Settings;
 
 /* defines for setting animation-channel flags */
@@ -672,6 +730,9 @@ static void setflag_anim_channels (bAnimContext *ac, short setting, short mode)
                                else if (setting == ACHANNEL_SETTING_PROTECT) {
                                        ACHANNEL_SET_FLAG(fcu, mode, FCURVE_PROTECTED);
                                }
+                               else if (setting == ACHANNEL_SETTING_VISIBLE) {
+                                       ACHANNEL_SET_FLAG(fcu, mode, FCURVE_VISIBLE);
+                               }
                        }
                                break;
                        case ANIMTYPE_GPLAYER:
@@ -1120,6 +1181,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
                case ANIMTYPE_FCURVE: 
                {
                        FCurve *fcu= (FCurve *)ale->data;
+                       short offset= (ac->datatype != ANIMCONT_ACTION)? 18 : 0;
                        
                        if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) {
                                /* toggle protection */
@@ -1129,6 +1191,11 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
                                /* toggle mute */
                                fcu->flag ^= FCURVE_MUTED;
                        }
+                       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;
@@ -1274,6 +1341,8 @@ void ED_operatortypes_animchannels(void)
        //WM_operatortype_append(ANIM_OT_channels_move_down);
        //WM_operatortype_append(ANIM_OT_channels_move_top);
        //WM_operatortype_append(ANIM_OT_channels_move_bottom);
+       
+       WM_operatortype_append(ANIM_OT_channels_visibility_toggle);
 }
 
 void ED_keymap_animchannels(wmWindowManager *wm)
@@ -1304,6 +1373,9 @@ void ED_keymap_animchannels(wmWindowManager *wm)
        //WM_keymap_add_item(keymap, "ANIM_OT_channels_move_down", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0);
        //WM_keymap_add_item(keymap, "ANIM_OT_channels_move_to_top", PAGEUPKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
        //WM_keymap_add_item(keymap, "ANIM_OT_channels_move_to_bottom", PAGEDOWNKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
+       
+       /* Graph Editor only */
+       WM_keymap_add_item(keymap, "ANIM_OT_channels_visibility_toggle", VKEY, KM_PRESS, 0, 0);
 }
 
 /* ************************************************************************** */
index 8b14b9b2d5c5c65ee1bf3152167bc210919a5960..75bc145e267578e944e6c106924c9fb0f187e111 100644 (file)
@@ -484,7 +484,7 @@ static int animdata_filter_fcurves (ListBase *anim_data, FCurve *first, bActionG
         */
        for (fcu= first; ((fcu) && (fcu->grp==grp)); fcu= fcu->next) {
                /* only include if visible (Graph Editor check, not channels check) */
-               //if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || (fcu->flag & FCURVE_VISIBLE)) { // XXX don't do this till we have tools to set this
+               if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || (fcu->flag & FCURVE_VISIBLE)) {
                        /* only work with this channel and its subchannels if it is editable */
                        if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_FCU(fcu)) {
                                /* only include this curve if selected */
@@ -498,7 +498,7 @@ static int animdata_filter_fcurves (ListBase *anim_data, FCurve *first, bActionG
                                        }
                                }
                        }
-               //}
+               }
        }
        
        /* return the number of items added to the list */
index 1924fc0b50871412b42e2961f1749320ebc38b64..7adb90e74649f5617a449b8c479109364646267d 100644 (file)
@@ -986,9 +986,7 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
                                        
                                        group= (fcu->grp) ? 1 : 0;
                                        grp= fcu->grp;
-                                       
-                                       // XXX include some UI element to allow toggling of visibility
-                                       
+                                                                               
                                        switch (ale->ownertype) {
                                                case ANIMTYPE_NONE:     /* no owner */
                                                case ANIMTYPE_FCURVE: 
@@ -1005,6 +1003,13 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
                                                        break;
                                        }
                                        
+                                       /* for now, 'special' (i.e. in front of name) is used to show visibility status */
+                                       // XXX these 'blank' icons are currently checkboxes
+                                       if (fcu->flag & FCURVE_VISIBLE)
+                                               special= ICON_BLANK012;
+                                       else
+                                               special= ICON_BLANK011;
+                                       
                                        if (fcu->flag & FCURVE_MUTED)
                                                mute = ICON_MUTE_IPO_ON;
                                        else    
@@ -1017,9 +1022,7 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
                                        
                                        sel = SEL_FCU(fcu);
                                        
-                                       // for now, we just print the full path... this needs more work!
                                        getname_anim_fcurve(name, ale->id, fcu);
-                                       //sprintf(name, "%s[%d]", fcu->rna_path, fcu->array_index);
                                }
                                        break;