Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_select.c
| Show All 38 Lines | |||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_sequence_types.h" | #include "DNA_sequence_types.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BKE_armature.h" | #include "BKE_armature.h" | ||||
| #include "BKE_collection.h" | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_group.h" | |||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_sequencer.h" | #include "BKE_sequencer.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| ▲ Show 20 Lines • Show All 619 Lines • ▼ Show 20 Lines | if (set == OL_SETSEL_NONE) { | ||||
| return OL_DRAWSEL_NORMAL; | return OL_DRAWSEL_NORMAL; | ||||
| } | } | ||||
| else { | else { | ||||
| kmi->flag ^= KMI_INACTIVE; | kmi->flag ^= KMI_INACTIVE; | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_collection( | static eOLDrawState tree_element_active_master_collection( | ||||
| bContext *C, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) | bContext *C, TreeElement *UNUSED(te), const eOLSetState set) | ||||
| { | { | ||||
| if (set == OL_SETSEL_NONE) { | if (set == OL_SETSEL_NONE) { | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | |||||
| LayerCollection *active = CTX_data_layer_collection(C); | LayerCollection *active = CTX_data_layer_collection(C); | ||||
| /* sometimes the renderlayer has no LayerCollection at all */ | if (active == view_layer->layer_collections.first) { | ||||
| if (active == NULL) { | |||||
| return OL_DRAWSEL_NONE; | |||||
| } | |||||
| if ((tselem->type == TSE_SCENE_COLLECTION && active->scene_collection == te->directdata) || | |||||
| (tselem->type == TSE_LAYER_COLLECTION && active == te->directdata)) | |||||
| { | |||||
| return OL_DRAWSEL_NORMAL; | return OL_DRAWSEL_NORMAL; | ||||
| } | } | ||||
| } | } | ||||
| /* don't allow selecting a scene collection, it can have multiple layer collection | else { | ||||
| * instances (which one would the user want to be selected then?) */ | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| else if (tselem->type == TSE_LAYER_COLLECTION) { | LayerCollection *layer_collection = view_layer->layer_collections.first; | ||||
| LayerCollection *layer_collection = te->directdata; | view_layer->active_collection = layer_collection; | ||||
| WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); | |||||
| } | |||||
| return OL_DRAWSEL_NONE; | |||||
| } | |||||
| switch (layer_collection->scene_collection->type) { | static eOLDrawState tree_element_active_layer_collection( | ||||
| case COLLECTION_TYPE_NONE: | bContext *C, TreeElement *te, const eOLSetState set) | ||||
| case COLLECTION_TYPE_GROUP_INTERNAL: | |||||
| { | { | ||||
| ViewLayer *view_layer = BKE_view_layer_find_from_collection(tselem->id, layer_collection); | if (set == OL_SETSEL_NONE) { | ||||
| const int collection_index = BKE_layer_collection_findindex(view_layer, layer_collection); | LayerCollection *active = CTX_data_layer_collection(C); | ||||
| if (collection_index > -1) { | if (active == te->directdata) { | ||||
| view_layer->active_collection = collection_index; | return OL_DRAWSEL_NORMAL; | ||||
| } | |||||
| break; | |||||
| } | } | ||||
| default: | |||||
| BLI_assert(!"Collection type not fully implemented"); | |||||
| } | } | ||||
| else { | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| LayerCollection *layer_collection = te->directdata; | |||||
| ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, layer_collection); | |||||
| view_layer->active_collection = layer_collection; | |||||
| WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); | WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| /* ---------------------------------------------- */ | /* ---------------------------------------------- */ | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | case TSE_SEQUENCE: | ||||
| return tree_element_active_sequence(C, scene, te, tselem, set); | return tree_element_active_sequence(C, scene, te, tselem, set); | ||||
| case TSE_SEQUENCE_DUP: | case TSE_SEQUENCE_DUP: | ||||
| return tree_element_active_sequence_dup(scene, te, tselem, set); | return tree_element_active_sequence_dup(scene, te, tselem, set); | ||||
| case TSE_KEYMAP_ITEM: | case TSE_KEYMAP_ITEM: | ||||
| return tree_element_active_keymap_item(C, scene, view_layer, te, tselem, set); | return tree_element_active_keymap_item(C, scene, view_layer, te, tselem, set); | ||||
| case TSE_GP_LAYER: | case TSE_GP_LAYER: | ||||
| //return tree_element_active_gplayer(C, scene, s, te, tselem, set); | //return tree_element_active_gplayer(C, scene, s, te, tselem, set); | ||||
| break; | break; | ||||
| case TSE_SCENE_COLLECTION: | case TSE_SCENE_COLLECTION_BASE: | ||||
| if (ELEM(soops->outlinevis, SO_COLLECTIONS, SO_VIEW_LAYER)) { | |||||
| return tree_element_active_master_collection(C, te, set); | |||||
| } | |||||
| else { | |||||
| return OL_DRAWSEL_NONE; | |||||
| } | |||||
| case TSE_LAYER_COLLECTION: | case TSE_LAYER_COLLECTION: | ||||
| return tree_element_active_collection(C, te, tselem, set); | return tree_element_active_layer_collection(C, te, set); | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| /* ================================================ */ | /* ================================================ */ | ||||
| /** | /** | ||||
| * Action when clicking to activate an item (typically under the mouse cursor), | * Action when clicking to activate an item (typically under the mouse cursor), | ||||
| Show All 19 Lines | static void do_outliner_item_activate_tree_element( | ||||
| if (tselem->type == 0) { // the lib blocks | if (tselem->type == 0) { // the lib blocks | ||||
| /* editmode? */ | /* editmode? */ | ||||
| if (te->idcode == ID_SCE) { | if (te->idcode == ID_SCE) { | ||||
| if (scene != (Scene *)tselem->id) { | if (scene != (Scene *)tselem->id) { | ||||
| WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), (Scene *)tselem->id); | WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), (Scene *)tselem->id); | ||||
| } | } | ||||
| } | } | ||||
| else if (te->idcode == ID_GR) { | else if (te->idcode == ID_GR) { | ||||
| Group *gr = (Group *)tselem->id; | Collection *gr = (Collection *)tselem->id; | ||||
| if (extend) { | if (extend) { | ||||
| int sel = BA_SELECT; | int sel = BA_SELECT; | ||||
| FOREACH_GROUP_BASE_BEGIN(gr, base) | FOREACH_COLLECTION_BASE_RECURSIVE_BEGIN(gr, base) | ||||
| { | { | ||||
| if (base->flag & BASE_SELECTED) { | if (base->flag & BASE_SELECTED) { | ||||
| sel = BA_DESELECT; | sel = BA_DESELECT; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| FOREACH_GROUP_BASE_END | FOREACH_COLLECTION_BASE_RECURSIVE_END | ||||
| FOREACH_GROUP_OBJECT_BEGIN(gr, object) | FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(gr, object) | ||||
| { | { | ||||
| ED_object_base_select(BKE_view_layer_base_find(view_layer, object), sel); | ED_object_base_select(BKE_view_layer_base_find(view_layer, object), sel); | ||||
| } | } | ||||
| FOREACH_GROUP_OBJECT_END; | FOREACH_COLLECTION_OBJECT_RECURSIVE_END; | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_view_layer_base_deselect_all(view_layer); | BKE_view_layer_base_deselect_all(view_layer); | ||||
| FOREACH_GROUP_OBJECT_BEGIN(gr, object) | FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(gr, object) | ||||
| { | { | ||||
| Base *base = BKE_view_layer_base_find(view_layer, object); | Base *base = BKE_view_layer_base_find(view_layer, object); | ||||
| /* Object may not be in this scene */ | /* Object may not be in this scene */ | ||||
| if (base != NULL) { | if (base != NULL) { | ||||
| if ((base->flag & BASE_SELECTED) == 0) { | if ((base->flag & BASE_SELECTED) == 0) { | ||||
| ED_object_base_select(base, BA_SELECT); | ED_object_base_select(base, BA_SELECT); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| FOREACH_GROUP_OBJECT_END; | FOREACH_COLLECTION_OBJECT_RECURSIVE_END; | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); | WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); | ||||
| } | } | ||||
| else if (ELEM(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { | else if (ELEM(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { | ||||
| WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); | WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); | ||||
| } | } | ||||
| else { // rest of types | else { // rest of types | ||||
| ▲ Show 20 Lines • Show All 217 Lines • Show Last 20 Lines | |||||