From 78ad368d12d8ff2d8c226353f5097b24afb8851b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Nov 2019 06:18:08 +1100 Subject: Fix inability to toggle pose-mode without sync-selection - There was no way to select some kinds of data without activating them. - Pose mode could not be activated at all. No change to behavior with sync-selection enabled. --- .../editors/space_outliner/outliner_intern.h | 3 +- .../editors/space_outliner/outliner_select.c | 40 ++++++++++++---------- .../editors/space_outliner/outliner_utils.c | 13 ++++++- 3 files changed, 35 insertions(+), 21 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 95e37dea249..ec85d05a1ff 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -267,7 +267,8 @@ void outliner_object_mode_toggle(struct bContext *C, void outliner_element_activate(struct SpaceOutliner *soops, struct TreeStoreElem *tselem); -bool outliner_item_is_co_within_close_toggle(TreeElement *te, float view_co_x); +bool outliner_item_is_co_over_name_icons(const TreeElement *te, float view_co_x); +bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_co_x); /* outliner_edit.c ---------------------------------------------- */ typedef void (*outliner_operation_cb)(struct bContext *C, diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 19bbb115788..15223ca4f8b 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1115,8 +1115,10 @@ static void do_outliner_item_activate_tree_element(bContext *C, TreeElement *te, TreeStoreElem *tselem, const bool extend, - const bool recursive) + const bool recursive, + const bool is_over_name_icons) { + bool do_activate_data = soops->flag & SO_SYNC_SELECT || is_over_name_icons; /* Always makes active object, except for some specific types. */ if (ELEM(tselem->type, TSE_SEQUENCE, @@ -1133,7 +1135,7 @@ static void do_outliner_item_activate_tree_element(bContext *C, else if (tselem->type == TSE_POSE_BASE) { /* Support pose mode toggle, keeping the active object as is. */ } - else if (soops->flag & SO_SYNC_SELECT) { + else if (do_activate_data) { /* Only activate when synced selection is enabled */ tree_element_set_active_object(C, scene, @@ -1149,8 +1151,10 @@ static void do_outliner_item_activate_tree_element(bContext *C, outliner_element_activate(soops, tselem); if (tselem->type == 0) { // the lib blocks - /* editmode? */ - if (te->idcode == ID_SCE) { + if (do_activate_data == false) { + /* Only select in outliner. */ + } + else if (te->idcode == ID_SCE) { if (scene != (Scene *)tselem->id) { WM_window_set_active_scene(CTX_data_main(C), C, CTX_wm_window(C), (Scene *)tselem->id); } @@ -1212,7 +1216,7 @@ static void do_outliner_item_activate_tree_element(bContext *C, tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NORMAL, false); } } - else if (soops->flag & SO_SYNC_SELECT) { + else if (do_activate_data) { tree_element_type_active(C, scene, view_layer, @@ -1332,7 +1336,7 @@ void outliner_item_do_activate_from_tree_element( SpaceOutliner *soops = CTX_wm_space_outliner(C); do_outliner_item_activate_tree_element( - C, scene, view_layer, soops, te, tselem, extend, recursive); + C, scene, view_layer, soops, te, tselem, extend, recursive, false); } /** @@ -1390,9 +1394,18 @@ static int outliner_item_do_activate_from_cursor(bContext *C, do_outliner_range_select(C, soops, activate_te, extend); } else { + const bool is_over_name_icons = outliner_item_is_co_over_name_icons(activate_te, + view_mval[0]); outliner_item_select(soops, activate_te, extend, extend); - do_outliner_item_activate_tree_element( - C, scene, view_layer, soops, activate_te, activate_tselem, extend, false); + do_outliner_item_activate_tree_element(C, + scene, + view_layer, + soops, + activate_te, + activate_tselem, + extend, + false, + is_over_name_icons); } changed = true; @@ -1505,17 +1518,6 @@ static int outliner_box_select_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -/* Find if x coordinate is over an icon or name */ -static bool outliner_item_is_co_over_name_icons(TreeElement *te, float view_co_x) -{ - /* Special case: count area left of Scene Collection as empty space */ - bool outside_left = (TREESTORE(te)->type == TSE_VIEW_COLLECTION_BASE) ? - (view_co_x > te->xs + UI_UNIT_X) : - (view_co_x > te->xs); - - return outside_left && (view_co_x < te->xend); -} - static int outliner_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) { SpaceOutliner *soops = CTX_wm_space_outliner(C); diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c index 5dfdf6f129b..31d930ce2e6 100644 --- a/source/blender/editors/space_outliner/outliner_utils.c +++ b/source/blender/editors/space_outliner/outliner_utils.c @@ -361,8 +361,19 @@ bool outliner_is_element_visible(const TreeElement *te) return true; } +/* Find if x coordinate is over an icon or name */ +bool outliner_item_is_co_over_name_icons(const TreeElement *te, float view_co_x) +{ + /* Special case: count area left of Scene Collection as empty space */ + bool outside_left = (TREESTORE(te)->type == TSE_VIEW_COLLECTION_BASE) ? + (view_co_x > te->xs + UI_UNIT_X) : + (view_co_x > te->xs); + + return outside_left && (view_co_x < te->xend); +} + /* Find if x coordinate is over element disclosure toggle */ -bool outliner_item_is_co_within_close_toggle(TreeElement *te, float view_co_x) +bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_co_x) { return (view_co_x > te->xs) && (view_co_x < te->xs + UI_UNIT_X); } -- cgit v1.2.3