20#include "RNA_prototypes.hh"
27#include <fmt/format.h>
49 void build_bcolls_with_selected_bones();
82 const int bcoll_index);
112 *r_disabled_hint =
"Cannot drag & drop bone collections between Armatures.";
125 *r_disabled_hint =
"Cannot drag a collection onto a descendent";
144 return fmt::format(
TIP_(
"Move {} into {}"), drag_name, drop_name);
146 return fmt::format(
TIP_(
"Move {} above {}"), drag_name, drop_name);
148 return fmt::format(
TIP_(
"Move {} below {}"), drag_name, drop_name);
160 const int from_bcoll_index = drag_arm_bcoll->
bcoll_index;
161 const int to_bcoll_index = drop_bonecoll_.
bcoll_index;
163 int new_bcoll_index = -1;
180 arm, from_bcoll_index, -1, from_parent_index, to_bcoll_index);
189 if (new_bcoll_index < 0) {
206 bool has_any_selected_bones_;
210 : armature_(armature),
211 bcoll_index_(bcoll_index),
212 bone_collection_(*armature.collection_array[bcoll_index]),
213 has_any_selected_bones_(has_any_selected_bones)
233 icon = ICON_LAYER_ACTIVE;
235 else if (has_any_selected_bones_) {
236 icon = ICON_LAYER_USED;
249 !is_solo_active && bone_collection_.is_visible_ancestors());
251 const int icon = bone_collection_.is_visible() ? ICON_HIDE_OFF : ICON_HIDE_ON;
258 const int icon = bone_collection_.is_solo() ? ICON_SOLO_ON : ICON_SOLO_OFF;
293 const bool is_collapsed = !bone_collection_.is_expanded();
315 &armature_.
id, &RNA_BoneCollection, &bone_collection_);
343 return bone_collection_.
name;
354 return std::make_unique<BoneCollectionDragController>(tree_view, armature_, bcoll_index_);
362 return std::make_unique<BoneCollectionDropTarget>(
378 build_bcolls_with_selected_bones();
381 build_tree_node_recursive(*
this, bcoll_index);
386 const int bcoll_index)
391 armature_, bcoll_index, has_any_selected_bones);
395 build_tree_node_recursive(bcoll_tree_item, child_index);
404void BoneCollectionTreeView::build_bcolls_with_selected_bones()
424 if ((bone->flag & BONE_SELECTED) == 0) {
429 bcolls_with_selected_bones_.add(ref->bcoll);
436 const int bcoll_index)
449 *drag_data = drag_arm_bcoll_;
465 if (armature ==
nullptr) {
474 "Bone Collection Tree View",
475 std::make_unique<blender::ui::bonecollections::BoneCollectionTreeView>(*armature));
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
bool ANIM_armature_bonecoll_is_editable(const bArmature *armature, const BoneCollection *bcoll)
void ANIM_armature_bonecoll_is_expanded_set(BoneCollection *bcoll, bool is_expanded)
int ANIM_armature_bonecoll_move_before_after_index(bArmature *armature, int from_index, int to_index, MoveLocation before_after)
bool ANIM_armature_bonecoll_contains_active_bone(const bArmature *armature, const BoneCollection *bcoll)
void ANIM_armature_bonecoll_active_index_set(bArmature *armature, int bone_collection_index)
#define LISTBASE_FOREACH(type, var, list)
void ED_undo_push(bContext *C, const char *str)
blender::ui::AbstractGridView * UI_block_add_view(uiBlock &block, blender::StringRef idname, std::unique_ptr< blender::ui::AbstractGridView > grid_view)
void uiLayoutSetActive(uiLayout *layout, bool active)
void uiItemL(uiLayout *layout, const char *name, int icon)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void uiTemplateBoneCollectionTree(uiLayout *layout, bContext *C)
void UI_menutype_draw(bContext *C, MenuType *mt, uiLayout *layout)
uiBut * uiItemL_ex(uiLayout *layout, const char *name, int icon, bool highlight, bool redalert)
void UI_but_flag_enable(uiBut *but, int flag)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
#define ND_BONE_COLLECTION
@ WM_DRAG_BONE_COLLECTION
bArmature * ED_armature_context(const bContext *C)
bool contains(const Key &key) const
constexpr const char * c_str() const
Abstract base class for defining a customizable tree-view item.
bool is_collapsed() const
AbstractTreeView & get_tree_view() const
virtual bool set_collapsed(bool collapsed)
void set_default_rows(int default_rows)
void set_context_menu_title(const std::string &title)
static void build_tree_view(AbstractTreeView &tree_view, uiLayout &layout, std::optional< StringRef > search_string={}, bool add_box=true)
ItemT & add_tree_item(Args &&...args)
BoneCollectionDragController(BoneCollectionTreeView &tree_view, bArmature &armature, const int bcoll_index)
void * create_drag_data() const override
void on_drag_start() override
eWM_DragDataType get_drag_type() const override
bool on_drop(bContext *C, const DragInfo &drag_info) const override
bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override
std::string drop_tooltip(const DragInfo &drag_info) const override
BoneCollectionDropTarget(AbstractTreeViewItem &item, DropBehavior behavior, const ArmatureBoneCollection &drop_bonecoll)
bool supports_renaming() const override
void build_row(uiLayout &row) override
std::unique_ptr< TreeViewItemDropTarget > create_drop_target() override
std::optional< bool > should_be_active() const override
StringRef get_rename_string() const override
void on_collapse_change(bContext &C, const bool is_collapsed) override
void build_context_menu(bContext &C, uiLayout &column) const override
BoneCollectionItem(bArmature &armature, const int bcoll_index, const bool has_any_selected_bones)
bool rename(const bContext &C, StringRefNull new_name) override
bool set_collapsed(const bool collapsed) override
std::unique_ptr< AbstractViewItemDragController > create_drag_controller() const override
void on_activate(bContext &C) override
std::optional< bool > should_be_collapsed() const override
bool listen(const wmNotifier ¬ifier) const override
Set< BoneCollection * > bcolls_with_selected_bones_
BoneCollectionTreeView(bArmature &armature)
void build_tree() override
static void ANIM_armature_foreach_bone(ListBase *bones, CB callback)
bool armature_bonecoll_is_descendant_of(const bArmature *armature, int potential_parent_index, int potential_descendant_index)
int armature_bonecoll_find_parent_index(const bArmature *armature, int bcoll_index)
int armature_bonecoll_move_to_parent(bArmature *armature, int from_bcoll_index, int to_child_num, int from_parent_index, int to_parent_index)
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
int active_collection_index
int collection_root_count
struct BoneCollection ** collection_array
struct bArmature_Runtime runtime
const DropLocation drop_location
ArmatureBoneCollection(bArmature *armature, int bcoll_index)
ArmatureBoneCollection()=default
const BoneCollection & bcoll() const
void WM_event_add_notifier(const bContext *C, uint type, void *reference)