Revision: 20754
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20754
Author:   aligorith
Date:     2009-06-09 14:28:49 +0200 (Tue, 09 Jun 2009)

Log Message:
-----------
NLA SoC: Added simple delete-strips operator (XKEY/DELKEY)

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.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_nla/nla_edit.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c     
2009-06-09 12:28:10 UTC (rev 20753)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c     
2009-06-09 12:28:49 UTC (rev 20754)
@@ -68,7 +68,7 @@
 #include "nla_intern.h"        // own include
 
 /* *********************************************** */
-/* General Editing */
+/* 'Special' Editing */
 
 /* ******************** Tweak-Mode Operators ***************************** */
 /* 'Tweak mode' allows the action referenced by the active NLA-strip to be 
edited 
@@ -211,5 +211,66 @@
 }
 
 /* *********************************************** */
+/* NLA Editing Operations */
 
+/* ******************** Delete Operator ***************************** */
+/* Deletes the selected NLA-Strips */
+
+static int nlaedit_delete_exec (bContext *C, wmOperator *op)
+{
+       bAnimContext ac;
+       
+       ListBase anim_data = {NULL, NULL};
+       bAnimListElem *ale;
+       int filter;
+       
+       /* get editor data */
+       if (ANIM_animdata_get_context(C, &ac) == 0)
+               return OPERATOR_CANCELLED;
+               
+       /* get a list of the AnimData blocks being shown in the NLA */
+       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | 
ANIMFILTER_FOREDIT);
+       ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+       
+       /* for each NLA-Track, delete all selected strips */
+       // FIXME: need to double-check that we've got tracks
+       for (ale= anim_data.first; ale; ale= ale->next) {
+               NlaTrack *nlt= (NlaTrack *)ale->data;
+               NlaStrip *strip, *nstrip;
+               
+               for (strip= nlt->strips.first; strip; strip= nstrip) {
+                       nstrip= strip->next;
+                       
+                       /* if selected, delete */
+                       if (strip->flag & NLASTRIP_FLAG_SELECT)
+                               free_nlastrip(&nlt->strips, 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_delete (wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Delete Strips";
+       ot->idname= "NLAEDIT_OT_delete";
+       ot->description= "Delete selected strips.";
+       
+       /* api callbacks */
+       ot->exec= nlaedit_delete_exec;
+       ot->poll= nlaop_poll_tweakmode_off;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 /* *********************************************** */

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-09 12:28:10 UTC (rev 20753)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h   
2009-06-09 12:28:49 UTC (rev 20754)
@@ -89,6 +89,11 @@
 void NLAEDIT_OT_tweakmode_enter(wmOperatorType *ot);
 void NLAEDIT_OT_tweakmode_exit(wmOperatorType *ot);
 
+/* --- */
+
+void NLAEDIT_OT_delete(wmOperatorType *ot);
+
+
 /* **************************************** */
 /* nla_channels.c */
 

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-09 12:28:10 UTC (rev 20753)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c      
2009-06-09 12:28:49 UTC (rev 20754)
@@ -131,6 +131,8 @@
        /* edit */
        WM_operatortype_append(NLAEDIT_OT_tweakmode_enter);
        WM_operatortype_append(NLAEDIT_OT_tweakmode_exit);
+       
+       WM_operatortype_append(NLAEDIT_OT_delete);
 }
 
 /* ************************** registration - keymaps 
**********************************/
@@ -191,6 +193,10 @@
                 */
        WM_keymap_add_item(keymap, "NLAEDIT_OT_tweakmode_enter", TABKEY, 
KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "NLAEDIT_OT_tweakmode_exit", TABKEY, 
KM_PRESS, 0, 0);
+               
+               /* delete */
+       WM_keymap_add_item(keymap, "NLAEDIT_OT_delete", XKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "NLAEDIT_OT_delete", DELKEY, KM_PRESS, 0, 0);
        
        /* transform system */
        transform_keymap_for_space(wm, keymap, SPACE_NLA);


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to