diff options
author | Joshua Leung <aligorith@gmail.com> | 2010-01-10 14:09:30 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2010-01-10 14:09:30 +0300 |
commit | 2c56c59dfe30b4a44fe06135aba60b60bc6aa457 (patch) | |
tree | 9019cfa6242aed57afc2a3145bae51ffd0dc92b6 /source/blender/editors | |
parent | e26005795d17d4d0516364ab1bcedd4dd7058efe (diff) |
Animation Channels - Protect + Mute toggles flushing:
Protect and Mute toggles now flush their values when changed, like for visibility, making the workflow a bit smoother. Currently, this only takes effect when clicking on the toggles (i.e. the hotkey+select based toggle setting operators don't take this into account yet).
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/anim_channels_defines.c | 33 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_channels_edit.c | 26 | ||||
-rw-r--r-- | source/blender/editors/include/ED_anim_api.h | 5 |
3 files changed, 42 insertions, 22 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index e1bbeec3be2..0f19da0e6bd 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -2556,14 +2556,15 @@ static void achannel_setting_widget_cb(bContext *C, void *poin, void *poin2) WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); } -/* callback for visiblility-toggle widget settings - perform value flushing (Graph Editor only) */ -static void achannel_setting_visible_widget_cb(bContext *C, void *ale_npoin, void *dummy_poin) +/* callback for widget settings that need flushing */ +static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void *setting_wrap) { bAnimListElem *ale_setting= (bAnimListElem *)ale_npoin; bAnimContext ac; ListBase anim_data = {NULL, NULL}; int filter; - short vizOn = 0; + int setting = GET_INT_FROM_POINTER(setting_wrap); + short on = 0; /* send notifiers before doing anything else... */ WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); @@ -2575,10 +2576,10 @@ static void achannel_setting_visible_widget_cb(bContext *C, void *ale_npoin, voi /* verify that we have a channel to operate on, and that it has all we need */ if (ale_setting) { /* check if the setting is on... */ - vizOn= ANIM_channel_setting_get(&ac, ale_setting, ACHANNEL_SETTING_VISIBLE); + on= ANIM_channel_setting_get(&ac, ale_setting, setting); - /* vizOn == -1 means setting not found... */ - if (vizOn == -1) + /* on == -1 means setting not found... */ + if (on == -1) return; } else @@ -2592,7 +2593,7 @@ static void achannel_setting_visible_widget_cb(bContext *C, void *ale_npoin, voi ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* call API method to flush the setting */ - ANIM_visibility_flush_anim_channels(&ac, &anim_data, ale_setting, vizOn); + ANIM_flush_setting_anim_channels(&ac, &anim_data, ale_setting, setting, on); /* free temp data */ BLI_freelistN(&anim_data); @@ -2770,11 +2771,19 @@ static void draw_setting_widget (bAnimContext *ac, bAnimListElem *ale, bAnimChan /* set call to send relevant notifiers and/or perform type-specific updates */ if (but) { - /* 'visibility' toggles for Graph Editor need special flushing */ - if (setting == ACHANNEL_SETTING_VISIBLE) - uiButSetNFunc(but, achannel_setting_visible_widget_cb, MEM_dupallocN(ale), 0); - else - uiButSetFunc(but, achannel_setting_widget_cb, NULL, NULL); + switch (setting) { + /* settings needing flushing up/down hierarchy */ + case ACHANNEL_SETTING_VISIBLE: /* Graph Editor - 'visibility' toggles */ + case ACHANNEL_SETTING_PROTECT: /* General - protection flags */ + case ACHANNEL_SETTING_MUTE: /* General - muting flags */ + uiButSetNFunc(but, achannel_setting_flush_widget_cb, MEM_dupallocN(ale), SET_INT_IN_POINTER(setting)); + break; + + /* no flushing */ + case ACHANNEL_SETTING_EXPAND: /* expanding - cannot flush, otherwise all would open/close at once */ + default: + uiButSetFunc(but, achannel_setting_widget_cb, NULL, NULL); + } } } } diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index ebb3136d530..530e9179474 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -364,9 +364,10 @@ void ANIM_deselect_anim_channels (void *data, short datatype, short test, short * then the channels under closed expanders get ignored... * - ale_setting: the anim channel (not in the anim_data list directly, though occuring there) * with the new state of the setting that we want flushed up/down the hierarchy - * - vizOn: whether the visibility setting has been enabled or disabled + * - setting: type of setting to set + * - on: whether the visibility setting has been enabled or disabled */ -void ANIM_visibility_flush_anim_channels (bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, short vizOn) +void ANIM_flush_setting_anim_channels (bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, int setting, short on) { bAnimListElem *ale, *match=NULL; int prevLevel=0, matchLevel=0; @@ -394,13 +395,22 @@ void ANIM_visibility_flush_anim_channels (bAnimContext *ac, ListBase *anim_data, * - we define the level as simply being the offset for the start of the channel */ matchLevel= (acf->get_offset)? acf->get_offset(ac, ale_setting) : 0; + prevLevel= matchLevel; } /* flush up? - * - only flush up if the current state is now enabled + * + * For Visibility: + * - only flush up if the current state is now enabled (positive 'on' state is default) * (otherwise, it's too much work to force the parents to be inactive too) + * + * For everything else: + * - only flush up if the current state is now disabled (negative 'off' state is default) + * (otherwise, it's too much work to force the parents to be active too) */ - if (vizOn) { + if ( ((setting == ACHANNEL_SETTING_VISIBLE) && on) || + ((setting != ACHANNEL_SETTING_VISIBLE) && on==0) ) + { /* go backwards in the list, until the highest-ranking element (by indention has been covered) */ for (ale= match->prev; ale; ale= ale->prev) { bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); @@ -416,7 +426,7 @@ void ANIM_visibility_flush_anim_channels (bAnimContext *ac, ListBase *anim_data, * when toggling visibility of F-Curves, gets flushed), flush the new status... */ if (level < prevLevel) - ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_VISIBLE, vizOn); + ANIM_channel_setting_set(ac, ale, setting, on); /* however, if the level is 'greater than' (i.e. less important than the previous channel, * stop searching, since we've already reached the bottom of another hierarchy */ @@ -444,7 +454,7 @@ void ANIM_visibility_flush_anim_channels (bAnimContext *ac, ListBase *anim_data, * flush the new status... */ if (level > matchLevel) - ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_VISIBLE, vizOn); + ANIM_channel_setting_set(ac, ale, setting, on); /* however, if the level is 'less than or equal to' the channel that was changed, * (i.e. the current channel is as important if not more important than the changed channel) * then we should stop, since we've found the last one of the children we should flush @@ -1054,7 +1064,7 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *op) ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD); /* now, also flush selection status up/down as appropriate */ - ANIM_visibility_flush_anim_channels(&ac, &all_data, ale, 1); + ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, 1); } BLI_freelistN(&anim_data); @@ -1128,7 +1138,7 @@ static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *op) ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, vis); /* now, also flush selection status up/down as appropriate */ - ANIM_visibility_flush_anim_channels(&ac, &all_data, ale, (vis == ACHANNEL_SETFLAG_ADD)); + ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, (vis == ACHANNEL_SETFLAG_ADD)); } /* cleanup */ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 3d8ea195707..531751a609e 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -386,9 +386,10 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, * then the channels under closed expanders get ignored... * - ale_setting: the anim channel (not in the anim_data list directly, though occuring there) * with the new state of the setting that we want flushed up/down the hierarchy - * - vizOn: whether the visibility setting has been enabled or disabled + * - setting: type of setting to set + * - on: whether the visibility setting has been enabled or disabled */ -void ANIM_visibility_flush_anim_channels(bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, short vizOn); +void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, int setting, short on); /* Deselect all animation channels */ |