Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_select.c
| Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| #include "outliner_intern.h" | #include "outliner_intern.h" | ||||
| /* ****************************************************** */ | /* ****************************************************** */ | ||||
| /* Outliner Element Selection/Activation on Click */ | /* Outliner Element Selection/Activation on Click */ | ||||
| static eOLDrawState tree_element_active_renderlayer( | static eOLDrawState tree_element_active_renderlayer( | ||||
| bContext *C, Scene *UNUSED(scene), SceneLayer *UNUSED(sl), TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) | bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) | ||||
| { | { | ||||
| Scene *sce; | Scene *sce; | ||||
| /* paranoia check */ | /* paranoia check */ | ||||
| if (te->idcode != ID_SCE) | if (te->idcode != ID_SCE) | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| sce = (Scene *)tselem->id; | sce = (Scene *)tselem->id; | ||||
| if (set != OL_SETSEL_NONE) { | if (set != OL_SETSEL_NONE) { | ||||
| sce->active_layer = tselem->nr; | sce->active_view_layer = tselem->nr; | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, sce); | WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, sce); | ||||
| } | } | ||||
| else { | else { | ||||
| return sce->active_layer == tselem->nr; | return sce->active_view_layer == tselem->nr; | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| /** | /** | ||||
| * Select object tree: | * Select object tree: | ||||
| * CTRL+LMB: Select/Deselect object and all cildren | * CTRL+LMB: Select/Deselect object and all cildren | ||||
| * CTRL+SHIFT+LMB: Add/Remove object and all children | * CTRL+SHIFT+LMB: Add/Remove object and all children | ||||
| */ | */ | ||||
| static void do_outliner_object_select_recursive(SceneLayer *sl, Object *ob_parent, bool select) | static void do_outliner_object_select_recursive(ViewLayer *sl, Object *ob_parent, bool select) | ||||
| { | { | ||||
| Base *base; | Base *base; | ||||
| for (base = FIRSTBASE(sl); base; base = base->next) { | for (base = FIRSTBASE(sl); base; base = base->next) { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| if ((((base->flag & BASE_VISIBLED) == 0) && BKE_object_is_child_recursive(ob_parent, ob))) { | if ((((base->flag & BASE_VISIBLED) == 0) && BKE_object_is_child_recursive(ob_parent, ob))) { | ||||
| ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT); | ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT); | ||||
| } | } | ||||
| Show All 21 Lines | if (ED_armature_ebone_is_child_recursive(ebone_parent, ebone)) { | ||||
| ebone->flag |= BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL; | ebone->flag |= BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL; | ||||
| else | else | ||||
| ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); | ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static eOLDrawState tree_element_set_active_object( | static eOLDrawState tree_element_set_active_object( | ||||
| bContext *C, Scene *scene, SceneLayer *sl, SpaceOops *soops, | bContext *C, Scene *scene, ViewLayer *sl, SpaceOops *soops, | ||||
| TreeElement *te, const eOLSetState set, bool recursive) | TreeElement *te, const eOLSetState set, bool recursive) | ||||
| { | { | ||||
| TreeStoreElem *tselem = TREESTORE(te); | TreeStoreElem *tselem = TREESTORE(te); | ||||
| Scene *sce; | Scene *sce; | ||||
| Base *base; | Base *base; | ||||
| Object *ob = NULL; | Object *ob = NULL; | ||||
| /* if id is not object, we search back */ | /* if id is not object, we search back */ | ||||
| Show All 12 Lines | static eOLDrawState tree_element_set_active_object( | ||||
| sce = (Scene *)outliner_search_back(soops, te, ID_SCE); | sce = (Scene *)outliner_search_back(soops, te, ID_SCE); | ||||
| if (sce && scene != sce) { | if (sce && scene != sce) { | ||||
| WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), sce); | WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), sce); | ||||
| scene = sce; | scene = sce; | ||||
| } | } | ||||
| /* find associated base in current scene */ | /* find associated base in current scene */ | ||||
| base = BKE_scene_layer_base_find(sl, ob); | base = BKE_view_layer_base_find(sl, ob); | ||||
| if (base) { | if (base) { | ||||
| if (set == OL_SETSEL_EXTEND) { | if (set == OL_SETSEL_EXTEND) { | ||||
| /* swap select */ | /* swap select */ | ||||
| if (base->flag & BASE_SELECTED) | if (base->flag & BASE_SELECTED) | ||||
| ED_object_base_select(base, BA_DESELECT); | ED_object_base_select(base, BA_DESELECT); | ||||
| else | else | ||||
| ED_object_base_select(base, BA_SELECT); | ED_object_base_select(base, BA_SELECT); | ||||
| } | } | ||||
| else { | else { | ||||
| /* deleselect all */ | /* deleselect all */ | ||||
| BKE_scene_layer_base_deselect_all(sl); | BKE_view_layer_base_deselect_all(sl); | ||||
| ED_object_base_select(base, BA_SELECT); | ED_object_base_select(base, BA_SELECT); | ||||
| } | } | ||||
| if (recursive) { | if (recursive) { | ||||
| /* Recursive select/deselect for Object hierarchies */ | /* Recursive select/deselect for Object hierarchies */ | ||||
| do_outliner_object_select_recursive(sl, ob, (ob->flag & SELECT) != 0); | do_outliner_object_select_recursive(sl, ob, (ob->flag & SELECT) != 0); | ||||
| } | } | ||||
| if (set != OL_SETSEL_NONE) { | if (set != OL_SETSEL_NONE) { | ||||
| ED_object_base_activate(C, base); /* adds notifier */ | ED_object_base_activate(C, base); /* adds notifier */ | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); | WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); | ||||
| } | } | ||||
| } | } | ||||
| if (ob != scene->obedit) | if (ob != scene->obedit) | ||||
| ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); | ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); | ||||
| return OL_DRAWSEL_NORMAL; | return OL_DRAWSEL_NORMAL; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_material( | static eOLDrawState tree_element_active_material( | ||||
| bContext *C, Scene *UNUSED(scene), SceneLayer *sl, SpaceOops *soops, | bContext *C, Scene *UNUSED(scene), ViewLayer *sl, SpaceOops *soops, | ||||
| TreeElement *te, const eOLSetState set) | TreeElement *te, const eOLSetState set) | ||||
| { | { | ||||
| TreeElement *tes; | TreeElement *tes; | ||||
| Object *ob; | Object *ob; | ||||
| /* we search for the object parent */ | /* we search for the object parent */ | ||||
| ob = (Object *)outliner_search_back(soops, te, ID_OB); | ob = (Object *)outliner_search_back(soops, te, ID_OB); | ||||
| // note: ob->matbits can be NULL when a local object points to a library mesh. | // note: ob->matbits can be NULL when a local object points to a library mesh. | ||||
| Show All 36 Lines | if (set != OL_SETSEL_NONE) { | ||||
| * Note that RNA material update does it too, see e.g. rna_MaterialSlot_update(). */ | * Note that RNA material update does it too, see e.g. rna_MaterialSlot_update(). */ | ||||
| DEG_id_tag_update((ID *)ob, OB_RECALC_OB); | DEG_id_tag_update((ID *)ob, OB_RECALC_OB); | ||||
| WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, NULL); | WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, NULL); | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_texture( | static eOLDrawState tree_element_active_texture( | ||||
| bContext *C, Scene *scene, SceneLayer *sl, SpaceOops *UNUSED(soops), | bContext *C, Scene *scene, ViewLayer *sl, SpaceOops *UNUSED(soops), | ||||
| TreeElement *te, const eOLSetState set) | TreeElement *te, const eOLSetState set) | ||||
| { | { | ||||
| TreeElement *tep; | TreeElement *tep; | ||||
| TreeStoreElem /* *tselem,*/ *tselemp; | TreeStoreElem /* *tselem,*/ *tselemp; | ||||
| Object *ob = OBACT(sl); | Object *ob = OBACT(sl); | ||||
| SpaceButs *sbuts = NULL; | SpaceButs *sbuts = NULL; | ||||
| if (ob == NULL) { | if (ob == NULL) { | ||||
| ▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture | ||||
| } | } | ||||
| /* no active object */ | /* no active object */ | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_lamp( | static eOLDrawState tree_element_active_lamp( | ||||
| bContext *UNUSED(C), Scene *UNUSED(scene), SceneLayer *sl, SpaceOops *soops, | bContext *UNUSED(C), Scene *UNUSED(scene), ViewLayer *sl, SpaceOops *soops, | ||||
| TreeElement *te, const eOLSetState set) | TreeElement *te, const eOLSetState set) | ||||
| { | { | ||||
| Object *ob; | Object *ob; | ||||
| /* we search for the object parent */ | /* we search for the object parent */ | ||||
| ob = (Object *)outliner_search_back(soops, te, ID_OB); | ob = (Object *)outliner_search_back(soops, te, ID_OB); | ||||
| if (ob == NULL || ob != OBACT(sl)) { | if (ob == NULL || ob != OBACT(sl)) { | ||||
| /* just paranoia */ | /* just paranoia */ | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| if (set != OL_SETSEL_NONE) { | if (set != OL_SETSEL_NONE) { | ||||
| // XXX extern_set_butspace(F5KEY, 0); | // XXX extern_set_butspace(F5KEY, 0); | ||||
| } | } | ||||
| else { | else { | ||||
| return OL_DRAWSEL_NORMAL; | return OL_DRAWSEL_NORMAL; | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_camera( | static eOLDrawState tree_element_active_camera( | ||||
| bContext *UNUSED(C), Scene *scene, SceneLayer *UNUSED(sl), SpaceOops *soops, | bContext *UNUSED(C), Scene *scene, ViewLayer *UNUSED(sl), SpaceOops *soops, | ||||
| TreeElement *te, const eOLSetState set) | TreeElement *te, const eOLSetState set) | ||||
| { | { | ||||
| Object *ob = (Object *)outliner_search_back(soops, te, ID_OB); | Object *ob = (Object *)outliner_search_back(soops, te, ID_OB); | ||||
| if (set != OL_SETSEL_NONE) { | if (set != OL_SETSEL_NONE) { | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| return scene->camera == ob; | return scene->camera == ob; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_world( | static eOLDrawState tree_element_active_world( | ||||
| bContext *C, Scene *scene, SceneLayer *UNUSED(sl), SpaceOops *UNUSED(soops), | bContext *C, Scene *scene, ViewLayer *UNUSED(sl), SpaceOops *UNUSED(soops), | ||||
| TreeElement *te, const eOLSetState set) | TreeElement *te, const eOLSetState set) | ||||
| { | { | ||||
| TreeElement *tep; | TreeElement *tep; | ||||
| TreeStoreElem *tselem = NULL; | TreeStoreElem *tselem = NULL; | ||||
| Scene *sce = NULL; | Scene *sce = NULL; | ||||
| tep = te->parent; | tep = te->parent; | ||||
| if (tep) { | if (tep) { | ||||
| Show All 16 Lines | // XXX extern_set_butspace(F8KEY, 0); | ||||
| else { | else { | ||||
| return OL_DRAWSEL_NORMAL; | return OL_DRAWSEL_NORMAL; | ||||
| } | } | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_defgroup( | static eOLDrawState tree_element_active_defgroup( | ||||
| bContext *C, SceneLayer *sl, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) | bContext *C, ViewLayer *sl, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) | ||||
| { | { | ||||
| Object *ob; | Object *ob; | ||||
| /* id in tselem is object */ | /* id in tselem is object */ | ||||
| ob = (Object *)tselem->id; | ob = (Object *)tselem->id; | ||||
| if (set != OL_SETSEL_NONE) { | if (set != OL_SETSEL_NONE) { | ||||
| BLI_assert(te->index + 1 >= 0); | BLI_assert(te->index + 1 >= 0); | ||||
| ob->actdef = te->index + 1; | ob->actdef = te->index + 1; | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); | ||||
| } | } | ||||
| else { | else { | ||||
| if (ob == OBACT(sl)) | if (ob == OBACT(sl)) | ||||
| if (ob->actdef == te->index + 1) { | if (ob->actdef == te->index + 1) { | ||||
| return OL_DRAWSEL_NORMAL; | return OL_DRAWSEL_NORMAL; | ||||
| } | } | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_posegroup( | static eOLDrawState tree_element_active_posegroup( | ||||
| bContext *C, Scene *UNUSED(scene), SceneLayer *sl, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) | bContext *C, Scene *UNUSED(scene), ViewLayer *sl, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) | ||||
| { | { | ||||
| Object *ob = (Object *)tselem->id; | Object *ob = (Object *)tselem->id; | ||||
| if (set != OL_SETSEL_NONE) { | if (set != OL_SETSEL_NONE) { | ||||
| if (ob->pose) { | if (ob->pose) { | ||||
| ob->pose->active_group = te->index + 1; | ob->pose->active_group = te->index + 1; | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (ob == OBACT(sl) && ob->pose) { | if (ob == OBACT(sl) && ob->pose) { | ||||
| if (ob->pose->active_group == te->index + 1) { | if (ob->pose->active_group == te->index + 1) { | ||||
| return OL_DRAWSEL_NORMAL; | return OL_DRAWSEL_NORMAL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_posechannel( | static eOLDrawState tree_element_active_posechannel( | ||||
| bContext *C, Scene *UNUSED(scene), SceneLayer *sl, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive) | bContext *C, Scene *UNUSED(scene), ViewLayer *sl, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive) | ||||
| { | { | ||||
| Object *ob = (Object *)tselem->id; | Object *ob = (Object *)tselem->id; | ||||
| bArmature *arm = ob->data; | bArmature *arm = ob->data; | ||||
| bPoseChannel *pchan = te->directdata; | bPoseChannel *pchan = te->directdata; | ||||
| if (set != OL_SETSEL_NONE) { | if (set != OL_SETSEL_NONE) { | ||||
| if (!(pchan->bone->flag & BONE_HIDDEN_P)) { | if (!(pchan->bone->flag & BONE_HIDDEN_P)) { | ||||
| Show All 27 Lines | if (ob == OBACT(sl) && ob->pose) { | ||||
| return OL_DRAWSEL_NORMAL; | return OL_DRAWSEL_NORMAL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_bone( | static eOLDrawState tree_element_active_bone( | ||||
| bContext *C, SceneLayer *sl, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive) | bContext *C, ViewLayer *sl, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive) | ||||
| { | { | ||||
| bArmature *arm = (bArmature *)tselem->id; | bArmature *arm = (bArmature *)tselem->id; | ||||
| Bone *bone = te->directdata; | Bone *bone = te->directdata; | ||||
| if (set != OL_SETSEL_NONE) { | if (set != OL_SETSEL_NONE) { | ||||
| if (!(bone->flag & BONE_HIDDEN_P)) { | if (!(bone->flag & BONE_HIDDEN_P)) { | ||||
| Object *ob = OBACT(sl); | Object *ob = OBACT(sl); | ||||
| if (ob) { | if (ob) { | ||||
| ▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | static eOLDrawState tree_element_active_ebone( | ||||
| else if (ebone->flag & BONE_SELECTED) { | else if (ebone->flag & BONE_SELECTED) { | ||||
| status = OL_DRAWSEL_NORMAL; | status = OL_DRAWSEL_NORMAL; | ||||
| } | } | ||||
| return status; | return status; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_modifier( | static eOLDrawState tree_element_active_modifier( | ||||
| bContext *C, Scene *UNUSED(scene), SceneLayer *UNUSED(sl), TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set) | bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set) | ||||
| { | { | ||||
| if (set != OL_SETSEL_NONE) { | if (set != OL_SETSEL_NONE) { | ||||
| Object *ob = (Object *)tselem->id; | Object *ob = (Object *)tselem->id; | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); | ||||
| // XXX extern_set_butspace(F9KEY, 0); | // XXX extern_set_butspace(F9KEY, 0); | ||||
| } | } | ||||
| Show All 11 Lines | |||||
| // XXX extern_set_butspace(F7KEY, 0); | // XXX extern_set_butspace(F7KEY, 0); | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| static int tree_element_active_constraint( | static int tree_element_active_constraint( | ||||
| bContext *C, Scene *UNUSED(scene), SceneLayer *UNUSED(sl), TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set) | bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set) | ||||
| { | { | ||||
| if (set != OL_SETSEL_NONE) { | if (set != OL_SETSEL_NONE) { | ||||
| Object *ob = (Object *)tselem->id; | Object *ob = (Object *)tselem->id; | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); | ||||
| // XXX extern_set_butspace(F7KEY, 0); | // XXX extern_set_butspace(F7KEY, 0); | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_text( | static eOLDrawState tree_element_active_text( | ||||
| bContext *UNUSED(C), Scene *UNUSED(scene), SceneLayer *UNUSED(sl), SpaceOops *UNUSED(soops), | bContext *UNUSED(C), Scene *UNUSED(scene), ViewLayer *UNUSED(sl), SpaceOops *UNUSED(soops), | ||||
| TreeElement *UNUSED(te), int UNUSED(set)) | TreeElement *UNUSED(te), int UNUSED(set)) | ||||
| { | { | ||||
| // XXX removed | // XXX removed | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_pose( | static eOLDrawState tree_element_active_pose( | ||||
| bContext *C, Scene *scene, SceneLayer *sl, TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set) | bContext *C, Scene *scene, ViewLayer *sl, TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set) | ||||
| { | { | ||||
| Object *ob = (Object *)tselem->id; | Object *ob = (Object *)tselem->id; | ||||
| Base *base = BKE_scene_layer_base_find(sl, ob); | Base *base = BKE_view_layer_base_find(sl, ob); | ||||
| if (base == NULL) { | if (base == NULL) { | ||||
| /* Armature not instantiated in current scene (e.g. inside an appended group...). */ | /* Armature not instantiated in current scene (e.g. inside an appended group...). */ | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| if (set != OL_SETSEL_NONE) { | if (set != OL_SETSEL_NONE) { | ||||
| if (scene->obedit) | if (scene->obedit) | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| // if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) | // if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) | ||||
| // XXX select_single_seq(p, 0); | // XXX select_single_seq(p, 0); | ||||
| p = p->next; | p = p->next; | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| static eOLDrawState tree_element_active_keymap_item( | static eOLDrawState tree_element_active_keymap_item( | ||||
| bContext *UNUSED(C), Scene *UNUSED(scene), SceneLayer *UNUSED(sl), TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set) | bContext *UNUSED(C), Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set) | ||||
| { | { | ||||
| wmKeyMapItem *kmi = te->directdata; | wmKeyMapItem *kmi = te->directdata; | ||||
| if (set == OL_SETSEL_NONE) { | if (set == OL_SETSEL_NONE) { | ||||
| if (kmi->flag & KMI_INACTIVE) { | if (kmi->flag & KMI_INACTIVE) { | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| return OL_DRAWSEL_NORMAL; | return OL_DRAWSEL_NORMAL; | ||||
| Show All 19 Lines | if ((tselem->type == TSE_SCENE_COLLECTION && active->scene_collection == te->directdata) || | ||||
| (tselem->type == TSE_LAYER_COLLECTION && active == 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 | /* don't allow selecting a scene collection, it can have multiple layer collection | ||||
| * instances (which one would the user want to be selected then?) */ | * instances (which one would the user want to be selected then?) */ | ||||
| else if (tselem->type == TSE_LAYER_COLLECTION) { | else if (tselem->type == TSE_LAYER_COLLECTION) { | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| LayerCollection *lc = te->directdata; | LayerCollection *lc = te->directdata; | ||||
| const int collection_index = BKE_layer_collection_findindex(sl, lc); | const int collection_index = BKE_layer_collection_findindex(sl, lc); | ||||
| BLI_assert(collection_index >= 0); | BLI_assert(collection_index >= 0); | ||||
| sl->active_collection = collection_index; | sl->active_collection = collection_index; | ||||
| 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; | ||||
| } | } | ||||
| /* ---------------------------------------------- */ | /* ---------------------------------------------- */ | ||||
| /* generic call for ID data check or make/check active in UI */ | /* generic call for ID data check or make/check active in UI */ | ||||
| eOLDrawState tree_element_active(bContext *C, Scene *scene, SceneLayer *sl, SpaceOops *soops, TreeElement *te, | eOLDrawState tree_element_active(bContext *C, Scene *scene, ViewLayer *sl, SpaceOops *soops, TreeElement *te, | ||||
| const eOLSetState set, const bool handle_all_types) | const eOLSetState set, const bool handle_all_types) | ||||
| { | { | ||||
| switch (te->idcode) { | switch (te->idcode) { | ||||
| /* Note: ID_OB only if handle_all_type is true, else objects are handled specially to allow multiple | /* Note: ID_OB only if handle_all_type is true, else objects are handled specially to allow multiple | ||||
| * selection. See do_outliner_item_activate. */ | * selection. See do_outliner_item_activate. */ | ||||
| case ID_OB: | case ID_OB: | ||||
| if (handle_all_types) { | if (handle_all_types) { | ||||
| return tree_element_set_active_object(C, scene, sl, soops, te, set, false); | return tree_element_set_active_object(C, scene, sl, soops, te, set, false); | ||||
| Show All 14 Lines | eOLDrawState tree_element_active(bContext *C, Scene *scene, ViewLayer *sl, SpaceOops *soops, TreeElement *te, | ||||
| } | } | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| /** | /** | ||||
| * Generic call for non-id data to make/check active in UI | * Generic call for non-id data to make/check active in UI | ||||
| */ | */ | ||||
| eOLDrawState tree_element_type_active( | eOLDrawState tree_element_type_active( | ||||
| bContext *C, Scene *scene, SceneLayer *sl, SpaceOops *soops, | bContext *C, Scene *scene, ViewLayer *sl, SpaceOops *soops, | ||||
| TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive) | TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive) | ||||
| { | { | ||||
| switch (tselem->type) { | switch (tselem->type) { | ||||
| case TSE_DEFGROUP: | case TSE_DEFGROUP: | ||||
| return tree_element_active_defgroup(C, sl, te, tselem, set); | return tree_element_active_defgroup(C, sl, te, tselem, set); | ||||
| case TSE_BONE: | case TSE_BONE: | ||||
| return tree_element_active_bone(C, sl, te, tselem, set, recursive); | return tree_element_active_bone(C, sl, te, tselem, set, recursive); | ||||
| case TSE_EBONE: | case TSE_EBONE: | ||||
| Show All 40 Lines | |||||
| /** | /** | ||||
| * Action when clicking to activate an item (typically under the mouse cursor), | * Action when clicking to activate an item (typically under the mouse cursor), | ||||
| * but don't do any cursor intersection checks. | * but don't do any cursor intersection checks. | ||||
| * | * | ||||
| * Needed to run from operators accessed from a menu. | * Needed to run from operators accessed from a menu. | ||||
| */ | */ | ||||
| static void do_outliner_item_activate_tree_element( | static void do_outliner_item_activate_tree_element( | ||||
| bContext *C, Scene *scene, SceneLayer *sl, SpaceOops *soops, | bContext *C, Scene *scene, ViewLayer *sl, SpaceOops *soops, | ||||
| TreeElement *te, TreeStoreElem *tselem, | TreeElement *te, TreeStoreElem *tselem, | ||||
| const bool extend, const bool recursive) | const bool extend, const bool recursive) | ||||
| { | { | ||||
| /* always makes active object, except for some specific types. | /* always makes active object, except for some specific types. | ||||
| * Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects, we do not want | * Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects, we do not want | ||||
| * to switch out of edit mode (see T48328 for details). */ | * to switch out of edit mode (see T48328 for details). */ | ||||
| if (!ELEM(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP, TSE_EBONE, TSE_LAYER_COLLECTION)) { | if (!ELEM(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP, TSE_EBONE, TSE_LAYER_COLLECTION)) { | ||||
| tree_element_set_active_object( | tree_element_set_active_object( | ||||
| Show All 18 Lines | else if (te->idcode == ID_GR) { | ||||
| for (gob = gr->gobject.first; gob; gob = gob->next) { | for (gob = gr->gobject.first; gob; gob = gob->next) { | ||||
| if (gob->ob->flag & SELECT) { | if (gob->ob->flag & SELECT) { | ||||
| sel = BA_DESELECT; | sel = BA_DESELECT; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| for (gob = gr->gobject.first; gob; gob = gob->next) { | for (gob = gr->gobject.first; gob; gob = gob->next) { | ||||
| ED_object_base_select(BKE_scene_layer_base_find(sl, gob->ob), sel); | ED_object_base_select(BKE_view_layer_base_find(sl, gob->ob), sel); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_scene_layer_base_deselect_all(sl); | BKE_view_layer_base_deselect_all(sl); | ||||
| for (gob = gr->gobject.first; gob; gob = gob->next) { | for (gob = gr->gobject.first; gob; gob = gob->next) { | ||||
| Base *base = BKE_scene_layer_base_find(sl, gob->ob); | Base *base = BKE_view_layer_base_find(sl, gob->ob); | ||||
| /* 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); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
| * | * | ||||
| * This allows us to simulate clicking on an item without dealing with the mouse cursor. | * This allows us to simulate clicking on an item without dealing with the mouse cursor. | ||||
| */ | */ | ||||
| void outliner_item_do_activate_from_tree_element( | void outliner_item_do_activate_from_tree_element( | ||||
| bContext *C, TreeElement *te, TreeStoreElem *tselem, | bContext *C, TreeElement *te, TreeStoreElem *tselem, | ||||
| bool extend, bool recursive) | bool extend, bool recursive) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| SpaceOops *soops = CTX_wm_space_outliner(C); | SpaceOops *soops = CTX_wm_space_outliner(C); | ||||
| do_outliner_item_activate_tree_element( | do_outliner_item_activate_tree_element( | ||||
| C, scene, sl, soops, | C, scene, sl, soops, | ||||
| te, tselem, | te, tselem, | ||||
| extend, recursive); | extend, recursive); | ||||
| } | } | ||||
| Show All 23 Lines | int outliner_item_do_activate_from_cursor( | ||||
| } | } | ||||
| else if (outliner_item_is_co_within_close_toggle(te, view_mval[0])) { | else if (outliner_item_is_co_within_close_toggle(te, view_mval[0])) { | ||||
| outliner_item_toggle_closed(te, extend); | outliner_item_toggle_closed(te, extend); | ||||
| changed = true; | changed = true; | ||||
| rebuild_tree = true; | rebuild_tree = true; | ||||
| } | } | ||||
| else { | else { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| /* the row may also contain children, if one is hovered we want this instead of current te */ | /* the row may also contain children, if one is hovered we want this instead of current te */ | ||||
| TreeElement *activate_te = outliner_find_item_at_x_in_row(soops, te, view_mval[0]); | TreeElement *activate_te = outliner_find_item_at_x_in_row(soops, te, view_mval[0]); | ||||
| TreeStoreElem *activate_tselem = TREESTORE(activate_te); | TreeStoreElem *activate_tselem = TREESTORE(activate_te); | ||||
| outliner_item_select(soops, activate_te, extend, extend); | outliner_item_select(soops, activate_te, extend, extend); | ||||
| do_outliner_item_activate_tree_element(C, scene, sl, soops, activate_te, activate_tselem, extend, recursive); | do_outliner_item_activate_tree_element(C, scene, sl, soops, activate_te, activate_tselem, extend, recursive); | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines | |||||