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
This commit is contained in:
parent
79e3a27c7a
commit
4d146bdf13
Notes:
blender-bot
2023-02-14 08:48:36 +01:00
Referenced by issue #45689, Proxy of armature, applying poses greyed out
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue