Outliner: "Show Users Column" in View Layer and Scenes mode

User counts are currently only visible in Outliner Blender File mode
or through the Properties Editor. Since the Outliner is most commonly
used in View Layer and Scenes modes, this PR introduces a new option,
“Show Users Column” (False by default) to make this information
available directly in those views.

See PR description for images and RCS thread

Pull Request: https://projects.blender.org/blender/blender/pulls/156555

---------

Co-authored-by: Pratik Borhade <25420+pratikpb2123@noreply.localhost>
This commit is contained in:
1P2D 2026-09-28 11:26:35 +02:00 • committed by Pratik Borhade
parent 27f8df2958
commit e2aaab991b
5 changed files with 41 additions and 4 deletions

View file

@ -461,6 +461,11 @@ class OUTLINER_PT_filter(Panel):
row = layout.row(align=True)
row.prop(space, "show_mode_column", text="Show Mode Column")
if display_mode in {'VIEW_LAYER', 'SCENES'}:
row = layout.row(align=True)
row.prop(space, "show_users_column", text="Show Users Column")
layout.separator()
if display_mode == 'LIBRARY_OVERRIDES' and space.lib_override_view_mode == 'PROPERTIES' and bpy.data.libraries:

View file

@ -1235,6 +1235,12 @@ static void outliner_draw_restrictbuts(ui::Block *block,
int restrict_column_offset = 0;
/* This will determine the order of drawing from RIGHT to LEFT. */
if (ELEM(space_outliner->outlinevis, SO_VIEW_LAYER, SO_SCENES)) {
/* Users column is the rightmost in both View Layer and Scenes; reserve its slot. */
if (space_outliner->flag & SO_USERS_COLUMN) {
restrict_column_offset++;
}
}
if (space_outliner->outlinevis == SO_VIEW_LAYER) {
if (space_outliner->show_restrict_flags & SO_RESTRICT_INDIRECT_ONLY) {
restrict_offsets.indirect_only = (++restrict_column_offset) * UI_UNIT_X + V2D_SCROLL_WIDTH;
@ -1925,15 +1931,23 @@ static void outliner_draw_userbuts(ui::Block *block,
const ARegion *region,
const SpaceOutliner *space_outliner)
{
const int xmax_offset = ELEM(space_outliner->outlinevis, SO_VIEW_LAYER, SO_SCENES) ?
int(UI_UNIT_X + V2D_SCROLL_WIDTH) :
int(OL_TOG_USER_BUTS_USERS);
tree_iterator::all_open(*space_outliner, [&](const TreeElement *te) {
if (!outliner_is_element_in_view(te, &region->v2d)) {
return;
}
const TreeStoreElem *tselem = TREESTORE(te);
ID *id = tselem->id;
if (tselem->type != TSE_SOME_ID || id->tag & ID_TAG_EXTRAUSER) {
if (tselem->type != TSE_SOME_ID && tselem->type != TSE_LAYER_COLLECTION) {
return;
}
ID *id = tselem->id;
if (!id || id->tag & ID_TAG_EXTRAUSER) {
return;
}
@ -1950,7 +1964,7 @@ static void outliner_draw_userbuts(ui::Block *block,
bt = uiDefBut(block,
ui::ButtonType::But,
overlay,
int(region->v2d.cur.xmax - OL_TOG_USER_BUTS_USERS),
int(region->v2d.cur.xmax - xmax_offset),
te->ys,
UI_UNIT_X,
UI_UNIT_Y,
@ -1981,7 +1995,7 @@ static void outliner_draw_userbuts(ui::Block *block,
ui::ButtonType::IconToggle,
ID_FLAG_FAKEUSER,
ICON_FAKE_USER_OFF,
int(region->v2d.cur.xmax - OL_TOG_USER_BUTS_USERS),
int(region->v2d.cur.xmax - xmax_offset),
te->ys,
UI_UNIT_X,
UI_UNIT_Y,
@ -3950,6 +3964,13 @@ void draw_outliner(const bContext *C, bool do_rebuild)
space_outliner,
&space_outliner->runtime->tree,
props_active);
/* For View Layer and Scenes, draw the optional users column as the rightmost column. */
if (ELEM(space_outliner->outlinevis, SO_VIEW_LAYER, SO_SCENES) &&
(space_outliner->flag & SO_USERS_COLUMN))
{
outliner_draw_userbuts(block, region, space_outliner);
}
}
/* Draw mode icons */

View file

@ -379,6 +379,9 @@ float outliner_right_columns_width(const SpaceOutliner *space_outliner)
}
ATTR_FALLTHROUGH;
case SO_SCENES:
if (space_outliner->flag & SO_USERS_COLUMN) {
num_columns++;
}
if (space_outliner->show_restrict_flags & SO_RESTRICT_SELECT) {
num_columns++;
}

View file

@ -156,6 +156,7 @@ enum eSpaceOutliner_Flag : short {
SO_MODE_COLUMN = (1 << 6),
SO_SCROLL_TO_ACTIVE = (1 << 7),
SO_EXPAND_ON_FOCUS = (1 << 8),
SO_USERS_COLUMN = (1 << 9),
};
ENUM_OPERATORS(eSpaceOutliner_Flag)

View file

@ -4651,6 +4651,13 @@ static void rna_def_space_outliner(BlenderRNA *brna)
prop, "Expand on Focus", "Uncollapse the active item when scrolling it into view");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, nullptr);
prop = RNA_def_property(srna, "show_users_column", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", SO_USERS_COLUMN);
RNA_def_property_ui_text(prop,
"Show Users Column",
"Display a column showing the number of users for each data-block");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, nullptr);
/* Granular restriction column option. */
prop = RNA_def_property(srna, "show_restrict_column_enable", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "show_restrict_flags", SO_RESTRICT_ENABLE);