42class CollectionDropTarget {
46 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const
61 *r_disabled_hint =
"Can only add objects and collections to the light linking collection";
68 CollectionDropTarget(
Collection &collection) : collection_(collection) {}
80 CollectionDropTarget collection_target_;
83 InsertCollectionDropTarget(
Collection &collection) : collection_target_(collection) {}
85 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const override
87 return collection_target_.can_drop(drag, r_disabled_hint);
90 std::string drop_tooltip(
const DragInfo & )
const override
92 return TIP_(
"Add to linking collection");
102 &collection_target_.get_collection(),
119 CollectionDropTarget collection_target_;
127 collection_target_(collection),
132 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const override
134 return collection_target_.can_drop(drag, r_disabled_hint);
137 std::string drop_tooltip(
const DragInfo &drag)
const override
143 return "Add to linking collection";
145 return fmt::format(fmt::runtime(
TIP_(
"Add to linking collection before {}")), drop_name);
147 return fmt::format(fmt::runtime(
TIP_(
"Add to linking collection after {}")), drop_name);
158 Collection &collection = collection_target_.get_collection();
162 if (drag_id->id == &drop_id_) {
171 bmain, &collection, drag_id->
id, link_state);
175 bmain, &collection, drag_id->
id, &drop_id_, link_state);
179 bmain, &collection, drag_id->
id, &drop_id_, link_state);
204 std::optional<eWM_DragDataType> get_drag_type()
const override
209 void *create_drag_data()
const override
211 return static_cast<void *
>(&id_);
223 CollectionViewItem(
uiLayout &context_layout,
229 context_layout_(context_layout),
230 collection_(collection),
232 collection_light_linking_(collection_light_linking)
236 void build_row(
uiLayout &row)
override
251 build_state_button(*sub);
254 std::unique_ptr<AbstractViewItemDragController> create_drag_controller()
const override
256 return std::make_unique<ItemDragController>(get_tree_view(), id_);
259 std::unique_ptr<TreeViewItemDropTarget> create_drop_target()
override
261 return std::make_unique<ReorderCollectionDropTarget>(*
this, collection_, id_);
265 int get_state_icon()
const
267 switch (collection_light_linking_.
link_state) {
269 return ICON_CHECKBOX_HLT;
271 return ICON_CHECKBOX_DEHLT;
279 switch (collection_light_linking.
link_state) {
291 void build_state_button(
uiLayout &row)
294 const int icon = get_state_icon();
297 &collection_.
id, &RNA_CollectionLightLinking, &collection_light_linking_);
307 &collection_light_linking_ptr,
315 link_state_toggle(collection_light_linking);
326 : context_layout_(context_layout), collection_(collection)
330 void build_tree()
override
333 Collection *child_collection = collection_child->collection;
334 add_tree_item<CollectionViewItem>(context_layout_,
336 child_collection->
id,
337 collection_child->light_linking,
338 ICON_OUTLINER_COLLECTION);
342 Object *child_object = collection_object->ob;
343 add_tree_item<CollectionViewItem>(context_layout_,
346 collection_object->light_linking,
351 std::unique_ptr<DropTargetInterface> create_drop_target()
override
353 return std::make_unique<InsertCollectionDropTarget>(collection_);
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
uiBut * uiDefIconButR(uiBlock *block, ButType 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)