patch from Xavier Thomas, add back the sequencer snap operator
authorCampbell Barton <ideasman42@gmail.com>
Tue, 9 Jun 2009 21:29:59 +0000 (21:29 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 9 Jun 2009 21:29:59 +0000 (21:29 +0000)
release/ui/space_sequencer.py
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_intern.h
source/blender/editors/space_sequencer/sequencer_ops.c

index fb8cc12c43601bec4cc3b33d9fb91114a4c785cd..c783fd27b98251d59c98520c520bba7eff832548 100644 (file)
@@ -239,7 +239,7 @@ class SEQUENCER_MT_strip(bpy.types.Menu):
                
                layout.item_enumO("SEQUENCER_OT_mute", property="type", value='UNSELECTED', text="Mute Deselected Strips")
 
-
+               layout.itemO("SEQUENCER_OT_snap")
 
 # Panels
 class SequencerButtonsPanel(bpy.types.Panel):
index 9c3191c93d6f7cea93f10ce43ea9c6768c591372..20ad1b619810b383c3a30a4719b120f04f38dad2 100644 (file)
@@ -1388,13 +1388,20 @@ static int seq_get_snaplimit(View2D *v2d)
 }
 #endif
 
-void seq_snap(Scene *scene, short event)
+/* Operator functions */
+
+/* snap operator*/
+static int sequencer_snap_exec(bContext *C, wmOperator *op)
 {
+       Scene *scene= CTX_data_scene(C);
+       
        Editing *ed= seq_give_editing(scene, FALSE);
        Sequence *seq;
-
+       int snap_frame;
        
-       if(ed==NULL) return;
+       if(ed==NULL) return OPERATOR_CANCELLED;
+
+       snap_frame= RNA_int_get(op->ptr, "frame");
 
        /* problem: contents of meta's are all shifted to the same position... */
 
@@ -1403,12 +1410,12 @@ void seq_snap(Scene *scene, short event)
                if (seq->flag & SELECT && !(seq->depth==0 && seq->flag & SEQ_LOCK) &&
                    seq_tx_test(seq)) {
                        if((seq->flag & (SEQ_LEFTSEL+SEQ_RIGHTSEL))==0) {
-                               seq->start= CFRA-seq->startofs+seq->startstill;
+                               seq->start= snap_frame-seq->startofs+seq->startstill;
                        } else { 
                                if(seq->flag & SEQ_LEFTSEL) {
-                                       seq_tx_set_final_left(seq, CFRA);
+                                       seq_tx_set_final_left(seq, snap_frame);
                                } else { /* SEQ_RIGHTSEL */
-                                       seq_tx_set_final_right(seq, CFRA);
+                                       seq_tx_set_final_right(seq, snap_frame);
                                }
                                seq_tx_handle_xlimits(seq, seq->flag & SEQ_LEFTSEL, seq->flag & SEQ_RIGHTSEL);
                        }
@@ -1438,21 +1445,43 @@ void seq_snap(Scene *scene, short event)
 
        /* as last: */
        sort_seq(scene);
-
+       
+       ED_area_tag_redraw(CTX_wm_area(C));
+       
+       return OPERATOR_FINISHED;
 }
 
-void seq_snap_menu(Scene *scene)
+static int sequencer_snap_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       short event;
+       Scene *scene = CTX_data_scene(C);
        
-       event= pupmenu("Snap %t|To Current Frame%x1");
-       if(event < 1) return;
+       int snap_frame;
        
-       seq_snap(scene, event);
+       snap_frame= CFRA;
+       
+       RNA_int_set(op->ptr, "frame", snap_frame);
+       return sequencer_snap_exec(C, op);
 }
 
-/* Operator functions */
+void SEQUENCER_OT_snap(struct wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Snap strips";
+       ot->idname= "SEQUENCER_OT_snap";
+
+       /* api callbacks */
+       ot->invoke= sequencer_snap_invoke;
+       ot->exec= sequencer_snap_exec;
+
+       ot->poll= ED_operator_sequencer_active;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       
+       RNA_def_int(ot->srna, "frame", 0, INT_MIN, INT_MAX, "Frame", "Frame where selected strips will snaped", INT_MIN, INT_MAX);
+}
 
+/* mute operator */
 static int sequencer_mute_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
index 1f78c4d5199cd5122255d297acc4447ff6083f96..6d61f7439174e0f0f4030ebff636abba3e536a83 100644 (file)
@@ -89,6 +89,7 @@ void SEQUENCER_OT_images_separate(struct wmOperatorType *ot);
 void SEQUENCER_OT_meta_toggle(struct wmOperatorType *ot);
 void SEQUENCER_OT_meta_make(struct wmOperatorType *ot);
 void SEQUENCER_OT_meta_separate(struct wmOperatorType *ot);
+void SEQUENCER_OT_snap(struct wmOperatorType *ot);
 
 void SEQUENCER_OT_view_all(struct wmOperatorType *ot);
 void SEQUENCER_OT_view_selected(struct wmOperatorType *ot);
index 600ef87e1b3ce0323cd61c0502bf423597992a6b..c6e5fbe39a4cf0cb7bd82f6823eb83a40138dcaa 100644 (file)
@@ -77,6 +77,7 @@ void sequencer_operatortypes(void)
        WM_operatortype_append(SEQUENCER_OT_meta_toggle);
        WM_operatortype_append(SEQUENCER_OT_meta_make);
        WM_operatortype_append(SEQUENCER_OT_meta_separate);
+       WM_operatortype_append(SEQUENCER_OT_snap);
 
        WM_operatortype_append(SEQUENCER_OT_view_all);
        WM_operatortype_append(SEQUENCER_OT_view_selected);