vse_toolbox/ui/panels.py

501 lines
17 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
2024-03-26 17:54:03 +01:00
from bpy.types import Panel, Menu
2023-04-24 18:50:41 +02:00
from bl_ui.utils import PresetPanel
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)
2024-04-10 16:15:57 +02:00
from vse_toolbox.constants import ASSET_PREVIEWS, REVIEW_TEMPLATE_BLEND
2023-04-22 21:12:21 +02:00
from vse_toolbox.sequencer_utils import (set_active_strip, get_channel_name, get_strips)
2024-02-15 10:38:36 +01:00
from vse_toolbox.file_utils import norm_str
2023-04-14 18:55:00 +02:00
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):
2024-04-10 16:15:57 +02:00
bl_options = {"HIDE_HEADER"}
2023-03-14 13:38:04 +01:00
2024-04-10 16:15:57 +02:00
# def draw_header(self, context):
# settings = get_scene_settings()
# prefs = get_addon_prefs()
# row = self.layout.row(align=True)
# row.label('VSE Toolbox')
# row.prop(settings, 'project_name', text='')
# project = settings.active_project
# if project and project.type == 'TVSHOW':
# row.prop(project, 'episode_name', text='')
# row.operator('vse_toolbox.load_projects', icon='FILE_REFRESH', text='', emboss=False)
2023-03-14 13:38:04 +01:00
def draw(self, context):
2024-04-16 14:28:02 +02:00
layout = self.layout
2023-03-14 13:38:04 +01:00
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()
2024-04-10 16:15:57 +02:00
2024-04-16 14:28:02 +02:00
row = layout.row(align=True)
2024-04-10 16:15:57 +02:00
row.operator('vse_toolbox.load_projects', icon='FILE_REFRESH', text='', emboss=False)
2024-04-16 14:28:02 +02:00
row.separator(factor=0.5)
2024-04-10 16:15:57 +02:00
row.prop(settings, 'project_name', text='')
2023-03-14 13:38:04 +01:00
project = settings.active_project
2024-04-16 18:28:36 +02:00
if not project:
return
2024-04-10 16:15:57 +02:00
if project and project.type == 'TVSHOW':
2024-04-16 14:28:02 +02:00
row.separator(factor=0.5)
2024-04-10 16:15:57 +02:00
row.prop(project, 'episode_name', text='')
2024-04-16 14:28:02 +02:00
row.separator(factor=0.5)
row.prop(project, "show_settings", icon="PREFERENCES", text='')
if project.show_settings:
box = layout.box()
split = box.split(factor=0.3)
name_col = split.column()
template_col = split.column()
row = name_col.row(align=True) # Padding
row.separator(factor=0.5)
row.label(text="Name")
row = template_col.row(align=True) # Padding
row.separator(factor=0.5)
row.label(text="Template")
row.operator("vse_toolbox.add_template", text="", icon='ADD', emboss=False)
for i, template in enumerate(project.templates):
row = name_col.row()
row.prop(template, "name", text="")
row = template_col.row(align=True)
subrow = row.row()
subrow.prop(template, "value", text="")
row.separator(factor=0.25)
row.operator("vse_toolbox.remove_template", text="", icon='REMOVE', emboss=False).index = i
2024-04-10 16:15:57 +02:00
# settings = get_scene_settings()
# prefs = get_addon_prefs()
# project = settings.active_project
2023-03-14 13:38:04 +01:00
2024-04-10 16:15:57 +02:00
# layout = self.layout
# col = layout.column()
2023-04-14 18:55:00 +02:00
2024-04-10 16:15:57 +02:00
# col.prop(settings, 'project_name', text='Project')
# if project:
# if project.type == 'TVSHOW':
# col.prop(project, 'episode_name', text='Episodes')
2023-04-14 18:55:00 +02:00
#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-05-08 18:25:04 +02:00
class VSETB_PT_strip(Panel):
bl_space_type = "SEQUENCE_EDITOR"
bl_region_type = "UI"
bl_category = "Strip"
bl_label = "VSE ToolBox"
#bl_order = 0
2023-05-31 12:52:35 +02:00
@classmethod
def poll(cls, context):
2024-03-14 17:44:05 +01:00
strip = context.active_sequence_strip
2023-05-31 12:52:35 +02:00
return strip and get_channel_name(strip) == 'Shots'
2023-05-08 18:25:04 +02:00
def draw(self, context):
prefs = get_addon_prefs()
layout = self.layout
settings = get_strip_settings()
layout.use_property_split = True
layout.use_property_decorate = False
layout.prop(settings, 'source_name', text='Source Name')
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"
2024-04-10 16:15:57 +02:00
#bl_parent_id = "VSETB_PT_main"
2023-03-14 13:38:04 +01:00
2023-04-14 18:55:00 +02:00
def draw_header_preset(self, context):
settings = get_scene_settings()
2023-04-22 21:12:21 +02:00
2024-05-14 11:49:47 +02:00
audio_strips = [s for s in get_strips('Audio') if s.type == "SOUND"]
2023-04-22 21:12:21 +02:00
depress = any(s.show_waveform for s in audio_strips)
self.layout.operator('vse_toolbox.show_waveform', text="", icon="IPO_ELASTIC", depress=depress).enabled = not depress
2023-04-14 18:55:00 +02:00
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
strip = context.active_sequence_strip
2024-04-10 16:15:57 +02:00
channel = get_channel_name(strip)
2023-04-25 11:39:06 +02:00
2024-04-10 16:15:57 +02:00
col = layout.column()
col.operator('vse_toolbox.set_sequencer', text='Set-Up Sequencer', icon='SEQ_SEQUENCER')
2024-05-24 09:44:19 +02:00
col.operator('vse_toolbox.auto_split', text='Auto Split Shots')
2024-04-10 16:15:57 +02:00
col.operator('vse_toolbox.strips_rename', text=f'Rename {channel}', icon='SORTALPHA')
2023-04-14 18:55:00 +02:00
col.operator('vse_toolbox.set_stamps', text='Set Stamps', icon='COLOR')
2024-04-10 16:15:57 +02:00
col.operator("vse_toolbox.collect_files", text='Collect Files', icon='PACKAGE')
2023-04-14 18:55:00 +02:00
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"
2024-04-10 16:15:57 +02:00
#bl_parent_id = "VSETB_PT_main"
2023-04-20 00:12:39 +02:00
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"
2024-04-10 16:15:57 +02:00
#bl_parent_id = "VSETB_PT_main"
2024-04-16 14:28:02 +02:00
#bl_options = {'DEFAULT_CLOSED'}
2023-04-14 18:55:00 +02:00
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)
2023-05-04 14:55:53 +02:00
#col.operator('vse_toolbox.import_files', text='Import', icon='IMPORT')
col.operator('vse_toolbox.import_spreadsheet', text='Import Spreadsheet', icon='SPREADSHEET')
2024-03-26 17:54:03 +01:00
col.operator("vse_toolbox.import_shots", text='Import Shots', icon="FILE_MOVIE")
2023-03-14 13:38:04 +01:00
2023-04-24 18:50:41 +02:00
class VSETB_PT_presets(PresetPanel, Panel):
bl_label = 'Spreadsheet Presets'
preset_subdir = 'vse_toolbox'
preset_operator = 'script.execute_preset'
preset_add_operator = "vse_toolbox.add_spreadsheet_preset"
2023-04-14 18:55:00 +02:00
class VSETB_PT_exports(VSETB_main, Panel):
bl_label = "Exports"
2024-04-10 16:15:57 +02:00
#bl_parent_id = "VSETB_PT_main"
2023-04-14 18:55:00 +02:00
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
2024-04-10 16:15:57 +02:00
col = layout.column(align=False)
2023-04-14 18:55:00 +02:00
# TODO FAIRE DES VRAIS OPS
2024-04-10 16:15:57 +02:00
col.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('_', ' ')
2024-04-10 16:15:57 +02:00
col.operator('vse_toolbox.upload_to_tracker', text=f'Upload to {tracker_label}', icon='EXPORT')
col.operator('vse_toolbox.export_spreadsheet', text='Export Spreadsheet', icon='SPREADSHEET')
col.operator('vse_toolbox.export_edl', text='Export edl', icon='SEQ_SEQUENCER')
2023-03-14 13:38:04 +01:00
2024-02-14 14:33:54 +01:00
class VSETB_PT_tracker(VSETB_main, Panel):
bl_label = "Tracker"
2024-04-10 16:15:57 +02:00
#bl_parent_id = "VSETB_PT_main"
2024-03-14 17:44:05 +01:00
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return context.active_sequence_strip
2023-03-17 20:03:38 +01:00
2023-04-14 18:55:00 +02:00
def draw_header_preset(self, context):
2024-03-14 17:44:05 +01:00
active_strip = context.active_sequence_strip
2023-04-14 18:55:00 +02:00
self.layout.label(text=active_strip.name)
2024-02-14 14:33:54 +01:00
def draw(self, context):
return
class VSETB_PT_casting(VSETB_main, Panel):
bl_label = "Casting"
bl_parent_id = "VSETB_PT_tracker"
2024-03-14 17:44:05 +01:00
bl_options = {'DEFAULT_CLOSED'}
2024-02-14 14:33:54 +01:00
2023-04-14 18:55:00 +02:00
@classmethod
def poll(cls, context):
2024-03-14 17:44:05 +01:00
strip = context.active_sequence_strip
2023-04-14 18:55:00 +02:00
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-04-24 18:50:41 +02:00
col_tool.separator()
col_tool.operator('vse_toolbox.casting_replace', icon='ZOOM_ALL', 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"
2024-02-14 14:33:54 +01:00
bl_parent_id = "VSETB_PT_tracker"
2024-03-14 17:44:05 +01:00
bl_options = {'DEFAULT_CLOSED'}
2024-02-14 14:33:54 +01:00
@classmethod
def poll(cls, context):
2024-03-14 17:44:05 +01:00
return context.active_sequence_strip and get_scene_settings().active_project
2023-03-23 17:33:49 +01:00
def draw(self, context):
strip_settings = get_strip_settings()
2024-02-14 14:33:54 +01:00
project = get_scene_settings().active_project
2023-03-23 17:33:49 +01:00
2024-02-14 14:33:54 +01:00
layout = self.layout
row = layout.row(align=True)
label_col = row.column(align=True)
label_col.alignment = 'RIGHT'
field_col = row.column(align=True)
2023-03-23 17:33:49 +01:00
2024-02-14 14:33:54 +01:00
for metadata_type in project.metadata_types:
if metadata_type.entity_type != 'SHOT':
continue
metadata_key = metadata_type.field_name
metadata_label = metadata_key.title()
label_col.label(text=metadata_label)
field_row = field_col.row(align=True)
field_row.separator()
if metadata_type.choices:
metadata_value = getattr(strip_settings.metadata, metadata_key)
icon = 'LAYER_USED'
if metadata_value:
if metadata_value in metadata_type.choices:
icon = 'DOT'
else:
icon = 'ADD'
field_row.prop_search(strip_settings.metadata, metadata_key, metadata_type, 'choices',
results_are_suggestions=True, icon=icon, text='')
else:
field_row.prop(strip_settings.metadata, metadata_key, text='')
class VSETB_PT_comments(VSETB_main, Panel):
bl_label = "Comments"
bl_parent_id = "VSETB_PT_tracker"
2024-03-14 17:44:05 +01:00
bl_options = {'DEFAULT_CLOSED'}
2024-02-14 14:33:54 +01:00
@classmethod
def poll(cls, context):
2024-03-14 17:44:05 +01:00
return context.active_sequence_strip and get_scene_settings().active_project
2024-02-14 14:33:54 +01:00
def draw(self, context):
layout = self.layout
row = layout.row(align=True)
label_col = row.column(align=True)
label_col.alignment = 'RIGHT'
field_col = row.column(align=True)
2023-04-21 21:44:05 +02:00
2024-02-14 14:33:54 +01:00
strip_settings = get_strip_settings()
project = get_scene_settings().active_project
for task_type in project.task_types:
2024-02-15 10:38:36 +01:00
norm_task_name = norm_str(task_type.name)
2024-02-14 14:33:54 +01:00
2024-02-15 10:38:36 +01:00
if not hasattr(strip_settings.tasks, norm_task_name):
2024-02-14 14:33:54 +01:00
continue
label_col.label(text=task_type.name)
row = field_col.row(align=True)
row.separator()
sub = row.row(align=True)
sub.alignment = 'LEFT'
sub.scale_x = 0.15
sub.prop(task_type, 'color', text='')
sub.enabled = False
2024-02-15 10:38:36 +01:00
row.prop(getattr(strip_settings.tasks, norm_task_name), 'comment', text='')
2023-03-23 17:33:49 +01:00
2023-04-25 18:43:04 +02:00
def context_menu_prop(self, context):
if not hasattr(context, 'button_prop') or context.space_data.type != 'SEQUENCE_EDITOR':
return
settings = get_strip_settings()
if not settings:
return
button_prop = context.button_prop
if button_prop not in settings.metadata.bl_rna.properties.values():
return
layout = self.layout
layout.separator()
layout.operator('vse_toolbox.copy_metadata', icon='PASTEDOWN', text='Copy metadata to selected').metadata = button_prop.name
2024-03-26 17:54:03 +01:00
class VSETB_MT_main_menu(Menu):
bl_label = "Vse Toolbox"
def draw(self, context):
layout = self.layout
2024-04-10 16:15:57 +02:00
op = layout.operator('workspace.append_activate', text='Set Review Workspace', icon="WORKSPACE")
op.idname = 'Review'
op.filepath = str(REVIEW_TEMPLATE_BLEND)
2024-03-26 17:54:03 +01:00
2024-04-10 16:15:57 +02:00
layout.operator("wm.split_view", icon="ARROW_LEFTRIGHT")
2024-12-19 16:15:34 +01:00
layout.separator()
layout.operator('vse_toolbox.update_media', text='Update Media', icon='FILE_REFRESH')
2024-04-10 16:15:57 +02:00
layout.operator('vse_toolbox.open_shot_on_tracker', text='Open Shot on Tracker', icon='URL')
2024-12-19 16:15:34 +01:00
layout.operator('vse_toolbox.open_strip_folder', text='Open Strip Folder', icon='FILE_FOLDER')
2024-05-14 11:49:47 +02:00
layout.separator()
layout.operator('vse_toolbox.insert_channel', text='Insert Channel', icon='TRIA_UP_BAR')
layout.operator('vse_toolbox.remove_channel', text='Remove Channel', icon='TRIA_DOWN_BAR')
2024-05-23 10:07:43 +02:00
layout.separator()
layout.operator('vse_toolbox.merge_shot_strips', text='Merge Shots')
2024-03-26 17:54:03 +01:00
def draw_vse_toolbox_menu(self, context):
self.layout.menu("VSETB_MT_main_menu")
2024-04-22 22:30:36 +02:00
def draw_file_new(self, context):
self.layout.separator()
op = self.layout.operator('wm.read_homefile', text="Review")
op.filepath = str(REVIEW_TEMPLATE_BLEND)
op.load_ui = True
2024-03-26 17:54:03 +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,
2024-02-14 14:33:54 +01:00
VSETB_PT_tracker,
2023-03-17 20:03:38 +01:00
VSETB_PT_casting,
2023-03-23 17:33:49 +01:00
VSETB_PT_metadata,
2024-02-14 14:33:54 +01:00
VSETB_PT_comments,
2023-04-24 18:50:41 +02:00
VSETB_PT_presets,
2023-04-14 18:55:00 +02:00
VSETB_PT_exports,
2024-03-26 17:54:03 +01:00
VSETB_PT_strip,
VSETB_MT_main_menu
2023-03-14 13:38:04 +01:00
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
2023-04-25 18:43:04 +02:00
bpy.types.UI_MT_button_context_menu.append(context_menu_prop)
2024-03-26 17:54:03 +01:00
bpy.types.SEQUENCER_MT_editor_menus.append(draw_vse_toolbox_menu)
2023-03-14 13:38:04 +01:00
2024-04-22 22:30:36 +02:00
bpy.types.TOPBAR_MT_file_new.append(draw_file_new)
2023-03-14 13:38:04 +01:00
def unregister():
for cls in reversed(classes):
2023-04-25 18:43:04 +02:00
bpy.utils.unregister_class(cls)
2024-03-26 17:54:03 +01:00
bpy.types.UI_MT_button_context_menu.remove(context_menu_prop)
2024-04-22 22:30:36 +02:00
bpy.types.SEQUENCER_MT_editor_menus.remove(draw_vse_toolbox_menu)
bpy.types.TOPBAR_MT_file_new.remove(draw_file_new)