[Bf-blender-cvs] [4d146bd] master: Fix T45689: Pose Libraries cannot be used when using lib-linked actions as poselibs

Joshua Leung noreply at git.blender.org
Sat Aug 22 08:17:20 CEST 2015


Commit: 4d146bdf13090008e6d3c552eb2fadc12c206369
Author: Joshua Leung
Date:   Sat Aug 22 18:16:55 2015 +1200
Branches: master
https://developer.blender.org/rB4d146bdf13090008e6d3c552eb2fadc12c206369

Fix T45689: Pose Libraries cannot be used when using lib-linked actions as poselibs

This commit makes some tweaks that make it at least possible to use lib-linked
actions as Pose Libraries. Specifically:
* The apply poses button is no longer greyed out

* It is possible to select different poses from the list of poses

* All pose library operators which edit the poses stored in the poselib
  now have improved poll callbacks which perform extra checks for lib-linked
  actions (which cannot be edited, as all those changes will be lost)


Caveats:
* Due to the way the UI list template works, it doesn't seem to be possible to
  make it not grey out the items in the list. (While the double-click to rename
  thing shouldn't be allowed, items should at least look like they can be clicked on)

* The difference between clickable vs not-clickable isn't too great, making it hard
  to tell that that while the Add/Remove/Sanitise toggles are not usable,
  the Apply Poses is actually functional. But, this is a more of a  UI-toolbox
  level issue

===================================================================

M	release/scripts/startup/bl_ui/properties_data_armature.py
M	source/blender/editors/armature/pose_lib.c
M	source/blender/makesrna/intern/rna_action.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py
index 84e06d4..3c9e2eb 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -186,7 +186,6 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
             # column of operators for active pose
             # - goes beside list
             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
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 31e6c8c..a984e5d 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -177,6 +177,15 @@ static int has_poselib_pose_data_poll(bContext *C)
 	return (ob && ob->poselib);
 }
 
+/* Poll callback for operators that require existing PoseLib data (with poses)
+ * as they need to do some editing work on those poses (i.e. not on lib-linked actions)
+ */
+static int has_poselib_pose_data_for_editing_poll(bContext *C)
+{
+	Object *ob = get_poselib_object(C);
+	return (ob && ob->poselib && !ob->poselib->id.lib);
+}
+
 /* ----------------------------------- */
 
 /* Initialize a new poselib (whether it is needed or not) */
@@ -357,7 +366,7 @@ void POSELIB_OT_action_sanitize(wmOperatorType *ot)
 	
 	/* callbacks */
 	ot->exec = poselib_sanitize_exec;
-	ot->poll = has_poselib_pose_data_poll;
+	ot->poll = has_poselib_pose_data_for_editing_poll;
 	
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -365,6 +374,25 @@ void POSELIB_OT_action_sanitize(wmOperatorType *ot)
 
 /* ------------------------------------------ */
 
+/* Poll callback for adding poses to a PoseLib */
+static int poselib_add_poll(bContext *C)
+{
+	/* There are 2 cases we need to be careful with:
+	 *  1) When this operator is invoked from a hotkey, there may be no PoseLib yet
+	 *  2) If a PoseLib already exists, we can't edit the action if it is a lib-linked
+	 *     actions, as data will be lost when saving the file
+	 */
+	if (ED_operator_posemode(C)) {
+		Object *ob = get_poselib_object(C);
+		if (ob) {
+			if ((ob->poselib == NULL) || (ob->poselib->id.lib == 0)) {
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
 static void poselib_add_menu_invoke__replacemenu(bContext *C, uiLayout *layout, void *UNUSED(arg))
 {
 	Object *ob = get_poselib_object(C);
@@ -488,7 +516,7 @@ void POSELIB_OT_pose_add(wmOperatorType *ot)
 	/* api callbacks */
 	ot->invoke = poselib_add_menu_invoke;
 	ot->exec = poselib_add_exec;
-	ot->poll = ED_operator_posemode;
+	ot->poll = poselib_add_poll;
 	
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -604,7 +632,7 @@ void POSELIB_OT_pose_remove(wmOperatorType *ot)
 	/* api callbacks */
 	ot->invoke = WM_menu_invoke;
 	ot->exec = poselib_remove_exec;
-	ot->poll = has_poselib_pose_data_poll;
+	ot->poll = has_poselib_pose_data_for_editing_poll;
 	
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -692,7 +720,7 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot)
 	/* api callbacks */
 	ot->invoke = poselib_rename_invoke;
 	ot->exec = poselib_rename_exec;
-	ot->poll = has_poselib_pose_data_poll;
+	ot->poll = has_poselib_pose_data_for_editing_poll;
 	
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index 424e200..b8a490e 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -650,13 +650,14 @@ static void rna_def_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop)
 	
 	prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
 	RNA_def_property_struct_type(prop, "TimelineMarker");
-	RNA_def_property_flag(prop, PROP_EDITABLE);
+	RNA_def_property_flag(prop, PROP_EDITABLE | PROP_LIB_EXCEPTION);
 	RNA_def_property_pointer_funcs(prop, "rna_Action_active_pose_marker_get",
 	                               "rna_Action_active_pose_marker_set", NULL, NULL);
 	RNA_def_property_ui_text(prop, "Active Pose Marker", "Active pose marker for this action");
 	
 	prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
 	RNA_def_property_int_sdna(prop, NULL, "active_marker");
+	RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
 	RNA_def_property_int_funcs(prop, "rna_Action_active_pose_marker_index_get",
 	                           "rna_Action_active_pose_marker_index_set", "rna_Action_active_pose_marker_index_range");
 	RNA_def_property_ui_text(prop, "Active Pose Marker Index", "Index of active pose marker");
@@ -688,6 +689,7 @@ static void rna_def_action(BlenderRNA *brna)
 	prop = RNA_def_property(srna, "pose_markers", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "markers", NULL);
 	RNA_def_property_struct_type(prop, "TimelineMarker");
+	RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); /* T45689 - so that the list isn't greyed out; adding/removing is still banned though */
 	RNA_def_property_ui_text(prop, "Pose Markers", "Markers specific to this action, for labeling poses");
 	rna_def_action_pose_markers(brna, prop);




More information about the Bf-blender-cvs mailing list