Revision: 21047
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21047
Author:   aligorith
Date:     2009-06-21 05:02:40 +0200 (Sun, 21 Jun 2009)

Log Message:
-----------
NLA SoC: Fixes for Operator Poll Callbacks 

* Clicking on NLA tracks while in TweakMode now works so that channels can be 
muted/protected/expanded as per usual. However, they cannot be selected, as 
changing the selection state can interfere with TweakMode state changes

* Operators for animation channel-lists now use proper poll callbacks, which 
also take into account TweakMode where appropriate (i.e. all selection 
operators are now allowed to operate in NLA while in TweakMode, and all other 
operators will only work in Animation Editors) 

* Action Editor operators now use the poll callback for Action 
Editors/DopeSheet instead of the generic active-araa one.

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/editors/animation/anim_channels.c
    
branches/soc-2009-aligorith/source/blender/editors/space_action/action_edit.c
    
branches/soc-2009-aligorith/source/blender/editors/space_action/action_select.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_channels.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c

Modified: 
branches/soc-2009-aligorith/source/blender/editors/animation/anim_channels.c
===================================================================
--- 
branches/soc-2009-aligorith/source/blender/editors/animation/anim_channels.c    
    2009-06-21 02:51:42 UTC (rev 21046)
+++ 
branches/soc-2009-aligorith/source/blender/editors/animation/anim_channels.c    
    2009-06-21 03:02:40 UTC (rev 21047)
@@ -271,6 +271,47 @@
 /* ************************************************************************** 
*/
 /* OPERATORS */
 
+/* ****************** Operator Utilities ********************************** */
+
+/* poll callback for being in an Animation Editor channels list region */
+int animedit_poll_channels_active (bContext *C)
+{
+       ScrArea *sa= CTX_wm_area(C);
+       
+       /* channels region test */
+       // TODO: could enhance with actually testing if channels region?
+       if (ELEM(NULL, sa, CTX_wm_region(C)))
+               return 0;
+       /* animation editor test */
+       if (ELEM3(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0)
+               return 0;
+               
+       return 1;
+}
+
+/* poll callback for Animation Editor channels list region + not in 
NLA-tweakmode for NLA */
+int animedit_poll_channels_nla_tweakmode_off (bContext *C)
+{
+       ScrArea *sa= CTX_wm_area(C);
+       Scene *scene = CTX_data_scene(C);
+       
+       /* channels region test */
+       // TODO: could enhance with actually testing if channels region?
+       if (ELEM(NULL, sa, CTX_wm_region(C)))
+               return 0;
+       /* animation editor test */
+       if (ELEM3(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0)
+               return 0;
+       
+       /* NLA TweakMode test */        
+       if (sa->spacetype == SPACE_NLA) {
+               if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON))
+                       return 0;
+       }
+               
+       return 1;
+}
+
 /* ****************** Rearrange Channels Operator ******************* */
 /* This operator only works for Action Editor mode for now, as having it 
elsewhere makes things difficult */
 
@@ -961,7 +1002,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= animchannels_setflag_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= animedit_poll_channels_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -982,7 +1023,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= animchannels_setflag_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= animedit_poll_channels_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1003,7 +1044,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= animchannels_setflag_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= animedit_poll_channels_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1024,7 +1065,7 @@
        
        /* api callbacks */
        ot->exec= animchannels_setflag_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= animedit_poll_channels_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1068,7 +1109,7 @@
        
        /* api callbacks */
        ot->exec= animchannels_expand_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= animedit_poll_channels_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1109,7 +1150,7 @@
        
        /* api callbacks */
        ot->exec= animchannels_collapse_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= animedit_poll_channels_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1148,7 +1189,7 @@
        
        /* api callbacks */
        ot->exec= animchannels_deselectall_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= animedit_poll_channels_nla_tweakmode_off;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1277,7 +1318,7 @@
        ot->exec= animchannels_borderselect_exec;
        ot->modal= WM_border_select_modal;
        
-       ot->poll= ED_operator_areaactive;
+       ot->poll= animedit_poll_channels_nla_tweakmode_off;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1636,7 +1677,7 @@
        
        /* api callbacks */
        ot->invoke= animchannels_mouseclick_invoke;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= animedit_poll_channels_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;

