From 147309e3c5b2047ee1017af7a810539f1514007d Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 16 Feb 2011 00:17:22 +0000 Subject: Pose Lib: Start of PoseLib UI in Armature buttons This presents a UI from which PoseLibs can be assigned/removed from Objects. From here, it is also possible to see the list of poses and add/remove poses from this list. Known Issues: - [Py/RNA/Operators BUG ALERT!] If after immediately starting Blender you try to remove a pose from the PoseLib using the UI buttons, you'll get a an error the first time you do so (but not for subsequent attempts). This seems to be caused by the "pose" enum (dynamically generated) of the POSELIB_OT_pose_remove operator, which does not seem to be getting initialised when the operator's exec gets called without the invoke having been called previously - Changing the active Pose Library still seems to be broken (to be fixed soon) Todos: - Operator button to make the selected pose get shown in the 3d view - Restore the "validate action" operator and add that to this panel - Rename pose access --- release/scripts/ui/properties_data_armature.py | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'release') diff --git a/release/scripts/ui/properties_data_armature.py b/release/scripts/ui/properties_data_armature.py index 6550e1bb1ed..566cf1dc3cc 100644 --- a/release/scripts/ui/properties_data_armature.py +++ b/release/scripts/ui/properties_data_armature.py @@ -154,6 +154,51 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, bpy.types.Panel): sub.operator("pose.group_deselect", text="Deselect") +class DATA_PT_pose_library(ArmatureButtonsPanel, bpy.types.Panel): + bl_label = "Pose Library" + bl_options = {'DEFAULT_CLOSED'} + + @classmethod + def poll(cls, context): + return (context.object and context.object.type == 'ARMATURE' and context.object.pose) + + def draw(self, context): + layout = self.layout + + ob = context.object + poselib = ob.pose_library + + row = layout.row() + row.template_ID(ob, "pose_library", new="poselib.new", unlink="poselib.unlink") + + if poselib: + activePoseIndex = poselib.pose_markers.active_index + if len(poselib.pose_markers): + activePose = poselib.pose_markers[activePoseIndex] + activePoseName = activePose.name if activePose else None + else: + activePose = None + activePoseName = None + + row = layout.row() + row.template_list(poselib, "pose_markers", poselib.pose_markers, "active_index", rows=5) + + col = row.column(align=True) + col.active = (poselib.library is None) + + # invoke should still be used for 'add', as it is needed to allow + # add/replace options to be used properly + col.operator("poselib.pose_add", icon='ZOOMIN', text="") + + col.operator_context = 'EXEC_DEFAULT' # exec not invoke, so that menu doesn't need showing + col.operator("poselib.pose_remove", icon='ZOOMOUT', text="").pose = activePoseName + + # TODO: + # - show selected pose in 3d-view using browse op... + # - rename selected pose... + + # TODO: "validate action" operator to be restored + # TODO: this panel will soon be depreceated too class DATA_PT_ghost(ArmatureButtonsPanel, bpy.types.Panel): bl_label = "Ghost" -- cgit v1.2.3