[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21188] branches/soc-2009-aligorith/source /blender/editors: NLA SoC: Move Strips Up/Down Operators
Joshua Leung
aligorith at gmail.com
Sat Jun 27 15:00:22 CEST 2009
Revision: 21188
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21188
Author: aligorith
Date: 2009-06-27 15:00:22 +0200 (Sat, 27 Jun 2009)
Log Message:
-----------
NLA SoC: Move Strips Up/Down Operators
These operators may be temporary only, depending on if a workable solution via transform is found.
* PageUp moves strips into the track above if there's space
* PageDown moves strips into the track below if there's space
* Also fixed a button-alignment bug in the DopeSheet header
Modified Paths:
--------------
branches/soc-2009-aligorith/source/blender/editors/space_action/action_header.c
branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c
branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_header.c
branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c
Modified: branches/soc-2009-aligorith/source/blender/editors/space_action/action_header.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_action/action_header.c 2009-06-27 12:58:34 UTC (rev 21187)
+++ branches/soc-2009-aligorith/source/blender/editors/space_action/action_header.c 2009-06-27 13:00:22 UTC (rev 21188)
@@ -398,7 +398,8 @@
/* COPY PASTE */
uiBlockBeginAlign(block);
uiDefIconButO(block, BUT, "ACT_OT_copy", WM_OP_INVOKE_REGION_WIN, ICON_COPYDOWN, xco,yco,XIC,YIC, "Copies the selected keyframes to the buffer.");
- uiDefIconButO(block, BUT, "ACT_OT_paste", WM_OP_INVOKE_REGION_WIN, ICON_COPYDOWN, xco,yco,XIC,YIC, "Pastes the keyframes from the buffer into the selected channels.");
+ xco += XIC;
+ uiDefIconButO(block, BUT, "ACT_OT_paste", WM_OP_INVOKE_REGION_WIN, ICON_PASTEDOWN, xco,yco,XIC,YIC, "Pastes the keyframes from the buffer into the selected channels.");
uiBlockEndAlign(block);
xco += (XIC + 8);
Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c 2009-06-27 12:58:34 UTC (rev 21187)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c 2009-06-27 13:00:22 UTC (rev 21188)
@@ -706,6 +706,160 @@
/* *********************************************** */
/* NLA Editing Operations (Modifying) */
+/* ******************** Move Strips Up Operator ************************** */
+/* Tries to move the selected strips into the track above if possible. */
+
+static int nlaedit_move_up_exec (bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ BeztEditData bed;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* get a list of the editable tracks being shown in the NLA */
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT);
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ /* init the editing data */
+ memset(&bed, 0, sizeof(BeztEditData));
+
+ /* since we're potentially moving strips from lower tracks to higher tracks, we should
+ * loop over the tracks in reverse order to avoid moving earlier strips up multiple tracks
+ */
+ for (ale= anim_data.last; ale; ale= ale->prev) {
+ NlaTrack *nlt= (NlaTrack *)ale->data;
+ NlaTrack *nltn= nlt->next;
+ NlaStrip *strip, *stripn;
+
+ /* if this track has no tracks after it, skip for now... */
+ if (nltn == NULL)
+ continue;
+
+ /* for every selected strip, try to move */
+ for (strip= nlt->strips.first; strip; strip= stripn) {
+ stripn= strip->next;
+
+ if (strip->flag & NLASTRIP_FLAG_SELECT) {
+ /* check if the track above has room for this strip */
+ if (BKE_nlatrack_has_space(nltn, strip->start, strip->end)) {
+ /* remove from its current track, and add to the one above (it 'should' work, so no need to worry) */
+ BLI_remlink(&nlt->strips, strip);
+ BKE_nlatrack_add_strip(nltn, strip);
+ }
+ }
+ }
+ }
+
+ /* free temp data */
+ BLI_freelistN(&anim_data);
+
+ /* set notifier that things have changed */
+ ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
+ WM_event_add_notifier(C, NC_SCENE, NULL);
+
+ /* done */
+ return OPERATOR_FINISHED;
+}
+
+void NLAEDIT_OT_move_up (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Move Strips Up";
+ ot->idname= "NLAEDIT_OT_move_up";
+ ot->description= "Move selected strips up a track if there's room.";
+
+ /* api callbacks */
+ ot->exec= nlaedit_move_up_exec;
+ ot->poll= nlaop_poll_tweakmode_off;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/* ******************** Move Strips Down Operator ************************** */
+/* Tries to move the selected strips into the track above if possible. */
+
+static int nlaedit_move_down_exec (bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ BeztEditData bed;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* get a list of the editable tracks being shown in the NLA */
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT);
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ /* init the editing data */
+ memset(&bed, 0, sizeof(BeztEditData));
+
+ /* loop through the tracks in normal order, since we're pushing strips down,
+ * strips won't get operated on twice
+ */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ NlaTrack *nlt= (NlaTrack *)ale->data;
+ NlaTrack *nltp= nlt->prev;
+ NlaStrip *strip, *stripn;
+
+ /* if this track has no tracks before it, skip for now... */
+ if (nltp == NULL)
+ continue;
+
+ /* for every selected strip, try to move */
+ for (strip= nlt->strips.first; strip; strip= stripn) {
+ stripn= strip->next;
+
+ if (strip->flag & NLASTRIP_FLAG_SELECT) {
+ /* check if the track below has room for this strip */
+ if (BKE_nlatrack_has_space(nltp, strip->start, strip->end)) {
+ /* remove from its current track, and add to the one above (it 'should' work, so no need to worry) */
+ BLI_remlink(&nlt->strips, strip);
+ BKE_nlatrack_add_strip(nltp, strip);
+ }
+ }
+ }
+ }
+
+ /* free temp data */
+ BLI_freelistN(&anim_data);
+
+ /* set notifier that things have changed */
+ ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
+ WM_event_add_notifier(C, NC_SCENE, NULL);
+
+ /* done */
+ return OPERATOR_FINISHED;
+}
+
+void NLAEDIT_OT_move_down (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Move Strips Down";
+ ot->idname= "NLAEDIT_OT_move_down";
+ ot->description= "Move selected strips down a track if there's room.";
+
+ /* api callbacks */
+ ot->exec= nlaedit_move_down_exec;
+ ot->poll= nlaop_poll_tweakmode_off;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/* ******************** Apply Scale Operator ***************************** */
/* Reset the scaling of the selected strips to 1.0f */
Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_header.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_header.c 2009-06-27 12:58:34 UTC (rev 21187)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_header.c 2009-06-27 13:00:22 UTC (rev 21188)
@@ -159,6 +159,11 @@
uiItemO(layout, NULL, 0, "NLAEDIT_OT_apply_scale");
uiItemO(layout, NULL, 0, "NLAEDIT_OT_clear_scale");
+
+ uiItemS(layout);
+
+ uiItemO(layout, NULL, 0, "NLAEDIT_OT_move_up");
+ uiItemO(layout, NULL, 0, "NLAEDIT_OT_move_down");
}
static void nla_addmenu(bContext *C, uiLayout *layout, void *arg_unused)
Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h 2009-06-27 12:58:34 UTC (rev 21187)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h 2009-06-27 13:00:22 UTC (rev 21188)
@@ -99,6 +99,9 @@
void NLAEDIT_OT_delete(wmOperatorType *ot);
void NLAEDIT_OT_split(wmOperatorType *ot);
+void NLAEDIT_OT_move_up(wmOperatorType *ot);
+void NLAEDIT_OT_move_down(wmOperatorType *ot);
+
void NLAEDIT_OT_apply_scale(wmOperatorType *ot);
void NLAEDIT_OT_clear_scale(wmOperatorType *ot);
Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c 2009-06-27 12:58:34 UTC (rev 21187)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c 2009-06-27 13:00:22 UTC (rev 21188)
@@ -150,6 +150,9 @@
WM_operatortype_append(NLAEDIT_OT_delete);
WM_operatortype_append(NLAEDIT_OT_split);
+ WM_operatortype_append(NLAEDIT_OT_move_up);
+ WM_operatortype_append(NLAEDIT_OT_move_down);
+
WM_operatortype_append(NLAEDIT_OT_apply_scale);
WM_operatortype_append(NLAEDIT_OT_clear_scale);
}
@@ -242,8 +245,14 @@
/* split */
WM_keymap_add_item(keymap, "NLAEDIT_OT_split", YKEY, KM_PRESS, 0, 0);
+ /* move up */
+ WM_keymap_add_item(keymap, "NLAEDIT_OT_move_up", PAGEUPKEY, KM_PRESS, 0, 0);
+ /* move down */
+ WM_keymap_add_item(keymap, "NLAEDIT_OT_move_down", PAGEDOWNKEY, KM_PRESS, 0, 0);
+
/* apply scale */
WM_keymap_add_item(keymap, "NLAEDIT_OT_apply_scale", AKEY, KM_PRESS, KM_CTRL, 0);
+ /* clear scale */
WM_keymap_add_item(keymap, "NLAEDIT_OT_clear_scale", SKEY, KM_PRESS, KM_ALT, 0);
/* transform system */
More information about the Bf-blender-cvs
mailing list