195 lines
6.2 KiB
Python
195 lines
6.2 KiB
Python
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
import bpy
|
|
from bpy.types import Panel
|
|
from pathlib import Path
|
|
from vse_toolbox.bl_utils import get_addon_prefs, get_scene_settings, get_strip_settings
|
|
from vse_toolbox.constants import ASSET_PREVIEWS
|
|
from vse_toolbox.sequencer_utils import get_active_strip
|
|
|
|
class VSETB_main:
|
|
bl_space_type = "SEQUENCE_EDITOR"
|
|
bl_region_type = "UI"
|
|
bl_category = "VSE ToolBox"
|
|
bl_label = "VSE ToolBox"
|
|
|
|
|
|
class VSETB_PT_main(VSETB_main, Panel):
|
|
|
|
def draw_header(self, context):
|
|
layout = self.layout
|
|
row = layout.row()
|
|
row.operator('vse_toolbox.load_projects', icon='FILE_REFRESH', text='')
|
|
|
|
def draw(self, context):
|
|
wm = context.window_manager
|
|
scn = context.scene
|
|
|
|
settings = get_scene_settings()
|
|
prefs = get_addon_prefs()
|
|
|
|
project = settings.active_project
|
|
|
|
layout = self.layout
|
|
col = layout.column()
|
|
row = col.row(align=True)
|
|
|
|
row.operator('vse_toolbox.set_scene', text='Set Scene', icon='SCENE_DATA')
|
|
row.prop(settings, 'toogle_prefs', text='', icon='PREFERENCES', toggle=True)
|
|
|
|
if settings.toogle_prefs:
|
|
box = col.box()
|
|
col = box.column(align=True)
|
|
col.use_property_split = True
|
|
col.use_property_decorate = False
|
|
|
|
col.prop(settings, 'project_name', text='Projects')
|
|
|
|
if project:
|
|
if project.episodes:
|
|
col.prop(project, 'episode_name', text='Episodes')
|
|
|
|
col.prop(project, 'shot_template')
|
|
# col.separator()
|
|
# col.operator('vse_toolbox.new_episode', text='Add Episode', icon='IMPORT')
|
|
|
|
col = layout.column()
|
|
row = col.row(align=True)
|
|
row.operator('sequencer.import_files', text='Import', icon='IMPORT')
|
|
# TODO FAIRE DES VRAIS OPS
|
|
row.operator('sequencer.export_csv', text='Export', icon='EXPORT')
|
|
op = col.operator('sequencer.strips_render', text='Render Strips', icon='RENDER_ANIMATION')
|
|
|
|
|
|
class VSETB_PT_rename(VSETB_main, Panel):
|
|
bl_label = "Rename Strips"
|
|
bl_parent_id = "VSETB_PT_main"
|
|
|
|
def draw(self, context):
|
|
prefs = get_addon_prefs()
|
|
settings = get_scene_settings()
|
|
project = settings.active_project
|
|
|
|
if not project:
|
|
return
|
|
|
|
episode = project.episode_name
|
|
|
|
layout = self.layout
|
|
col = layout.column()
|
|
|
|
col.use_property_split = True
|
|
|
|
row = col.row()
|
|
shot_increment = project.shot_increment
|
|
shot_template = project.shot_template.format(
|
|
episode=episode, index=0 * shot_increment)
|
|
|
|
row.separator()
|
|
|
|
op = row.operator('sequencer.strips_rename', text='Rename Shots', icon='SORTALPHA')
|
|
op.channel_name = 'Shots'
|
|
op.template = project.shot_template
|
|
op.increment = project.shot_increment
|
|
op.start_number = 10
|
|
row.label(text=f'{shot_template}')
|
|
|
|
|
|
class VSETB_PT_casting(VSETB_main, Panel):
|
|
bl_label = "Shot Casting"
|
|
bl_parent_id = "VSETB_PT_main"
|
|
|
|
def draw(self, context):
|
|
layout = self.layout
|
|
scn = context.scene
|
|
active_strip = scn.sequence_editor.active_strip
|
|
|
|
if not active_strip:
|
|
return
|
|
|
|
settings = get_scene_settings()
|
|
strip_settings = get_strip_settings()
|
|
|
|
project = settings.active_project
|
|
|
|
if not project:
|
|
return
|
|
|
|
if not project.assets:
|
|
row = layout.row(align=True)
|
|
row.label(text='No Assets found. Load Assets first.')
|
|
else:
|
|
row = layout.row(align=True)
|
|
row.label(text=f'Assets for {project.name} successfully loaded.')
|
|
|
|
row.operator('vse_toolbox.load_assets', icon='FILE_REFRESH', text='')
|
|
|
|
row = layout.row()
|
|
ico = ("RESTRICT_SELECT_OFF" if settings.auto_select_strip else "RESTRICT_SELECT_ON")
|
|
row.prop(settings, "auto_select_strip", icon=ico)
|
|
|
|
row = layout.row()
|
|
row.label(text=f"Current Shot: {Path(active_strip.name).stem}")
|
|
row = layout.row()
|
|
col = row.column()
|
|
col.template_list("VSETB_UL_casting", "shot_casting", strip_settings, "casting", strip_settings, "casting_index", rows=6)
|
|
|
|
if strip_settings.casting:
|
|
casting_item = strip_settings.casting[strip_settings.casting_index]
|
|
asset = casting_item.asset
|
|
if asset:
|
|
ico = ASSET_PREVIEWS.get(asset.preview)
|
|
if ico:
|
|
box = col.box()
|
|
box.template_icon(icon_value=ico.icon_id, scale=7.5)
|
|
|
|
col_tool = row.column(align=True)
|
|
col_tool.operator('vse_toolbox.casting_add', icon='ADD', text="")
|
|
col_tool.operator('vse_toolbox.casting_remove', icon='REMOVE', text="")
|
|
col_tool.separator()
|
|
col_tool.operator('vse_toolbox.casting_move', icon='TRIA_UP', text="").action = 'UP'
|
|
col_tool.operator('vse_toolbox.casting_move', icon='TRIA_DOWN', text="").action = 'DOWN'
|
|
col_tool.separator()
|
|
col_tool.operator('sequencer.copy_casting', icon='COPYDOWN', text="")
|
|
col_tool.operator('sequencer.paste_casting', icon='PASTEDOWN', text="")
|
|
|
|
|
|
class VSETB_PT_metadata(VSETB_main, Panel):
|
|
bl_label = "Shot Metadata"
|
|
bl_parent_id = "VSETB_PT_casting"
|
|
bl_options = {"DEFAULT_CLOSED"}
|
|
|
|
def draw(self, context):
|
|
layout = self.layout
|
|
scn = context.scene
|
|
active_strip = scn.sequence_editor.active_strip
|
|
|
|
if not active_strip:
|
|
return
|
|
|
|
settings = get_scene_settings()
|
|
strip_settings = get_strip_settings()
|
|
|
|
project = settings.active_project
|
|
|
|
if not project:
|
|
return
|
|
|
|
col = layout.column()
|
|
for key in strip_settings.metadata.keys():
|
|
col.prop(strip_settings.metadata, key)
|
|
|
|
classes=(
|
|
VSETB_PT_main,
|
|
VSETB_PT_rename,
|
|
VSETB_PT_casting,
|
|
VSETB_PT_metadata,
|
|
)
|
|
|
|
def register():
|
|
for cls in classes:
|
|
bpy.utils.register_class(cls)
|
|
|
|
def unregister():
|
|
for cls in reversed(classes):
|
|
bpy.utils.unregister_class(cls) |