39class CollectionDropTarget {
43 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const
58 *r_disabled_hint =
"Can only add objects and collections to the light linking collection";
65 CollectionDropTarget(
Collection &collection) : collection_(collection) {}
77 CollectionDropTarget collection_target_;
80 InsertCollectionDropTarget(
Collection &collection) : collection_target_(collection) {}
82 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const override
84 return collection_target_.can_drop(drag, r_disabled_hint);
87 std::string drop_tooltip(
const DragInfo & )
const override
89 return TIP_(
"Add to linking collection");
99 &collection_target_.get_collection(),
116 CollectionDropTarget collection_target_;
124 collection_target_(collection),
129 bool can_drop(
const wmDrag &drag,
const char **r_disabled_hint)
const override
131 return collection_target_.can_drop(drag, r_disabled_hint);
134 std::string drop_tooltip(
const DragInfo &drag)
const override
140 return "Add to linking collection";
142 return fmt::format(
TIP_(
"Add to linking collection before {}"), drop_name);
144 return fmt::format(
TIP_(
"Add to linking collection after {}"), drop_name);
155 Collection &collection = collection_target_.get_collection();
159 if (drag_id->id == &drop_id_) {
168 bmain, &collection, drag_id->id, link_state);
172 bmain, &collection, drag_id->id, &drop_id_, link_state);
176 bmain, &collection, drag_id->id, &drop_id_, link_state);
206 void *create_drag_data()
const override
208 return static_cast<void *
>(&id_);
220 CollectionViewItem(
uiLayout &context_layout,
226 context_layout_(context_layout),
227 collection_(collection),
229 collection_light_linking_(collection_light_linking)
233 void build_row(
uiLayout &row)
override
248 build_state_button(*sub);
251 std::unique_ptr<AbstractViewItemDragController> create_drag_controller()
const override
253 return std::make_unique<ItemDragController>(get_tree_view(), id_);
256 std::unique_ptr<TreeViewItemDropTarget> create_drop_target()
override
258 return std::make_unique<ReorderCollectionDropTarget>(*
this, collection_, id_);
262 int get_state_icon()
const
264 switch (collection_light_linking_.
link_state) {
266 return ICON_CHECKBOX_HLT;
268 return ICON_CHECKBOX_DEHLT;
276 switch (collection_light_linking.
link_state) {
288 void build_state_button(
uiLayout &row)
291 const int icon = get_state_icon();
294 &collection_.
id, &RNA_CollectionLightLinking, &collection_light_linking_);
304 &collection_light_linking_ptr,
312 link_state_toggle(collection_light_linking);
323 : context_layout_(context_layout), collection_(collection)
327 void build_tree()
override
330 Collection *child_collection = collection_child->collection;
331 add_tree_item<CollectionViewItem>(context_layout_,
333 child_collection->
id,
334 collection_child->light_linking,
335 ICON_OUTLINER_COLLECTION);
339 Object *child_object = collection_object->ob;
340 add_tree_item<CollectionViewItem>(context_layout_,
343 collection_object->light_linking,
348 std::unique_ptr<DropTargetInterface> create_drop_target()
override
350 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, const char *propname, int index, float min, float max, const char *tip)