Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/space_outliner.c
| Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | if (GS(id->name) == ID_OB) { | ||||
| view_layer = view_layer->next) | view_layer = view_layer->next) | ||||
| { | { | ||||
| if (BKE_view_layer_base_find(view_layer, (Object *)id)) { | if (BKE_view_layer_base_find(view_layer, (Object *)id)) { | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (ELEM(tselem->type, TSE_LAYER_COLLECTION, TSE_SCENE_COLLECTION)) { | |||||
| /* support adding object from different scene to collection */ | |||||
| return 1; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static void outliner_parent_drop_copy(wmDrag *drag, wmDropBox *drop) | static void outliner_parent_drop_copy(wmDrag *drag, wmDropBox *drop) | ||||
| { | { | ||||
| ID *id = drag->poin; | ID *id = drag->poin; | ||||
| RNA_string_set(drop->ptr, "child", id->name + 2); | RNA_string_set(drop->ptr, "child", id->name + 2); | ||||
| } | } | ||||
| static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event) | static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event) | ||||
| { | { | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| SpaceOops *soops = CTX_wm_space_outliner(C); | SpaceOops *soops = CTX_wm_space_outliner(C); | ||||
| TreeElement *te = NULL; | TreeElement *te = NULL; | ||||
| float fmval[2]; | float fmval[2]; | ||||
| UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); | UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); | ||||
| if (!ELEM(soops->outlinevis, SO_SCENES, SO_GROUPS, SO_COLLECTIONS)) { | if (!ELEM(soops->outlinevis, SO_SCENES, SO_COLLECTIONS, SO_OBJECTS)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (drag->type == WM_DRAG_ID) { | if (drag->type == WM_DRAG_ID) { | ||||
| ID *id = drag->poin; | ID *id = drag->poin; | ||||
| if (GS(id->name) == ID_OB) { | if (GS(id->name) == ID_OB) { | ||||
| if (((Object *)id)->parent) { | if (((Object *)id)->parent) { | ||||
| if ((te = outliner_dropzone_find(soops, fmval, true))) { | if ((te = outliner_dropzone_find(soops, fmval, true))) { | ||||
| ▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | |||||
| static void outliner_material_drop_copy(wmDrag *drag, wmDropBox *drop) | static void outliner_material_drop_copy(wmDrag *drag, wmDropBox *drop) | ||||
| { | { | ||||
| ID *id = drag->poin; | ID *id = drag->poin; | ||||
| RNA_string_set(drop->ptr, "material", id->name + 2); | RNA_string_set(drop->ptr, "material", id->name + 2); | ||||
| } | } | ||||
| static int outliner_group_link_poll(bContext *C, wmDrag *drag, const wmEvent *event) | static int outliner_collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | ||||
| { | { | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| SpaceOops *soops = CTX_wm_space_outliner(C); | SpaceOops *soops = CTX_wm_space_outliner(C); | ||||
| float fmval[2]; | float fmval[2]; | ||||
| UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); | UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); | ||||
| if (drag->type == WM_DRAG_ID) { | if (drag->type == WM_DRAG_ID) { | ||||
| ID *id = drag->poin; | ID *id = drag->poin; | ||||
| if (GS(id->name) == ID_OB) { | if (ELEM(GS(id->name), ID_OB, ID_GR)) { | ||||
| /* Ensure item under cursor is valid drop target */ | /* Ensure item under cursor is valid drop target */ | ||||
| TreeElement *te = outliner_dropzone_find(soops, fmval, true); | TreeElement *te = outliner_dropzone_find(soops, fmval, true); | ||||
| return (te && te->idcode == ID_GR && TREESTORE(te)->type == 0); | return (te && outliner_is_collection_tree_element(te)); | ||||
| } | } | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static void outliner_group_link_copy(wmDrag *drag, wmDropBox *drop) | static void outliner_collection_drop_copy(wmDrag *drag, wmDropBox *drop) | ||||
| { | { | ||||
| ID *id = drag->poin; | ID *id = drag->poin; | ||||
| RNA_string_set(drop->ptr, "object", id->name + 2); | RNA_string_set(drop->ptr, "child", id->name + 2); | ||||
| } | } | ||||
| /* region dropbox definition */ | /* region dropbox definition */ | ||||
| static void outliner_dropboxes(void) | static void outliner_dropboxes(void) | ||||
| { | { | ||||
| ListBase *lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW); | ListBase *lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW); | ||||
| WM_dropbox_add(lb, "OUTLINER_OT_parent_drop", outliner_parent_drop_poll, outliner_parent_drop_copy); | WM_dropbox_add(lb, "OUTLINER_OT_parent_drop", outliner_parent_drop_poll, outliner_parent_drop_copy); | ||||
| WM_dropbox_add(lb, "OUTLINER_OT_parent_clear", outliner_parent_clear_poll, outliner_parent_clear_copy); | WM_dropbox_add(lb, "OUTLINER_OT_parent_clear", outliner_parent_clear_poll, outliner_parent_clear_copy); | ||||
| WM_dropbox_add(lb, "OUTLINER_OT_scene_drop", outliner_scene_drop_poll, outliner_scene_drop_copy); | WM_dropbox_add(lb, "OUTLINER_OT_scene_drop", outliner_scene_drop_poll, outliner_scene_drop_copy); | ||||
| WM_dropbox_add(lb, "OUTLINER_OT_material_drop", outliner_material_drop_poll, outliner_material_drop_copy); | WM_dropbox_add(lb, "OUTLINER_OT_material_drop", outliner_material_drop_poll, outliner_material_drop_copy); | ||||
| WM_dropbox_add(lb, "OUTLINER_OT_group_link", outliner_group_link_poll, outliner_group_link_copy); | WM_dropbox_add(lb, "OUTLINER_OT_collection_drop", outliner_collection_drop_poll, outliner_collection_drop_copy); | ||||
| } | } | ||||
| static void outliner_main_region_draw(const bContext *C, ARegion *ar) | static void outliner_main_region_draw(const bContext *C, ARegion *ar) | ||||
| { | { | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| View2DScrollers *scrollers; | View2DScrollers *scrollers; | ||||
| /* clear */ | /* clear */ | ||||
| ▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| SpaceOops *soops = sa->spacedata.first; | SpaceOops *soops = sa->spacedata.first; | ||||
| wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { | wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { | ||||
| .owner = ar, | .owner = ar, | ||||
| .user_data = ar, | .user_data = ar, | ||||
| .notify = ED_region_do_msg_notify_tag_redraw, | .notify = ED_region_do_msg_notify_tag_redraw, | ||||
| }; | }; | ||||
| if (soops->outlinevis == SO_COLLECTIONS) { | if (ELEM(soops->outlinevis, SO_VIEW_LAYER, SO_COLLECTIONS, SO_OBJECTS)) { | ||||
| WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_region_tag_redraw); | WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_region_tag_redraw); | ||||
| } | } | ||||
| } | } | ||||
| /* ************************ header outliner area region *********************** */ | /* ************************ header outliner area region *********************** */ | ||||
| /* add handlers, stuff you only do once or on area/region changes */ | /* add handlers, stuff you only do once or on area/region changes */ | ||||
| ▲ Show 20 Lines • Show All 167 Lines • Show Last 20 Lines | |||||