Revision: 21298
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21298
Author:   aligorith
Date:     2009-07-02 03:01:18 +0200 (Thu, 02 Jul 2009)

Log Message:
-----------
NLA SoC: Proper poll callbacks for Graph Editor

For now, some of these polls may be a bit too restrictive, but at least we have 
some unified+cleaned bases to work from now (instead of relying on the generic 
ED_operator_area_active).

Modified Paths:
--------------
    
branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c
    branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_draw.c
    branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_edit.c
    
branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_intern.h
    branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_ops.c
    
branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_select.c

Added Paths:
-----------
    branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_utils.c

Modified: 
branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c
===================================================================
--- 
branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c  
    2009-07-01 22:53:55 UTC (rev 21297)
+++ 
branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c  
    2009-07-02 01:01:18 UTC (rev 21298)
@@ -1000,34 +1000,6 @@
 
 /* ******************* general ******************************** */
 
-/* Find 'active' F-Curve. It must be editable, since that's the purpose of 
these buttons (subject to change).  
- * We return the 'wrapper' since it contains valuable context info (about 
hierarchy), which will need to be freed 
- * when the caller is done with it.
- */
-// TODO: move this to anim api with another name?
-bAnimListElem *get_active_fcurve_channel (bAnimContext *ac)
-{
-       ListBase anim_data = {NULL, NULL};
-       int filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | 
ANIMFILTER_ACTIVE | ANIMFILTER_CURVESONLY);
-       int items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, 
ac->datatype);
-       
-       /* We take the first F-Curve only, since some other ones may have had 
'active' flag set
-        * if they were from linked data.
-        */
-       if (items) {
-               bAnimListElem *ale= (bAnimListElem *)anim_data.first;
-               
-               /* remove first item from list, then free the rest of the list 
and return the stored one */
-               BLI_remlink(&anim_data, ale);
-               BLI_freelistN(&anim_data);
-               
-               return ale;
-       }
-       
-       /* no active F-Curve */
-       return NULL;
-}
-
 void graph_buttons_register(ARegionType *art)
 {
        PanelType *pt;

Modified: 
branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_draw.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_draw.c 
2009-07-01 22:53:55 UTC (rev 21297)
+++ branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_draw.c 
2009-07-02 01:01:18 UTC (rev 21298)
@@ -775,46 +775,6 @@
        glDisable(GL_BLEND);
 }
 
-/* check if any FModifiers to draw controls for  - fcm is 'active' modifier */
-static short fcurve_needs_draw_fmodifier_controls (FCurve *fcu, FModifier *fcm)
-{
-       /* don't draw if there aren't any modifiers at all */
-       if (fcu->modifiers.first == NULL) 
-               return 0;
-       
-       /* if there's an active modifier - don't draw if it doesn't drastically
-        * alter the curve...
-        */
-       if (fcm) {
-               switch (fcm->type) {
-                       /* clearly harmless */
-                       case FMODIFIER_TYPE_CYCLES:
-                               return 0;
-                               
-                       /* borderline... */
-                       case FMODIFIER_TYPE_NOISE:
-                               return 0;
-               }
-       }
-       
-       /* if only one modifier - don't draw if it is muted or disabled */
-       if (fcu->modifiers.first == fcu->modifiers.last) {
-               fcm= fcu->modifiers.first;
-               if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) 
-                       return 0;
-       }
-       
-       /* if only active modifier - don't draw if it is muted or disabled */
-       if (fcm) {
-               if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) 
-                       return 0;
-       }
-       
-       /* if we're still here, this means that there are modifiers with 
controls to be drawn */
-       // FIXME: what happens if all the modifiers were muted/disabled
-       return 1;
-}
-
 /* This is called twice from space_graph.c -> graph_main_area_draw()
  * Unselected then selected F-Curves are drawn so that they do not occlude 
each other.
  */

