44class CollectionDropTarget {
48 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const
63 *r_disabled_hint =
"Can only add objects and collections to the light linking collection";
70 CollectionDropTarget(
Collection &collection) : collection_(collection) {}
78class CollectionInsertDropTarget :
public CollectionDropTarget {
82 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const
84 if (!CollectionDropTarget::can_drop(drag, r_disabled_hint)) {
88 bool have_ids_outside_collection =
false;
90 const ID *
id = drag_id.
id;
97 const Object *drag_object = id_cast<const Object *>(
id);
99 have_ids_outside_collection =
true;
104 const Collection *drag_collection = id_cast<const Collection *>(
id);
106 have_ids_outside_collection =
true;
114 if (have_ids_outside_collection) {
119 if (have_ids_outside_collection) {
121 *r_disabled_hint =
"Can not modify collection that is used by a scene";
130 : CollectionDropTarget(collection), bmain_(bmain)
139 CollectionInsertDropTarget collection_target_;
143 : collection_target_(bmain, collection)
147 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const override
149 return collection_target_.can_drop(drag, r_disabled_hint);
152 std::string drop_tooltip(
const DragInfo & )
const override
154 return TIP_(
"Add to linking collection");
164 &collection_target_.get_collection(),
181 CollectionDropTarget collection_target_;
189 collection_target_(collection),
194 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const override
196 return collection_target_.can_drop(drag, r_disabled_hint);
199 std::string drop_tooltip(
const DragInfo &drag)
const override
205 return "Add to linking collection";
207 return fmt::format(fmt::runtime(
TIP_(
"Add to linking collection before {}")), drop_name);
209 return fmt::format(fmt::runtime(
TIP_(
"Add to linking collection after {}")), drop_name);
220 Collection &collection = collection_target_.get_collection();
224 if (drag_id.
id == &drop_id_) {
236 bmain, &collection, drag_id.
id, &drop_id_, link_state);
240 bmain, &collection, drag_id.
id, &drop_id_, link_state);
262 std::optional<eWM_DragDataType> get_drag_type()
const override
267 void *create_drag_data()
const override
269 return static_cast<void *
>(&id_);
281 CollectionViewItem(
Layout &context_layout,
287 context_layout_(context_layout),
288 collection_(collection),
290 collection_light_linking_(collection_light_linking)
294 void build_row(
Layout &row)
override
309 build_state_button(sub);
312 std::unique_ptr<AbstractViewItemDragController> create_drag_controller()
const override
314 return std::make_unique<ItemDragController>(get_tree_view(), id_);
317 std::unique_ptr<TreeViewItemDropTarget> create_drop_target()
override
319 return std::make_unique<ReorderCollectionDropTarget>(*
this, collection_, id_);
323 int get_state_icon()
const
325 switch (collection_light_linking_.
link_state) {
327 return ICON_CHECKBOX_HLT;
329 return ICON_CHECKBOX_DEHLT;
337 switch (collection_light_linking.
link_state) {
349 void build_state_button(
Layout &row)
352 const int icon = get_state_icon();
355 &collection_.
id, RNA_CollectionLightLinking, &collection_light_linking_);
364 &collection_light_linking_ptr,
372 link_state_toggle(collection_light_linking);
384 : context_layout_(context_layout), bmain_(bmain), collection_(collection)
388 void build_tree()
override
392 add_tree_item<CollectionViewItem>(context_layout_,
394 child_collection->
id,
396 ICON_OUTLINER_COLLECTION);
400 Object *child_object = collection_object.
ob;
401 add_tree_item<CollectionViewItem>(context_layout_,
409 std::unique_ptr<DropTargetInterface> create_drop_target()
override
411 return std::make_unique<InsertCollectionDropTarget>(bmain_, collection_);
Button * uiDefIconButR(Block *block, ButtonType type, int icon, int x, int y, short width, short height, PointerRNA *ptr, StringRefNull propname, int index, float min, float max, std::optional< StringRef > tip)