Blender V5.0
bone_collections.cc File Reference
#include <cstring>
#include "ANIM_armature.hh"
#include "ANIM_bone_collections.hh"
#include "DNA_ID.h"
#include "DNA_object_types.h"
#include "BLI_listbase.h"
#include "BKE_action.hh"
#include "BKE_context.hh"
#include "BKE_lib_override.hh"
#include "BKE_library.hh"
#include "BKE_report.hh"
#include "BLT_translation.hh"
#include "DEG_depsgraph.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "ED_armature.hh"
#include "ED_object.hh"
#include "ED_outliner.hh"
#include "UI_interface.hh"
#include "UI_interface_layout.hh"
#include "UI_resources.hh"
#include "armature_intern.hh"

Go to the source code of this file.

Typedefs

using assign_bone_func = bool (*)(BoneCollection *bcoll, Bone *bone)
using assign_ebone_func = bool (*)(BoneCollection *bcoll, EditBone *ebone)

Functions

static bool bone_collection_add_poll (bContext *C)
static bool active_bone_collection_poll (bContext *C)
static wmOperatorStatus bone_collection_add_exec (bContext *C, wmOperator *)
void ARMATURE_OT_collection_add (wmOperatorType *ot)
static wmOperatorStatus bone_collection_remove_exec (bContext *C, wmOperator *)
void ARMATURE_OT_collection_remove (wmOperatorType *ot)
static wmOperatorStatus bone_collection_move_exec (bContext *C, wmOperator *op)
void ARMATURE_OT_collection_move (wmOperatorType *ot)
static BoneCollectionget_bonecoll_named_or_active (bContext *, wmOperator *op, Object *ob)
static void bone_collection_assign_pchans (bContext *C, Object *ob, BoneCollection *bcoll, assign_bone_func assign_func, bool *made_any_changes, bool *had_bones_to_assign)
static void bone_collection_assign_editbones (bContext *C, Object *ob, BoneCollection *bcoll, assign_ebone_func assign_func, bool *made_any_changes, bool *had_bones_to_assign)
static bool bone_collection_assign_mode_specific (bContext *C, Object *ob, BoneCollection *bcoll, assign_bone_func assign_bone_func, assign_ebone_func assign_ebone_func, bool *made_any_changes, bool *had_bones_to_assign)
static bool bone_collection_assign_named_mode_specific (bContext *C, Object *ob, BoneCollection *bcoll, const char *bone_name, assign_bone_func assign_bone_func, assign_ebone_func assign_ebone_func, bool *made_any_changes, bool *had_bones_to_assign)
static bool bone_collection_assign_poll (bContext *C)
static wmOperatorStatus bone_collection_assign_exec (bContext *C, wmOperator *op)
void ARMATURE_OT_collection_assign (wmOperatorType *ot)
static bool bone_collection_create_and_assign_poll (bContext *C)
static wmOperatorStatus bone_collection_create_and_assign_exec (bContext *C, wmOperator *op)
void ARMATURE_OT_collection_create_and_assign (wmOperatorType *ot)
static wmOperatorStatus bone_collection_unassign_exec (bContext *C, wmOperator *op)
void ARMATURE_OT_collection_unassign (wmOperatorType *ot)
static wmOperatorStatus bone_collection_unassign_named_exec (bContext *C, wmOperator *op)
void ARMATURE_OT_collection_unassign_named (wmOperatorType *ot)
static bool editbone_is_member (const EditBone *ebone, const BoneCollection *bcoll)
static bool armature_bone_select_poll (bContext *C)
static void bone_collection_select (bContext *C, bArmature *armature, BoneCollection *bcoll, const bool select)
static wmOperatorStatus bone_collection_select_exec (bContext *C, wmOperator *)
void ARMATURE_OT_collection_select (wmOperatorType *ot)
static wmOperatorStatus bone_collection_deselect_exec (bContext *C, wmOperator *)
void ARMATURE_OT_collection_deselect (wmOperatorType *ot)
static BoneCollectionadd_or_move_to_collection_bcoll (wmOperator *op, bArmature *arm)
static wmOperatorStatus add_or_move_to_collection_exec (bContext *C, wmOperator *op, const assign_bone_func assign_func_bone, const assign_ebone_func assign_func_ebone)
static wmOperatorStatus move_to_collection_exec (bContext *C, wmOperator *op)
static wmOperatorStatus assign_to_collection_exec (bContext *C, wmOperator *op)
static bool move_to_collection_poll (bContext *C)
static void * menu_custom_data_encode (const int bcoll_index, const bool is_move_operation)
static std::pair< int, bool > menu_custom_data_decode (void *menu_custom_data)
static int icon_for_bone_collection (const bool collection_contains_active_bone)
static void menu_add_item_for_move_assign_unassign (uiLayout *layout, const bArmature *arm, const BoneCollection *bcoll, const int bcoll_index, const bool is_move_operation)
static void move_to_collection_menu_create (bContext *C, uiLayout *layout, void *menu_custom_data)
static wmOperatorStatus move_to_collection_regular_invoke (bContext *C, wmOperator *op)
static wmOperatorStatus move_to_new_collection_invoke (bContext *C, wmOperator *op)
static wmOperatorStatus move_to_collection_invoke (bContext *C, wmOperator *op, const wmEvent *)
void ARMATURE_OT_move_to_collection (wmOperatorType *ot)
void ARMATURE_OT_assign_to_collection (wmOperatorType *ot)

