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-01-02 04:28:05 +0300
committerJoshua Leung <aligorith@gmail.com>2009-01-02 04:28:05 +0300
commit96d80b28b20fb2148dfb7f4e03a12cbecb6db8c0 (patch)
treec2de23f63e3d410c172edc772c02830c1539acc9 /source/blender/editors
parentf4a4279611938c8e4003a8a112584ece0fd25665 (diff)
2.5 Animation Channels - Borderselect Tool
Added BorderSelect operator for animation channels.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/anim_channels.c164
-rw-r--r--source/blender/editors/space_action/action_select.c4
2 files changed, 162 insertions, 6 deletions
diff --git a/source/blender/editors/animation/anim_channels.c b/source/blender/editors/animation/anim_channels.c
index d0403d023d8..b7f1b51605d 100644
--- a/source/blender/editors/animation/anim_channels.c
+++ b/source/blender/editors/animation/anim_channels.c
@@ -104,8 +104,6 @@
/* -------------------------- Exposed API ----------------------------------- */
-
-
/* Deselect all animation channels
* - data: pointer to datatype, as contained in bAnimContext
* - datatype: the type of data that 'data' represents (eAnim_ChannelType)
@@ -258,6 +256,159 @@ void ANIM_OT_channels_deselectall (wmOperatorType *ot)
RNA_def_property(ot->srna, "invert", PROP_BOOLEAN, PROP_NONE);
}
+/* ******************** Borderselect Operator *********************** */
+
+// XXX do we need to set some extra thingsfor each channel selected?
+static void borderselect_anim_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=0, ymax=(float)(-ACHANNEL_HEIGHT);
+
+ /* 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(&anim_data, filter, ac->data, ac->datatype);
+
+ /* loop over data, doing border select */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ ymin= ymax - ACHANNEL_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_GROUP: /* action group */
+ {
+ bActionGroup *agrp= (bActionGroup *)ale->data;
+
+ ACHANNEL_SET_FLAG(agrp, selectmode, AGRP_SELECTED);
+ }
+ break;
+ case ANIMTYPE_ACHAN: /* action channel */
+ case ANIMTYPE_FILLIPO: /* expand ipo curves = action channel */
+ case ANIMTYPE_FILLCON: /* expand constraint channels = action channel */
+ {
+ bActionChannel *achan= (bActionChannel *)ale->data;
+
+ ACHANNEL_SET_FLAG(achan, selectmode, ACHAN_SELECTED);
+
+ /* messy... set active bone */
+ //select_poseelement_by_name(achan->name, selectmode);
+ }
+ break;
+ case ANIMTYPE_CONCHAN: /* constraint channel */
+ {
+ bConstraintChannel *conchan = (bConstraintChannel *)ale->data;
+
+ ACHANNEL_SET_FLAG(conchan, selectmode, CONSTRAINT_CHANNEL_SELECT);
+ }
+ break;
+ case ANIMTYPE_ICU: /* ipo-curve channel */
+ {
+ IpoCurve *icu = (IpoCurve *)ale->data;
+
+ ACHANNEL_SET_FLAG(icu, selectmode, IPO_SELECT);
+ }
+ break;
+ case ANIMTYPE_GPLAYER: /* grease-pencil layer */
+ {
+ bGPDlayer *gpl = (bGPDlayer *)ale->data;
+
+ ACHANNEL_SET_FLAG(gpl, selectmode, GP_LAYER_SELECT);
+ }
+ break;
+ }
+
+ /* select action-channel 'owner' */
+ if ((ale->owner) && (ale->ownertype == ANIMTYPE_ACHAN)) {
+ //bActionChannel *achano= (bActionChannel *)ale->owner;
+
+ /* messy... set active bone */
+ //select_poseelement_by_name(achano->name, selectmode);
+ }
+ }
+
+ /* set minimum extent to be the maximum of the next channel */
+ ymax= ymin;
+ }
+
+ /* cleanup */
+ BLI_freelistN(&anim_data);
+}
+
+/* ------------------- */
+
+static int animchannels_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_anim_channels(&ac, &rect, selectmode);
+
+ return OPERATOR_FINISHED;
+}
+
+void ANIM_OT_channels_borderselect(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Border Select";
+ ot->idname= "ANIM_OT_channels_borderselect";
+
+ /* api callbacks */
+ ot->invoke= WM_border_select_invoke;
+ ot->exec= animchannels_borderselect_exec;
+ ot->modal= WM_border_select_modal;
+
+ ot->poll= ED_operator_areaactive;
+
+ /* flags */
+ // XXX er...
+ ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+
+ /* rna */
+ RNA_def_property(ot->srna, "event_type", PROP_INT, PROP_NONE);
+ RNA_def_property(ot->srna, "xmin", PROP_INT, PROP_NONE);
+ RNA_def_property(ot->srna, "xmax", PROP_INT, PROP_NONE);
+ RNA_def_property(ot->srna, "ymin", PROP_INT, PROP_NONE);
+ RNA_def_property(ot->srna, "ymax", PROP_INT, PROP_NONE);
+}
+
/* ******************** Mouse-Click Operator *********************** */
/* Depending on the channel that was clicked on, the mouse click will activate whichever
* part of the channel is relevant.
@@ -650,6 +801,7 @@ void ANIM_OT_channels_mouseclick (wmOperatorType *ot)
void ED_operatortypes_animchannels(void)
{
WM_operatortype_append(ANIM_OT_channels_deselectall);
+ WM_operatortype_append(ANIM_OT_channels_borderselect);
WM_operatortype_append(ANIM_OT_channels_mouseclick);
}
@@ -657,14 +809,18 @@ void ED_keymap_animchannels(wmWindowManager *wm)
{
ListBase *keymap = WM_keymap_listbase(wm, "Animation_Channels", 0, 0);
- /* click-select */
+ /* selection */
+ /* click-select */
// XXX for now, only leftmouse....
WM_keymap_add_item(keymap, "ANIM_OT_channels_mouseclick", LEFTMOUSE, KM_PRESS, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_mouseclick", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend_select", 1);
- /* deselect all */
+ /* deselect all */
WM_keymap_add_item(keymap, "ANIM_OT_channels_deselectall", AKEY, KM_PRESS, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_deselectall", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
+
+ /* borderselect */
+ WM_keymap_add_item(keymap, "ANIM_OT_channels_borderselect", BKEY, KM_PRESS, 0, 0);
}
/* ************************************************************************** */
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 144f9b4bcdd..7cb1912f321 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -852,7 +852,7 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short selectmode)
deselect_action_keys(ac, 0, 0);
if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET)) {
- //deselect_action_channels(0);
+ ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
/* Highlight either an Action-Channel or Action-Group */
if (achan) {
@@ -866,7 +866,7 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short selectmode)
}
}
else if (ac->datatype == ANIMCONT_GPENCIL) {
- //deselect_action_channels(0);
+ ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
/* Highlight gpencil layer */
gpl->flag |= GP_LAYER_SELECT;