Modified: 
branches/soc-2009-aligorith/source/blender/editors/space_action/action_edit.c
===================================================================
--- 
branches/soc-2009-aligorith/source/blender/editors/space_action/action_edit.c   
    2009-06-21 02:51:42 UTC (rev 21046)
+++ 
branches/soc-2009-aligorith/source/blender/editors/space_action/action_edit.c   
    2009-06-21 03:02:40 UTC (rev 21047)
@@ -181,7 +181,7 @@
        
        /* api callbacks */
        ot->exec= actkeys_previewrange_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -228,7 +228,7 @@
        
        /* api callbacks */
        ot->exec= actkeys_viewall_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -315,7 +315,7 @@
        
        /* api callbacks */
        ot->exec= actkeys_copy_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -359,7 +359,7 @@
        
        /* api callbacks */
        ot->exec= actkeys_paste_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -456,7 +456,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= actkeys_insertkey_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -533,7 +533,7 @@
        /* api callbacks */
        ot->invoke= actkeys_duplicate_invoke;
        ot->exec= actkeys_duplicate_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -600,7 +600,7 @@
        /* api callbacks */
        ot->invoke= WM_operator_confirm;
        ot->exec= actkeys_delete_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -663,7 +663,7 @@
        /* api callbacks */
        //ot->invoke=  // XXX we need that number popup for this! 
        ot->exec= actkeys_clean_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -786,7 +786,7 @@
        
        /* api callbacks */
        ot->exec= actkeys_sample_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -862,7 +862,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= actkeys_expo_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -932,7 +932,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= actkeys_ipo_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1020,7 +1020,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= actkeys_handletype_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1079,7 +1079,7 @@
        
        /* api callbacks */
        ot->exec= actkeys_cfrasnap_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1175,7 +1175,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= actkeys_snap_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1291,7 +1291,7 @@
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= actkeys_mirror_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;

Modified: 
branches/soc-2009-aligorith/source/blender/editors/space_action/action_select.c
===================================================================
--- 
branches/soc-2009-aligorith/source/blender/editors/space_action/action_select.c 
    2009-06-21 02:51:42 UTC (rev 21046)
+++ 
branches/soc-2009-aligorith/source/blender/editors/space_action/action_select.c 
    2009-06-21 03:02:40 UTC (rev 21047)
@@ -187,7 +187,7 @@
        
        /* api callbacks */
        ot->exec= actkeys_deselectall_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -349,7 +349,7 @@
        ot->exec= actkeys_borderselect_exec;
        ot->modal= WM_border_select_modal;
        
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -563,7 +563,7 @@
        
        /* api callbacks */
        ot->exec= actkeys_columnselect_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -968,7 +968,7 @@
        
        /* api callbacks - absolutely no exec() this yet... */
        ot->invoke= actkeys_clickselect_invoke;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_action_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;

Modified: 
branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_channels.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_channels.c 
2009-06-21 02:51:42 UTC (rev 21046)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_channels.c 
2009-06-21 03:02:40 UTC (rev 21047)
@@ -143,7 +143,7 @@
                                /* toggle expand */
                                ob->nlaflag ^= OB_ADS_COLLAPSED; // XXX 
                        }
-                       else {
+                       else if (nlaedit_is_tweakon(ac) == 0) {
                                /* set selection status */
                                if (selectmode == SELECT_INVERT) {
                                        /* swap select */
@@ -242,7 +242,7 @@
                                /* toggle 'solo' */
                                BKE_nlatrack_solo_toggle(adt, nlt);
                        }
-                       else {
+                       else if (nlaedit_is_tweakon(ac) == 0) {
                                /* set selection */
                                if (selectmode == SELECT_INVERT) {
                                        /* inverse selection status of this 
F-Curve only */
@@ -266,10 +266,12 @@
                        
                        /* for now, only do something if user clicks on the 
'push-down' button */
                        if (x >= 
(NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) {
-                               /* activate push-down function */
-                               // TODO: make this use the operator instead of 
calling the function directly
-                               //      however, calling the operator requires 
that we supply the args, and that works with proper buttons only
-                               BKE_nla_action_pushdown(adt);

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