41class CollectionDropTarget {
45 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const
60 *r_disabled_hint =
"Can only add objects and collections to the light linking collection";
67 CollectionDropTarget(
Collection &collection) : collection_(collection) {}
79 CollectionDropTarget collection_target_;
82 InsertCollectionDropTarget(
Collection &collection) : collection_target_(collection) {}
84 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const override
86 return collection_target_.can_drop(drag, r_disabled_hint);
89 std::string drop_tooltip(
const DragInfo & )
const override
91 return TIP_(
"Add to linking collection");
101 &collection_target_.get_collection(),
118 CollectionDropTarget collection_target_;
126 collection_target_(collection),
131 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const override
133 return collection_target_.can_drop(drag, r_disabled_hint);
136 std::string drop_tooltip(
const DragInfo &drag)
const override
142 return "Add to linking collection";
144 return fmt::format(fmt::runtime(
TIP_(
"Add to linking collection before {}")), drop_name);
146 return fmt::format(fmt::runtime(
TIP_(
"Add to linking collection after {}")), drop_name);
157 Collection &collection = collection_target_.get_collection();
161 if (drag_id->id == &drop_id_) {
170 bmain, &collection, drag_id->
id, link_state);
174 bmain, &collection, drag_id->
id, &drop_id_, link_state);
178 bmain, &collection, drag_id->
id, &drop_id_, link_state);
208 void *create_drag_data()
const override
210 return static_cast<void *
>(&id_);
222 CollectionViewItem(
uiLayout &context_layout,
228 context_layout_(context_layout),
229 collection_(collection),
231 collection_light_linking_(collection_light_linking)
235 void build_row(
uiLayout &row)
override
250 build_state_button(*sub);
253 std::unique_ptr<AbstractViewItemDragController> create_drag_controller()
const override
255 return std::make_unique<ItemDragController>(get_tree_view(), id_);
258 std::unique_ptr<TreeViewItemDropTarget> create_drop_target()
override
260 return std::make_unique<ReorderCollectionDropTarget>(*
this, collection_, id_);
264 int get_state_icon()
const
266 switch (collection_light_linking_.
link_state) {
268 return ICON_CHECKBOX_HLT;
270 return ICON_CHECKBOX_DEHLT;
278 switch (collection_light_linking.
link_state) {
290 void build_state_button(
uiLayout &row)
293 const int icon = get_state_icon();
296 &collection_.
id, &RNA_CollectionLightLinking, &collection_light_linking_);
306 &collection_light_linking_ptr,
314 link_state_toggle(collection_light_linking);
325 : context_layout_(context_layout), collection_(collection)
329 void build_tree()
override
332 Collection *child_collection = collection_child->collection;
333 add_tree_item<CollectionViewItem>(context_layout_,
335 child_collection->
id,
336 collection_child->light_linking,
337 ICON_OUTLINER_COLLECTION);
341 Object *child_object = collection_object->ob;
342 add_tree_item<CollectionViewItem>(context_layout_,
345 collection_object->light_linking,
350 std::unique_ptr<DropTargetInterface> create_drop_target()
override
352 return std::make_unique<InsertCollectionDropTarget>(collection_);
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
uiBut * uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, PointerRNA *ptr, blender::StringRefNull propname, int index, float min, float max, std::optional< blender::StringRef > tip)