From e1ae5bd45fd0a8c0073039fa3b46835fe20f530e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 7 Apr 2021 15:58:34 +0200 Subject: LibOverride: Add a dedicated view in the Outliner. This is a minimal, information-only view currently, listing by default all the override data-blocks, with their user-edited override properties. System-generated overrides (like the overrides of pointers to other override data-blocks) can be shown through a filter option. Finally, potential info or warning messages from (auto-)resync propcess are also shown, as an icon + tooltip next to the affected items. Part of D10855. --- .../blender/editors/space_outliner/outliner_draw.c | 100 ++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/space_outliner/outliner_draw.c') diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 0916e106abf..99bc23ad246 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1775,6 +1775,88 @@ static void outliner_draw_userbuts(uiBlock *block, } } +static bool outliner_draw_overrides_buts(uiBlock *block, + ARegion *region, + SpaceOutliner *space_outliner, + ListBase *lb, + const bool is_open) +{ + bool any_item_has_warnings = false; + + LISTBASE_FOREACH (TreeElement *, te, lb) { + bool item_has_warnings = false; + const bool do_draw = (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && + te->ys <= region->v2d.cur.ymax); + int but_flag = UI_BUT_DRAG_LOCK; + const char *tip = NULL; + + TreeStoreElem *tselem = TREESTORE(te); + switch (tselem->type) { + case TSE_LIBRARY_OVERRIDE_BASE: { + ID *id = tselem->id; + + if (ID_IS_OVERRIDE_LIBRARY_REAL(id) && ID_REAL_USERS(id) == 0) { + item_has_warnings = true; + if (do_draw) { + tip = TIP_("This override data-block is unused"); + } + } + + else if (id->flag & LIB_LIB_OVERRIDE_RESYNC_LEFTOVER) { + item_has_warnings = true; + if (do_draw) { + tip = TIP_( + "This override data-block is not needed anymore, but was detected as user-edited"); + } + } + break; + } + case TSE_LIBRARY_OVERRIDE: { + const bool is_rna_path_valid = (bool)(POINTER_AS_UINT(te->directdata)); + if (!is_rna_path_valid) { + item_has_warnings = true; + if (do_draw) { + tip = TIP_( + "This override property does not exist in current data, it will be removed on " + "next .blend file save"); + } + } + break; + } + default: + break; + } + + const bool any_child_has_warnings = outliner_draw_overrides_buts( + block, + region, + space_outliner, + &te->subtree, + is_open && TSELEM_OPEN(tselem, space_outliner)); + + if (do_draw && + (item_has_warnings || (any_child_has_warnings && !TSELEM_OPEN(tselem, space_outliner)))) { + if (tip == NULL) { + tip = TIP_("Some sub-items require attention"); + } + uiBut *bt = uiDefIconBlockBut(block, + NULL, + NULL, + 1, + ICON_ERROR, + (int)(region->v2d.cur.xmax - OL_TOG_USER_BUTS_STATUS), + te->ys, + UI_UNIT_X, + UI_UNIT_Y, + tip); + UI_but_flag_enable(bt, but_flag); + } + any_item_has_warnings = any_item_has_warnings || item_has_warnings || any_child_has_warnings; + } + + return any_item_has_warnings; +} + static void outliner_draw_rnacols(ARegion *region, int sizex) { View2D *v2d = ®ion->v2d; @@ -2896,7 +2978,13 @@ static void outliner_draw_iconrow(bContext *C, active = tree_element_type_active_state_get(C, tvc, te, tselem); } - if (!ELEM(tselem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION, TSE_R_LAYER, TSE_GP_LAYER)) { + if (!ELEM(tselem->type, + TSE_SOME_ID, + TSE_LAYER_COLLECTION, + TSE_R_LAYER, + TSE_GP_LAYER, + TSE_LIBRARY_OVERRIDE_BASE, + TSE_LIBRARY_OVERRIDE)) { outliner_draw_iconrow_doit(block, te, fstyle, xmax, offsx, ys, alpha_fac, active, 1); } else { @@ -3656,7 +3744,11 @@ void draw_outliner(const bContext *C) } /* Sync selection state from view layer. */ - if (!ELEM(space_outliner->outlinevis, SO_LIBRARIES, SO_DATA_API, SO_ID_ORPHANS) && + if (!ELEM(space_outliner->outlinevis, + SO_LIBRARIES, + SO_OVERRIDES_LIBRARY, + SO_DATA_API, + SO_ID_ORPHANS) && space_outliner->flag & SO_SYNC_SELECT) { outliner_sync_selection(C, space_outliner); } @@ -3703,6 +3795,10 @@ void draw_outliner(const bContext *C) /* draw user toggle columns */ outliner_draw_userbuts(block, region, space_outliner, &space_outliner->tree); } + else if (space_outliner->outlinevis == SO_OVERRIDES_LIBRARY) { + /* Draw overrides status columns. */ + outliner_draw_overrides_buts(block, region, space_outliner, &space_outliner->tree, true); + } else if (restrict_column_width > 0.0f) { /* draw restriction columns */ RestrictPropertiesActive props_active; -- cgit v1.2.3