[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26753] trunk/blender/source/blender/ editors: Bugfix #20903: Concitency issues between point and click and Tab Key in the Graph Editor
Joshua Leung
aligorith at gmail.com
Tue Feb 9 22:22:24 CET 2010
Revision: 26753
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26753
Author: aligorith
Date: 2010-02-09 22:22:24 +0100 (Tue, 09 Feb 2010)
Log Message:
-----------
Bugfix #20903: Concitency issues between point and click and Tab Key in the Graph Editor
- 'Toggle' operators for channel settings now now act more like the select-all type of "toggle" operator. The old behaviour has now been moved to "invert".
- Channel settings are now flushed (like for visibility and when clicking) for muting and locking when using the operators
Modified Paths:
--------------
trunk/blender/source/blender/editors/animation/anim_channels_defines.c
trunk/blender/source/blender/editors/animation/anim_channels_edit.c
trunk/blender/source/blender/editors/include/ED_anim_api.h
Modified: trunk/blender/source/blender/editors/animation/anim_channels_defines.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_defines.c 2010-02-09 21:18:50 UTC (rev 26752)
+++ trunk/blender/source/blender/editors/animation/anim_channels_defines.c 2010-02-09 21:22:24 UTC (rev 26753)
@@ -2398,12 +2398,12 @@
#define ACF_SETTING_SET(sval, sflag, smode) \
{\
if (negflag) {\
- if (smode == ACHANNEL_SETFLAG_TOGGLE) (sval) ^= (sflag); \
+ if (smode == ACHANNEL_SETFLAG_INVERT) (sval) ^= (sflag); \
else if (smode == ACHANNEL_SETFLAG_ADD) (sval) &= ~(sflag); \
else (sval) |= (sflag); \
} \
else {\
- if (smode == ACHANNEL_SETFLAG_TOGGLE) (sval) ^= (sflag); \
+ if (smode == ACHANNEL_SETFLAG_INVERT) (sval) ^= (sflag); \
else if (smode == ACHANNEL_SETFLAG_ADD) (sval) |= (sflag); \
else (sval) &= ~(sflag); \
}\
Modified: trunk/blender/source/blender/editors/animation/anim_channels_edit.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_edit.c 2010-02-09 21:18:50 UTC (rev 26752)
+++ trunk/blender/source/blender/editors/animation/anim_channels_edit.c 2010-02-09 21:22:24 UTC (rev 26753)
@@ -1153,12 +1153,11 @@
/* 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;
-
/* set the setting in the appropriate way (if available) */
- if (ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_VISIBLE))
+ if (ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_VISIBLE)) {
vis= ACHANNEL_SETFLAG_CLEAR;
+ break;
+ }
}
/* Now set the flags */
@@ -1184,7 +1183,7 @@
return OPERATOR_FINISHED;
}
-
+
void ANIM_OT_channels_visibility_toggle (wmOperatorType *ot)
{
/* identifiers */
@@ -1204,9 +1203,10 @@
/* defines for setting animation-channel flags */
EnumPropertyItem prop_animchannel_setflag_types[] = {
+ {ACHANNEL_SETFLAG_TOGGLE, "TOGGLE", 0, "Toggle", ""},
{ACHANNEL_SETFLAG_CLEAR, "DISABLE", 0, "Disable", ""},
{ACHANNEL_SETFLAG_ADD, "ENABLE", 0, "Enable", ""},
- {ACHANNEL_SETFLAG_TOGGLE, "TOGGLE", 0, "Toggle", ""},
+ {ACHANNEL_SETFLAG_INVERT, "INVERT", 0, "Invert", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -1230,24 +1230,57 @@
* mode: eAnimChannels_SetFlag
* onlysel: only selected channels get the flag set
*/
-static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, short onlysel)
+// TODO: enable a setting which turns flushing on/off?
+static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, short onlysel, short flush)
{
ListBase anim_data = {NULL, NULL};
+ ListBase all_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
- /* filter data */
+ /* filter data that we need if flush is on */
+ if (flush) {
+ /* get list of all channels that selection may need to be flushed to */
+ filter= ANIMFILTER_CHANNELS;
+ ANIM_animdata_filter(ac, &all_data, filter, ac->data, ac->datatype);
+ }
+
+ /* filter data that we're working on */
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS);
if (onlysel) filter |= ANIMFILTER_SEL;
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- /* affect selected channels */
+ /* if toggling, check if disable or enable */
+ if (mode == ACHANNEL_SETFLAG_TOGGLE) {
+ /* default to turn all on, unless we encounter one that's on... */
+ mode= ACHANNEL_SETFLAG_ADD;
+
+ /* see if we should turn off instead... */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ /* set the setting in the appropriate way (if available) */
+ if (ANIM_channel_setting_get(ac, ale, setting) > 0) {
+ mode= ACHANNEL_SETFLAG_CLEAR;
+ break;
+ }
+ }
+ }
+
+ /* apply the setting */
for (ale= anim_data.first; ale; ale= ale->next) {
- /* set the setting in the appropriate way (if available) */
+ /* skip channel if setting is not available */
+ if (ANIM_channel_setting_get(ac, ale, setting) == -1)
+ continue;
+
+ /* set the setting in the appropriate way */
ANIM_channel_setting_set(ac, ale, setting, mode);
+
+ /* if flush status... */
+ if (flush)
+ ANIM_flush_setting_anim_channels(ac, &all_data, ale, setting, mode);
}
BLI_freelistN(&anim_data);
+ BLI_freelistN(&all_data);
}
/* ------------------- */
@@ -1256,6 +1289,7 @@
{
bAnimContext ac;
short mode, setting;
+ short flush=1;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -1265,9 +1299,15 @@
mode= RNA_enum_get(op->ptr, "mode");
setting= RNA_enum_get(op->ptr, "type");
- /* modify setting */
- setflag_anim_channels(&ac, setting, mode, 1);
+ /* check if setting is flushable */
+ if (setting == ACHANNEL_SETTING_EXPAND)
+ flush= 0;
+ /* modify setting
+ * - only selected channels are affected
+ */
+ setflag_anim_channels(&ac, setting, mode, 1, flush);
+
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
@@ -1319,6 +1359,28 @@
ot->prop= RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", "");
}
+void ANIM_OT_channels_setting_invert (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Invert Channel Setting";
+ ot->idname= "ANIM_OT_channels_setting_toggle";
+ ot->description= "Invert specified setting on all selected animation channels.";
+
+ /* api callbacks */
+ ot->invoke= WM_menu_invoke;
+ ot->exec= animchannels_setflag_exec;
+ ot->poll= animedit_poll_channels_active;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* props */
+ /* flag-setting mode */
+ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_INVERT, "Mode", "");
+ /* setting to set */
+ ot->prop= RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", "");
+}
+
void ANIM_OT_channels_setting_toggle (wmOperatorType *ot)
{
/* identifiers */
@@ -1341,7 +1403,6 @@
ot->prop= RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", "");
}
-// XXX currently, this is a separate operator, but perhaps we could in future specify in keymaps whether to call invoke or exec?
void ANIM_OT_channels_editable_toggle (wmOperatorType *ot)
{
/* identifiers */
@@ -1379,7 +1440,7 @@
onlysel= 0;
/* modify setting */
- setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel);
+ setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel, 0);
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
@@ -1421,7 +1482,7 @@
onlysel= 0;
/* modify setting */
- setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel);
+ setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel, 0);
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
@@ -1930,6 +1991,7 @@
WM_operatortype_append(ANIM_OT_channels_setting_enable);
WM_operatortype_append(ANIM_OT_channels_setting_disable);
+ WM_operatortype_append(ANIM_OT_channels_setting_invert);
WM_operatortype_append(ANIM_OT_channels_setting_toggle);
WM_operatortype_append(ANIM_OT_channels_delete);
Modified: trunk/blender/source/blender/editors/include/ED_anim_api.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_anim_api.h 2010-02-09 21:18:50 UTC (rev 26752)
+++ trunk/blender/source/blender/editors/include/ED_anim_api.h 2010-02-09 21:22:24 UTC (rev 26753)
@@ -311,9 +311,10 @@
/* flag-setting behaviour */
typedef enum eAnimChannels_SetFlag {
- ACHANNEL_SETFLAG_CLEAR = 0,
- ACHANNEL_SETFLAG_ADD,
- ACHANNEL_SETFLAG_TOGGLE
+ ACHANNEL_SETFLAG_CLEAR = 0, /* turn off */
+ ACHANNEL_SETFLAG_ADD, /* turn on */
+ ACHANNEL_SETFLAG_INVERT, /* on->off, off->on */
+ ACHANNEL_SETFLAG_TOGGLE, /* some on -> all off // all on */
} eAnimChannels_SetFlag;
/* types of settings for AnimChannels */
@@ -504,24 +505,24 @@
/* set/clear/toggle macro
* - channel - channel with a 'flag' member that we're setting
- * - smode - 0=clear, 1=set, 2=toggle
+ * - smode - 0=clear, 1=set, 2=invert
* - sflag - bitflag to set
*/
#define ACHANNEL_SET_FLAG(channel, smode, sflag) \
{ \
- if (smode == ACHANNEL_SETFLAG_TOGGLE) (channel)->flag ^= (sflag); \
+ if (smode == ACHANNEL_SETFLAG_INVERT) (channel)->flag ^= (sflag); \
else if (smode == ACHANNEL_SETFLAG_ADD) (channel)->flag |= (sflag); \
else (channel)->flag &= ~(sflag); \
}
/* set/clear/toggle macro, where the flag is negative
* - channel - channel with a 'flag' member that we're setting
- * - smode - 0=clear, 1=set, 2=toggle
+ * - smode - 0=clear, 1=set, 2=invert
* - sflag - bitflag to set
*/
#define ACHANNEL_SET_FLAG_NEG(channel, smode, sflag) \
{ \
- if (smode == ACHANNEL_SETFLAG_TOGGLE) (channel)->flag ^= (sflag); \
+ if (smode == ACHANNEL_SETFLAG_INVERT) (channel)->flag ^= (sflag); \
else if (smode == ACHANNEL_SETFLAG_ADD) (channel)->flag &= ~(sflag); \
else (channel)->flag |= (sflag); \
}
More information about the Bf-blender-cvs
mailing list