sequencer clipboard
authorCampbell Barton <ideasman42@gmail.com>
Thu, 17 Dec 2009 14:45:47 +0000 (14:45 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 17 Dec 2009 14:45:47 +0000 (14:45 +0000)
note: for inter-scene copying this uses a hack because Colin needs it because half his scene was scrambled by blender.

release/scripts/ui/space_sequencer.py
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/intern/sequencer.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_intern.h
source/blender/editors/space_sequencer/sequencer_ops.c
source/blender/makesdna/DNA_sequence_types.h

index 7a51f1aa6d7d051d434cdea3c4ce23b8e822c878..8edadb96de3b3b64296d7ea25cbc7cc5a6a496c7 100644 (file)
@@ -56,6 +56,10 @@ class SEQUENCER_HT_header(bpy.types.Header):
             layout.prop(st, "display_mode", text="")
 
         if (st.view_type == 'SEQUENCER'):
             layout.prop(st, "display_mode", text="")
 
         if (st.view_type == 'SEQUENCER'):
+            row = layout.row(align=True)
+            row.operator("sequencer.copy", text="", icon='COPYDOWN')
+            row.operator("sequencer.paste", text="", icon='PASTEDOWN')
+
             layout.separator()
             layout.operator("sequencer.refresh_all")
         elif (st.view_type == 'SEQUENCER_PREVIEW'):
             layout.separator()
             layout.operator("sequencer.refresh_all")
         elif (st.view_type == 'SEQUENCER_PREVIEW'):
index 34d4b15b4377e44a11b2ef7d8009dc756c4bc03d..a101a096fe8733d95902e228d79835770dbe97ee 100644 (file)
@@ -141,6 +141,7 @@ void printf_strip(struct Sequence *seq);
 void seq_free_sequence(struct Scene *scene, struct Sequence *seq);
 void seq_free_strip(struct Strip *strip);
 void seq_free_editing(struct Scene *scene);
 void seq_free_sequence(struct Scene *scene, struct Sequence *seq);
 void seq_free_strip(struct Strip *strip);
 void seq_free_editing(struct Scene *scene);
+void seq_free_clipboard(struct Scene *scene);
 struct Editing *seq_give_editing(struct Scene *scene, int alloc);
 char *give_seqname(struct Sequence *seq);
 struct ImBuf *give_ibuf_seq(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size);
 struct Editing *seq_give_editing(struct Scene *scene, int alloc);
 char *give_seqname(struct Sequence *seq);
 struct ImBuf *give_ibuf_seq(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size);
index 5165e570504fc57098b4123da8eb4af5c5ddf3c9..41e51885bfcf21fe1aeb06d8b664bad60237cc47 100644 (file)
@@ -232,11 +232,23 @@ Editing *seq_give_editing(Scene *scene, int alloc)
        return scene->ed;
 }
 
        return scene->ed;
 }
 
+void seq_free_clipboard(Scene *scene)
+{
+       Editing *ed = scene->ed;
+       Sequence *seq, *nseq;
+
+       for(seq= ed->seqbase_clipboard.first; seq; seq= nseq) {
+               nseq= seq->next;
+               seq_free_sequence(scene, seq);
+       }
+       ed->seqbase_clipboard.first= ed->seqbase_clipboard.last= NULL;
+}
+
 void seq_free_editing(Scene *scene)
 {
        Editing *ed = scene->ed;
        MetaStack *ms;
 void seq_free_editing(Scene *scene)
 {
        Editing *ed = scene->ed;
        MetaStack *ms;
-       Sequence *seq;
+       Sequence *seq, *nseq;
 
        if(ed==NULL)
                return;
 
        if(ed==NULL)
                return;
@@ -246,6 +258,8 @@ void seq_free_editing(Scene *scene)
        }
        SEQ_END
 
        }
        SEQ_END
 
+       seq_free_clipboard(scene);
+
        while((ms= ed->metastack.first)) {
                BLI_remlink(&ed->metastack, ms);
                MEM_freeN(ms);
        while((ms= ed->metastack.first)) {
                BLI_remlink(&ed->metastack, ms);
                MEM_freeN(ms);
index 844bf51ae32626f9fb26bd62b63e1ebf58b9c76b..8c228e9ca74123d1ccbfcb542e867725610e3221 100644 (file)
@@ -2746,3 +2746,66 @@ void SEQUENCER_OT_rendersize(wmOperatorType *ot)
        /* properties */
 }
 
        /* properties */
 }
 