Detailed Description

Implementation of Bone Collection operators and editing API's.

Definition in file editors/armature/bone_collections.cc.

Typedef Documentation

◆ assign_bone_func

using assign_bone_func = bool (*)(BoneCollection *bcoll, Bone *bone)

Definition at line 239 of file editors/armature/bone_collections.cc.

◆ assign_ebone_func

using assign_ebone_func = bool (*)(BoneCollection *bcoll, EditBone *ebone)

Definition at line 240 of file editors/armature/bone_collections.cc.

Function Documentation

◆ active_bone_collection_poll()

bool active_bone_collection_poll ( bContext * C)
static

◆ add_or_move_to_collection_bcoll()

◆ add_or_move_to_collection_exec()

◆ armature_bone_select_poll()

◆ ARMATURE_OT_assign_to_collection()

◆ ARMATURE_OT_collection_add()

void ARMATURE_OT_collection_add ( wmOperatorType * ot)

◆ ARMATURE_OT_collection_assign()

void ARMATURE_OT_collection_assign ( wmOperatorType * ot)

◆ ARMATURE_OT_collection_create_and_assign()

◆ ARMATURE_OT_collection_deselect()

void ARMATURE_OT_collection_deselect ( wmOperatorType * ot)

◆ ARMATURE_OT_collection_move()

◆ ARMATURE_OT_collection_remove()

void ARMATURE_OT_collection_remove ( wmOperatorType * ot)

◆ ARMATURE_OT_collection_select()

void ARMATURE_OT_collection_select ( wmOperatorType * ot)

◆ ARMATURE_OT_collection_unassign()

void ARMATURE_OT_collection_unassign ( wmOperatorType * ot)

◆ ARMATURE_OT_collection_unassign_named()

void ARMATURE_OT_collection_unassign_named ( wmOperatorType * ot)

◆ ARMATURE_OT_move_to_collection()

◆ assign_to_collection_exec()

◆ bone_collection_add_exec()

◆ bone_collection_add_poll()

◆ bone_collection_assign_editbones()

◆ bone_collection_assign_exec()

◆ bone_collection_assign_mode_specific()

bool bone_collection_assign_mode_specific ( bContext * C,
Object * ob,
BoneCollection * bcoll,
assign_bone_func assign_bone_func,
assign_ebone_func assign_ebone_func,
bool * made_any_changes,
bool * had_bones_to_assign )
static

◆ bone_collection_assign_named_mode_specific()

bool bone_collection_assign_named_mode_specific ( bContext * C,
Object * ob,
BoneCollection * bcoll,
const char * bone_name,
assign_bone_func assign_bone_func,
assign_ebone_func assign_ebone_func,
bool * made_any_changes,
bool * had_bones_to_assign )
static

