[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18035] branches/blender2.5/blender/source /blender/editors: 2.5 - Action Editor Select Tools

Joshua Leung aligorith at gmail.com
Wed Dec 24 00:34:19 CET 2008


Revision: 18035
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18035
Author:   aligorith
Date:     2008-12-24 00:34:19 +0100 (Wed, 24 Dec 2008)

Log Message:
-----------
2.5 - Action Editor Select Tools  

Ported the following tools 
* borderselect
* invert selection

Note: while porting these, I noticed a few issues with some stuff that still needs to be cleaned up.

Events handling in scrollers won't work yet, for the useful select all in frame(-range) or select all in channel(s). We should probably review ways to expose this more clearly in the UI too.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c
    branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
    branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
    branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h
    branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_select.c

Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c	2008-12-23 22:40:25 UTC (rev 18034)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c	2008-12-23 23:34:19 UTC (rev 18035)
@@ -270,7 +270,6 @@
 	RNA_def_property(ot->srna, "xmin", PROP_INT, PROP_NONE);
 	RNA_def_property(ot->srna, "xmax", PROP_INT, PROP_NONE);
 		/* these are not used, but are needed by borderselect gesture operator stuff */
-	RNA_def_property(ot->srna, "event_type", PROP_INT, PROP_NONE);
 	RNA_def_property(ot->srna, "ymin", PROP_INT, PROP_NONE);
 	RNA_def_property(ot->srna, "ymax", PROP_INT, PROP_NONE);
 }

Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c	2008-12-23 22:40:25 UTC (rev 18034)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c	2008-12-23 23:34:19 UTC (rev 18035)
@@ -613,7 +613,7 @@
 }
 
 
-void borderselect_icu_key(Scene *scene, IpoCurve *icu, float xmin, float xmax, BeztEditFunc select_cb)
+void borderselect_icu_key(IpoCurve *icu, float xmin, float xmax, BeztEditFunc select_cb)
 {
 	/* Selects all bezier triples in the Ipocurve 
 	 * between times xmin and xmax, using the selection
@@ -623,18 +623,19 @@
 	int i;
 	
 	/* loop through all of the bezier triples in
-	* the Ipocurve -- if the triple occurs between
-	* times xmin and xmax then select it using the selection
-	* function
-	*/
+	 * the Ipocurve -- if the triple occurs between
+	 * times xmin and xmax then select it using the selection
+	 * function
+	 */
 	for (i=0, bezt=icu->bezt; i<icu->totvert; i++, bezt++) {
 		if ((bezt->vec[1][0] > xmin) && (bezt->vec[1][0] < xmax)) {
-			select_cb(scene, bezt);
+			/* scene is NULL (irrelevant here) */
+			select_cb(NULL, bezt); 
 		}
 	}
 }
 
-void borderselect_ipo_key(Scene *scene, Ipo *ipo, float xmin, float xmax, short selectmode)
+void borderselect_ipo_key(Ipo *ipo, float xmin, float xmax, short selectmode)
 {
 	/* Selects all bezier triples in each Ipocurve of the
 	 * Ipo between times xmin and xmax, using the selection mode.
@@ -660,7 +661,7 @@
 		* function
 		*/
 	for (icu=ipo->curve.first; icu; icu=icu->next) {
-		borderselect_icu_key(scene, icu, xmin, xmax, select_cb);
+		borderselect_icu_key(icu, xmin, xmax, select_cb);
 	}
 }
 

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h	2008-12-23 22:40:25 UTC (rev 18034)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h	2008-12-23 23:34:19 UTC (rev 18035)
@@ -101,7 +101,10 @@
 short is_ipo_key_selected(struct Ipo *ipo);
 void set_ipo_key_selection(struct Ipo *ipo, short sel);
 
+void borderselect_ipo_key(struct Ipo *ipo, float xmin, float xmax, short selectmode);
+void borderselect_icu_key(struct IpoCurve *icu, float xmin, float xmax, BeztEditFunc select_cb);
 
+
 /* ************************************************ */
 
 #endif /* ED_KEYFRAMES_EDIT_H */

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h	2008-12-23 22:40:25 UTC (rev 18034)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h	2008-12-23 23:34:19 UTC (rev 18035)
@@ -46,6 +46,7 @@
 
 /* action_select.c */
 void ED_ACT_OT_keyframes_deselectall(struct wmOperatorType *ot);
+void ED_ACT_OT_keyframes_borderselect(struct wmOperatorType *ot);
 void ED_ACT_OT_keyframes_clickselect(struct wmOperatorType *ot);
 
 /* action_ops.c */

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c	2008-12-23 22:40:25 UTC (rev 18034)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c	2008-12-23 23:34:19 UTC (rev 18035)
@@ -64,6 +64,7 @@
 	/* keyframes */
 	WM_operatortype_append(ED_ACT_OT_keyframes_clickselect);
 	WM_operatortype_append(ED_ACT_OT_keyframes_deselectall);
+	WM_operatortype_append(ED_ACT_OT_keyframes_borderselect);
 }
 
 /* ************************** registration - keymaps **********************************/
@@ -77,6 +78,10 @@
 	
 		/* deselect all */
 	WM_keymap_add_item(keymap, "ED_ACT_OT_keyframes_deselectall", AKEY, KM_PRESS, 0, 0);
+	RNA_boolean_set(WM_keymap_add_item(keymap, "ED_ACT_OT_keyframes_deselectall", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
+	
+		/* borderselect */
+	WM_keymap_add_item(keymap, "ED_ACT_OT_keyframes_borderselect", BKEY, KM_PRESS, 0, 0);
 }
 
 /* --------------- */

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_select.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_select.c	2008-12-23 22:40:25 UTC (rev 18034)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_select.c	2008-12-23 23:34:19 UTC (rev 18035)
@@ -317,9 +317,20 @@
 /* KEYFRAMES STUFF */
 
 /* ******************** Deselect All Operator ***************************** */
+/* This operator works in one of three ways:
+ *	1) (de)select all (AKEY) - test if select all or deselect all
+ *	2) invert all (CTRL-IKEY) - invert selection of all keyframes
+ *	3) (de)select all - no testing is done; only for use internal tools as normal function...
+ */
 
 /* Deselects keyframes in the action editor
  *	- This is called by the deselect all operator, as well as other ones!
+ *
+ * 	- test: check if select or deselect all
+ *	- sel: how to select keyframes 
+ *		0 = deselect
+ *		1 = select
+ *		2 = invert
  */
 static void deselect_action_keys (bAnimContext *ac, short test, short sel)
 {
@@ -368,7 +379,7 @@
 
 /* ------------------- */
 
-static int actkeys_deselectall_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int actkeys_deselectall_exec(bContext *C, wmOperator *op)
 {
 	bAnimContext ac;
 	
@@ -377,7 +388,10 @@
 		return OPERATOR_CANCELLED;
 		
 	/* 'standard' behaviour - check if selected, then apply relevant selection */
-	deselect_action_keys(&ac, 1, 1);
+	if (RNA_boolean_get(op->ptr, "invert"))
+		deselect_action_keys(&ac, 0, 2);
+	else
+		deselect_action_keys(&ac, 1, 1);
 	
 	/* set notifier tha things have changed */
 	ED_area_tag_redraw(CTX_wm_area(C)); // FIXME... should be updating 'keyframes' data context or so instead!
@@ -388,14 +402,225 @@
 void ED_ACT_OT_keyframes_deselectall (wmOperatorType *ot)
 {
 	/* identifiers */
-	ot->name= "Deselect All";
+	ot->name= "Select All";
 	ot->idname= "ED_ACT_OT_keyframes_deselectall";
 	
 	/* api callbacks */
-	ot->invoke= actkeys_deselectall_invoke;
-	//ot->poll= ED_operator_areaactive;
+	ot->exec= actkeys_deselectall_exec;
+	ot->poll= ED_operator_areaactive;
+	
+	/* props */
+	RNA_def_property(ot->srna, "invert", PROP_BOOLEAN, PROP_NONE);
 }
 
+/* ******************** Border Select Operator **************************** */
+/* This operator works in one of three ways:
+ *	1) borderselect over keys (BKEY) - mouse over main area when initialised; will select keys in region
+ *	2) borderselect over horizontal scroller - mouse over horizontal scroller when initialised; will select keys in frame range
+ *	3) borderselect over vertical scroller - mouse over vertical scroller when initialised; will select keys in row range
+ */
+
+static void borderselect_action (bAnimContext *ac, rcti rect, short in_scroller, short selectmode)
+{
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	
+	View2D *v2d= &ac->ar->v2d;
+	BeztEditFunc select_cb;
+	rctf rectf;
+	float ymin=0, ymax=ACHANNEL_HEIGHT;
+	
+	UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin+2, &rectf.xmin, &rectf.ymin);
+	UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax-2, &rectf.xmax, &rectf.ymax);
+	
+	/* filter data */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS);
+	ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
+	
+	/* get selection editing func */
+	select_cb= ANIM_editkeyframes_select(selectmode);
+	
+	/* loop over data, doing border select */
+	for (ale= anim_data.first; ale; ale= ale->next) {
+		Object *nob= ANIM_nla_mapping_get(ac, ale);
+		
+		ymin= ymax - ACHANNEL_STEP;
+		
+		/* if action is mapped in NLA, it returns a correction */
+		if (nob) {
+			rectf.xmin= get_action_frame(nob, rectf.xmin);
+			rectf.xmax= get_action_frame(nob, rectf.xmax);
+		}
+		
+		/* what gets selected depends on the mode (based on initial position of cursor) */
+		switch (in_scroller) {
+		case 'h': /* all in frame(s) */
+			if (ale->key_data) {
+				if (ale->datatype == ALE_IPO)
+					borderselect_ipo_key(ale->key_data, rectf.xmin, rectf.xmax, selectmode);
+				else if (ale->datatype == ALE_ICU)
+					borderselect_icu_key(ale->key_data, rectf.xmin, rectf.xmax, select_cb);
+			}
+			else if (ale->type == ANIMTYPE_GROUP) {
+				bActionGroup *agrp= ale->data;
+				bActionChannel *achan;
+				bConstraintChannel *conchan;
+				
+				for (achan= agrp->channels.first; achan && achan->grp==agrp; achan= achan->next) {
+					borderselect_ipo_key(achan->ipo, rectf.xmin, rectf.xmax, selectmode);
+					
+					for (conchan=achan->constraintChannels.first; conchan; conchan=conchan->next)
+						borderselect_ipo_key(conchan->ipo, rectf.xmin, rectf.xmax, selectmode);
+				}
+			}
+			//else if (ale->type == ANIMTYPE_GPLAYER) {
+			//	borderselect_gplayer_frames(ale->data, rectf.xmin, rectf.xmax, selectmode);
+			//}
+			break;
+		case 'v': /* all in channel(s) */
+			if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) {
+				if (ale->key_data) {
+					if (ale->datatype == ALE_IPO)
+						ipo_keys_bezier_loop(ac->scene, ale->key_data, select_cb, NULL);
+					else if (ale->datatype == ALE_ICU)
+						icu_keys_bezier_loop(ac->scene, ale->key_data, select_cb, NULL);
+				}
+				else if (ale->type == ANIMTYPE_GROUP) {
+					bActionGroup *agrp= ale->data;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list