Remove menu handler and refactor add/replace menu
This commit is contained in:
26
gui.py
26
gui.py
@ -125,7 +125,7 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
||||
# Pose operators
|
||||
pose_ops_layout = pose_list_entries_layout.column(align=True)
|
||||
pose_ops_layout.operator(
|
||||
"dspl.draw_new_pose_menu", icon='ADD', text="")
|
||||
"wm.call_menu", icon='ADD', text="").name = "OBJECT_MT_AddPoseMenu"
|
||||
if active_pose_library.pose_markers.active:
|
||||
pose_ops_layout.operator(
|
||||
"dspl.remove_pose", icon='REMOVE', text="")
|
||||
@ -157,15 +157,31 @@ class OBJECT_MT_AddPoseMenu(bpy.types.Menu):
|
||||
|
||||
dspl_add_menu_layout = self.layout
|
||||
dspl_add_menu_layout.operator(
|
||||
"dspl.draw_new_pose_menu", icon='DECORATE_DRIVER', text="Add New Pose")
|
||||
if action_object.pose_markers.active:
|
||||
dspl_add_menu_layout.operator(
|
||||
"dspl.add_pose", icon='DECORATE_OVERRIDE', text="Replace Existing Pose").replace = True
|
||||
"dspl.add_pose", icon='ADD', text="Add New Pose").posename = arm_object.dsplvars.pose_new_name
|
||||
if len(action_object.pose_markers):
|
||||
dspl_add_menu_layout.menu(
|
||||
"OBJECT_MT_ReplacePoseMenu", text="Replace Existing Pose", icon="DECORATE_OVERRIDE")
|
||||
|
||||
|
||||
class OBJECT_MT_ReplacePoseMenu(bpy.types.Menu):
|
||||
bl_idname = "OBJECT_MT_ReplacePoseMenu"
|
||||
bl_label = "Add Pose"
|
||||
|
||||
def draw(self, context):
|
||||
arm_object = getArmatureObject(context)
|
||||
action_object = getPoseLib(context)
|
||||
|
||||
dspl_replace_menu_layout = self.layout
|
||||
for pm in action_object.pose_markers:
|
||||
op = dspl_replace_menu_layout.operator("dspl.add_pose", text=pm.name, icon="PMARKER")
|
||||
op.replace = True
|
||||
op.posename = pm.name
|
||||
|
||||
|
||||
classes = (
|
||||
DATA_PT_DSPLPanel,
|
||||
OBJECT_MT_AddPoseMenu,
|
||||
OBJECT_MT_ReplacePoseMenu,
|
||||
)
|
||||
|
||||
|
||||
|
51
operators.py
51
operators.py
@ -38,54 +38,6 @@ class DSPL_OT_ConvertPoseLibrary(bpy.types.Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
# Operator to to draw a menu for new poses
|
||||
|
||||
|
||||
class DSPL_OT_DrawNewPoseMenu(bpy.types.Operator):
|
||||
bl_idname = "dspl.draw_new_pose_menu"
|
||||
bl_label = "New Pose Menu"
|
||||
bl_description = "New Pose Menu"
|
||||
bl_options = {'INTERNAL'}
|
||||
|
||||
def execute(self, context):
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
return context.window_manager.invoke_popup(self, width=200)
|
||||
|
||||
def draw(self, context):
|
||||
dspl_create_popup_layout = self.layout
|
||||
dspl_new_pose_menu = dspl_create_popup_layout.box()
|
||||
|
||||
arm_object = getArmatureObject(context)
|
||||
pose_library = getPoseLib(context)
|
||||
dspl_new_pose_menu.prop(
|
||||
arm_object.dsplvars, "pose_new_name", text="Name")
|
||||
# dspl_new_pose_menu.prop(
|
||||
# # Might want to add this back in some form to match native copy/paste pose
|
||||
# arm_object.dsplvars,
|
||||
# "only_selected", icon='GROUP_BONE', text="Selected", toggle=True)
|
||||
dspl_new_pose_menu.operator(
|
||||
"dspl.add_pose", icon='ADD', text="Add New Pose").posename = arm_object.dsplvars.pose_new_name
|
||||
|
||||
|
||||
# Operator to call up popup menus by ID
|
||||
|
||||
|
||||
class DSPL_OT_CallPopupMenu(bpy.types.Operator):
|
||||
bl_idname = "dspl.call_popup_menu"
|
||||
bl_label = "Popup menu"
|
||||
bl_description = "Popup menu"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
menuID: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
bpy.ops.wm.call_menu(name=self.menuID)
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
# Operator to manage the big menu buttons
|
||||
|
||||
|
||||
@ -174,7 +126,7 @@ class DSPL_OT_AddPose(bpy.types.Operator):
|
||||
action_object = getPoseLib(context)
|
||||
pose_markers = action_object.pose_markers
|
||||
active_marker = pose_markers.active
|
||||
new_name = active_marker.name
|
||||
new_name = self.posename
|
||||
counter = 1
|
||||
|
||||
for pm in pose_markers:
|
||||
@ -533,7 +485,6 @@ classes = (
|
||||
DSPL_OT_CreatePoseLibrary,
|
||||
DSPL_OT_ConvertPoseLibrary,
|
||||
DSPL_OT_CallPopupMenu,
|
||||
DSPL_OT_DrawNewPoseMenu,
|
||||
DSPL_OT_MenuButtonHandler,
|
||||
DSPL_OT_AddPose,
|
||||
DSPL_OT_RemovePose,
|
||||
|
Reference in New Issue
Block a user