Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_dragdrop.c
| Show First 20 Lines • Show All 257 Lines • ▼ Show 20 Lines | static bool parent_drop_allowed(TreeElement *te, Object *potential_child) | ||||
| /* check that parent/child are both in the same scene */ | /* check that parent/child are both in the same scene */ | ||||
| Scene *scene = (Scene *)outliner_search_back(te, ID_SCE); | Scene *scene = (Scene *)outliner_search_back(te, ID_SCE); | ||||
| /* currently outliner organized in a way that if there's no parent scene | /* currently outliner organized in a way that if there's no parent scene | ||||
| * element for object it means that all displayed objects belong to | * element for object it means that all displayed objects belong to | ||||
| * active scene and parenting them is allowed (sergey) */ | * active scene and parenting them is allowed (sergey) */ | ||||
| if (scene) { | if (scene) { | ||||
| for (ViewLayer *view_layer = scene->view_layers.first; view_layer; | LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { | ||||
| view_layer = view_layer->next) { | |||||
| if (BKE_view_layer_base_find(view_layer, potential_child)) { | if (BKE_view_layer_base_find(view_layer, potential_child)) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| else { | else { | ||||
| return true; | return true; | ||||
| ▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | static int parent_clear_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | ||||
| if (event->custom != EVT_DATA_DRAGDROP) { | if (event->custom != EVT_DATA_DRAGDROP) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| ListBase *lb = event->customdata; | ListBase *lb = event->customdata; | ||||
| wmDrag *drag = lb->first; | wmDrag *drag = lb->first; | ||||
| for (wmDragID *drag_id = drag->ids.first; drag_id; drag_id = drag_id->next) { | LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) { | ||||
| if (GS(drag_id->id->name) == ID_OB) { | if (GS(drag_id->id->name) == ID_OB) { | ||||
| Object *object = (Object *)drag_id->id; | Object *object = (Object *)drag_id->id; | ||||
| ED_object_parent_clear(object, event->alt ? CLEAR_PARENT_KEEP_TRANSFORM : CLEAR_PARENT_ALL); | ED_object_parent_clear(object, event->alt ? CLEAR_PARENT_KEEP_TRANSFORM : CLEAR_PARENT_ALL); | ||||
| } | } | ||||
| } | } | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | if (scene != CTX_data_scene(C)) { | ||||
| collection = scene->master_collection; | collection = scene->master_collection; | ||||
| } | } | ||||
| else { | else { | ||||
| collection = CTX_data_collection(C); | collection = CTX_data_collection(C); | ||||
| } | } | ||||
| BKE_collection_object_add(bmain, collection, ob); | BKE_collection_object_add(bmain, collection, ob); | ||||
| for (ViewLayer *view_layer = scene->view_layers.first; view_layer; | LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { | ||||
| view_layer = view_layer->next) { | |||||
| Base *base = BKE_view_layer_base_find(view_layer, ob); | Base *base = BKE_view_layer_base_find(view_layer, ob); | ||||
| if (base) { | if (base) { | ||||
| ED_object_base_select(base, BA_SELECT); | ED_object_base_select(base, BA_SELECT); | ||||
| } | } | ||||
| } | } | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| ▲ Show 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | static int collection_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | ||||
| if (!data.to) { | if (!data.to) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (BKE_collection_is_empty(data.to)) { | if (BKE_collection_is_empty(data.to)) { | ||||
| TREESTORE(data.te)->flag &= ~TSE_CLOSED; | TREESTORE(data.te)->flag &= ~TSE_CLOSED; | ||||
| } | } | ||||
| for (wmDragID *drag_id = drag->ids.first; drag_id; drag_id = drag_id->next) { | LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) { | ||||
| /* Ctrl enables linking, so we don't need a from collection then. */ | /* Ctrl enables linking, so we don't need a from collection then. */ | ||||
| Collection *from = (event->ctrl) ? NULL : collection_parent_from_ID(drag_id->from_parent); | Collection *from = (event->ctrl) ? NULL : collection_parent_from_ID(drag_id->from_parent); | ||||
| if (GS(drag_id->id->name) == ID_OB) { | if (GS(drag_id->id->name) == ID_OB) { | ||||
| /* Move/link object into collection. */ | /* Move/link object into collection. */ | ||||
| Object *object = (Object *)drag_id->id; | Object *object = (Object *)drag_id->id; | ||||
| if (from) { | if (from) { | ||||
| ▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines | |||||