[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34832] trunk/blender: Graph Editor part of the changes in the previous commit...
Joshua Leung
aligorith at gmail.com
Mon Feb 14 03:50:56 CET 2011
Revision: 34832
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34832
Author: aligorith
Date: 2011-02-14 02:50:52 +0000 (Mon, 14 Feb 2011)
Log Message:
-----------
Graph Editor part of the changes in the previous commit...
Modified Paths:
--------------
trunk/blender/release/scripts/ui/space_graph.py
trunk/blender/source/blender/editors/space_action/action_select.c
trunk/blender/source/blender/editors/space_graph/graph_intern.h
trunk/blender/source/blender/editors/space_graph/graph_ops.c
trunk/blender/source/blender/editors/space_graph/graph_select.c
Modified: trunk/blender/release/scripts/ui/space_graph.py
===================================================================
--- trunk/blender/release/scripts/ui/space_graph.py 2011-02-14 02:30:33 UTC (rev 34831)
+++ trunk/blender/release/scripts/ui/space_graph.py 2011-02-14 02:50:52 UTC (rev 34832)
@@ -130,6 +130,10 @@
layout.operator("graph.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
layout.separator()
+ layout.operator("graph.select_leftright", text="Before Current Frame").mode = 'LEFT'
+ layout.operator("graph.select_leftright", text="After Current Frame").mode = 'RIGHT'
+
+ layout.separator()
layout.operator("graph.select_more")
layout.operator("graph.select_less")
Modified: trunk/blender/source/blender/editors/space_action/action_select.c
===================================================================
--- trunk/blender/source/blender/editors/space_action/action_select.c 2011-02-14 02:30:33 UTC (rev 34831)
+++ trunk/blender/source/blender/editors/space_action/action_select.c 2011-02-14 02:50:52 UTC (rev 34832)
@@ -741,15 +741,12 @@
ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
select_cb= ANIM_editkeyframes_select(select_mode);
- /* NOTE: we used to include FRAME_CLICK_THRESH in the tolerance for the current frame,
- * but this has now been remove, since it is not so relevant anymore
- */
if (leftright == ACTKEYS_LRSEL_LEFT) {
ked.f1 = MINAFRAMEF;
- ked.f2 = (float)(CFRA);
+ ked.f2 = (float)(CFRA + 0.1f);
}
else {
- ked.f1 = (float)(CFRA);
+ ked.f1 = (float)(CFRA - 0.1f);
ked.f2 = MAXFRAMEF;
}
Modified: trunk/blender/source/blender/editors/space_graph/graph_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_intern.h 2011-02-14 02:30:33 UTC (rev 34831)
+++ trunk/blender/source/blender/editors/space_graph/graph_intern.h 2011-02-14 02:50:52 UTC (rev 34832)
@@ -66,14 +66,14 @@
void GRAPH_OT_select_linked(struct wmOperatorType *ot);
void GRAPH_OT_select_more(struct wmOperatorType *ot);
void GRAPH_OT_select_less(struct wmOperatorType *ot);
+void GRAPH_OT_select_leftright(struct wmOperatorType *ot);
void GRAPH_OT_clickselect(struct wmOperatorType *ot);
/* defines for left-right select tool */
enum {
- GRAPHKEYS_LRSEL_TEST = -1,
- GRAPHKEYS_LRSEL_NONE,
+ GRAPHKEYS_LRSEL_TEST = 0,
GRAPHKEYS_LRSEL_LEFT,
- GRAPHKEYS_LRSEL_RIGHT,
+ GRAPHKEYS_LRSEL_RIGHT
} eGraphKeys_LeftRightSelect_Mode;
/* defines for column-select mode */
Modified: trunk/blender/source/blender/editors/space_graph/graph_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_ops.c 2011-02-14 02:30:33 UTC (rev 34831)
+++ trunk/blender/source/blender/editors/space_graph/graph_ops.c 2011-02-14 02:50:52 UTC (rev 34832)
@@ -235,6 +235,7 @@
WM_operatortype_append(GRAPH_OT_select_linked);
WM_operatortype_append(GRAPH_OT_select_more);
WM_operatortype_append(GRAPH_OT_select_less);
+ WM_operatortype_append(GRAPH_OT_select_leftright);
/* editing */
WM_operatortype_append(GRAPH_OT_snap);
@@ -287,14 +288,22 @@
kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT|KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", 1);
RNA_boolean_set(kmi->ptr, "column", 1);
- kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
- RNA_enum_set(kmi->ptr, "left_right", GRAPHKEYS_LRSEL_TEST);
kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "curves", 1);
kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT|KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "curves", 1);
RNA_boolean_set(kmi->ptr, "extend", 1);
+ /* select left/right */
+ WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
+ kmi= WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "extend", 1);
+
+ kmi= WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_LEFT);
+ kmi= WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT);
+
/* deselect all */
WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
Modified: trunk/blender/source/blender/editors/space_graph/graph_select.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_select.c 2011-02-14 02:30:33 UTC (rev 34831)
+++ trunk/blender/source/blender/editors/space_graph/graph_select.c 2011-02-14 02:50:52 UTC (rev 34832)
@@ -704,6 +704,157 @@
ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
}
+/* ******************** Select Left/Right Operator ************************* */
+/* Select keyframes left/right of the current frame indicator */
+
+/* defines for left-right select tool */
+static EnumPropertyItem prop_graphkeys_leftright_select_types[] = {
+ {GRAPHKEYS_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""},
+ {GRAPHKEYS_LRSEL_LEFT, "LEFT", 0, "Before current frame", ""},
+ {GRAPHKEYS_LRSEL_RIGHT, "RIGHT", 0, "After current frame", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+/* --------------------------------- */
+
+static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short select_mode)
+{
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ KeyframeEditFunc ok_cb, select_cb;
+ KeyframeEditData ked= {{0}};
+ Scene *scene= ac->scene;
+
+ /* if select mode is replace, deselect all keyframes (and channels) first */
+ if (select_mode==SELECT_REPLACE) {
+ select_mode= SELECT_ADD;
+
+ /* deselect all other channels and keyframes */
+ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ deselect_graph_keys(ac, 0, SELECT_SUBTRACT);
+ }
+
+ /* set callbacks and editing data */
+ ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
+ select_cb= ANIM_editkeyframes_select(select_mode);
+
+ if (leftright == GRAPHKEYS_LRSEL_LEFT) {
+ ked.f1 = MINAFRAMEF;
+ ked.f2 = (float)(CFRA + 0.1f);
+ }
+ else {
+ ked.f1 = (float)(CFRA - 0.1f);
+ ked.f2 = MAXFRAMEF;
+ }
+
+ /* filter data */
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
+ /* select keys */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
+
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
+ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
+ }
+ else
+ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
+ }
+
+ /* Cleanup */
+ BLI_freelistN(&anim_data);
+}
+
+/* ----------------- */
+
+static int graphkeys_select_leftright_exec (bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+ short leftright = RNA_enum_get(op->ptr, "mode");
+ short selectmode;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* select mode is either replace (deselect all, then add) or add/extend */
+ if (RNA_boolean_get(op->ptr, "extend"))
+ selectmode= SELECT_INVERT;
+ else
+ selectmode= SELECT_REPLACE;
+
+ /* if "test" mode is set, we don't have any info to set this with */
+ if (leftright == GRAPHKEYS_LRSEL_TEST)
+ return OPERATOR_CANCELLED;
+
+ /* do the selecting now */
+ graphkeys_select_leftright(&ac, leftright, selectmode);
+
+ /* set notifier that keyframe selection (and channels too) have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+static int graphkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent *event)
+{
+ bAnimContext ac;
+ short leftright = RNA_enum_get(op->ptr, "mode");
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* handle mode-based testing */
+ if (leftright == GRAPHKEYS_LRSEL_TEST) {
+ Scene *scene= ac.scene;
+ ARegion *ar= ac.ar;
+ View2D *v2d= &ar->v2d;
+
+ short mval[2];
+ float x;
+
+ /* get mouse coordinates (in region coordinates) */
+ mval[0]= (event->x - ar->winrct.xmin);
+ mval[1]= (event->y - ar->winrct.ymin);
+
+ /* determine which side of the current frame mouse is on */
+ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, NULL);
+ if (x < CFRA)
+ RNA_int_set(op->ptr, "mode", GRAPHKEYS_LRSEL_LEFT);
+ else
+ RNA_int_set(op->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT);
+ }
+
+ /* perform selection */
+ return graphkeys_select_leftright_exec(C, op);
+}
+
+void GRAPH_OT_select_leftright (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Select Left/Right";
+ ot->idname= "GRAPH_OT_select_leftright";
+ ot->description= "Select keyframes to the left or the right of the current keyframe ";
+
+ /* api callbacks */
+ ot->invoke= graphkeys_select_leftright_invoke;
+ ot->exec= graphkeys_select_leftright_exec;
+ ot->poll= graphop_visible_keyframes_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* id-props */
+ ot->prop= RNA_def_enum(ot->srna, "mode", prop_graphkeys_leftright_select_types, GRAPHKEYS_LRSEL_TEST, "Mode", "");
+ RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "");
+}
+
/* ******************** Mouse-Click Select Operator *********************** */
/* This operator works in one of three ways:
* - 1) keyframe under mouse - no special modifiers
@@ -714,17 +865,6 @@
* selection mode between replacing the selection (without) and inverting the selection (with).
*/
-/* defines for left-right select tool */
-static EnumPropertyItem prop_graphkeys_leftright_select_types[] = {
- {GRAPHKEYS_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""},
- {GRAPHKEYS_LRSEL_NONE, "OFF", 0, "Don't select", ""},
- {GRAPHKEYS_LRSEL_LEFT, "LEFT", 0, "Before current frame", ""},
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list