add comments panel

pull/5/head
florentin.luce 2024-02-14 14:33:54 +01:00
parent 571f7d5807
commit 10f9824ac2
4 changed files with 120 additions and 46 deletions

View File

@ -103,21 +103,26 @@ class VSETB_OT_load_projects(Operator):
def poll(cls, context):
return True
@staticmethod
def hex_to_rgb(hex_value):
print(hex_value)
b = (hex_value & 0xFF) / 255.0
g = ((hex_value >> 8) & 0xFF) / 255.0
r = ((hex_value >> 16) & 0xFF) / 255.0
return r, g, b
@staticmethod
def hex_to_rgb(color_str):
# supports '123456', '#123456' and '0x123456'
(r,g,b), a = map(lambda component: component / 255, bytes.fromhex(color_str[-6:])), 1.0
return (r,g,b,a)
def execute(self, context):
settings = get_scene_settings()
prefs = get_addon_prefs()
tracker = prefs.tracker
prev_project_name = settings.project_name
prev_project_name = settings.project_name#.replace(' ', '_').upper()
print("prev_project_name", prev_project_name)
# old_episode_name = None
# if settings.active_project:
# old_episode_name = settings.active_project.episode_name.replace(' ', '_').upper()
#settings.projects.clear()
tracker.connect()
project_datas = tracker.get_projects()
@ -175,6 +180,9 @@ class VSETB_OT_load_projects(Operator):
for task_type_data in tracker.get_shot_task_types(project_data):
task_type = project.task_types.add()
task_type.name = task_type_data['name']
task_type.color = self.hex_to_rgb(task_type_data['color'])[:3]
project.set_shot_tasks()
project.asset_types.clear()
for asset_type_data in tracker.get_asset_types(project_data):

View File

@ -126,6 +126,7 @@ class Kitsu(Tracker):
def get_shot_task_types(self, project=None):
project = self.get_project(project)
task_types = gazu.task.all_task_types_for_project(project)
task_types.sort(key=lambda x: x['priority'])
return [t for t in task_types if t['for_entity'].lower() == 'shot']
def get_metadata_types(self, project=None):

View File

@ -216,14 +216,22 @@ class VSETB_PT_exports(VSETB_main, Panel):
layout.operator('vse_toolbox.export_edl', text='Export edl', icon='SEQ_SEQUENCER')
class VSETB_PT_casting(VSETB_main, Panel):
bl_label = "Casting"
class VSETB_PT_tracker(VSETB_main, Panel):
bl_label = "Tracker"
bl_parent_id = "VSETB_PT_main"
def draw_header_preset(self, context):
active_strip = context.scene.sequence_editor.active_strip
self.layout.label(text=active_strip.name)
def draw(self, context):
return
class VSETB_PT_casting(VSETB_main, Panel):
bl_label = "Casting"
bl_parent_id = "VSETB_PT_tracker"
@classmethod
def poll(cls, context):
strip = context.scene.sequence_editor.active_strip
@ -277,50 +285,88 @@ class VSETB_PT_casting(VSETB_main, Panel):
class VSETB_PT_metadata(VSETB_main, Panel):
bl_label = "Shot Metadata"
bl_parent_id = "VSETB_PT_casting"
#bl_options = {"DEFAULT_CLOSED"}
bl_parent_id = "VSETB_PT_tracker"
@classmethod
def poll(cls, context):
return context.scene.sequence_editor.active_strip and get_scene_settings().active_project
def draw(self, context):
strip_settings = get_strip_settings()
project = get_scene_settings().active_project
layout = self.layout
row = layout.row(align=True)
label_col = row.column(align=True)
label_col.alignment = 'RIGHT'
field_col = row.column(align=True)
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"
@classmethod
def poll(cls, context):
return context.scene.sequence_editor.active_strip and get_scene_settings().active_project
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()
row = layout.row(align=True)
label_col = row.column(align=True)
label_col.alignment = 'RIGHT'
field_col = row.column(align=True)
strip_settings = get_strip_settings()
project = get_scene_settings().active_project
project = settings.active_project
if not project:
return
col = layout.column(align=True)
col.prop(strip_settings, 'description', text='DESCRIPTION')
for task_type in project.task_types:
if not hasattr(strip_settings.tasks, task_type.name):
continue
for metadata_type in project.metadata_types:
if metadata_type.entity_type == 'SHOT':
#row = layout.row(align=False)
metadata_key = metadata_type.field_name
metadata_label = metadata_key.upper()
label_col.label(text=task_type.name)
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'
row = field_col.row(align=True)
row.separator()
sub = row.row(align=True)
sub.alignment = 'LEFT'
sub.scale_x = 0.15
col.prop_search(strip_settings.metadata, metadata_key, metadata_type, 'choices',
results_are_suggestions=True, icon=icon, text=metadata_label)
else:
col.prop(strip_settings.metadata, metadata_key, text=metadata_label)
sub.prop(task_type, 'color', text='')
sub.enabled = False
row.prop(getattr(strip_settings.tasks, task_type.name), 'comment', text='')
#row.operator('vse_toolbox.copy_metadata', icon='PASTEDOWN', text='', emboss=False).metadata = metadata_key
def context_menu_prop(self, context):
if not hasattr(context, 'button_prop') or context.space_data.type != 'SEQUENCE_EDITOR':
@ -343,8 +389,10 @@ classes = (
VSETB_PT_main,
VSETB_PT_imports,
VSETB_PT_sequencer,
VSETB_PT_tracker,
VSETB_PT_casting,
VSETB_PT_metadata,
VSETB_PT_comments,
VSETB_PT_presets,
VSETB_PT_exports,
VSETB_PT_strip

View File

@ -12,6 +12,7 @@ from bpy.props import (
IntProperty,
PointerProperty,
StringProperty,
FloatVectorProperty
)
from bpy.types import PropertyGroup, UIList
from pprint import pprint as pp
@ -106,7 +107,7 @@ class MetadataType(PropertyGroup):
class TaskType(PropertyGroup):
__annotations__ = {}
color : FloatVectorProperty(subtype='COLOR')
class TaskStatus(PropertyGroup):
@ -117,6 +118,14 @@ class Metadata(CollectionPropertyGroup):
__annotations__ = {}
class ShotTasks(PropertyGroup):
__annotations__ = {}
class ShotTask(PropertyGroup):
comment : StringProperty()
class Episode(PropertyGroup):
id : StringProperty(default='')
@ -358,7 +367,12 @@ class Project(PropertyGroup):
Metadata.__annotations__[field_name] = prop
setattr(Metadata, field_name, prop)
def set_shot_tasks(self):
for task_type in self.task_types:
prop = bpy.props.PointerProperty(type=ShotTask)
ShotTasks.__annotations__[task_type.name] = prop
setattr(ShotTasks, task_type.name, prop)
class VSETB_UL_casting(UIList):
@ -561,6 +575,7 @@ class VSETB_PGT_strip_settings(PropertyGroup):
source_name : StringProperty(name='')
metadata : PointerProperty(type=Metadata)
description : StringProperty()
tasks: PointerProperty(type=ShotTasks)
@property
def active_casting(self):
@ -600,6 +615,8 @@ classes = (
Metadata,
MetadataType,
TaskType,
ShotTasks,
ShotTask,
SpreadsheetImport,
SpreadsheetExport,
Project,