Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-06-21 07:02:40 +0400
committerJoshua Leung <aligorith@gmail.com>2009-06-21 07:02:40 +0400
commited316ad8e967b85a79bb67b79ffc5e3cd90820a5 (patch)
treedc7b9b16fa06d6d4cf9b91c52f1b23ba0f6329e7
parent6bca54aac17212f9c40b0a54a50a6c39e0817815 (diff)
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.
-rw-r--r--source/blender/editors/animation/anim_channels.c59
-rw-r--r--source/blender/editors/space_action/action_edit.c30
-rw-r--r--source/blender/editors/space_action/action_select.c8
-rw-r--r--source/blender/editors/space_nla/nla_channels.c16
-rw-r--r--source/blender/editors/space_nla/nla_edit.c2
-rw-r--r--source/blender/editors/space_nla/nla_intern.h2
-rw-r--r--source/blender/editors/space_nla/nla_ops.c12
7 files changed, 91 insertions, 38 deletions
diff --git a/source/blender/editors/animation/anim_channels.c b/source/blender/editors/animation/anim_channels.c
index d753f65ff50..9230cdfc9a2 100644
--- a/source/blender/editors/animation/anim_channels.c
+++ b/source/blender/editors/animation/anim_channels.c
@@ -271,6 +271,47 @@ void ANIM_deselect_anim_channels (void *data, short datatype, short test, short
/* ************************************************************************** */
/* 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 @@ void ANIM_OT_channels_setting_enable (wmOperatorType *ot)
/* 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 @@ void ANIM_OT_channels_setting_disable (wmOperatorType *ot)
/* 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 @@ void ANIM_OT_channels_setting_toggle (wmOperatorType *ot)
/* 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 @@ void ANIM_OT_channels_editable_toggle (wmOperatorType *ot)
/* 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 @@ void ANIM_OT_channels_expand (wmOperatorType *ot)
/* 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 @@ void ANIM_OT_channels_collapse (wmOperatorType *ot)
/* 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 @@ void ANIM_OT_channels_select_all_toggle (wmOperatorType *ot)
/* 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 @@ void ANIM_OT_channels_select_border(wmOperatorType *ot)
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 @@ void ANIM_OT_channels_click (wmOperatorType *ot)
/* 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;
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index a0f1adbd97e..27be82ccec0 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -181,7 +181,7 @@ void ACT_OT_previewrange_set (wmOperatorType *ot)
/* 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 @@ void ACT_OT_view_all (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_copy (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_paste (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_insert (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_duplicate (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_delete (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_clean (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_sample (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_extrapolation_type_set (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_interpolation_type (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_handle_type_set (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_cfrasnap (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_snap (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_mirror (wmOperatorType *ot)
/* 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;
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 6bfdf77e2e7..f99a08bc26d 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -187,7 +187,7 @@ void ACT_OT_keyframes_select_all_toggle (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_select_border(wmOperatorType *ot)
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 @@ void ACT_OT_keyframes_select_column (wmOperatorType *ot)
/* 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 @@ void ACT_OT_keyframes_clickselect (wmOperatorType *ot)
/* 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;
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index f928daa523b..a1c0de1e552 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -143,7 +143,7 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
/* toggle expand */
ob->nlaflag ^= OB_ADS_COLLAPSED; // XXX
}
- else {
+ else if (nlaedit_is_tweakmode_on(ac) == 0) {
/* set selection status */
if (selectmode == SELECT_INVERT) {
/* swap select */
@@ -242,7 +242,7 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
/* toggle 'solo' */
BKE_nlatrack_solo_toggle(adt, nlt);
}
- else {
+ else if (nlaedit_is_tweakmode_on(ac) == 0) {
/* set selection */
if (selectmode == SELECT_INVERT) {
/* inverse selection status of this F-Curve only */
@@ -266,10 +266,12 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
/* 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);
+ /* activate push-down function - only usable when not in TweakMode */
+ if (nlaedit_is_tweakmode_on(ac) == 0) {
+ // 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);
+ }
}
}
break;
@@ -339,7 +341,7 @@ void NLA_OT_channels_click (wmOperatorType *ot)
/* api callbacks */
ot->invoke= nlachannels_mouseclick_invoke;
- ot->poll= nlaop_poll_tweakmode_off; // xxx?
+ ot->poll= ED_operator_nla_active;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index ebb0589a82d..70a033052bd 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -625,7 +625,7 @@ static int nlaedit_split_exec (bContext *C, wmOperator *op)
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- /* for each NLA-Track, delete all selected strips */
+ /* for each NLA-Track, split all selected strips into two strips */
for (ale= anim_data.first; ale; ale= ale->next) {
NlaTrack *nlt= (NlaTrack *)ale->data;
NlaStrip *strip, *nstrip, *next;
diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h
index 1237542172f..79ee5396f36 100644
--- a/source/blender/editors/space_nla/nla_intern.h
+++ b/source/blender/editors/space_nla/nla_intern.h
@@ -113,6 +113,8 @@ void NLA_OT_add_tracks(wmOperatorType *ot);
int nlaop_poll_tweakmode_off(bContext *C);
int nlaop_poll_tweakmode_on (bContext *C);
+short nlaedit_is_tweakmode_on(bAnimContext *ac);
+
/* --- */
void nla_operatortypes(void);
diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c
index 52b529661cb..df731e9d0fb 100644
--- a/source/blender/editors/space_nla/nla_ops.c
+++ b/source/blender/editors/space_nla/nla_ops.c
@@ -113,6 +113,14 @@ int nlaop_poll_tweakmode_on (bContext *C)
return 1;
}
+/* is tweakmode enabled - for use in NLA operator code */
+short nlaedit_is_tweakmode_on (bAnimContext *ac)
+{
+ if (ac && ac->scene)
+ return (ac->scene->flag & SCE_NLA_EDIT_ON);
+ return 0;
+}
+
/* ************************** registration - operator types **********************************/
void nla_operatortypes(void)
@@ -160,10 +168,10 @@ static void nla_keymap_channels (wmWindowManager *wm, ListBase *keymap)
/* General Animation Channels keymap (see anim_channels.c) ----------------------- */
/* selection */
- /* borderselect */
+ /* borderselect - not in tweakmode */
WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", BKEY, KM_PRESS, 0, 0);
- /* deselect all */
+ /* deselect all - not in tweakmode */
WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", AKEY, KM_PRESS, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);