Ui improvment

pull/5/head
Clément Ducarteron 2023-03-17 22:55:06 +01:00
parent c518ccf2b4
commit 3e8cfec634
3 changed files with 70 additions and 11 deletions

View File

@ -54,6 +54,26 @@ def norm_str(string, separator='_', format=str.lower, padding=0):
return string return string
def norm_name(string, separator='_', format=str.lower, padding=0):
string = str(string)
string = string.split('/')[-1] #used to remove first slash -> albert / albert_casque -> albert_casque
string = string.replace('_', ' ')
string = string.replace('-', ' ')
string = re.sub('[ ]+', ' ', string)
string = re.sub('[ ]+\/[ ]+', '/', string)
string = string.strip()
if format:
string = format(string)
# Padd rightest number
string = re.sub(r'(\d+)(?!.*\d)', lambda x : x.group(1).zfill(padding), string)
string = string.replace(' ', separator)
string = unicodedata.normalize('NFKD', string).encode('ASCII', 'ignore').decode("utf-8")
return string
def read_file(path): def read_file(path):
'''Read a file with an extension in (json, yaml, yml, txt)''' '''Read a file with an extension in (json, yaml, yml, txt)'''

View File

@ -39,7 +39,7 @@ from vse_toolbox.sequencer_utils import (
set_channels, set_channels,
) )
from vse_toolbox.bl_utils import get_addon_prefs, get_settings from vse_toolbox.bl_utils import get_addon_prefs, get_settings
from vse_toolbox.file_utils import install_module, norm_str from vse_toolbox.file_utils import install_module, norm_name, norm_str
class VSETB_OT_export_csv(Operator): class VSETB_OT_export_csv(Operator):
bl_idname = "sequencer.export_csv" bl_idname = "sequencer.export_csv"
@ -102,8 +102,34 @@ class VSETB_OT_auto_select_files(Operator):
return {'FINISHED'} return {'FINISHED'}
class VSETB_OT_import(Operator): # class VSETB_OT_select_file(Operator):
bl_idname = "sequencer.import" # bl_idname = "import.select_file"
# bl_label = "Select File"
# bl_description = "Select Active as File"
# bl_options = {"REGISTER", "UNDO"}
# type : StringProperty('')
# @classmethod
# def poll(cls, context):
# return True
# def execute(self, context):
# params = context.space_data.params
# print(params.filename)
# if self.type == 'edit':
# bpy.ops.sequencer.import_files(edit=params.filename)
# elif self.type == 'movie':
# bpy.ops.sequencer.import_files(movie=params.filename)
# elif self.type == 'sound':
# bpy.ops.sequencer.import_files(sound=params.filename)
# return {'FINISHED'}
class VSETB_OT_import_files(Operator):
bl_idname = "sequencer.import_files"
bl_label = "Import" bl_label = "Import"
bl_description = "Import Edit" bl_description = "Import Edit"
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
@ -116,7 +142,6 @@ class VSETB_OT_import(Operator):
subtype='FILE_PATH', subtype='FILE_PATH',
) )
files : CollectionProperty(type=bpy.types.OperatorFileListElement) files : CollectionProperty(type=bpy.types.OperatorFileListElement)
clean_sequencer : BoolProperty( clean_sequencer : BoolProperty(
name="Clean Sequencer", name="Clean Sequencer",
default=False, default=False,
@ -149,21 +174,27 @@ class VSETB_OT_import(Operator):
row = self.layout.row(heading="Import Edit", align=True) row = self.layout.row(heading="Import Edit", align=True)
row.prop(self, 'import_edit') row.prop(self, 'import_edit')
sub = row.row() sub = row.row(align=True)
sub.active = self.import_edit sub.active = self.import_edit
sub.prop(self, 'edit') sub.prop(self, 'edit')
# op = sub.operator('import.select_file', text="", icon='EYEDROPPER')
# op.type = 'edit'
row = self.layout.row(heading="Import Movie", align=True) row = self.layout.row(heading="Import Movie", align=True)
row.prop(self, 'import_movie') row.prop(self, 'import_movie')
sub = row.row() sub = row.row()
sub.active = self.import_movie sub.active = self.import_movie
sub.prop(self, 'movie') sub.prop(self, 'movie')
# op = sub.operator('import.select_file', text="", icon='EYEDROPPER')
# op.type = 'movie'
row = self.layout.row(heading="Import Sound", align=True) row = self.layout.row(heading="Import Sound", align=True)
row.prop(self, 'import_sound') row.prop(self, 'import_sound')
sub = row.row() sub = row.row()
sub.active = self.import_sound sub.active = self.import_sound
sub.prop(self, 'sound') sub.prop(self, 'sound')
# op = sub.operator('import.select_file', text="", icon='EYEDROPPER')
# op.type = 'sound'
col = layout.column() col = layout.column()
col.separator() col.separator()
@ -230,10 +261,16 @@ class VSETB_OT_load_assets(Operator):
def get_items(self, items=[]): def get_items(self, items=[]):
if not items: if not items:
return [('NONE', 'None', '', 0)] return [('NONE', 'None', '', 0)]
item_sorted = [(e.name, e.name, '', i) for i, e in enumerate(sorted(items, key=lambda x:x.name))]
return item_sorted
icons = {
'camera':'CAMERA_DATA',
'chars':'COMMUNITY',
'props':'OBJECT_DATAMODE',
'sets':'SMOOTHCURVE',
}
# return [(e.name, e.norm_name, '', i) for i, e in enumerate(items)]
return [(e.name, e.name, '', icons[e.asset_type], i) for i, e in enumerate(items)]
def execute(self, context): def execute(self, context):
settings = get_settings() settings = get_settings()
prefs = get_addon_prefs() prefs = get_addon_prefs()
@ -249,6 +286,7 @@ class VSETB_OT_load_assets(Operator):
for asset_data in assets: for asset_data in assets:
asset = project.assets.add() asset = project.assets.add()
asset.name = asset_data['name'] asset.name = asset_data['name']
# asset.norm_name = norm_name(asset_data['name'], separator=' ', format=str.title)
asset.id = asset_data['id'] asset.id = asset_data['id']
asset.asset_type = asset_data['asset_type'] asset.asset_type = asset_data['asset_type']
@ -578,13 +616,14 @@ classes=(
VSETB_OT_casting_add, VSETB_OT_casting_add,
VSETB_OT_casting_actions, VSETB_OT_casting_actions,
VSETB_OT_export_csv, VSETB_OT_export_csv,
VSETB_OT_import, VSETB_OT_import_files,
VSETB_OT_load_assets, VSETB_OT_load_assets,
VSETB_OT_load_projects, VSETB_OT_load_projects,
VSETB_OT_new_episode, VSETB_OT_new_episode,
VSETB_OT_reload_addon, VSETB_OT_reload_addon,
VSETB_OT_rename, VSETB_OT_rename,
VSETB_OT_render, VSETB_OT_render,
# VSETB_OT_select_file,
VSETB_OT_set_scene, VSETB_OT_set_scene,
) )

View File

@ -52,10 +52,10 @@ class VSETB_PT_main(VSETB_main, Panel):
col.separator() col.separator()
col.operator('vse_toolbox.new_episode', text='Add Episode', icon='IMPORT') col.operator('vse_toolbox.new_episode', text='Add Episode', icon='IMPORT')
# TODO FAIRE DES VRAIS OPS
col = layout.column() col = layout.column()
row = col.row(align=True) row = col.row(align=True)
row.operator('sequencer.import', text='Import', icon='IMPORT') row.operator('sequencer.import_files', text='Import', icon='IMPORT')
# TODO FAIRE DES VRAIS OPS
row.operator('sequencer.export_csv', text='Export', icon='EXPORT') row.operator('sequencer.export_csv', text='Export', icon='EXPORT')
op = col.operator('sequencer.strips_render', text='Render Strips', icon='RENDER_ANIMATION') op = col.operator('sequencer.strips_render', text='Render Strips', icon='RENDER_ANIMATION')