diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2021-01-18 17:02:24 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2021-01-18 17:02:24 +0300 |
commit | 023ebb890b760f4d6e7bcaa4848e5f5339ac1321 (patch) | |
tree | 0b37923cc2103894b7d60900e7b577dfff0343df | |
parent | a1fb3dc7aeb939eed084aa998193536ac2198f6a (diff) | |
parent | 1c2b2037956bf1d46a10842a4b503d20714bdcf2 (diff) |
Merge branch 'blender-v2.92-release'
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_armature.py | 2 | ||||
-rw-r--r-- | source/blender/editors/armature/pose_group.c | 27 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_pose.c | 31 |
3 files changed, 50 insertions, 10 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index 05abfa02500..4cdcab45926 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -133,7 +133,6 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel): ) col = row.column(align=True) - col.active = (ob.proxy is None) col.operator("pose.group_add", icon='ADD', text="") col.operator("pose.group_remove", icon='REMOVE', text="") col.menu("DATA_MT_bone_group_context_menu", icon='DOWNARROW_HLT', text="") @@ -156,7 +155,6 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel): sub.prop(group.colors, "active", text="") row = layout.row() - row.active = (ob.proxy is None) sub = row.row(align=True) sub.operator("pose.group_assign", text="Assign") diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c index 1e5004ba341..6ef46a792c4 100644 --- a/source/blender/editors/armature/pose_group.c +++ b/source/blender/editors/armature/pose_group.c @@ -55,6 +55,21 @@ /* ********************************************** */ /* Bone Groups */ +static bool pose_group_poll(bContext *C) +{ + if (!ED_operator_posemode_context(C)) { + return false; + } + + Object *obpose = ED_pose_object_from_context(C); + if ((obpose->proxy != NULL) || (obpose->proxy_group != NULL) || ID_IS_OVERRIDE_LIBRARY(obpose)) { + CTX_wm_operator_poll_msg_set(C, "Cannot edit bonegroups for proxies or library overrides"); + return false; + } + + return true; +} + static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_pose_object_from_context(C); @@ -82,7 +97,7 @@ void POSE_OT_group_add(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_add_exec; - ot->poll = ED_operator_posemode_context; + ot->poll = pose_group_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -116,7 +131,7 @@ void POSE_OT_group_remove(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_remove_exec; - ot->poll = ED_operator_posemode_context; + ot->poll = pose_group_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -233,7 +248,7 @@ void POSE_OT_group_assign(wmOperatorType *ot) /* api callbacks */ ot->invoke = pose_groups_menu_invoke; ot->exec = pose_group_assign_exec; - ot->poll = ED_operator_posemode_context; + ot->poll = pose_group_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -281,7 +296,7 @@ void POSE_OT_group_unassign(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_unassign_exec; - ot->poll = ED_operator_posemode_context; + ot->poll = pose_group_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -346,7 +361,7 @@ void POSE_OT_group_move(wmOperatorType *ot) /* api callbacks */ ot->exec = group_move_exec; - ot->poll = ED_operator_posemode_context; + ot->poll = pose_group_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -437,7 +452,7 @@ void POSE_OT_group_sort(wmOperatorType *ot) /* api callbacks */ ot->exec = group_sort_exec; - ot->poll = ED_operator_posemode_context; + ot->poll = pose_group_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 7f98ae47c6f..cd3e4a09fc3 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -138,8 +138,22 @@ static char *rna_PoseBone_path(PointerRNA *ptr) /* Bone groups only. */ -static bActionGroup *rna_bone_group_new(ID *id, bPose *pose, const char *name) +static bool rna_bone_group_poll(Object *ob, ReportList *reports) { + if ((ob->proxy != NULL) || (ob->proxy_group != NULL) || ID_IS_OVERRIDE_LIBRARY(ob)) { + BKE_report(reports, RPT_ERROR, "Cannot edit bonegroups for proxies or library overrides"); + return false; + } + + return true; +} + +static bActionGroup *rna_bone_group_new(ID *id, bPose *pose, ReportList *reports, const char *name) +{ + if (!rna_bone_group_poll((Object *)id, reports)) { + return NULL; + } + bActionGroup *grp = BKE_pose_add_group(pose, name); WM_main_add_notifier(NC_OBJECT | ND_POSE | NA_ADDED, id); return grp; @@ -147,6 +161,10 @@ static bActionGroup *rna_bone_group_new(ID *id, bPose *pose, const char *name) static void rna_bone_group_remove(ID *id, bPose *pose, ReportList *reports, PointerRNA *grp_ptr) { + if (!rna_bone_group_poll((Object *)id, reports)) { + return; + } + bActionGroup *grp = grp_ptr->data; const int grp_idx = BLI_findindex(&pose->agroups, grp); @@ -163,6 +181,11 @@ static void rna_bone_group_remove(ID *id, bPose *pose, ReportList *reports, Poin void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value) { + Object *ob = (Object *)ptr->owner_id; + if (!rna_bone_group_poll(ob, NULL)) { + return; + } + bActionGroup *grp = ptr->data; /* ensure only valid values get set */ @@ -184,6 +207,10 @@ bool rna_ActionGroup_is_custom_colorset_get(PointerRNA *ptr) static void rna_BoneGroup_name_set(PointerRNA *ptr, const char *value) { Object *ob = (Object *)ptr->owner_id; + if (!rna_bone_group_poll(ob, NULL)) { + return; + } + bActionGroup *agrp = ptr->data; /* copy the new name into the name slot */ @@ -1619,7 +1646,7 @@ static void rna_def_bone_groups(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_bone_group_new"); RNA_def_function_ui_description(func, "Add a new bone group to the object"); - RNA_def_function_flag(func, FUNC_USE_SELF_ID); /* ID needed for refresh */ + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS); /* ID needed for refresh */ RNA_def_string(func, "name", "Group", MAX_NAME, "", "Name of the new group"); /* return type */ parm = RNA_def_pointer(func, "group", "BoneGroup", "", "New bone group"); |