[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18260] branches/blender2.5/blender/source /blender/editors: 2.5 - Action Editor: Toggle settings

Joshua Leung aligorith at gmail.com
Fri Jan 2 12:06:29 CET 2009


Revision: 18260
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18260
Author:   aligorith
Date:     2009-01-02 12:06:27 +0100 (Fri, 02 Jan 2009)

Log Message:
-----------
2.5 - Action Editor: Toggle settings

* Added back enable (Ctrl-Shift-W), disable (Alt-W), and toggle (Shift-W) operators to channels view. They are separate operators which use the same backend code.

* Fixed icon-drawing for IPO-curve 'protect' buttons. After doing this, I've realised that many tools will need some alterations to take this into account. That commit will come later.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_header.c

Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c	2009-01-02 10:59:19 UTC (rev 18259)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c	2009-01-02 11:06:27 UTC (rev 18260)
@@ -217,6 +217,240 @@
 /* ************************************************************************** */
 /* OPERATORS */
 
+/* ********************** Set Flags Operator *********************** */
+
+enum {
+// 	ACHANNEL_SETTING_SELECT = 0,
+	ACHANNEL_SETTING_PROTECT = 1,
+	ACHANNEL_SETTING_MUTE,
+} eAnimChannel_Settings;
+
+/* defines for setting animation-channel flags */
+EnumPropertyItem prop_animchannel_setflag_types[] = {
+	{ACHANNEL_SETFLAG_CLEAR, "DISABLE", "Disable", ""},
+	{ACHANNEL_SETFLAG_ADD, "ENABLE", "Enable", ""},
+	{ACHANNEL_SETFLAG_TOGGLE, "TOGGLE", "Toggle", ""},
+	{0, NULL, NULL, NULL}
+};
+
+/* defines for set animation-channel settings */
+EnumPropertyItem prop_animchannel_settings_types[] = {
+	{ACHANNEL_SETTING_PROTECT, "PROTECT", "Protect", ""},
+	{ACHANNEL_SETTING_MUTE, "MUTE", "Mute", ""},
+	{0, NULL, NULL, NULL}
+};
+
+
+/* ------------------- */
+
+/* Set/clear a particular flag (setting) for all selected + visible channels 
+ *	setting: the setting to modify
+ *	mode: eAnimChannels_SetFlag
+ */
+static void setflag_anim_channels (bAnimContext *ac, short setting, short mode)
+{
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	
+	/* filter data */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS | ANIMFILTER_SEL);
+	ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
+	
+	/* affect selected channels */
+	for (ale= anim_data.first; ale; ale= ale->next) {
+		switch (ale->type) {
+			case ANIMTYPE_GROUP:
+			{
+				bActionGroup *agrp= (bActionGroup *)ale->data;
+				
+				/* only 'protect' is available */
+				if (setting == ACHANNEL_SETTING_PROTECT) {
+					ACHANNEL_SET_FLAG(agrp, mode, AGRP_PROTECTED);
+				}
+			}
+				break;
+			case ANIMTYPE_ACHAN:
+			{
+				bActionChannel *achan= (bActionChannel *)ale->data;
+				
+				/* 'protect' and 'mute' */
+				if ((setting == ACHANNEL_SETTING_MUTE) && (achan->ipo)) {
+					Ipo *ipo= achan->ipo;
+					
+					/* mute */
+					if (mode == 0)
+						ipo->muteipo= 0;
+					else if (mode == 1)
+						ipo->muteipo= 1;
+					else if (mode == 2) 
+						ipo->muteipo= (ipo->muteipo) ? 0 : 1;
+				}
+				else if (setting == ACHANNEL_SETTING_PROTECT) {
+					/* protected */
+					ACHANNEL_SET_FLAG(achan, mode, ACHAN_PROTECTED);
+				}
+			}
+				break;
+			case ANIMTYPE_CONCHAN:
+			{
+				bConstraintChannel *conchan= (bConstraintChannel *)ale->data;
+				
+				/* 'protect' and 'mute' */
+				if ((setting == ACHANNEL_SETTING_MUTE) && (conchan->ipo)) {
+					Ipo *ipo= conchan->ipo;
+					
+					/* mute */
+					if (mode == 0)
+						ipo->muteipo= 0;
+					else if (mode == 1)
+						ipo->muteipo= 1;
+					else if (mode == 2) 
+						ipo->muteipo= (ipo->muteipo) ? 0 : 1;
+				}
+				else if (setting == ACHANNEL_SETTING_PROTECT) {
+					/* protect */
+					ACHANNEL_SET_FLAG(conchan, mode, CONSTRAINT_CHANNEL_PROTECTED);
+				}
+			}
+				break;
+			case ANIMTYPE_ICU:
+			{
+				IpoCurve *icu= (IpoCurve *)ale->data;
+				
+				/* mute */
+				if (setting == ACHANNEL_SETTING_MUTE) {
+					ACHANNEL_SET_FLAG(icu, mode, IPO_MUTE);
+				}
+				else if (setting == ACHANNEL_SETTING_PROTECT) {
+					ACHANNEL_SET_FLAG(icu, mode, IPO_PROTECT);
+				}
+			}
+				break;
+			case ANIMTYPE_GPLAYER:
+			{
+				bGPDlayer *gpl= (bGPDlayer *)ale->data;
+				
+				/* 'protect' and 'mute' */
+				if (setting == ACHANNEL_SETTING_MUTE) {
+					/* mute */
+					ACHANNEL_SET_FLAG(gpl, mode, GP_LAYER_HIDE);
+				}
+				else if (setting == ACHANNEL_SETTING_PROTECT) {
+					/* protected */
+					ACHANNEL_SET_FLAG(gpl, mode, GP_LAYER_LOCKED);
+				}
+			}
+				break;
+		}
+	}
+	
+	BLI_freelistN(&anim_data);
+}
+
+/* ------------------- */
+
+static int animchannels_setflag_exec(bContext *C, wmOperator *op)
+{
+	bAnimContext ac;
+	short mode, setting;
+	
+	/* get editor data */
+	if (ANIM_animdata_get_context(C, &ac) == 0)
+		return OPERATOR_CANCELLED;
+		
+	/* mode (eAnimChannels_SetFlag), setting (eAnimChannel_Settings) */
+	mode= RNA_enum_get(op->ptr, "mode");
+	setting= RNA_enum_get(op->ptr, "type");
+	
+	/* modify setting */
+	setflag_anim_channels(&ac, setting, mode);
+	
+	/* set notifier tha things have changed */
+	ED_area_tag_redraw(CTX_wm_area(C)); // FIXME... should be updating 'keyframes' data context or so instead!
+	
+	return OPERATOR_FINISHED;
+}
+
+
+void ANIM_OT_channels_enable_setting (wmOperatorType *ot)
+{
+	PropertyRNA *prop;
+	
+	/* identifiers */
+	ot->name= "Enable Channel Setting";
+	ot->idname= "ANIM_OT_channels_enable_setting";
+	
+	/* api callbacks */
+	ot->invoke= WM_menu_invoke;
+	ot->exec= animchannels_setflag_exec;
+	ot->poll= ED_operator_areaactive;
+	
+	/* flags */
+	ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+	
+	/* props */
+		/* flag-setting mode */
+	prop= RNA_def_property(ot->srna, "mode", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_items(prop, prop_animchannel_setflag_types);
+	RNA_def_property_enum_default(prop, ACHANNEL_SETFLAG_ADD);
+		/* setting to set */
+	prop= RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_items(prop, prop_animchannel_settings_types);
+}
+
+void ANIM_OT_channels_disable_setting (wmOperatorType *ot)
+{
+	PropertyRNA *prop;
+	
+	/* identifiers */
+	ot->name= "Disable Channel Setting";
+	ot->idname= "ANIM_OT_channels_disable_setting";
+	
+	/* api callbacks */
+	ot->invoke= WM_menu_invoke;
+	ot->exec= animchannels_setflag_exec;
+	ot->poll= ED_operator_areaactive;
+	
+	/* flags */
+	ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+	
+	/* props */
+		/* flag-setting mode */
+	prop= RNA_def_property(ot->srna, "mode", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_items(prop, prop_animchannel_setflag_types);
+	RNA_def_property_enum_default(prop, ACHANNEL_SETFLAG_CLEAR);
+		/* setting to set */
+	prop= RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_items(prop, prop_animchannel_settings_types);
+}
+
+void ANIM_OT_channels_toggle_setting (wmOperatorType *ot)
+{
+	PropertyRNA *prop;
+	
+	/* identifiers */
+	ot->name= "Toggle Channel Setting";
+	ot->idname= "ANIM_OT_channels_toggle_setting";
+	
+	/* api callbacks */
+	ot->invoke= WM_menu_invoke;
+	ot->exec= animchannels_setflag_exec;
+	ot->poll= ED_operator_areaactive;
+	
+	/* flags */
+	ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+	
+	/* props */
+		/* flag-setting mode */
+	prop= RNA_def_property(ot->srna, "mode", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_items(prop, prop_animchannel_setflag_types);
+	RNA_def_property_enum_default(prop, ACHANNEL_SETFLAG_TOGGLE);
+		/* setting to set */
+	prop= RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_items(prop, prop_animchannel_settings_types);
+}
+
 /* ********************** Select All Operator *********************** */
 
 static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
@@ -803,6 +1037,10 @@
 	WM_operatortype_append(ANIM_OT_channels_deselectall);
 	WM_operatortype_append(ANIM_OT_channels_borderselect);
 	WM_operatortype_append(ANIM_OT_channels_mouseclick);
+	
+	WM_operatortype_append(ANIM_OT_channels_enable_setting);
+	WM_operatortype_append(ANIM_OT_channels_disable_setting);
+	WM_operatortype_append(ANIM_OT_channels_toggle_setting);
 }
 
 void ED_keymap_animchannels(wmWindowManager *wm)
@@ -821,6 +1059,11 @@
 	
 		/* borderselect */
 	WM_keymap_add_item(keymap, "ANIM_OT_channels_borderselect", BKEY, KM_PRESS, 0, 0);
+	
+	/* settings */
+	RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_toggle_setting", WKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", ACHANNEL_SETFLAG_TOGGLE);
+	RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_enable_setting", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "mode", ACHANNEL_SETFLAG_ADD);
+	RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_disable_setting", WKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", ACHANNEL_SETFLAG_CLEAR);
 }
 
 /* ************************************************************************** */

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c	2009-01-02 10:59:19 UTC (rev 18259)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c	2009-01-02 11:06:27 UTC (rev 18260)
@@ -745,7 +745,7 @@
 					else	
 						mute = ICON_MUTE_IPO_OFF;
 						
-					if (icu->flag & IPO_PROTECT)
+					if (EDITABLE_ICU(icu))
 						protect = ICON_UNLOCKED;
 					else
 						protect = ICON_LOCKED;

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c	2009-01-02 10:59:19 UTC (rev 18259)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c	2009-01-02 11:06:27 UTC (rev 18260)
@@ -836,7 +836,7 @@
 
 /* ******************** Set Extrapolation-Type Operator *********************** */
 
-/* defines for set ipo-type for selected keyframes tool */
+/* defines for set extrapolation-type for selected keyframes tool */
 EnumPropertyItem prop_actkeys_expo_types[] = {
 	{IPO_HORIZ, "CONSTANT", "Constant", ""},
 	{IPO_DIR, "DIRECTIONAL", "Extrapolation", ""},

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_header.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_header.c	2009-01-02 10:59:19 UTC (rev 18259)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_header.c	2009-01-02 11:06:27 UTC (rev 18260)
@@ -619,10 +619,11 @@
 		}
 		
 		/* draw LOCK */
-		uiDefIconButS(block, ICONTOG, 1, ICON_UNLOCKED,	xco, yco, XIC, YIC, 
-					  &(saction->lock), 0, 0, 0, 0, 
-					  "Updates other affected window spaces automatically "
-					  "to reflect changes in real time");
+			// XXX this feature is probably not relevant anymore!
+		//uiDefIconButS(block, ICONTOG, B_LOCK, ICON_UNLOCKED,	xco, yco, XIC, YIC, 
+		//			  &(saction->lock), 0, 0, 0, 0, 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list