Modified: 
branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_edit.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_edit.c 
2009-07-01 22:53:55 UTC (rev 21297)
+++ branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_edit.c 
2009-07-02 01:01:18 UTC (rev 21298)
@@ -189,7 +189,7 @@
        
        /* api callbacks */
        ot->exec= graphkeys_previewrange_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_visible_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -236,7 +236,7 @@
        
        /* api callbacks */
        ot->exec= graphkeys_viewall_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_visible_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -347,7 +347,7 @@
        
        /* api callbacks */
        ot->exec= graphkeys_create_ghostcurves_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_visible_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -390,7 +390,7 @@
        
        /* api callbacks */
        ot->exec= graphkeys_clear_ghostcurves_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_ipo_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -488,7 +488,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= graphkeys_insertkey_exec;
-       ot->poll= ED_operator_ipo_active; // xxx
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -575,7 +575,7 @@
        /* api callbacks */
        ot->invoke= graphkeys_click_insert_invoke;
        ot->exec= graphkeys_click_insert_exec;
-       ot->poll= ED_operator_areaactive; // XXX active + editable poll
+       ot->poll= graphop_active_fcurve_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -657,7 +657,7 @@
        
        /* api callbacks */
        ot->exec= graphkeys_copy_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -696,7 +696,7 @@
        
        /* api callbacks */
        ot->exec= graphkeys_paste_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -764,7 +764,7 @@
        /* api callbacks */
        ot->invoke= graphkeys_duplicate_invoke;
        ot->exec= graphkeys_duplicate_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -825,7 +825,7 @@
        /* api callbacks */
        ot->invoke= WM_operator_confirm;
        ot->exec= graphkeys_delete_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -886,7 +886,7 @@
        /* api callbacks */
        //ot->invoke=  // XXX we need that number popup for this! 
        ot->exec= graphkeys_clean_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -967,7 +967,7 @@
        /* api callbacks */
        ot->invoke= WM_operator_confirm; // FIXME...
        ot->exec= graphkeys_bake_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1092,7 +1092,7 @@
        
        /* api callbacks */
        ot->exec= graphkeys_sample_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1167,7 +1167,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= graphkeys_expo_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1235,7 +1235,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= graphkeys_ipo_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1322,7 +1322,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= graphkeys_handletype_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1411,7 +1411,7 @@
        
        /* api callbacks */
        ot->exec= graphkeys_euler_filter_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1438,7 +1438,7 @@
        memset(&bed, 0, sizeof(BeztEditData));
        
        /* loop over action data, averaging values */
-       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE| 
ANIMFILTER_CURVESONLY);
+       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | 
ANIMFILTER_CURVESONLY);
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        for (ale= anim_data.first; ale; ale= ale->next) {
@@ -1476,7 +1476,7 @@
        
        /* api callbacks */
        ot->exec= graphkeys_framejump_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_visible_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1568,7 +1568,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= graphkeys_snap_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1679,7 +1679,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= graphkeys_mirror_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1732,7 +1732,7 @@
        
        /* api callbacks */
        ot->exec= graphkeys_smooth_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= graphop_editable_keyframes_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1795,7 +1795,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= graph_fmodifier_add_exec;
-       ot->poll= ED_operator_areaactive; // XXX need active F-Curve
+       ot->poll= graphop_active_fcurve_poll; 
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;

Modified: 
branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_intern.h
===================================================================
--- 
branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_intern.h   
    2009-07-01 22:53:55 UTC (rev 21297)
+++ 
branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_intern.h   
    2009-07-02 01:01:18 UTC (rev 21298)
@@ -141,8 +141,17 @@
 void GRAPH_OT_properties(struct wmOperatorType *ot);
 void graph_buttons_register(struct ARegionType *art);
 
+/* ***************************************** */
+/* graph_utils.c */
+
 struct bAnimListElem *get_active_fcurve_channel(struct bAnimContext *ac);
 
+short fcurve_needs_draw_fmodifier_controls(struct FCurve *fcu, struct 
FModifier *fcm);
+
+int graphop_visible_keyframes_poll(struct bContext *C);
+int graphop_editable_keyframes_poll(struct bContext *C);
+int graphop_active_fcurve_poll(struct bContext *C);
+
 /* ***************************************** */
 /* graph_ops.c */
 void graphedit_keymap(struct wmWindowManager *wm);


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