Skip to content

Instantly share code, notes, and snippets.

@tin2tin
Last active October 21, 2018 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tin2tin/b7fd08762d1d8290626ee299488e2798 to your computer and use it in GitHub Desktop.
Save tin2tin/b7fd08762d1d8290626ee299488e2798 to your computer and use it in GitHub Desktop.
VSE_Trim_Mode.py
bl_info = {
"name": "Areatype Trim",
"description":"This example adds a button which toggles a split of an area with another.",
"author":"dustractor, tintwotin, Snuq, Stephen Graham",
"version":(0,2),
"blender":(2,79,0),
"location":"Button prepended to the header of the sequencer.",
"warning":"",
"wiki_url":"",
"category": "Sequencer"
}
import bpy
class AREATYPE_OT_trim(bpy.types.Operator):
bl_idname = "areatype.trimview"
bl_label = "Dual View"
original_area = None
def execute(self,context):
self.original_area = context.area
original = context.copy()
thisarea = context.area
otherarea = None
tgxvalue = thisarea.x + thisarea.width + 1
thistype = context.area.type
arealist = list(context.screen.areas)
for area in context.screen.areas:
if area == thisarea:
continue
elif area.x == tgxvalue and area.y == thisarea.y:
otherarea = area
break
if otherarea: #leave trim-mode
#join
bpy.ops.screen.area_join(min_x=thisarea.x,min_y=thisarea.y,max_x=otherarea.x,max_y=otherarea.y)
# normal settings
bpy.context.scene.sequence_editor.show_overlay = False
bpy.context.scene.sequence_editor.overlay_frame = 0 # clip start
bpy.context.space_data.overlay_type = 'CURRENT'
bpy.ops.screen.screen_full_area()
bpy.ops.screen.screen_full_area()
override = context.copy()
area = self.original_area
override['area'] = area
override['space_data'] = area.spaces.active
for region in area.regions:
if region.type == 'PREVIEW':
break
override['region'] = region
bpy.ops.sequencer.view_all_preview(override)
return {"FINISHED"}
else: # enter trim-mode
bpy.context.scene.sequence_editor.show_overlay = True
bpy.context.scene.sequence_editor.overlay_frame = -1 # clip start/ +1 if clip end
bpy.context.space_data.overlay_type = 'REFERENCE'
areax = None
#split
bpy.ops.screen.area_split(direction="VERTICAL")
#settings for preview 2.
bpy.context.space_data.overlay_type = 'CURRENT'
bpy.ops.sequencer.view_all_preview()
# fit 1. preview to window
bpy.ops.screen.screen_full_area()
bpy.ops.screen.screen_full_area()
override = original
area = self.original_area
override['area'] = area
override['space_data'] = area.spaces.active
for xarea in context.screen.areas:
#print("XAREA")
for xregion in xarea.regions:
#print("XREGION TYPE")
#print(xregion.type)
if xregion.type == 'PREVIEW': # replaced PREVIEW
override['region'] = xregion
bpy.ops.sequencer.view_all_preview(override)
for area in context.screen.areas:
if area not in arealist:
areax = area
break
if areax:
areax.type = thistype
return {"FINISHED"}
return {"CANCELLED"}
def draw_func(self,context):
layout = self.layout
layout.operator("areatype.trimview",text="Dual View",icon="ARROW_LEFTRIGHT")
def register():
bpy.utils.register_class(AREATYPE_OT_trim)
bpy.types.SEQUENCER_HT_header.prepend(draw_func)
def unregister():
bpy.utils.unregister_class(AREATYPE_OT_trim)
bpy.types.SEQUENCER_HT_header.remove(draw_func)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment