Revision: 18903
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18903
Author:   aligorith
Date:     2009-02-10 12:37:14 +0100 (Tue, 10 Feb 2009)

Log Message:
-----------
Graph Editor: Visibility toggles

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.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
    branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c

Modified: 
branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c    
    2009-02-10 10:42:04 UTC (rev 18902)
+++ 
branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c    
    2009-02-10 11:37:14 UTC (rev 18903)
@@ -608,12 +608,70 @@
 
 #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 @@
                                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 @@
                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 @@
                                /* 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 @@
        //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 @@
        //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);
 }
 
 /* ************************************************************************** 
*/

Modified: 
branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c  
2009-02-10 10:42:04 UTC (rev 18902)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c  
2009-02-10 11:37:14 UTC (rev 18903)
@@ -484,7 +484,7 @@
         */
        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 @@
                                        }
                                }
                        }
-               //}
+               }
        }
        
        /* return the number of items added to the list */

Modified: 
branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c 
2009-02-10 10:42:04 UTC (rev 18902)
+++ branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c 
2009-02-10 11:37:14 UTC (rev 18903)
@@ -986,9 +986,7 @@
                                        
                                        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 @@
                                                        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 @@
                                        
                                        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;
                                        


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

Reply via email to