[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34833] trunk/blender: Forgot NLA Editor support for this...
Joshua Leung
aligorith at gmail.com
Mon Feb 14 04:05:04 CET 2011
Revision: 34833
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34833
Author: aligorith
Date: 2011-02-14 03:04:59 +0000 (Mon, 14 Feb 2011)
Log Message:
-----------
Forgot NLA Editor support for this...
Modified Paths:
--------------
trunk/blender/release/scripts/ui/space_nla.py
trunk/blender/source/blender/editors/space_action/action_select.c
trunk/blender/source/blender/editors/space_graph/graph_select.c
trunk/blender/source/blender/editors/space_nla/nla_intern.h
trunk/blender/source/blender/editors/space_nla/nla_ops.c
trunk/blender/source/blender/editors/space_nla/nla_select.c
Modified: trunk/blender/release/scripts/ui/space_nla.py
===================================================================
--- trunk/blender/release/scripts/ui/space_nla.py 2011-02-14 02:50:52 UTC (rev 34832)
+++ trunk/blender/release/scripts/ui/space_nla.py 2011-02-14 03:04:59 UTC (rev 34833)
@@ -93,7 +93,12 @@
layout.operator("nla.select_border")
layout.operator("nla.select_border", text="Border Axis Range").axis_range = True
+ layout.separator()
+ layout.operator("nla.select_leftright", text="Before Current Frame").mode = 'LEFT'
+ layout.operator("nla.select_leftright", text="After Current Frame").mode = 'RIGHT'
+
+
class NLA_MT_marker(bpy.types.Menu):
bl_label = "Marker"
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:50:52 UTC (rev 34832)
+++ trunk/blender/source/blender/editors/space_action/action_select.c 2011-02-14 03:04:59 UTC (rev 34833)
@@ -843,7 +843,7 @@
ARegion *ar= ac.ar;
View2D *v2d= &ar->v2d;
- short mval[2];
+ int mval[2];
float x;
/* get mouse coordinates (in region coordinates) */
@@ -867,7 +867,7 @@
/* identifiers */
ot->name= "Select Left/Right";
ot->idname= "ACTION_OT_select_leftright";
- ot->description= "Select keyframes to the left or the right of the current keyframe ";
+ ot->description= "Select keyframes to the left or the right of the current frame";
/* api callbacks */
ot->invoke= actkeys_select_leftright_invoke;
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:50:52 UTC (rev 34832)
+++ trunk/blender/source/blender/editors/space_graph/graph_select.c 2011-02-14 03:04:59 UTC (rev 34833)
@@ -840,7 +840,7 @@
/* 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 ";
+ ot->description= "Select keyframes to the left or the right of the current frame";
/* api callbacks */
ot->invoke= graphkeys_select_leftright_invoke;
Modified: trunk/blender/source/blender/editors/space_nla/nla_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_nla/nla_intern.h 2011-02-14 02:50:52 UTC (rev 34832)
+++ trunk/blender/source/blender/editors/space_nla/nla_intern.h 2011-02-14 03:04:59 UTC (rev 34833)
@@ -67,6 +67,7 @@
void NLA_OT_select_all_toggle(wmOperatorType *ot);
void NLA_OT_select_border(wmOperatorType *ot);
+void NLA_OT_select_leftright(wmOperatorType *ot);
void NLA_OT_click_select(wmOperatorType *ot);
/* **************************************** */
Modified: trunk/blender/source/blender/editors/space_nla/nla_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_nla/nla_ops.c 2011-02-14 02:50:52 UTC (rev 34832)
+++ trunk/blender/source/blender/editors/space_nla/nla_ops.c 2011-02-14 03:04:59 UTC (rev 34833)
@@ -122,6 +122,7 @@
WM_operatortype_append(NLA_OT_click_select);
WM_operatortype_append(NLA_OT_select_border);
WM_operatortype_append(NLA_OT_select_all_toggle);
+ WM_operatortype_append(NLA_OT_select_leftright);
/* edit */
WM_operatortype_append(NLA_OT_tweakmode_enter);
@@ -185,9 +186,18 @@
WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, 0, 0);
kmi= WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", 1);
- kmi= WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
- RNA_enum_set(kmi->ptr, "left_right", NLAEDIT_LRSEL_TEST);
+
+ /* select left/right */
+ WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
+ kmi= WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "extend", 1);
+ kmi= WM_keymap_add_item(keymap, "NLA_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_LEFT);
+ kmi= WM_keymap_add_item(keymap, "NLA_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_RIGHT);
+
+
/* deselect all */
WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
Modified: trunk/blender/source/blender/editors/space_nla/nla_select.c
===================================================================
--- trunk/blender/source/blender/editors/space_nla/nla_select.c 2011-02-14 02:50:52 UTC (rev 34832)
+++ trunk/blender/source/blender/editors/space_nla/nla_select.c 2011-02-14 03:04:59 UTC (rev 34833)
@@ -199,10 +199,10 @@
/* ******************** Border Select Operator **************************** */
/* This operator currently works in one of three ways:
- * -> BKEY - 1) all strips within region are selected (ACTKEYS_BORDERSEL_ALLSTRIPS)
+ * -> BKEY - 1) all strips within region are selected (NLAEDIT_BORDERSEL_ALLSTRIPS)
* -> ALT-BKEY - depending on which axis of the region was larger...
- * -> 2) x-axis, so select all frames within frame range (ACTKEYS_BORDERSEL_FRAMERANGE)
- * -> 3) y-axis, so select all frames within channels that region included (ACTKEYS_BORDERSEL_CHANNELS)
+ * -> 2) x-axis, so select all frames within frame range (NLAEDIT_BORDERSEL_FRAMERANGE)
+ * -> 3) y-axis, so select all frames within channels that region included (NLAEDIT_BORDERSEL_CHANNELS)
*/
/* defines for borderselect mode */
@@ -210,7 +210,7 @@
NLA_BORDERSEL_ALLSTRIPS = 0,
NLA_BORDERSEL_FRAMERANGE,
NLA_BORDERSEL_CHANNELS,
-} eActKeys_BorderSelect_Mode;
+} eNLAEDIT_BorderSelect_Mode;
static void borderselect_nla_strips (bAnimContext *ac, rcti rect, short mode, short selectmode)
@@ -340,28 +340,164 @@
RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
}
-/* ******************** Mouse-Click Select Operator *********************** */
-/* This operator works in one of 2 ways:
- * 1) Select the strip directly under the mouse
- * 2) Select all the strips to one side of the mouse
- */
+/* ******************** Select Left/Right Operator ************************* */
+/* Select keyframes left/right of the current frame indicator */
/* defines for left-right select tool */
static EnumPropertyItem prop_nlaedit_leftright_select_types[] = {
{NLAEDIT_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""},
- {NLAEDIT_LRSEL_NONE, "OFF", 0, "Don't select", ""},
{NLAEDIT_LRSEL_LEFT, "LEFT", 0, "Before current frame", ""},
{NLAEDIT_LRSEL_RIGHT, "RIGHT", 0, "After current frame", ""},
{0, NULL, 0, NULL, NULL}
};
-/* sensitivity factor for frame-selections */
-#define FRAME_CLICK_THRESH 0.1f
+/* ------------------- */
+static void nlaedit_select_leftright (bContext *C, bAnimContext *ac, short leftright, short select_mode)
+{
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ Scene *scene= ac->scene;
+ float xmin, xmax;
+
+ /* if currently in tweakmode, exit tweakmode first */
+ if (scene->flag & SCE_NLA_EDIT_ON)
+ WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL);
+
+ /* 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_nla_strips(ac, 0, SELECT_SUBTRACT);
+ }
+
+ /* get range, and get the right flag-setting mode */
+ if (leftright == NLAEDIT_LRSEL_LEFT) {
+ xmin = MINAFRAMEF;
+ xmax = (float)(CFRA + 0.1f);
+ }
+ else {
+ xmin = (float)(CFRA - 0.1f);
+ xmax = MAXFRAMEF;
+ }
+
+ select_mode= selmodes_to_flagmodes(select_mode);
+
+
+ /* filter data */
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS);
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
+ /* select strips on the side where most data occurs */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ NlaTrack *nlt= (NlaTrack *)ale->data;
+ NlaStrip *strip;
+
+ /* check each strip to see if it is appropriate */
+ for (strip= nlt->strips.first; strip; strip= strip->next) {
+ if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) {
+ ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT);
+ }
+ }
+ }
+
+ /* Cleanup */
+ BLI_freelistN(&anim_data);
+}
/* ------------------- */
-/* option 1) select strip directly under mouse */
+static int nlaedit_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 == NLAEDIT_LRSEL_TEST)
+ return OPERATOR_CANCELLED;
+
+ /* do the selecting now */
+ nlaedit_select_leftright(C, &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 nlaedit_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 == NLAEDIT_LRSEL_TEST) {
+ Scene *scene= ac.scene;
+ ARegion *ar= ac.ar;
+ View2D *v2d= &ar->v2d;
+
+ int 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 */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list