diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-30 16:24:45 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-30 16:33:05 +0300 |
commit | 38957c183885e8dc3d8d0df4103b8d9c6cddae7c (patch) | |
tree | 1a30ef79e4310be00cd85f8c35e828324420aaa1 /source/blender/editors/space_outliner | |
parent | 5954a5c465fed21d19feb4bda3e42448ea003b39 (diff) |
Object Modes: stay in object mode when setting active
When activating an object from the 3D view or outliner,
keep the newly selected object in object mode.
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_select.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 65cf08d87df..dfeea12a2f1 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -249,6 +249,23 @@ static eOLDrawState tree_element_set_active_object( /* find associated base in current scene */ base = BKE_view_layer_base_find(view_layer, ob); +#ifdef USE_OBJECT_MODE_STRICT + if (base != NULL) { + Object *obact = OBACT(view_layer); + const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT; + if (base && !BKE_object_is_mode_compat(base->object, object_mode)) { + if (object_mode == OB_MODE_OBJECT) { + struct Main *bmain = CTX_data_main(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); + ED_object_mode_generic_exit(bmain, depsgraph, scene, base->object); + } + if (!BKE_object_is_mode_compat(base->object, object_mode)) { + base = NULL; + } + } + } +#endif + if (base) { if (set == OL_SETSEL_EXTEND) { /* swap select */ @@ -272,10 +289,10 @@ static eOLDrawState tree_element_set_active_object( ED_object_base_activate(C, base); /* adds notifier */ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } - } - - if (ob != OBEDIT_FROM_VIEW_LAYER(view_layer)) { - ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); + + if (ob != OBEDIT_FROM_VIEW_LAYER(view_layer)) { + ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); + } } return OL_DRAWSEL_NORMAL; } |