From 38871b9728e607914cb2b2cc8c07951dd9521291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 18 Sep 2023 14:46:54 +0200 Subject: [PATCH] Anim: (de)select bones in collection, remove 'name' operator property Simplify the "(de)select bones in collection" operators by removing their 'name' property. They now only operate on the active bone collection. This means the poll function can be more specific, making the enabled/disabled state of the buttons more sensible. --- .../editors/armature/bone_collections.cc | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/source/blender/editors/armature/bone_collections.cc b/source/blender/editors/armature/bone_collections.cc index 5c8c9dadb89..950bfacc1c9 100644 --- a/source/blender/editors/armature/bone_collections.cc +++ b/source/blender/editors/armature/bone_collections.cc @@ -507,6 +507,11 @@ static bool armature_bone_select_poll(bContext *C) return false; } + const bArmature *armature = reinterpret_cast(ob->data); + if (armature->runtime.active_collection == nullptr) { + CTX_wm_operator_poll_msg_set(C, "No active bone collection"); + return false; + } return true; } @@ -559,14 +564,15 @@ static void bone_collection_select(bContext *C, } } -static int bone_collection_select_exec(bContext *C, wmOperator *op) +static int bone_collection_select_exec(bContext *C, wmOperator * /*op*/) { Object *ob = ED_object_context(C); if (ob == nullptr) { return OPERATOR_CANCELLED; } - BoneCollection *bcoll = get_bonecoll_named_or_active(C, op, ob, FAIL_IF_MISSING); + bArmature *armature = reinterpret_cast(ob->data); + BoneCollection *bcoll = armature->runtime.active_collection; if (bcoll == nullptr) { return OPERATOR_CANCELLED; } @@ -588,25 +594,17 @@ void ARMATURE_OT_collection_select(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - PropertyRNA *prop = RNA_def_string( - ot->srna, - "name", - nullptr, - MAX_NAME, - "Bone Collection", - "Name of the bone collection to select bones from; empty use the active bone collection"); - RNA_def_property_flag(prop, PROP_HIDDEN); } -static int bone_collection_deselect_exec(bContext *C, wmOperator *op) +static int bone_collection_deselect_exec(bContext *C, wmOperator * /*op*/) { Object *ob = ED_object_context(C); if (ob == nullptr) { return OPERATOR_CANCELLED; } - BoneCollection *bcoll = get_bonecoll_named_or_active(C, op, ob, FAIL_IF_MISSING); + bArmature *armature = reinterpret_cast(ob->data); + BoneCollection *bcoll = armature->runtime.active_collection; if (bcoll == nullptr) { return OPERATOR_CANCELLED; } @@ -628,15 +626,6 @@ void ARMATURE_OT_collection_deselect(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - PropertyRNA *prop = RNA_def_string( - ot->srna, - "name", - nullptr, - MAX_NAME, - "Bone Collection", - "Name of the bone collection to deselect bones from; empty use the active bone collection"); - RNA_def_property_flag(prop, PROP_HIDDEN); } /* -------------------------- */