Outliner: Switch properties tabs only on icon click

According to feedback the outliner to properties editor tab switching
was annoying when it always changed tabs on selection, especially for
selecting individual objects. This limits the tab switching behavior to
only when the icons in the outliner are selected.
This commit is contained in:
Nathan Craddock
2020-11-23 15:58:56 -07:00
parent d86fcde39c
commit 037ce662e5
3 changed files with 14 additions and 2 deletions

View File

@@ -299,6 +299,7 @@ void outliner_item_select(struct bContext *C,
const short select_flag);
bool outliner_item_is_co_over_name_icons(const TreeElement *te, float view_co_x);
bool outliner_item_is_co_over_icon(const TreeElement *te, float view_co_x);
bool outliner_item_is_co_over_name(const TreeElement *te, float view_co_x);
bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_co_x);
bool outliner_is_co_within_mode_column(SpaceOutliner *space_outliner, const float view_mval[2]);

View File

@@ -1387,8 +1387,6 @@ static void do_outliner_item_activate_tree_element(bContext *C,
extend ? OL_SETSEL_EXTEND : OL_SETSEL_NORMAL,
recursive);
}
outliner_set_properties_tab(C, te, tselem);
}
/* Select the item using the set flags */
@@ -1568,6 +1566,9 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
TreeElement *activate_te = outliner_find_item_at_x_in_row(
space_outliner, te, view_mval[0], &merged_elements);
/* If `outliner_find_item_at_x_in_row` returned a different element a row icon was selected. */
const bool is_row_icon = te != activate_te;
/* If the selected icon was an aggregate of multiple elements, run the search popup */
if (merged_elements) {
merged_element_search_menu_invoke(C, te, activate_te);
@@ -1591,6 +1592,11 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
(extend ? OL_ITEM_EXTEND : 0);
outliner_item_select(C, space_outliner, activate_te, select_flag);
/* Only switch properties editor tabs when icons are selected. */
if (is_row_icon || outliner_item_is_co_over_icon(activate_te, view_mval[0])) {
outliner_set_properties_tab(C, activate_te, activate_tselem);
}
}
changed = true;

View File

@@ -429,6 +429,11 @@ bool outliner_item_is_co_over_name_icons(const TreeElement *te, float view_co_x)
return outside_left && (view_co_x < te->xend);
}
bool outliner_item_is_co_over_icon(const TreeElement *te, float view_co_x)
{
return (view_co_x > (te->xs + UI_UNIT_X)) && (view_co_x < (te->xs + UI_UNIT_X * 2));
}
/* Find if x coordinate is over element name. */
bool outliner_item_is_co_over_name(const TreeElement *te, float view_co_x)
{