Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2010-02-07 14:50:03 +0300
committerJoshua Leung <aligorith@gmail.com>2010-02-07 14:50:03 +0300
commit20fb4e3367a4a544e15fa7c556868a37966356de (patch)
tree210d314df871e2122592e8a0eeeb4416cfcf1d3f /source/blender/editors/space_graph
parent7d2c4384e275a1ff5ab289b859d6e75a29645115 (diff)
DopeSheet and Graph Editors: Select More/Less Operators
This commit introduces the Select More/Less Operators (Ctrl +/-) for keyframes. This works like the ones for curves, by only selecting/deselecting keyframes lying in the same F-Curve. Inter F-Curve selection is not done by this operator. That is the job for another one. This is especially useful for F-Curves set in the 0-1-0 pattern (i.e. 3 keyframes forming localised peaks), where the peaks can be selected by clicking on them individually, and immediately surrounding '0' values are selected too using "Select More".
Diffstat (limited to 'source/blender/editors/space_graph')
-rw-r--r--source/blender/editors/space_graph/graph_intern.h2
-rw-r--r--source/blender/editors/space_graph/graph_ops.c6
-rw-r--r--source/blender/editors/space_graph/graph_select.c112
3 files changed, 120 insertions, 0 deletions
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index ec6f38c93b7..a42944f0b35 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -63,6 +63,8 @@ void graph_header_buttons(const bContext *C, struct ARegion *ar);
void GRAPH_OT_select_all_toggle(struct wmOperatorType *ot);
void GRAPH_OT_select_border(struct wmOperatorType *ot);
void GRAPH_OT_select_column(struct wmOperatorType *ot);
+void GRAPH_OT_select_more(struct wmOperatorType *ot);
+void GRAPH_OT_select_less(struct wmOperatorType *ot);
void GRAPH_OT_clickselect(struct wmOperatorType *ot);
/* defines for left-right select tool */
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 7be2d7b3e4b..648a162890d 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -237,6 +237,8 @@ void graphedit_operatortypes(void)
WM_operatortype_append(GRAPH_OT_select_all_toggle);
WM_operatortype_append(GRAPH_OT_select_border);
WM_operatortype_append(GRAPH_OT_select_column);
+ WM_operatortype_append(GRAPH_OT_select_more);
+ WM_operatortype_append(GRAPH_OT_select_less);
/* editing */
WM_operatortype_append(GRAPH_OT_snap);
@@ -310,6 +312,10 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap)
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN);
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN);
+ /* select more/less */
+ WM_keymap_add_item(keymap, "GRAPH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "GRAPH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
+
/* graph_edit.c */
/* snap - current frame to selected keys */
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index b90d5a48d9a..872b688bea1 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -549,6 +549,118 @@ void GRAPH_OT_select_column (wmOperatorType *ot)
RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
}
+/* ******************** Select More/Less Operators *********************** */
+
+/* Common code to perform selection */
+static void select_moreless_graph_keys (bAnimContext *ac, short mode)
+{
+ ListBase anim_data= {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ BeztEditData bed;
+ BeztEditFunc build_cb;
+
+
+ /* init selmap building data */
+ build_cb= ANIM_editkeyframes_buildselmap(mode);
+ memset(&bed, 0, sizeof(BeztEditData));
+
+ /* loop through all of the keys and select additional keyframes based on these */
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY);
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ FCurve *fcu= (FCurve *)ale->key_data;
+
+ /* only continue if F-Curve has keyframes */
+ if (fcu->bezt == NULL)
+ continue;
+
+ /* build up map of whether F-Curve's keyframes should be selected or not */
+ bed.data= MEM_callocN(fcu->totvert, "selmap graphEdit");
+ ANIM_fcurve_keys_bezier_loop(&bed, fcu, NULL, build_cb, NULL);
+
+ /* based on this map, adjust the selection status of the keyframes */
+ ANIM_fcurve_keys_bezier_loop(&bed, fcu, NULL, bezt_selmap_flush, NULL);
+
+ /* free the selmap used here */
+ MEM_freeN(bed.data);
+ bed.data= NULL;
+ }
+
+ /* Cleanup */
+ BLI_freelistN(&anim_data);
+}
+
+/* ----------------- */
+
+static int graphkeys_select_more_exec (bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* perform select changes */
+ select_moreless_graph_keys(&ac, SELMAP_MORE);
+
+ /* set notifier that keyframe selection has changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_SELECT, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void GRAPH_OT_select_more (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Select More";
+ ot->idname= "GRAPH_OT_select_more";
+ ot->description = "Select keyframes beside already selected ones.";
+
+ /* api callbacks */
+ ot->exec= graphkeys_select_more_exec;
+ ot->poll= graphop_visible_keyframes_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+}
+
+/* ----------------- */
+
+static int graphkeys_select_less_exec (bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* perform select changes */
+ select_moreless_graph_keys(&ac, SELMAP_LESS);
+
+ /* set notifier that keyframe selection has changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_SELECT, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void GRAPH_OT_select_less (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Select Less";
+ ot->idname= "GRAPH_OT_select_less";
+ ot->description = "Deselect keyframes on ends of selection islands.";
+
+ /* api callbacks */
+ ot->exec= graphkeys_select_less_exec;
+ ot->poll= graphop_visible_keyframes_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+}
+
/* ******************** Mouse-Click Select Operator *********************** */
/* This operator works in one of three ways:
* - 1) keyframe under mouse - no special modifiers