[Bf-blender-cvs] [7e53f9f] master: Dopesheet: Lasso and Circle Select tools work for selecting keyframes

Joshua Leung noreply at git.blender.org
Thu Jun 23 17:19:56 CEST 2016


Commit: 7e53f9fb1af850271d92ddc92a50acbc7aafd48f
Author: Joshua Leung
Date:   Thu Jun 23 23:16:14 2016 +1200
Branches: master
https://developer.blender.org/rB7e53f9fb1af850271d92ddc92a50acbc7aafd48f

Dopesheet: Lasso and Circle Select tools work for selecting keyframes

This only works in the Action and Dopesheet modes (which operate on FCurve keyframes).
Support for Grease Pencil and Mask Keyframes though is still pending.

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

M	release/scripts/startup/bl_ui/space_dopesheet.py
M	source/blender/editors/animation/keyframes_edit.c
M	source/blender/editors/include/ED_keyframes_edit.h
M	source/blender/editors/space_action/action_intern.h
M	source/blender/editors/space_action/action_ops.c
M	source/blender/editors/space_action/action_select.c
M	source/blender/editors/space_graph/graph_select.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index 779303c..546c9c2 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -250,6 +250,8 @@ class DOPESHEET_MT_select(Menu):
         layout.operator("action.select_border").axis_range = False
         layout.operator("action.select_border", text="Border Axis Range").axis_range = True
 
+        layout.operator("action.select_circle")
+
         layout.separator()
         layout.operator("action.select_column", text="Columns on Selected Keys").mode = 'KEYS'
         layout.operator("action.select_column", text="Column on Current Frame").mode = 'CFRA'
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index cd00b96..f909b39 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -539,7 +539,7 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt)
 }
 
 /**
- * only called from #ok_bezier_region_lasso
+ * Called from #ok_bezier_region_lasso and #ok_bezier_channel_lasso
  */
 static bool bezier_region_lasso_test(
         const KeyframeEdit_LassoData *data_lasso,
@@ -575,8 +575,35 @@ static short ok_bezier_region_lasso(KeyframeEditData *ked, BezTriple *bezt)
 		return 0;
 }
 
+static short ok_bezier_channel_lasso(KeyframeEditData *ked, BezTriple *bezt)
+{
+	/* check for lasso customdata (KeyframeEdit_LassoData) */
+	if (ked->data) {
+		KeyframeEdit_LassoData *data = ked->data;
+		float pt[2];
+		
+		/* late-binding remap of the x values (for summary channels) */
+		/* XXX: Ideally we reset, but it should be fine just leaving it as-is
+		 * as the next channel will reset it properly, while the next summary-channel
+		 * curve will also reset by itself...
+		 */
+		if (ked->iterflags & (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP)) {
+			data->rectf_scaled->xmin = ked->f1;
+			data->rectf_scaled->xmax = ked->f2;
+		}
+		
+		/* only use the x-coordinate of the point; the y is the channel range... */
+		pt[0] = bezt->vec[1][0];
+		pt[1] = ked->channel_y;
+		
+		if (bezier_region_lasso_test(data, pt))
+			return KEYFRAME_OK_KEY;
+	}
+	return 0;
+}
+
 /**
- * only called from #ok_bezier_region_circle
+ * Called from #ok_bezier_region_circle and #ok_bezier_channel_circle
  */
 static bool bezier_region_circle_test(
         const KeyframeEdit_CircleData *data_circle,
@@ -613,6 +640,33 @@ static short ok_bezier_region_circle(KeyframeEditData *ked, BezTriple *bezt)
 		return 0;
 }
 
+static short ok_bezier_channel_circle(KeyframeEditData *ked, BezTriple *bezt)
+{
+	/* check for circle select customdata (KeyframeEdit_CircleData) */
+	if (ked->data) {
+		KeyframeEdit_CircleData *data = ked->data;
+		float pt[2];
+		
+		/* late-binding remap of the x values (for summary channels) */
+		/* XXX: Ideally we reset, but it should be fine just leaving it as-is
+		 * as the next channel will reset it properly, while the next summary-channel
+		 * curve will also reset by itself...
+		 */
+		if (ked->iterflags & (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP)) {
+			data->rectf_scaled->xmin = ked->f1;
+			data->rectf_scaled->xmax = ked->f2;
+		}
+		
+		/* only use the x-coordinate of the point; the y is the channel range... */
+		pt[0] = bezt->vec[1][0];
+		pt[1] = ked->channel_y;
+		
+		if (bezier_region_circle_test(data, pt))
+			return KEYFRAME_OK_KEY;
+	}
+	return 0;
+}
+
 
 KeyframeEditFunc ANIM_editkeyframes_ok(short mode)
 {
@@ -634,6 +688,10 @@ KeyframeEditFunc ANIM_editkeyframes_ok(short mode)
 			return ok_bezier_region_lasso;
 		case BEZT_OK_REGION_CIRCLE: /* only if the point falls within KeyframeEdit_CircleData defined data */
 			return ok_bezier_region_circle;
+		case BEZT_OK_CHANNEL_LASSO: /* same as BEZT_OK_REGION_LASSO, but we're only using the x-value of the points */
+			return ok_bezier_channel_lasso;
+		case BEZT_OK_CHANNEL_CIRCLE: /* same as BEZT_OK_REGION_CIRCLE, but we're only using the x-value of the points */
+			return ok_bezier_channel_circle;
 		default: /* nothing was ok */
 			return NULL;
 	}
diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h
index ab51298..0d352ab 100644
--- a/source/blender/editors/include/ED_keyframes_edit.h
+++ b/source/blender/editors/include/ED_keyframes_edit.h
@@ -45,14 +45,21 @@ struct Scene;
 
 /* bezt validation */
 typedef enum eEditKeyframes_Validate {
+	/* Frame range */
 	BEZT_OK_FRAME = 1,
 	BEZT_OK_FRAMERANGE,
+	/* Selection status */
 	BEZT_OK_SELECTED,
+	/* Values (y-val) only */
 	BEZT_OK_VALUE,
 	BEZT_OK_VALUERANGE,
+	/* For graph editor keyframes (2D tests) */
 	BEZT_OK_REGION,
 	BEZT_OK_REGION_LASSO,
 	BEZT_OK_REGION_CIRCLE,
+	/* Only for keyframes a certain Dopesheet channel */
+	BEZT_OK_CHANNEL_LASSO,
+	BEZT_OK_CHANNEL_CIRCLE,
 } eEditKeyframes_Validate;
 
 /* ------------ */
@@ -98,7 +105,7 @@ typedef enum eEditKeyframes_Mirror {
 
 /* use with BEZT_OK_REGION_LASSO */
 typedef struct KeyframeEdit_LassoData {
-	const rctf *rectf_scaled;
+	rctf *rectf_scaled;
 	const rctf *rectf_view;
 	const int (*mcords)[2];
 	int mcords_tot;
@@ -106,7 +113,7 @@ typedef struct KeyframeEdit_LassoData {
 
 /* use with BEZT_OK_REGION_CIRCLE */
 typedef struct KeyframeEdit_CircleData {
-	const rctf *rectf_scaled;
+	rctf *rectf_scaled;
 	const rctf *rectf_view;
 	float mval[2];
 	float radius_squared;
@@ -157,7 +164,8 @@ typedef struct KeyframeEditData {
 	/* current iteration data */
 	struct FCurve *fcu;         /* F-Curve that is being iterated over */
 	int curIndex;               /* index of current keyframe being iterated over */
-
+	float channel_y;            /* y-position of midpoint of the channel (for the dopesheet) */
+	
 	/* flags */
 	eKeyframeVertOk curflags;        /* current flags for the keyframe we're reached in the iteration process */
 	eKeyframeIterFlags iterflags;    /* settings for iteration process */
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index 50e10e7..408eb38 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -59,6 +59,8 @@ void draw_channel_strips(struct bAnimContext *ac, struct SpaceAction *saction, s
 
 void ACTION_OT_select_all_toggle(struct wmOperatorType *ot);
 void ACTION_OT_select_border(struct wmOperatorType *ot);
+void ACTION_OT_select_lasso(struct wmOperatorType *ot);
+void ACTION_OT_select_circle(struct wmOperatorType *ot);
 void ACTION_OT_select_column(struct wmOperatorType *ot);
 void ACTION_OT_select_linked(struct wmOperatorType *ot);
 void ACTION_OT_select_more(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index f69f994..a261202 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -59,6 +59,8 @@ void action_operatortypes(void)
 	WM_operatortype_append(ACTION_OT_clickselect);
 	WM_operatortype_append(ACTION_OT_select_all_toggle);
 	WM_operatortype_append(ACTION_OT_select_border);
+	WM_operatortype_append(ACTION_OT_select_lasso);
+	WM_operatortype_append(ACTION_OT_select_circle);
 	WM_operatortype_append(ACTION_OT_select_column);
 	WM_operatortype_append(ACTION_OT_select_linked);
 	WM_operatortype_append(ACTION_OT_select_more);
@@ -178,6 +180,14 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
 	kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0);
 	RNA_boolean_set(kmi->ptr, "axis_range", true);
 	
+	/* region select */
+	kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
+	RNA_boolean_set(kmi->ptr, "deselect", false);
+	kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT, 0);
+	RNA_boolean_set(kmi->ptr, "deselect", true);
+	
+	WM_keymap_add_item(keymap, "ACTION_OT_select_circle", CKEY, KM_PRESS, 0, 0);
+	
 	/* column select */
 	RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_KEYS);
 	RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_CFRA);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index f2813b2..c9a4922 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -36,6 +36,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_dlrbTree.h"
+#include "BLI_lasso.h"
 #include "BLI_utildefines.h"
 
 #include "DNA_anim_types.h"
@@ -375,6 +376,264 @@ void ACTION_OT_select_border(wmOperatorType *ot)
 	ot->prop = RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
 }
 
+/* ******************** Region Select Operators ***************************** */
+/* "Region Select" operators include the Lasso and Circle Select operators.
+ * These two ended up being lumped together, as it was easier in the 
+ * original Graph Editor implmentation of these to do it this way.
+ */
+
+static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view, short mode, short selectmode, void *data)
+{
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	
+	KeyframeEditData ked;
+	KeyframeEditFunc ok_cb, select_cb;
+	View2D *v2d = &ac->ar->v2d;
+	rctf rectf, scaled_rectf;
+	float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF);
+	
+	/* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
+	UI_view2d_region_to_view_rctf(v2d, rectf_view, &rectf);
+	
+	/* filter data */
+	filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS);
+	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+	
+	/* get beztriple editing/validation funcs  */
+	select_cb = ANIM_editkeyframes_select(selectmode);
+	ok_cb = ANIM_editkeyframes_ok(mode);
+	
+	/* init edi

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list