+static void *_copy_scene= NULL; // XXX - FIXME
+static int sequencer_copy_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Editing *ed= seq_give_editing(scene, FALSE);
+
+       if(ed==NULL)
+               return OPERATOR_CANCELLED;
+
+       seq_free_clipboard(scene);
+       recurs_dupli_seq(scene, ed->seqbasep, &ed->seqbase_clipboard);
+
+       _copy_scene = scene;
+       return OPERATOR_FINISHED;
+}
+
+void SEQUENCER_OT_copy(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Copy";
+       ot->idname= "SEQUENCER_OT_copy";
+       ot->description="";
+
+       /* api callbacks */
+       ot->exec= sequencer_copy_exec;
+       ot->poll= ED_operator_sequencer_active;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       /* properties */
+}
+
+static int sequencer_paste_exec(bContext *C, wmOperator *op)
+{
+       int retval = OPERATOR_CANCELLED;
+       Scene *scene= CTX_data_scene(C);
+       Editing *ed= seq_give_editing(scene, TRUE); /* create if needed */
+       Editing *ed_from= seq_give_editing((Scene *)_copy_scene, TRUE); /* create if needed */
+
+
+       addlisttolist(ed->seqbasep, &ed_from->seqbase_clipboard);
+       ed_from->seqbase_clipboard.first= ed_from->seqbase_clipboard.last= NULL; // XXX - could duplicate these to use the clip
+
+       return OPERATOR_FINISHED;
+}
+
+void SEQUENCER_OT_paste(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Paste";
+       ot->idname= "SEQUENCER_OT_paste";
+       ot->description="";
+
+       /* api callbacks */
+       ot->exec= sequencer_paste_exec;
+       ot->poll= ED_operator_sequencer_active;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       /* properties */
+}
index 1cbc6e1bd1d22e65b24aa73f5bf41391f266883f..cf598bfb61360c00030697c4195e7d2812b996b8 100644 (file)
@@ -98,6 +98,9 @@ void SEQUENCER_OT_view_toggle(struct wmOperatorType *ot);
 void SEQUENCER_OT_view_all(struct wmOperatorType *ot);
 void SEQUENCER_OT_view_selected(struct wmOperatorType *ot);
 
 void SEQUENCER_OT_view_all(struct wmOperatorType *ot);
 void SEQUENCER_OT_view_selected(struct wmOperatorType *ot);
 
+void SEQUENCER_OT_copy(struct wmOperatorType *ot);
+void SEQUENCER_OT_paste(struct wmOperatorType *ot);
+
 /* preview specific operators */
 void SEQUENCER_OT_view_all_preview(struct wmOperatorType *ot);
 
 /* preview specific operators */
 void SEQUENCER_OT_view_all_preview(struct wmOperatorType *ot);
 
index 941df4d2e363f191bab5c52e22d65943870b08f5..76c7b37f59eb52ba4a83ecb2cbbc6c0d253007e5 100644 (file)
@@ -106,6 +106,9 @@ void sequencer_operatortypes(void)
        WM_operatortype_append(SEQUENCER_OT_image_strip_add);
        WM_operatortype_append(SEQUENCER_OT_effect_strip_add);
        WM_operatortype_append(SEQUENCER_OT_properties);
        WM_operatortype_append(SEQUENCER_OT_image_strip_add);
        WM_operatortype_append(SEQUENCER_OT_effect_strip_add);
        WM_operatortype_append(SEQUENCER_OT_properties);
+
+       WM_operatortype_append(SEQUENCER_OT_copy);
+       WM_operatortype_append(SEQUENCER_OT_paste);
 }
 
 
 }
 
 
index 0b45d62e347958884e9a8b8e78191213f209dff2..329b5ef6d34693b6b58a34107b0c56e876057136 100644 (file)
@@ -186,6 +186,7 @@ typedef struct Editing {
        ListBase *seqbasep; /* pointer to the current list of seq's being edited (can be within a meta strip) */
        ListBase seqbase;       /* pointer to the top-most seq's */
        ListBase metastack;
        ListBase *seqbasep; /* pointer to the current list of seq's being edited (can be within a meta strip) */
        ListBase seqbase;       /* pointer to the top-most seq's */
        ListBase metastack;
+       ListBase seqbase_clipboard; /* optionally store a copy */
        
        /* Context vars, used to be static */
        Sequence *act_seq;
        
        /* Context vars, used to be static */
        Sequence *act_seq;