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.
This commit is contained in:
Nathan Craddock
2020-11-26 14:19:05 -07:00
parent 3d0c5455ed
commit 3fc178b19e
5 changed files with 27 additions and 9 deletions

View File

@@ -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)) {

View File

@@ -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 {

View File

@@ -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) {

View File

@@ -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));
}

View File

@@ -66,7 +66,9 @@ enum {
/* Needed because outliner-only elements can be active */
TSE_ACTIVE = (1 << 9),
/* TSE_ACTIVE_WALK = (1 << 10), */ /* Unused */
TSE_HIGHLIGHTED_ICON = (1 << 11),
TSE_DRAG_ANY = (TSE_DRAG_INTO | TSE_DRAG_BEFORE | TSE_DRAG_AFTER),
TSE_HIGHLIGHTED_ANY = (TSE_HIGHLIGHTED | TSE_HIGHLIGHTED_ICON),
};
/* TreeStoreElem->types */