diff --git a/context.py b/context.py index f1b8e5b..155cec1 100644 --- a/context.py +++ b/context.py @@ -45,18 +45,18 @@ class BW_context: if ops and ops[-1].bl_idname == op_idname: return ops[-1] - @property - def show_prefs_op(self): - ops = bpy.context.window_manager.operators - id_names = [ - self.get_op_id('show_preferences'), - self.get_op_id('add_folder'), - self.get_op_id('remove_folder') - ] + # @property + # def show_prefs_op(self): + # ops = bpy.context.window_manager.operators + # id_names = [ + # self.get_op_id('show_preferences'), + # self.get_op_id('add_folder'), + # self.get_op_id('remove_folder') + # ] - #transforms = self.prefs.transforms - if ops and ops[-1].bl_idname in id_names: - return True + # #transforms = self.prefs.transforms + # if ops and ops[-1].bl_idname in id_names: + # return True @property def category(self): diff --git a/operators.py b/operators.py index d15ead9..2c2fa07 100644 --- a/operators.py +++ b/operators.py @@ -381,15 +381,15 @@ class BW_OT_rename_folder(Operator): return wm.invoke_props_dialog(self) -class BW_OT_show_preferences(Operator): - """Display the preferences to the tab panel""" - bl_idname = 'bonewidget.show_preferences' - bl_label = "Show Preferences" - bl_options = {'REGISTER'} +# class BW_OT_show_preferences(Operator): +# """Display the preferences to the tab panel""" +# bl_idname = 'bonewidget.show_preferences' +# bl_label = "Show Preferences" +# bl_options = {'REGISTER'} - def execute(self, context): - #ctx.init_transforms() - return {'FINISHED'} +# def execute(self, context): +# #ctx.init_transforms() +# return {'FINISHED'} class BW_OT_transform_widget(Operator): @@ -749,7 +749,7 @@ classes = ( BW_OT_add_widget, BW_OT_remove_widget, BW_OT_clean_widget, - BW_OT_show_preferences, + # BW_OT_show_preferences, BW_OT_copy_widgets, BW_OT_paste_widgets, BW_OT_copy_bone_groups, diff --git a/properties.py b/properties.py index 0d486b9..25eaa40 100644 --- a/properties.py +++ b/properties.py @@ -207,6 +207,8 @@ class BW_prefs(AddonPreferences): folder_index: IntProperty() folder_enum: EnumProperty(name='Folders', items=lambda s,c: ctx.folder_items) collection: StringProperty(name='Collection', default='Widgets', description='Name of the widget collection use {ob.name} to include the name of the rig') + use_custom_collection: BoolProperty(name='Custom Collection', default=False, description='Allow to pick a collection from the scene') + prefix: StringProperty(name='Prefix', default='WGT-', description='Prefix for the shape object and data name') category: StringProperty(name='Tab', default='Rigging', update=lambda s,c: update_tab()) @@ -216,6 +218,7 @@ class BW_prefs(AddonPreferences): rename: BoolProperty(default=True, name="Rename", update=undo_redo) show_transforms: BoolProperty(default=False) + show_preferences: BoolProperty(default=False) transforms: PointerProperty(type=BW_PG_transforms) #grid_view: BoolProperty(name='Grid View', default=True) @@ -240,7 +243,7 @@ def register(): for cls in classes: bpy.utils.register_class(cls) - #bpy.types.Armature.widget_collection = PointerProperty(type=bpy.types.Collection) + bpy.types.Armature.widget_collection = PointerProperty(type=bpy.types.Collection) #update_folder_items() @@ -250,7 +253,7 @@ def unregister(): #for f in ctx.folders: # bpy.utils.previews.remove(f.icons) - #del bpy.types.Armature.widget_collection + del bpy.types.Armature.widget_collection for cls in classes: bpy.utils.unregister_class(cls) \ No newline at end of file diff --git a/ui.py b/ui.py index 14c7721..d2bfda7 100644 --- a/ui.py +++ b/ui.py @@ -65,6 +65,7 @@ def draw_prefs(layout): add_row(col, 'category', name='Tab', icon='COPY_ID') add_row(col, 'collection', name='Collection', icon='OUTLINER_COLLECTION') + add_row(col, 'use_custom_collection', name='Custom Collection', icon='OUTLINER_COLLECTION') add_row(col, 'prefix', name='Prefix', icon='SYNTAX_OFF') col.separator() @@ -141,7 +142,7 @@ class BW_MT_folder(Menu): #layout.operator("bonewidget.rename_folder", icon='SYNTAX_OFF') layout.operator('bonewidget.refresh_folders', icon='FILE_REFRESH') layout.operator('bonewidget.remove_unused_shape', icon='TRASH') - layout.operator('bonewidget.show_preferences', icon='PREFERENCES') + #layout.operator('bonewidget.show_preferences', icon='PREFERENCES') layout.operator('bonewidget.copy_widgets', icon='COPYDOWN') layout.operator('bonewidget.paste_widgets', icon='PASTEDOWN') @@ -220,6 +221,9 @@ class BW_PT_main(Panel): op_col.scale_y = 1.5 op_col.operator('bonewidget.transform_widget', icon='EMPTY_ARROWS', text='') # op_col.operator('bonewidget.clean_widget', icon='SHADERFX', text='') + + op_col.separator() + tool_col.prop(ctx.prefs, 'show_preferences', icon='PREFERENCES', text='') folder = ctx.active_folder widget_col = row.column(align=True) @@ -234,7 +238,7 @@ class BW_PT_main(Panel): if folder: widget_col.template_list('BW_UL_widget', 'BW_widgets', folder, 'widgets', folder, 'widget_index', - rows=5, columns=self.get_nb_col(context), type='DEFAULT') + rows=6, columns=self.get_nb_col(context), type='DEFAULT') #widget_col.template_list('UI_UL_list', 'BW_widgets', folder, 'widgets', folder, 'widget_index', rows=4) #layout.prop(self, 'folder_enum') @@ -244,6 +248,12 @@ class BW_PT_main(Panel): else: edit_row.operator('bonewidget.create_widget', text='Create') edit_row.operator('bonewidget.edit_widget', text='Edit') + + if ctx.prefs.use_custom_collection and ctx.rig: + widget_col.separator() + row = widget_col.row() + row.use_property_split = True + row.prop(ctx.rig.data, 'widget_collection', text='Widget Collection') if ctx.show_transforms: data = context.window_manager.operators[-1].properties @@ -269,7 +279,7 @@ class BW_PT_main(Panel): #layout.separator() #opt_col = layout.column() - elif ctx.show_prefs_op: + elif ctx.prefs.show_preferences: #layout.separator() draw_prefs(layout)