Page Menu
Home
Search
Configure Global Search
Log In
Files
F11036
poselib-20101213-1.diff
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Jason van Gumster (thefallenweeble)
Nov 13 2013, 2:20 PM
Size
4 KB
Subscribers
None
poselib-20101213-1.diff
View Options
Index: release/scripts/ui/properties_data_armature.py
===================================================================
--- release/scripts/ui/properties_data_armature.py (revision 33643)
+++ release/scripts/ui/properties_data_armature.py (working copy)
@@ -156,6 +156,40 @@
sub.operator("pose.group_deselect", text="Deselect")
+# This is slapdash, but at least it mostly works as a start.
+# TODO:
+# *Datablock drop-down doesn't actually switch between poselib actions
+# *Datablock X doesn't delete poselib
+# *Add button only works if you only have a pose selected in the list and it only adds a single pose ('Pose.000')
+# *Remove button needs to work on selected poses
+class DATA_PT_pose_libraries(ArmatureButtonsPanel, bpy.types.Panel):
+ bl_label = "Pose Libraries"
+
+ @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
+ pose = ob.pose
+ poselib = ob.pose_library
+
+ layout.operator_context = 'EXEC_DEFAULT'
+ split = layout.split(percentage=0.65)
+ split.template_ID(ob, "pose_library", new="poselib.new")
+
+ if poselib:
+ posemark = poselib.pose_markers[0]
+ row = layout.row()
+ row.template_list(poselib, "pose_markers", posemark, "frame", rows=2)
+ col = row.column(align=True)
+ col.active = (ob.proxy is None)
+ col.operator("poselib.pose_add", icon='ZOOMIN', text="")
+ col.operator("poselib.pose_remove", icon='ZOOMOUT', text="")
+
+
# TODO: this panel will soon be depreceated too
class DATA_PT_ghost(ArmatureButtonsPanel, bpy.types.Panel):
bl_label = "Ghost"
Index: source/blender/editors/armature/armature_ops.c
===================================================================
--- source/blender/editors/armature/armature_ops.c (revision 33643)
+++ source/blender/editors/armature/armature_ops.c (working copy)
@@ -141,6 +141,7 @@
/* POSELIB */
WM_operatortype_append(POSELIB_OT_browse_interactive);
+ WM_operatortype_append(POSELIB_OT_new);
WM_operatortype_append(POSELIB_OT_pose_add);
WM_operatortype_append(POSELIB_OT_pose_remove);
WM_operatortype_append(POSELIB_OT_pose_rename);
Index: source/blender/editors/armature/armature_intern.h
===================================================================
--- source/blender/editors/armature/armature_intern.h (revision 33643)
+++ source/blender/editors/armature/armature_intern.h (working copy)
@@ -169,6 +169,7 @@
/* PoseLib */
/* poselib.c */
+void POSELIB_OT_new(struct wmOperatorType *ot);
void POSELIB_OT_pose_add(struct wmOperatorType *ot);
void POSELIB_OT_pose_remove(struct wmOperatorType *ot);
void POSELIB_OT_pose_rename(struct wmOperatorType *ot);
Index: source/blender/editors/armature/poselib.c
===================================================================
--- source/blender/editors/armature/poselib.c (revision 33643)
+++ source/blender/editors/armature/poselib.c (working copy)
@@ -400,6 +400,60 @@
RNA_def_string(ot->srna, "name", "Pose", 64, "Pose Name", "Name of newly added Pose");
}
+/* Hacky addition of new poselib functions and operators */
+static int poselib_new_exec (bContext *C, wmOperator *op)
+{
+ Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
+ bArmature *arm= (ob) ? ob->data : NULL;
+ bPose *pose= (ob) ? ob->pose : NULL;
+ bAction *poselib;
+ PointerRNA ptr, idptr;
+ PropertyRNA *prop;
+
+ /* sanity check */
+ if (ELEM3(NULL, ob, arm, pose))
+ return OPERATOR_CANCELLED;
+
+ poselib = poselib_init_new(ob);
+
+ /* hook into UI */
+ uiIDContextProperty(C, &ptr, &prop);
+
+ if(prop) {
+ /* when creating new ID blocks, use is already 1, but RNA
+ * pointer se also increases user, so this compensates it */
+ poselib->id.us--;
+
+ RNA_id_pointer_create(&poselib->id, &idptr);
+ RNA_property_pointer_set(&ptr, prop, idptr);
+ RNA_property_update(C, &ptr, prop);
+ }
+
+ poselib_add_exec(C, op);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, poselib);
+
+ return OPERATOR_FINISHED;
+}
+
+void POSELIB_OT_new (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "PoseLib Add New PoseLib";
+ ot->idname= "POSELIB_OT_new";
+ ot->description= "Create a New Pose Library";
+
+ /* api callbacks */
+ ot->exec= poselib_new_exec;
+ ot->poll= ED_operator_posemode;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_int(ot->srna, "frame", 1, 0, INT_MAX, "Frame", "Frame to store pose on", 0, INT_MAX);
+ RNA_def_string(ot->srna, "name", "Pose", 64, "Pose Name", "Name of newly added Pose");
+}
+
/* ----- */
static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free)
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
cf/20/c256f4580040683ea0f15580ba39
Event Timeline
Log In to Comment