Blender V4.3
bone_collections.cc File Reference
#include <cstring>
#include "ANIM_bone_collections.hh"
#include "DNA_ID.h"
#include "DNA_object_types.h"
#include "BKE_action.hh"
#include "BKE_context.hh"
#include "BKE_lib_override.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_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 int bone_collection_add_exec (bContext *C, wmOperator *)
 
void ARMATURE_OT_collection_add (wmOperatorType *ot)
 
static int bone_collection_remove_exec (bContext *C, wmOperator *)
 
void ARMATURE_OT_collection_remove (wmOperatorType *ot)
 
static int 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 int 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 int bone_collection_create_and_assign_exec (bContext *C, wmOperator *op)
 
void ARMATURE_OT_collection_create_and_assign (wmOperatorType *ot)
 
static int bone_collection_unassign_exec (bContext *C, wmOperator *op)
 
void ARMATURE_OT_collection_unassign (wmOperatorType *ot)
 
static int 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, Object *ob, BoneCollection *bcoll, const bool select)
 
static int bone_collection_select_exec (bContext *C, wmOperator *)
 
void ARMATURE_OT_collection_select (wmOperatorType *ot)
 
static int 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 int 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 int move_to_collection_exec (bContext *C, wmOperator *op)
 
static int 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 int move_to_collection_regular_invoke (bContext *C, wmOperator *op)
 
static int move_to_new_collection_invoke (bContext *C, wmOperator *op)
 
static int 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 234 of file editors/armature/bone_collections.cc.

◆ assign_ebone_func

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

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

Function Documentation

◆ active_bone_collection_poll()

static 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()

◆ ARMATURE_OT_collection_assign()

◆ ARMATURE_OT_collection_create_and_assign()

◆ ARMATURE_OT_collection_deselect()

◆ ARMATURE_OT_collection_move()

◆ ARMATURE_OT_collection_remove()

◆ ARMATURE_OT_collection_select()

◆ ARMATURE_OT_collection_unassign()

◆ ARMATURE_OT_collection_unassign_named()

◆ ARMATURE_OT_move_to_collection()

◆ assign_to_collection_exec()

◆ bone_collection_add_exec()

◆ bone_collection_add_poll()

◆ bone_collection_assign_editbones()

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

◆ bone_collection_assign_exec()

◆ bone_collection_assign_mode_specific()

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

◆ bone_collection_assign_named_mode_specific()

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

◆ bone_collection_assign_pchans()

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

◆ 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()

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

◆ get_bonecoll_named_or_active()

◆ icon_for_bone_collection()

static int icon_for_bone_collection ( const bool collection_contains_active_bone)
static

◆ menu_add_item_for_move_assign_unassign()

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

◆ menu_custom_data_decode()

static 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 1013 of file editors/armature/bone_collections.cc.

References int.

Referenced by move_to_collection_menu_create().

◆ menu_custom_data_encode()

static 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 uiItemMenuF(). 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 1001 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()

static 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 uiItemMenuF. 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 1064 of file editors/armature/bone_collections.cc.

References ANIM_armature_bonecoll_is_editable(), blender::animrig::bonecoll_has_children(), BoneCollection::child_count, BoneCollection::child_index, bArmature::collection_array, bArmature::collection_root_count, blender::ed::object::context_object(), Object::data, wmOperator::layout, menu_add_item_for_move_assign_unassign(), menu_custom_data_decode(), menu_custom_data_encode(), move_to_collection_menu_create(), BoneCollection::name, uiItemIntO(), uiItemMenuF(), uiItemS(), uiLayoutRow(), uiLayoutSetEnabled(), uiLayoutSetOperatorContext(), WM_OP_EXEC_DEFAULT, and WM_OP_INVOKE_DEFAULT.

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()

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