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>2009-05-31 15:14:50 +0400
committerJoshua Leung <aligorith@gmail.com>2009-05-31 15:14:50 +0400
commit33267f58581ea8f9d89028958c6e64a8d048d4db (patch)
tree5bd7494f65b9a3914a945926df92d303b659d0d2 /source/blender/editors/space_nla/nla_channels.c
parentc42eeddea491d6a79dbcc0b8b28386237085643d (diff)
NLA SoC: Basic selection operators
* Added click-select/left-right select and deselect all/invert all selection operators. For now, these basic operators will suffice (more advanced selection operators will be coded at a later stage). * Fixed a few bugs in DopeSheet found while coding the relevant tools for NLA. * Added custom border-select operator for NLA channels (since the standard one assumes negative direction channel order) * Added new API-method for NLA strips to check if the strip occurs within a given range, since this test needed to be performed in a few places... * Tweaked the NLA Editor View2D ranges a bit to give saner default sizing. This still isn't right yet though.
Diffstat (limited to 'source/blender/editors/space_nla/nla_channels.c')
-rw-r--r--source/blender/editors/space_nla/nla_channels.c110
1 files changed, 109 insertions, 1 deletions
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index 658ce69cc10..a839ccbf3d6 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -82,7 +82,115 @@
/* *********************************************** */
/* Operators for NLA channels-list which need to be different from the standard Animation Editor ones */
-// TODO: implemented borderselect too, since that also relies on ranges of buttons
+/* ******************** Borderselect Operator *********************** */
+
+static void borderselect_nla_channels (bAnimContext *ac, rcti *rect, short selectmode)
+{
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ View2D *v2d= &ac->ar->v2d;
+ rctf rectf;
+ float ymin=(float)(-NLACHANNEL_HEIGHT), ymax=0;
+
+ /* convert border-region to view coordinates */
+ 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(ac, &anim_data, filter, ac->data, ac->datatype);
+
+ /* loop over data, doing border select */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ ymax= ymin + NLACHANNEL_STEP;
+
+ /* if channel is within border-select region, alter it */
+ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) {
+ /* only the following types can be selected */
+ switch (ale->type) {
+ case ANIMTYPE_OBJECT: /* object */
+ {
+ Base *base= (Base *)ale->data;
+ Object *ob= base->object;
+
+ ACHANNEL_SET_FLAG(base, selectmode, SELECT);
+ ACHANNEL_SET_FLAG(ob, selectmode, SELECT);
+ }
+ break;
+ case ANIMTYPE_NLATRACK: /* nla-track */
+ {
+ NlaTrack *nlt= (NlaTrack *)ale->data;
+
+ ACHANNEL_SET_FLAG(nlt, selectmode, NLATRACK_SELECTED);
+ }
+ break;
+ }
+ }
+
+ /* set maximum extent to be the minimum of the next channel */
+ ymin= ymax;
+ }
+
+ /* cleanup */
+ BLI_freelistN(&anim_data);
+}
+
+/* ------------------- */
+
+static int nlachannels_borderselect_exec(bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+ rcti rect;
+ short selectmode=0;
+ int event;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* get settings from operator */
+ rect.xmin= RNA_int_get(op->ptr, "xmin");
+ rect.ymin= RNA_int_get(op->ptr, "ymin");
+ rect.xmax= RNA_int_get(op->ptr, "xmax");
+ rect.ymax= RNA_int_get(op->ptr, "ymax");
+
+ event= RNA_int_get(op->ptr, "event_type");
+ if (event == LEFTMOUSE) // FIXME... hardcoded
+ selectmode = ACHANNEL_SETFLAG_ADD;
+ else
+ selectmode = ACHANNEL_SETFLAG_CLEAR;
+
+ /* apply borderselect animation channels */
+ borderselect_nla_channels(&ac, &rect, selectmode);
+
+ return OPERATOR_FINISHED;
+}
+
+void NLA_OT_channels_select_border(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Border Select";
+ ot->idname= "NLA_OT_channels_select_border";
+
+ /* api callbacks */
+ ot->invoke= WM_border_select_invoke;
+ ot->exec= nlachannels_borderselect_exec;
+ ot->modal= WM_border_select_modal;
+
+ ot->poll= ED_operator_areaactive;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* rna */
+ RNA_def_int(ot->srna, "event_type", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX);
+ RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
+ RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
+ RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX);
+ RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX);
+}
/* ******************** Mouse-Click Operator *********************** */
/* Depending on the channel that was clicked on, the mouse click will activate whichever