Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoomTen committed Dec 28, 2018
1 parent 54be963 commit e80dbd6
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
"name": "Cinebars",
"description": "Add fake-letterboxing without changing the resolution of your video.",
"author": "ZoomTen",
"version": (0, 0, 1),
"version": (0, 0, 2),
"blender": (2, 71, 0),
"wiki_url": "https://github.com/ZoomTen/blender-vse-cinebars",
"tracker_url": "https://github.com/ZoomTen/blender-vse-cinebars/issues",
"location": "Video Sequence Editor > Properties > Cinebars",
"category": "Sequencer"
}

# vars

class cbVals(bpy.types.PropertyGroup):
ratio_x = bpy.props.FloatProperty(
name="ratio_x",
Expand All @@ -25,26 +26,35 @@ class cbVals(bpy.types.PropertyGroup):
)

# funcs
def ShowMessageBox(message = "", title = "info", icon = 'INFO'):
def msgbox(message = "", title = "info", icon = 'INFO'):
def draw(self, context):
self.layout.label(message)
bpy.context.window_manager.popup_menu(draw, title = title, icon = icon)

def main(context):
# get render resolution
rsx = bpy.context.scene.render.resolution_x
rsy = bpy.context.scene.render.resolution_y

# get target AR
target_rsx = context.scene.cb_ratios.ratio_x
target_rsy = context.scene.cb_ratios.ratio_y

if target_rsx/target_rsy == rsx/rsy:
ShowMessageBox("Source AR is the same as destination AR!")
msgbox("Source AR is the same as destination AR!")
return 0


bpy.ops.sequencer.effect_strip_add(frame_start=bpy.context.scene.frame_start,
frame_end=bpy.context.scene.frame_end,
type="COLOR")
color = context.scene.sequence_editor.active_strip

bpy.ops.sequencer.effect_strip_add(type="TRANSFORM")
bar = context.scene.sequence_editor.active_strip
bar.name = "cinebars "+str(target_rsx)+":"+str(target_rsy)

bar.name = "cinebars "+str('%.2f' % target_rsx)+":"+str('%.2f' % target_rsy)
# wide ratio
if target_rsx/target_rsy > rsx/rsy:
bar.scale_start_y = (1-((rsx/target_rsx*target_rsy)/rsy))/2
bar.translate_start_y= 50 - (bar.scale_start_y*50)
Expand All @@ -59,6 +69,7 @@ def main(context):
color.mute = True
# i would make them into a metastrip but there isn't a function for
# that apparently
# tall / square ratio
if target_rsx/target_rsy < rsx/rsy:
bar.scale_start_x = (1-((rsy/target_rsy*target_rsx)/rsx))/2
bar.translate_start_x= 50 - (bar.scale_start_x*50)
Expand All @@ -72,18 +83,18 @@ def main(context):
otherbar.blend_type='ALPHA_OVER'
color.mute = True
# i would make them into a metastrip but there isn't a function for
# that apparently
# that which doesn't require selections apparently

# class
# actions
class cbMake(bpy.types.Operator):
bl_idname = "sequencer.cb_make"
bl_label = "Make Cinebars"

def execute(self, context):
main(context)
return {'FINISHED'}

# ui

class cbPanel(bpy.types.Panel):
bl_space_type = "SEQUENCE_EDITOR"
bl_region_type = "UI"
Expand All @@ -94,9 +105,10 @@ def draw(self, context):
l.prop(context.scene.cb_ratios, "ratio_x",text="Horizontal ratio")
l.prop(context.scene.cb_ratios, "ratio_y",text="Vertical ratio")
l.operator('sequencer.cb_make',
text='Generate Cinebars Strip',
text='Generate Cinebars Strips',
icon='FILE_TICK')

# addon registry
def register():
bpy.utils.register_class(cbVals)
bpy.utils.register_class(cbMake)
Expand Down

0 comments on commit e80dbd6

Please sign in to comment.