◆ bone_collection_assign_pchans()

void bone_collection_assign_pchans ( bContext * C,
Object * ob,
BoneCollection * bcoll,
assign_bone_func assign_func,
bool * made_any_changes,
bool * had_bones_to_assign )
static

◆ bone_collection_assign_poll()

◆ bone_collection_create_and_assign_exec()

◆ bone_collection_create_and_assign_poll()

◆ bone_collection_deselect_exec()

◆ bone_collection_move_exec()

◆ bone_collection_remove_exec()

◆ bone_collection_select()

◆ bone_collection_select_exec()

◆ bone_collection_unassign_exec()

◆ bone_collection_unassign_named_exec()

◆ editbone_is_member()

bool editbone_is_member ( const EditBone * ebone,
const BoneCollection * bcoll )
static

◆ get_bonecoll_named_or_active()

◆ icon_for_bone_collection()

int icon_for_bone_collection ( const bool collection_contains_active_bone)
static

◆ menu_add_item_for_move_assign_unassign()

void menu_add_item_for_move_assign_unassign ( uiLayout * layout,
const bArmature * arm,
const BoneCollection * bcoll,
const int bcoll_index,
const bool is_move_operation )
static

◆ menu_custom_data_decode()

std::pair< int, bool > menu_custom_data_decode ( void * menu_custom_data)
static

Decode the void* back into a bone collection index and a boolean is_move_operation.

See also
menu_custom_data_encode for rationale.

Definition at line 1058 of file editors/armature/bone_collections.cc.

Referenced by move_to_collection_menu_create().

◆ menu_custom_data_encode()

void * menu_custom_data_encode ( const int bcoll_index,
const bool is_move_operation )
static

Encode the parameters into an integer, and return as void*.

NOTE(@sybren): This makes it possible to use these values and pass them directly as 'custom data' pointer to uiLayout::menu_fn(). This makes it possible to give every menu a unique bone collection index for which it should show the child collections, without having to allocate memory or use static variables. See move_to_collection_invoke() in object_edit.cc for the alternative that I wanted to avoid.

Definition at line 1046 of file editors/armature/bone_collections.cc.

Referenced by move_to_collection_menu_create(), and move_to_collection_regular_invoke().

◆ move_to_collection_exec()

◆ move_to_collection_invoke()

◆ move_to_collection_menu_create()

void move_to_collection_menu_create ( bContext * C,
uiLayout * layout,
void * menu_custom_data )
static

Add menu items to the layout, for a set of bone collections.

Parameters
menu_custom_dataContains two values, encoded as void* to match the signature required by uiLayout::menu_fn. It contains the parent bone collection index (either -1 to show all roots, or another value to show the children of that collection), as well as a boolean that indicates whether the menu is created for the "move to collection" or "assign to collection" operator.
See also
menu_custom_data_encode

Definition at line 1107 of file editors/armature/bone_collections.cc.

References ANIM_armature_bonecoll_is_editable(), BLT_I18NCONTEXT_OPERATOR_DEFAULT, blender::animrig::bonecoll_has_children(), C, BoneCollection::child_count, BoneCollection::child_index, bArmature::collection_array, bArmature::collection_root_count, blender::ed::object::context_object(), CTX_IFACE_, Object::data, uiLayout::enabled_set(), blender::wm::ExecDefault, blender::wm::InvokeDefault, wmOperator::layout, menu_add_item_for_move_assign_unassign(), menu_custom_data_decode(), menu_custom_data_encode(), uiLayout::menu_fn(), move_to_collection_menu_create(), BoneCollection::name, uiLayout::op(), uiLayout::operator_context_set(), RNA_int_set(), uiLayout::row(), and uiLayout::separator().

Referenced by move_to_collection_menu_create(), and move_to_collection_regular_invoke().

◆ move_to_collection_poll()

◆ move_to_collection_regular_invoke()

◆ move_to_new_collection_invoke()

wmOperatorStatus move_to_new_collection_invoke ( bContext * C,
wmOperator * op )
static