vse_toolbox/panels.py

289 lines
9.4 KiB
Python
Raw Normal View History

2023-03-14 13:38:04 +01:00
# SPDX-License-Identifier: GPL-2.0-or-later
2023-04-22 15:42:38 +02:00
from pathlib import Path
2023-03-14 13:38:04 +01:00
import bpy
from bpy.types import Panel
2023-04-22 15:42:38 +02:00
2023-04-14 18:55:00 +02:00
from vse_toolbox.bl_utils import (get_addon_prefs, get_scene_settings, get_strip_settings)
2023-03-20 19:05:22 +01:00
from vse_toolbox.constants import ASSET_PREVIEWS
2023-04-14 18:55:00 +02:00
from vse_toolbox.sequencer_utils import (set_active_strip, get_channel_name)
2023-03-14 13:38:04 +01:00
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):
2023-04-14 18:55:00 +02:00
def draw_header_preset(self, context):
self.layout.operator('vse_toolbox.load_projects', icon='FILE_REFRESH', text='', emboss=False)
2023-03-14 13:38:04 +01:00
def draw(self, context):
wm = context.window_manager
scn = context.scene
2023-03-21 18:33:29 +01:00
settings = get_scene_settings()
2023-03-14 13:38:04 +01:00
prefs = get_addon_prefs()
project = settings.active_project
2023-04-14 18:55:00 +02:00
layout = self.layout
2023-03-14 13:38:04 +01:00
col = layout.column()
2023-04-14 18:55:00 +02:00
col.prop(settings, 'project_name', text='Project')
if project:
2023-04-19 10:37:38 +02:00
if project.type == 'TVSHOW':
2023-04-14 18:55:00 +02:00
col.prop(project, 'episode_name', text='Episodes')
#col.separator()
#row = col.row(align=True)
#row.prop(settings, 'toogle_prefs', text='', icon='PREFERENCES', toggle=True)
2023-03-14 13:38:04 +01:00
2023-04-14 18:55:00 +02:00
'''
2023-03-14 13:38:04 +01:00
if settings.toogle_prefs:
box = col.box()
2023-03-16 18:39:15 +01:00
col = box.column(align=True)
col.use_property_split = True
col.use_property_decorate = False
2023-03-14 13:38:04 +01:00
2023-03-16 18:39:15 +01:00
col.prop(settings, 'project_name', text='Projects')
2023-03-14 13:38:04 +01:00
if project:
2023-04-14 18:55:00 +02:00
if project.type == 'TV Shows':
2023-03-16 18:39:15 +01:00
col.prop(project, 'episode_name', text='Episodes')
2023-03-14 13:38:04 +01:00
2023-04-14 18:55:00 +02:00
#col.prop(project, 'sequence_template')
#col.prop(project, 'shot_template')
2023-04-04 12:21:32 +02:00
# col.separator()
# col.operator('vse_toolbox.new_episode', text='Add Episode', icon='IMPORT')
2023-04-14 18:55:00 +02:00
'''
2023-03-14 13:38:04 +01:00
2023-04-14 18:55:00 +02:00
# Rename
2023-03-14 13:38:04 +01:00
2023-04-14 18:55:00 +02:00
class VSETB_PT_sequencer(VSETB_main, Panel):
bl_label = "Sequencer"
2023-03-14 13:38:04 +01:00
bl_parent_id = "VSETB_PT_main"
2023-04-14 18:55:00 +02:00
def draw_header_preset(self, context):
settings = get_scene_settings()
ico = ("RESTRICT_SELECT_OFF" if settings.auto_select_strip else "RESTRICT_SELECT_ON")
self.layout.prop(settings, "auto_select_strip", text="", icon=ico)
2023-03-14 13:38:04 +01:00
def draw(self, context):
prefs = get_addon_prefs()
2023-04-14 18:55:00 +02:00
layout = self.layout
2023-03-21 18:33:29 +01:00
settings = get_scene_settings()
2023-03-14 13:38:04 +01:00
project = settings.active_project
2023-04-14 18:55:00 +02:00
col = layout.column()
col.operator('vse_toolbox.set_sequencer', text='Set-Up Sequencer', icon='SEQ_SEQUENCER')
#row = col.row()
2023-04-20 00:12:39 +02:00
shot_label = ''
sequence_label = ''
if project:
episode = project.episode_name
sequence_label = project.sequence_template.format(episode=episode, index=project.sequence_start_number)
shot_label = project.shot_template.format(episode=episode, sequence=sequence_label, index=project.shot_start_number)
2023-04-14 18:55:00 +02:00
#row.separator()
strip = context.active_sequence_strip
channel_name = get_channel_name(strip) or ''
if channel_name == 'Shots':
label = shot_label
elif channel_name == 'Sequences':
label = sequence_label
else:
label = 'Not Supported'
row = col.row(align=True)
if label == 'Not Supported':
row.enabled = False
op = row.operator('vse_toolbox.strips_rename', text=f'Rename {channel_name} ( {label} )', icon='SORTALPHA')
2023-04-20 00:12:39 +02:00
if project:
op.channel_name = channel_name
if channel_name == 'Shots':
op.start_number = project.shot_start_number
op.template = project.shot_template
op.increment = project.shot_increment
else:
op.start_number = project.sequence_start_number
op.template = project.sequence_template
op.increment = project.sequence_increment
2023-04-14 18:55:00 +02:00
col.operator('vse_toolbox.set_stamps', text='Set Stamps', icon='COLOR')
2023-03-14 13:38:04 +01:00
2023-04-20 00:12:39 +02:00
class VSETB_PT_settings(VSETB_main, Panel):
bl_label = "Settings"
bl_parent_id = "VSETB_PT_main"
bl_options = {'DEFAULT_CLOSED'}
#def draw_header_preset(self, context):
# self.layout.operator('vse_toolbox.import_files', icon='IMPORT', text='', emboss=False)
def draw(self, context):
prefs = get_addon_prefs()
layout = self.layout
settings = get_scene_settings()
project = settings.active_project
col = layout.column()
#row = col.row(align=True)
col.prop(project, 'sequence_template')
col.prop(project, 'shot_template')
col.prop(project, 'render_template')
2023-04-14 18:55:00 +02:00
class VSETB_PT_imports(VSETB_main, Panel):
bl_label = "Imports"
bl_parent_id = "VSETB_PT_main"
bl_options = {'DEFAULT_CLOSED'}
def draw_header_preset(self, context):
self.layout.operator('vse_toolbox.import_files', icon='IMPORT', text='', emboss=False)
def draw(self, context):
prefs = get_addon_prefs()
2023-03-14 13:38:04 +01:00
layout = self.layout
2023-04-14 18:55:00 +02:00
settings = get_scene_settings()
project = settings.active_project
2023-03-14 13:38:04 +01:00
col = layout.column()
2023-04-14 18:55:00 +02:00
#row = col.row(align=True)
col.operator('vse_toolbox.import_files', text='Import', icon='IMPORT')
2023-03-14 13:38:04 +01:00
2023-04-14 18:55:00 +02:00
class VSETB_PT_exports(VSETB_main, Panel):
bl_label = "Exports"
bl_parent_id = "VSETB_PT_main"
bl_options = {'DEFAULT_CLOSED'}
def draw_header_preset(self, context):
2023-04-21 21:44:05 +02:00
self.layout.operator('vse_toolbox.export_spreadsheet', icon='EXPORT', text='', emboss=False)
2023-04-14 18:55:00 +02:00
def draw(self, context):
prefs = get_addon_prefs()
layout = self.layout
settings = get_scene_settings()
project = settings.active_project
# TODO FAIRE DES VRAIS OPS
layout.operator('vse_toolbox.strips_render', text='Render Strips', icon='SEQUENCE')
2023-04-20 00:12:39 +02:00
tracker_label = settings.tracker_name.title().replace('_', ' ')
layout.operator('vse_toolbox.upload_to_tracker', text=f'Upload to {tracker_label}', icon='EXPORT')
2023-04-21 21:44:05 +02:00
layout.operator('vse_toolbox.export_spreadsheet', text='Export Spreadsheet', icon='SPREADSHEET')
2023-03-14 13:38:04 +01:00
2023-03-17 20:03:38 +01:00
class VSETB_PT_casting(VSETB_main, Panel):
2023-04-14 18:55:00 +02:00
bl_label = "Casting"
2023-03-17 20:03:38 +01:00
bl_parent_id = "VSETB_PT_main"
2023-04-14 18:55:00 +02:00
def draw_header_preset(self, context):
active_strip = context.scene.sequence_editor.active_strip
self.layout.label(text=active_strip.name)
@classmethod
def poll(cls, context):
strip = context.scene.sequence_editor.active_strip
return strip and get_channel_name(strip) == 'Shots'
2023-03-17 20:03:38 +01:00
def draw(self, context):
layout = self.layout
2023-03-21 18:33:29 +01:00
settings = get_scene_settings()
strip_settings = get_strip_settings()
2023-03-17 20:03:38 +01:00
project = settings.active_project
if not project:
return
if not project.assets:
row = layout.row(align=True)
2023-04-14 18:55:00 +02:00
row.label(text='No Assets in this Project')
2023-03-17 20:03:38 +01:00
else:
2023-04-14 18:55:00 +02:00
row = layout.row()
col = row.column()
col.template_list("VSETB_UL_casting", "shot_casting", strip_settings, "casting", strip_settings, "casting_index", rows=6)
2023-04-22 15:42:38 +02:00
2023-04-14 18:55:00 +02:00
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()
2023-04-21 21:44:05 +02:00
col_tool.operator('vse_toolbox.casting_move', icon='TRIA_UP', text="").direction = 'UP'
col_tool.operator('vse_toolbox.casting_move', icon='TRIA_DOWN', text="").direction = 'DOWN'
2023-04-14 18:55:00 +02:00
col_tool.separator()
col_tool.operator('vse_toolbox.copy_casting', icon='COPYDOWN', text="")
col_tool.operator('vse_toolbox.paste_casting', icon='PASTEDOWN', text="")
2023-03-17 20:03:38 +01:00
2023-04-22 15:42:38 +02:00
if strip_settings.casting:
casting_item = strip_settings.casting[strip_settings.casting_index]
asset = casting_item.asset
if asset:
if asset.icon_id:
row = col.row(align=True)
#row.scale_y = 0.5
# box = col.box()
# box.template_icon(icon_value=ico.icon_id, scale=7.5)
row.template_icon_view(asset, "previews", show_labels=False)
2023-03-17 20:03:38 +01:00
2023-03-23 17:33:49 +01:00
class VSETB_PT_metadata(VSETB_main, Panel):
bl_label = "Shot Metadata"
bl_parent_id = "VSETB_PT_casting"
2023-04-14 18:55:00 +02:00
#bl_options = {"DEFAULT_CLOSED"}
2023-03-23 17:33:49 +01:00
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
2023-04-21 21:44:05 +02:00
layout.prop(strip_settings, 'description', text='DESCRIPTION')
2023-03-23 17:33:49 +01:00
2023-04-14 18:55:00 +02:00
#col = layout.column()
for key in strip_settings.metadata.__annotations__.keys():
layout.prop(strip_settings.metadata, key, text=key.upper())
2023-03-23 17:33:49 +01:00
2023-04-14 18:55:00 +02:00
classes = (
2023-03-14 13:38:04 +01:00
VSETB_PT_main,
2023-04-14 18:55:00 +02:00
VSETB_PT_imports,
VSETB_PT_sequencer,
2023-03-17 20:03:38 +01:00
VSETB_PT_casting,
2023-03-23 17:33:49 +01:00
VSETB_PT_metadata,
2023-04-14 18:55:00 +02:00
VSETB_PT_exports,
2023-03-14 13:38:04 +01:00
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)