Animation Editors - Moved the code for drawing the filtering toggles into a single...
authorJoshua Leung <aligorith@gmail.com>
Sun, 27 Sep 2009 06:14:42 +0000 (06:14 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sun, 27 Sep 2009 06:14:42 +0000 (06:14 +0000)
source/blender/editors/animation/anim_draw.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/space_action/action_header.c
source/blender/editors/space_graph/graph_header.c
source/blender/editors/space_graph/graph_utils.c
source/blender/editors/space_nla/nla_header.c
source/blender/makesdna/DNA_action_types.h

index 6388106fdb5d1bd72909453c500b62ff23a9aee0..507bf03e7efb7f393d952233f8c28d4ecd29b3fe 100644 (file)
@@ -55,6 +55,7 @@
 
 #include "ED_anim_api.h"
 #include "ED_keyframes_edit.h"
+#include "ED_types.h"
 #include "ED_util.h"
 
 #include "WM_api.h"
@@ -316,3 +317,52 @@ void ANIM_nla_mapping_apply_fcurve (AnimData *adt, FCurve *fcu, short restore, s
 } 
 
 /* *************************************************** */
+/* ANIMATION EDITOR UI-WIDGETS */
+
+/* ui button event */
+#define B_REDR                 1
+
+/* standard header buttons for Animation Editors */
+short ANIM_headerUI_standard_buttons (const bContext *C, bDopeSheet *ads, uiBlock *block, short xco, short yco)
+{
+       ScrArea *sa= CTX_wm_area(C);
+       short nlaActive= ((sa) && (sa->spacetype==SPACE_NLA));
+       
+       /* check if the DopeSheet data exists, just in case... */
+       if (ads) {
+               /* more 'generic' filtering options */
+               if (nlaActive) uiBlockBeginAlign(block);
+                       uiDefIconButBitI(block, TOG, ADS_FILTER_ONLYSEL, B_REDR, ICON_RESTRICT_SELECT_OFF,      (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Only display selected Objects");
+                       if (nlaActive) uiDefIconButBitI(block, TOGN, ADS_FILTER_NLA_NOACT, B_REDR, ICON_ACTION, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Include AnimData blocks with no NLA Data");
+               if (nlaActive) uiBlockEndAlign(block);
+               xco += 5;
+               
+               /* datatype based */
+               // TODO: only show the datablocks which exist
+               uiBlockBeginAlign(block);
+                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSCE, B_REDR, ICON_SCENE_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Scene Animation");
+                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOWOR, B_REDR, ICON_WORLD_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display World Animation");
+                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSHAPEKEYS, B_REDR, ICON_SHAPEKEY_DATA,       (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display ShapeKeys");
+                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMAT, B_REDR, ICON_MATERIAL_DATA,     (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Material Data");
+                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Lamp Data");
+                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCAM, B_REDR, ICON_CAMERA_DATA,       (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Camera Data");
+                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCUR, B_REDR, ICON_CURVE_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Curve Data");
+                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMBA, B_REDR, ICON_META_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display MetaBall Data");
+                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOARM, B_REDR, ICON_ARMATURE_DATA,     (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Armature Data");
+                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOPART, B_REDR, ICON_PARTICLE_DATA,    (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Particle Data");
+               uiBlockEndAlign(block);
+               xco += 30;
+       }
+       else {
+               // XXX this case shouldn't happen at all... for now, just pad out same amount of space
+               printf("ERROR: dopesheet data not available when drawing Animation Editor header \n");
+               xco += 11*XIC + 30;
+       }
+       
+       // TODO: include auto-snapping menu here too...
+       
+       /* return the width of the buttons */
+       return xco;
+}
+
+/* *************************************************** */
index 7e7aba8536374695570e4bc031c9f611a7e44c12..d943995656913d560a655ff69e8beb342bf55cad 100644 (file)
@@ -42,11 +42,14 @@ struct View2D;
 struct Scene;
 struct Object;
 
+struct bDopeSheet;
+
 struct bActionGroup;
 struct FCurve;
 struct FModifier;
 
 struct uiBlock;
+struct uiLayout;
 
 /* ************************************************ */
 /* ANIMATION CHANNEL FILTERING */
@@ -394,11 +397,14 @@ void ANIM_draw_cfra(const struct bContext *C, struct View2D *v2d, short flag);
 /* main call to draw preview range curtains */
 void ANIM_draw_previewrange(const struct bContext *C, struct View2D *v2d);
 
+/* ------------- Preview Range Drawing -------------- */
+
+/* standard header buttons for Animation Editors */
+short ANIM_headerUI_standard_buttons(const struct bContext *C, struct bDopeSheet *ads, struct uiBlock *block, short xco, short yco);
+
 /* ************************************************* */
 /* F-MODIFIER TOOLS */
 
-struct uiLayout;
-
 /* draw a given F-Modifier for some layout/UI-Block */
 void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, struct ID *id, ListBase *modifiers, struct FModifier *fcm);
 
index f602345baea71e60d7b5d525046992d920cc1372..25a5123d1b5f840d6da7e63cd9acfd94baa23b9f 100644 (file)
@@ -336,24 +336,7 @@ void action_header_buttons(const bContext *C, ARegion *ar)
                        /* FILTERING OPTIONS */
                        xco -= 10;
                        
-                       //uiBlockBeginAlign(block);
-                               uiDefIconButBitI(block, TOG, ADS_FILTER_ONLYSEL, B_REDR, ICON_RESTRICT_SELECT_OFF,      (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Only display selected Objects");
-                       //uiBlockEndAlign(block);
-                       xco += 5;
-                       
-                       uiBlockBeginAlign(block);
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSCE, B_REDR, ICON_SCENE_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Scene Animation");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOWOR, B_REDR, ICON_WORLD_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display World Animation");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSHAPEKEYS, B_REDR, ICON_SHAPEKEY_DATA,       (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display ShapeKeys");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMAT, B_REDR, ICON_MATERIAL_DATA,     (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Materials");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Lamps");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCAM, B_REDR, ICON_CAMERA_DATA,       (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Cameras");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCUR, B_REDR, ICON_CURVE_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Curves");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMBA, B_REDR, ICON_META_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display MetaBalls");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOARM, B_REDR, ICON_ARMATURE_DATA,     (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Armature/Bone");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOPART, B_REDR, ICON_PARTICLE_DATA,    (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Particles");
-                       uiBlockEndAlign(block);
-                       xco += 30;
+                       xco= ANIM_headerUI_standard_buttons(C, &saction->ads, block, xco, yco);
                }
                else if (saction->mode == SACTCONT_ACTION) {
                        uiLayout *layout;
index 79d38d9c2523c1de54e5fe412afb6cdc1fcc7852..98d58c92da48be35df0804c6c6f89ef148726702 100644 (file)
@@ -298,30 +298,7 @@ void graph_header_buttons(const bContext *C, ARegion *ar)
        xco+= 120;
        
        /* filtering buttons */
-       if (sipo->ads) {
-               //uiBlockBeginAlign(block);
-                       uiDefIconButBitI(block, TOG, ADS_FILTER_ONLYSEL, B_REDR, ICON_RESTRICT_SELECT_OFF,      (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Only display selected Objects");
-               //uiBlockEndAlign(block);
-               xco += 5;
-               
-               uiBlockBeginAlign(block);
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSCE, B_REDR, ICON_SCENE_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display Scene Animation");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOWOR, B_REDR, ICON_WORLD_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display World Animation");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSHAPEKEYS, B_REDR, ICON_SHAPEKEY_DATA,       (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display ShapeKeys");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMAT, B_REDR, ICON_MATERIAL_DATA,     (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display Materials");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display Lamps");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCAM, B_REDR, ICON_CAMERA_DATA,       (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display Cameras");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCUR, B_REDR, ICON_CURVE_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display Curves");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMBA, B_REDR, ICON_META_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display MetaBalls");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOARM, B_REDR, ICON_ARMATURE_DATA,     (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display Armature/Bone data");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOPART, B_REDR, ICON_PARTICLE_DATA,    (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display Particles");
-               uiBlockEndAlign(block);
-               xco += 30;
-       }
-       else {
-               // XXX this case shouldn't happen at all... for now, just pad out same amount of space
-               xco += 10*XIC + 30;
-       }
+       xco= ANIM_headerUI_standard_buttons(C, sipo->ads, block, xco, yco);
        
        /* auto-snap selector */
        if (sipo->flag & SIPO_DRAWTIME) {
index 19cffb5cde195bf67bfed2c79b0da78599d15681..25087441b6a4b55dd203deb8209bf74e2acad5e8 100644 (file)
@@ -289,7 +289,6 @@ int graphop_active_fcurve_poll (bContext *C)
 int graphop_selected_fcurve_poll (bContext *C)
 {
        bAnimContext ac;
-       bAnimListElem *ale;
        ListBase anim_data = {NULL, NULL};
        ScrArea *sa= CTX_wm_area(C);
        int filter, items;
index 0d3bf2cb6b13f60f05ca4fd58c3ebb5a7d4ecab5..4eb9fac5cb89e0ff82dc0994643c3dd10098f6ba 100644 (file)
@@ -246,31 +246,7 @@ void nla_header_buttons(const bContext *C, ARegion *ar)
        uiBlockSetEmboss(block, UI_EMBOSS);
        
        /* filtering buttons */
-       if (snla->ads) {
-               uiBlockBeginAlign(block);
-                       uiDefIconButBitI(block, TOG, ADS_FILTER_ONLYSEL, B_REDR, ICON_RESTRICT_SELECT_OFF,      (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Only display selected Objects");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NLA_NOACT, B_REDR, ICON_ACTION,        (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Include AnimData blocks with no NLA Data");
-               uiBlockEndAlign(block);
-               xco += 5;
-               
-               uiBlockBeginAlign(block);
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSCE, B_REDR, ICON_SCENE_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Scene Animation");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOWOR, B_REDR, ICON_WORLD_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display World Animation");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSHAPEKEYS, B_REDR, ICON_SHAPEKEY_DATA,       (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display ShapeKeys");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMAT, B_REDR, ICON_MATERIAL_DATA,     (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Materials");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Lamps");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCAM, B_REDR, ICON_CAMERA_DATA,       (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Cameras");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCUR, B_REDR, ICON_CURVE_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Curves");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMBA, B_REDR, ICON_META_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display MetaBalls");
-                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOPART, B_REDR, ICON_PARTICLE_DATA,    (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Particles");
-               uiBlockEndAlign(block);
-               xco += 15;
-       }
-       else {
-               // XXX this case shouldn't happen at all... for now, just pad out same amount of space
-               xco += 10*XIC + 15;
-       }
-       xco += (XIC + 8);
+       xco= ANIM_headerUI_standard_buttons(C, snla->ads, block, xco, yco);
        
        /* auto-snap selector */
        if (snla->flag & SNLA_DRAWTIME) {
index 43ef9f2882848599433f0e2f801175920e1b64e7..2ed08150f3ef215aeea7af32bea87272a2315ff5 100644 (file)
@@ -433,7 +433,7 @@ typedef enum DOPESHEET_FILTERFLAG {
        ADS_FILTER_NLA_NOACT            = (1<<20),      /* if the AnimData block has no NLA data, don't include to just show Action-line */
        
                /* combination filters (some only used at runtime) */
-       ADS_FILTER_NOOBDATA = (ADS_FILTER_NOCAM|ADS_FILTER_NOMAT|ADS_FILTER_NOLAM|ADS_FILTER_NOCUR|ADS_FILTER_NOPART),
+       ADS_FILTER_NOOBDATA = (ADS_FILTER_NOCAM|ADS_FILTER_NOMAT|ADS_FILTER_NOLAM|ADS_FILTER_NOCUR|ADS_FILTER_NOPART|ADS_FILTER_NOARM),
 } DOPESHEET_FILTERFLAG;        
 
 /* DopeSheet general flags */