From 3fc178b19e4c11ac384731c4088b2bd3fa809794 Mon Sep 17 00:00:00 2001 From: Nathan Craddock Date: Thu, 26 Nov 2020 14:19:05 -0700 Subject: Outliner: Highlight icons on cursor hover The icons for collapsed children already draw highlighted when hovered. Because the item icons are now select targets (for outliner to properties editor tab switching) this adds highlights on hover for all outliner element icons. --- source/blender/editors/space_outliner/outliner_dragdrop.c | 6 ++++-- source/blender/editors/space_outliner/outliner_draw.c | 12 +++++++++--- source/blender/editors/space_outliner/outliner_edit.c | 14 +++++++++++--- source/blender/editors/space_outliner/space_outliner.c | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index 865e06bf0b6..d3da7b80765 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -854,7 +854,8 @@ static bool datastack_drop_poll(bContext *C, SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); ARegion *region = CTX_wm_region(C); - bool changed = outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED | TSE_DRAG_ANY, false); + bool changed = outliner_flag_set( + &space_outliner->tree, TSE_HIGHLIGHTED_ANY | TSE_DRAG_ANY, false); StackDropData *drop_data = drag->poin; if (!drop_data) { @@ -1173,7 +1174,8 @@ static bool collection_drop_poll(bContext *C, { SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); ARegion *region = CTX_wm_region(C); - bool changed = outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED | TSE_DRAG_ANY, false); + bool changed = outliner_flag_set( + &space_outliner->tree, TSE_HIGHLIGHTED_ANY | TSE_DRAG_ANY, false); CollectionDrop data; if (!event->shift && collection_drop_init(C, drag, event, &data)) { diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index ea2e3ce2565..6364fbc0a87 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -2782,7 +2782,7 @@ static void outliner_draw_iconrow_doit(uiBlock *block, icon_border); } - if (tselem->flag & TSE_HIGHLIGHTED) { + if (tselem->flag & TSE_HIGHLIGHTED_ICON) { alpha_fac += 0.5; } tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, alpha_fac, false); @@ -3078,8 +3078,14 @@ static void outliner_draw_tree_element(bContext *C, /* datatype icon */ if (!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM, TSE_ID_BASE))) { - tselem_draw_icon( - block, xmax, (float)startx + offsx, (float)*starty, tselem, te, alpha_fac, true); + tselem_draw_icon(block, + xmax, + (float)startx + offsx, + (float)*starty, + tselem, + te, + (tselem->flag & TSE_HIGHLIGHTED_ICON) ? alpha_fac + 0.5f : alpha_fac, + true); offsx += UI_UNIT_X + 4 * ufac; } else { diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index bf94e9e04a4..6c0759b9842 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -117,19 +117,27 @@ static int outliner_highlight_update(bContext *C, wmOperator *UNUSED(op), const TreeElement *hovered_te = outliner_find_item_at_y( space_outliner, &space_outliner->tree, view_mval[1]); + TreeElement *icon_te = NULL; bool is_over_icon; if (hovered_te) { - hovered_te = outliner_find_item_at_x_in_row( + icon_te = outliner_find_item_at_x_in_row( space_outliner, hovered_te, view_mval[0], NULL, &is_over_icon); } + bool changed = false; - if (!hovered_te || !(hovered_te->store_elem->flag & TSE_HIGHLIGHTED)) { - changed = outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED | TSE_DRAG_ANY, false); + if (!hovered_te || !is_over_icon || !(hovered_te->store_elem->flag & TSE_HIGHLIGHTED) || + !(icon_te->store_elem->flag & TSE_HIGHLIGHTED_ICON)) { + /* Clear highlights when nothing is hovered or when a new item is hovered. */ + changed = outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED_ANY | TSE_DRAG_ANY, false); if (hovered_te) { hovered_te->store_elem->flag |= TSE_HIGHLIGHTED; changed = true; } + if (is_over_icon) { + icon_te->store_elem->flag |= TSE_HIGHLIGHTED_ICON; + changed = true; + } } if (changed) { diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 5ec55eee7fb..cd8e8a0be98 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -426,7 +426,7 @@ static void outliner_deactivate(struct ScrArea *area) { /* Remove hover highlights */ SpaceOutliner *space_outliner = area->spacedata.first; - outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED, false); + outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED_ANY, false); ED_region_tag_redraw_no_rebuild(BKE_area_find_region_type(area, RGN_TYPE_WINDOW)); } -- cgit v1.2.3