[Durian-svn] [1668] sequencer slide modal python operator

campbell institute at blender.org
Thu Apr 1 17:14:36 CEST 2010


Revision: 1668
          https://blenderinstitute.dyndns.org/durian-svn/?do=log&project=durian&path=/&rev=1668
Author:   campbell
Date:     2010-04-01 17:14:35 +0200 (Thu, 01 Apr 2010)
Log Message:
-----------
sequencer slide modal python operator

Added Paths:
-----------
    pro/scripts/ui/sequencer_slide.py

Added: pro/scripts/ui/sequencer_slide.py
===================================================================
--- pro/scripts/ui/sequencer_slide.py	                        (rev 0)
+++ pro/scripts/ui/sequencer_slide.py	2010-04-01 15:14:35 UTC (rev 1668)
@@ -0,0 +1,44 @@
+import bpy
+from bpy.props import *
+
+class SlideSequence(bpy.types.Operator):
+    '''Move an object with the mouse, example.'''
+    bl_idname = "sequencer.slide_inverse"
+    bl_label = "Sequencer Slide Inverse"
+
+    first_mouse_x = IntProperty()
+
+    def modal(self, context, event):
+        if event.type == 'MOUSEMOVE':
+            delta = self.properties.first_mouse_x - event.mouse_x
+            for strip, start, final_start, final_end in self.strip_info:
+                strip.start_frame = start - delta
+                strip.start_frame_final = final_start
+                strip.end_frame_final = final_end
+
+        elif event.type == 'LEFTMOUSE':
+            return {'FINISHED'}
+
+        return {'RUNNING_MODAL'}
+
+    def invoke(self, context, event):
+        self.strip_info = [(strip, strip.start_frame, strip.start_frame_final, strip.end_frame_final) for strip in context.scene.sequence_editor.sequences if strip.selected]
+            
+        if context.scene:
+            context.manager.add_modal_handler(self)
+            self.properties.first_mouse_x = event.mouse_x
+            return {'RUNNING_MODAL'}
+        else:
+            self.report({'WARNING'}, "No active object, could not finish")
+            return {'CANCELLED'}
+
+def register():
+    bpy.types.register(SlideSequence)
+    bpy.context.manager.active_keyconfig.keymaps['SequencerCommon'].add_item("sequencer.slide_inverse", 'G', 'PRESS', shift=True)
+
+def unregister():
+    bpy.types.unregister(SlideSequence)
+
+if __name__ == "__main__":
+    bpy.ops.sequencer.slide()
+



More information about the Durian-svn mailing list