From cd54f07a3c71ba146542e41c7b3407b287b52b4c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 20 Nov 2014 03:07:09 +1300 Subject: [PATCH] Fix: Shift-H now works in main graph editor area too In the process, I've removed the old operator (ANIM_OT_channels_visibility_set) and folded that option in with the hide operator, to make this consistent with how this is done in the 3D view and other parts of Blender. --- release/scripts/startup/bl_ui/space_graph.py | 8 +- .../editors/animation/anim_channels_edit.c | 97 ------------------- .../blender/editors/space_graph/graph_ops.c | 24 ++++- 3 files changed, 25 insertions(+), 104 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py index cb5926b37e4..5861bc0dc95 100644 --- a/release/scripts/startup/bl_ui/space_graph.py +++ b/release/scripts/startup/bl_ui/space_graph.py @@ -189,11 +189,13 @@ class GRAPH_MT_channel(Menu): layout.separator() layout.operator("anim.channels_editable_toggle") - layout.operator("graph.hide") - layout.operator("graph.reveal") - layout.operator("anim.channels_visibility_set") layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode") + layout.separator() + layout.operator("graph.hide", text="Hide Selected Curves").unselected = False + layout.operator("graph.hide", text="Hide Unselected Curves").unselected = True + layout.operator("graph.reveal") + layout.separator() layout.operator("anim.channels_expand") layout.operator("anim.channels_collapse") diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 9a2235a9a6c..579275d0799 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1585,98 +1585,6 @@ static void ANIM_OT_channels_delete(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* ******************** Set Channel Visibility Operator *********************** */ -/* NOTE: this operator is only valid in the Graph Editor channels region */ - -static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) -{ - bAnimContext ac; - ListBase anim_data = {NULL, NULL}; - ListBase all_data = {NULL, NULL}; - bAnimListElem *ale; - int filter; - - /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) - return OPERATOR_CANCELLED; - - /* get list of all channels that selection may need to be flushed to - * - hierarchy mustn't affect what we have access to here... - */ - filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); - ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype); - - /* hide all channels not selected - * - hierarchy matters if we're doing this from the channels region - * since we only want to apply this to channels we can "see", - * and have these affect their relatives - * - but for Graph Editor, this gets used also from main region - * where hierarchy doesn't apply, as for [#21276] - */ - if ((ac.spacetype == SPACE_IPO) && (ac.regiontype != RGN_TYPE_CHANNELS)) { - /* graph editor (case 2) */ - filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); - } - else { - /* standard case */ - filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_NODUPLIS); - } - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - - for (ale = anim_data.first; ale; ale = ale->next) { - /* clear setting first */ - ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR); - - /* now also flush selection status as appropriate - * NOTE: in some cases, this may result in repeat flushing being performed - */ - ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, 0); - } - - ANIM_animdata_freelist(&anim_data); - - /* make all the selected channels visible */ - filter = (ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - - for (ale = anim_data.first; ale; ale = ale->next) { - /* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */ - /* TODO: find out why this is the case, and fix that */ - if (ale->type == ANIMTYPE_OBJECT) - continue; - - /* enable the setting */ - ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD); - - /* now, also flush selection status up/down as appropriate */ - ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, 1); - } - - ANIM_animdata_freelist(&anim_data); - BLI_freelistN(&all_data); - - - /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - - return OPERATOR_FINISHED; -} - -static void ANIM_OT_channels_visibility_set(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Show Selected Curves Only"; - ot->idname = "ANIM_OT_channels_visibility_set"; - ot->description = "Make only the selected animation channels visible in the Graph Editor"; - - /* api callbacks */ - ot->exec = animchannels_visibility_set_exec; - ot->poll = ED_operator_graphedit_active; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - /* ********************** Set Flags Operator *********************** */ /* defines for setting animation-channel flags */ @@ -2965,8 +2873,6 @@ void ED_operatortypes_animchannels(void) WM_operatortype_append(ANIM_OT_channels_expand); WM_operatortype_append(ANIM_OT_channels_collapse); - WM_operatortype_append(ANIM_OT_channels_visibility_set); - WM_operatortype_append(ANIM_OT_channels_fcurves_enable); WM_operatortype_append(ANIM_OT_channels_clean_empty); @@ -3032,9 +2938,6 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) /* grouping */ WM_keymap_add_item(keymap, "ANIM_OT_channels_group", GKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_ungroup", GKEY, KM_PRESS, KM_ALT, 0); - - /* Graph Editor only */ - WM_keymap_add_item(keymap, "ANIM_OT_channels_visibility_set", HKEY, KM_PRESS, KM_SHIFT, 0); } /* ************************************************************************** */ diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index bb041c57a87..de9fbca5a31 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -203,13 +203,14 @@ static void GRAPH_OT_cursor_set(wmOperatorType *ot) /* Hide/Reveal ------------------------------------------------------------ */ -static int graphview_curves_hide_exec(bContext *C, wmOperator *UNUSED(op)) +static int graphview_curves_hide_exec(bContext *C, wmOperator *op) { bAnimContext ac; ListBase anim_data = {NULL, NULL}; ListBase all_data = {NULL, NULL}; bAnimListElem *ale; int filter; + const bool unselected = RNA_boolean_get(op->ptr, "unselected"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -222,9 +223,15 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype); /* filter data - * - of the remaining visible curves, we want to hide the ones that are selected + * - of the remaining visible curves, we want to hide the ones that are + * selected/unselected (depending on "unselected" prop) */ - filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + if (unselected) + filter |= ANIMFILTER_UNSEL; + else + filter |= ANIMFILTER_SEL; + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); for (ale = anim_data.first; ale; ale = ale->next) { @@ -264,6 +271,9 @@ static void GRAPH_OT_hide(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* props */ + RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected curves"); } /* ........ */ @@ -575,6 +585,7 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) void graphedit_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; + wmKeyMapItem *kmi; /* keymap for all regions */ keymap = WM_keymap_find(keyconf, "Graph Editor Generic", SPACE_IPO, 0); @@ -587,7 +598,12 @@ void graphedit_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0); /* hide/reveal selected curves */ - WM_keymap_add_item(keymap, "GRAPH_OT_hide", HKEY, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_hide", HKEY, KM_PRESS, 0, 0); + RNA_boolean_set(kmi->ptr, "unselected", false); + + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "unselected", true); + WM_keymap_add_item(keymap, "GRAPH_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);