# 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_settings 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_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') # TODO FAIRE DES VRAIS OPS col = layout.column() row = col.row(align=True) row.operator('sequencer.import', text='Import', icon='IMPORT') 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_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_header(self, context): # settings = get_settings() # project = settings.active_project # if not project or not project.assets: # ico = 'ERROR' # else: # ico = 'REFRESH' # layout = self.layout # row = layout.row() # row.operator('vse_toolbox.load_assets', icon=ico, text='') def draw(self, context): layout = self.layout scn = context.scene active_strip = scn.sequence_editor.active_strip if not active_strip: return settings = get_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.') row.operator('vse_toolbox.load_assets', icon='FILE_REFRESH', text='') else: row = layout.row(align=True) row.label(text=f'Assets for {project.name} successfully loaded.') 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() row.template_list( "VSETB_UL_casting", "shot_casting", active_strip, "casting", active_strip, "casting_index" ) col = row.column(align=True) col.operator('vse_toolbox.casting_add', icon='ADD', text="") col.operator('vse_toolbox.casting_actions', icon='REMOVE', text="").action = 'REMOVE' col.separator() col.operator('vse_toolbox.casting_actions', icon='TRIA_UP', text="").action = 'UP' col.operator('vse_toolbox.casting_actions', icon='TRIA_DOWN', text="").action = 'DOWN' classes=( VSETB_PT_main, VSETB_PT_rename, VSETB_PT_casting, ) def register(): for cls in classes: bpy.utils.register_class(cls) def unregister(): for cls in reversed(classes): bpy.utils.unregister_class(cls)