From b58f837a9460cc648ede4e686cdd63c953c3e9d1 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sat, 28 Jan 2023 11:15:41 +0800 Subject: [PATCH] [feat] add confirm window for some dangerous opers - add clear oper in Virtools group panel. - add confirm window for clear Virtools groups opers. both panel and context menu. --- ballance_blender_plugin/OBJS_group_opers.py | 7 ++++-- .../PROPS_virtools_group.py | 24 ++++++++++++++++++- ballance_blender_plugin/__init__.py | 1 + 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ballance_blender_plugin/OBJS_group_opers.py b/ballance_blender_plugin/OBJS_group_opers.py index 1491945..d611bfe 100644 --- a/ballance_blender_plugin/OBJS_group_opers.py +++ b/ballance_blender_plugin/OBJS_group_opers.py @@ -169,11 +169,14 @@ class BALLANCE_OT_ctx_clear_group(bpy.types.Operator): def poll(self, context): return len(bpy.context.selected_objects) != 0 + def invoke(self, context, event): + wm = context.window_manager + return wm.invoke_confirm(self, event) + def execute(self, context): # iterate object for obj in bpy.context.selected_objects: UTILS_virtools_prop.clear_virtools_group_data(obj) - - + return {'FINISHED'} diff --git a/ballance_blender_plugin/PROPS_virtools_group.py b/ballance_blender_plugin/PROPS_virtools_group.py index 35bd9eb..be77f3e 100644 --- a/ballance_blender_plugin/PROPS_virtools_group.py +++ b/ballance_blender_plugin/PROPS_virtools_group.py @@ -44,9 +44,29 @@ class BALLANCE_OT_rm_virtools_group(bpy.types.Operator): UTILS_virtools_prop.remove_virtools_group_data_by_index(obj, int(UTILS_virtools_prop.get_active_virtools_group(obj))) return {'FINISHED'} +class BALLANCE_OT_clear_virtools_group(bpy.types.Operator): + """Clear All Virtools Group for Active Object.""" + bl_idname = "ballance.clear_virtools_group" + bl_label = "Clear Virtools Group" + bl_options = {'UNDO'} + + @classmethod + def poll(self, context): + return context.object is not None + + def invoke(self, context, event): + wm = context.window_manager + return wm.invoke_confirm(self, event) + + def execute(self, context): + obj = context.object + UTILS_virtools_prop.clear_virtools_group_data(obj) + return {'FINISHED'} + class BALLANCE_UL_virtools_group(bpy.types.UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): - layout.prop(item, 'group_name', icon='GROUP', emboss=False, text="") + layout.label(text=item.group_name, translate=False, icon='GROUP') + #layout.prop(item, 'group_name', icon='GROUP', emboss=False, text="") class BALLANCE_PT_virtools_group(bpy.types.Panel): """Show Virtools Group Properties.""" @@ -71,3 +91,5 @@ class BALLANCE_PT_virtools_group(bpy.types.Panel): col = row.column(align=True) col.operator(BALLANCE_OT_add_virtools_group.bl_idname, icon='ADD', text="") col.operator(BALLANCE_OT_rm_virtools_group.bl_idname, icon='REMOVE', text="") + col.separator() + col.operator(BALLANCE_OT_clear_virtools_group.bl_idname, icon='TRASH', text="") diff --git a/ballance_blender_plugin/__init__.py b/ballance_blender_plugin/__init__.py index 4a6eec1..1d30311 100644 --- a/ballance_blender_plugin/__init__.py +++ b/ballance_blender_plugin/__init__.py @@ -150,6 +150,7 @@ classes = ( UTILS_virtools_prop.BALLANCE_PG_virtools_group, PROPS_virtools_group.BALLANCE_OT_add_virtools_group, PROPS_virtools_group.BALLANCE_OT_rm_virtools_group, + PROPS_virtools_group.BALLANCE_OT_clear_virtools_group, PROPS_virtools_group.BALLANCE_UL_virtools_group, PROPS_virtools_group.BALLANCE_PT_virtools_group, PROPS_virtools_material.BALLANCE_OT_apply_virtools_material,