[Bf-blender-cvs] [fbd4dfb] master: Graph Editor: H/Shift-H now hide and unhide selected curves (Gooseberry Request)

Joshua Leung noreply at git.blender.org
Wed Nov 19 14:26:13 CET 2014


Commit: fbd4dfb2c6435ca095fe64d2fbd76abdb9f550f9
Author: Joshua Leung
Date:   Thu Nov 20 02:24:42 2014 +1300
Branches: master
https://developer.blender.org/rBfbd4dfb2c6435ca095fe64d2fbd76abdb9f550f9

Graph Editor: H/Shift-H now hide and unhide selected curves (Gooseberry Request)

Revised the tools for managing which FCurves are visible in the Graph Editor
curves area. Now, there are the following tools in place:
* V (channels region only) = Hide all curves except those in selected channels  [OLD]

* H       = Hide all selected curves  [NEW]
* Shift-H = Show all previously hidden curves [NEW]

I've removed the old operator to toggle visibility status of selected curves,
as it doesn't seem that useful anymore.

===================================================================

M	release/scripts/startup/bl_ui/space_graph.py
M	source/blender/editors/animation/anim_channels_edit.c
M	source/blender/editors/space_graph/graph_ops.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py
index 6fc3d9e..a815540 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -189,6 +189,8 @@ class GRAPH_MT_channel(Menu):
 
         layout.separator()
         layout.operator("anim.channels_editable_toggle")
+        layout.operator("graph.hide")
+        layout.operator("graph.unhide")
         layout.operator("anim.channels_visibility_set")
         layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode")
 
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index b6ab040..33c9aab 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -1665,7 +1665,7 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op))
 static void ANIM_OT_channels_visibility_set(wmOperatorType *ot)
 {
 	/* identifiers */
-	ot->name = "Set Visibility";
+	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";
 	
@@ -1677,83 +1677,6 @@ static void ANIM_OT_channels_visibility_set(wmOperatorType *ot)
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
-
-/* ******************** Toggle Channel Visibility Operator *********************** */
-/* NOTE: this operator is only valid in the Graph Editor channels region */
-
-static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
-	bAnimContext ac;
-	ListBase anim_data = {NULL, NULL};
-	ListBase all_data = {NULL, NULL};
-	bAnimListElem *ale;
-	int filter;
-	short vis = ACHANNEL_SETFLAG_ADD;
-	
-	/* 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);
-		
-	/* filter data
-	 * - restrict this to only applying on settings we can get to in the list
-	 */
-	filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
-	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-	
-	/* See if we should be making showing all selected or hiding */
-	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, ACHANNEL_SETTING_VISIBLE)) {
-			vis = ACHANNEL_SETFLAG_CLEAR;
-			break;
-		}
-	}
-
-	/* Now set the flags */
-	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;
-		
-		/* change the setting */
-		ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, vis);
-		
-		/* now, also flush selection status up/down as appropriate */
-		ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, (vis == ACHANNEL_SETFLAG_ADD));
-	}
-	
-	/* cleanup */
-	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_toggle(wmOperatorType *ot)
-{
-	/* identifiers */
-	ot->name = "Toggle Visibility";
-	ot->idname = "ANIM_OT_channels_visibility_toggle";
-	ot->description = "Toggle visibility in Graph Editor of all selected animation channels";
-	
-	/* api callbacks */
-	ot->exec = animchannels_visibility_toggle_exec;
-	ot->poll = ED_operator_graphedit_active;
-	
-	/* flags */
-	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
 /* ********************** Set Flags Operator *********************** */
 
 /* defines for setting animation-channel flags */
@@ -3042,7 +2965,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_toggle);
 	WM_operatortype_append(ANIM_OT_channels_visibility_set);
 	
 	WM_operatortype_append(ANIM_OT_channels_fcurves_enable);
@@ -3113,7 +3035,6 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf)
 	
 	/* Graph Editor only */
 	WM_keymap_add_item(keymap, "ANIM_OT_channels_visibility_set", VKEY, KM_PRESS, 0, 0);
-	WM_keymap_add_item(keymap, "ANIM_OT_channels_visibility_toggle", VKEY, 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 62b6b59..a4f5750 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -34,6 +34,7 @@
 
 #include "DNA_scene_types.h"
 
+#include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
 #include "BLI_math_base.h"
 
@@ -200,6 +201,139 @@ static void GRAPH_OT_cursor_set(wmOperatorType *ot)
 	RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Value", "", -100.0f, 100.0f);
 }
 
+/* Hide/UnHide Curves ----------------------------------------------------------------------------- */
+
+static int graphview_curves_hide_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 must not 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);
+	
+	/* filter data
+	 * - of the remaining visible curves, we want to hide the ones that are selected 
+	 */
+	filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | 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;
+		
+		/* change the hide setting, and unselect it... */
+		ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR);
+		ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_SELECT,  ACHANNEL_SETFLAG_CLEAR);
+		
+		/* now, also flush selection status up/down as appropriate */
+		ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, false);
+	}
+	
+	/* cleanup */
+	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 GRAPH_OT_hide(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Hide Curves";
+	ot->idname = "GRAPH_OT_hide";
+	ot->description = "Hide selected curves from Graph Editor view";
+	
+	/* api callbacks */
+	ot->exec = graphview_curves_hide_exec;
+	ot->poll = ED_operator_graphedit_active;
+	
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+/* ........ */
+
+static int graphview_curves_unhide_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 must not 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);
+	
+	/* filter data
+	 * - just go through all visible channels, ensuring that everything is set to be curve-visible
+	 */
+	filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 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;
+		
+		/* select if it is not visible */
+		if (ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_VISIBLE) == 0)
+			ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_SELECT, ACHANNEL_SETFLAG_ADD);
+		
+		/* change the visibility 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, true);
+	}
+	
+	/* cleanup */
+	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 GRAPH_OT_unhide(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Unhide Curves";
+	ot->idname = "GRAPH_OT_unhide";
+	ot->description = "Make previously hidden curves visible again in Graph Editor view";
+	
+	/* api callbacks */
+	ot->exec = graphview_curves_unhide_exec;
+	ot->poll = ED_operator_graphedit_active;
+	
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
 /* ************************** 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list