Asset Shelf: Transparent asset shelf header with background for buttons #112241

Merged
Julian Eisel merged 19 commits from JulianEisel/blender:temp-asset-shelf-button-sections into main 2023-09-26 17:12:45 +02:00
Member

Draw the background of the asset shelf header fully transparent, with an opaque background with rounded corners behind sections containing buttons. This reduces the visual space consumed by the asset shelf, and makes the header follow a tabbed folder metaphor better. Also, this works much better with our click-through feature, where transparent parts of regions without buttons are passed through the region under it (we might want to consider unifying code here a bit).

Region resizing respects the transparent sections:

When there is little space between sections, the sections get merged so that there are no small gaps in the bar:

Part of #107881.


Note that the core of this is implemented in a generic way, so this can be reused for other regions:

Draw the background of the asset shelf header fully transparent, with an opaque background with rounded corners behind sections containing buttons. This reduces the visual space consumed by the asset shelf, and makes the header follow a tabbed folder metaphor better. Also, this works much better with our click-through feature, where transparent parts of regions without buttons are passed through the region under it (we might want to consider unifying code here a bit). ![](https://projects.blender.org/attachments/40ed10cb-a165-4a08-adba-1bfa10afcaf4) Region resizing respects the transparent sections: <video controls src="https://projects.blender.org/attachments/b89670d4-a580-4f92-a98c-56351ae65e4a" width="500px"><source/></video> When there is little space between sections, the sections get merged so that there are no small gaps in the bar: <video controls src="https://projects.blender.org/attachments/7ae8976e-6020-4881-ac6d-b26ec98d5009" width="500px"><source/></video> Part of #107881. ---- Note that the core of this is implemented in a generic way, so this can be reused for other regions: ![](https://projects.blender.org/attachments/b32d00c2-75ee-4da0-94ef-8b60257e2e1d)
Julian Eisel added the
Module
User Interface
Interest
Asset System
labels 2023-09-11 15:39:26 +02:00
Julian Eisel added 2 commits 2023-09-11 15:39:40 +02:00
Julian Eisel changed title from Asset Shelf: Draw asset shelf header transparent with button background to WIP: Asset Shelf: Draw asset shelf header transparent with button background 2023-09-11 15:39:52 +02:00
Hans Goudey reviewed 2023-09-11 16:32:36 +02:00
@ -2251,1 +2251,4 @@
}
void ui_draw_button_sections_background(const ARegion *region,
const blender::Vector<rcti> &section_bounds,
Member

Use Span here since this function doesn't need to know the data is stored in a vector.

Use `Span` here since this function doesn't need to know the data is stored in a vector.
JulianEisel marked this conversation as resolved
@ -52,0 +79,4 @@
BLI_assert(merge_distance_x >= 0);
const std::function finish_section_fn = [&section_bounds,
Member

This can just be a lambda, it doesn't need to be a std::function

Also no need to be specific about the captures, it's fine to capture everything by reference.

const auto finish_section = [&](const rcti cur_section_bounds) { ... };
This can just be a lambda, it doesn't need to be a `std::function` Also no need to be specific about the captures, it's fine to capture everything by reference. ``` const auto finish_section = [&](const rcti cur_section_bounds) { ... }; ```
Author
Member

[&] can be a bit memory wasting since it essentially adds a new member variable for each outer scope variable to the function object generated by the compiler - being lazy has a cost here :) So I prefer not to default to it. In this case it's fine though.

`[&]` can be a bit memory wasting since it essentially adds a new member variable for each outer scope variable to the function object generated by the compiler - being lazy has a cost here :) So I prefer not to default to it. In this case it's fine though.
Author
Member

I'm not too keen on auto here, but I guess std::function add costs that can be avoided (micro-optimizing here). But at least with the _fn suffix it's clear that this object is a functor when it pops up later in the function, so I guess it's fine.

I'm not too keen on `auto` here, but I guess `std::function` add costs that can be avoided (micro-optimizing here). But at least with the `_fn` suffix it's clear that this object is a functor when it pops up later in the function, so I guess it's fine.
JulianEisel marked this conversation as resolved
Julian Eisel added 2 commits 2023-09-11 21:00:11 +02:00
Julian Eisel added 1 commit 2023-09-11 21:14:24 +02:00
Makes the feature a lot more isolated and easier to navigate.
Julian Eisel added 1 commit 2023-09-13 16:10:58 +02:00
Julian Eisel added 1 commit 2023-09-13 16:44:26 +02:00
Julian Eisel changed title from WIP: Asset Shelf: Draw asset shelf header transparent with button background to Asset Shelf: Transparent asset shelf header with background for buttons 2023-09-13 16:45:27 +02:00
Julian Eisel added 1 commit 2023-09-13 16:55:41 +02:00
Julian Eisel requested review from Campbell Barton 2023-09-13 16:57:43 +02:00
Julian Eisel requested review from Dalai Felinto 2023-09-13 16:57:43 +02:00
Hans Goudey reviewed 2023-09-13 17:08:12 +02:00
@ -0,0 +103,4 @@
}
static void ui_draw_button_sections_background(const ARegion *region,
const Span<rcti> &section_bounds,
Member

Span should be passed by value, otherwise it acts like a pointer to a pointer.

`Span` should be passed by value, otherwise it acts like a pointer to a pointer.
Author
Member

Heh, rushing things before the meeting much? Thanks :)

Heh, rushing things before the meeting much? Thanks :)
JulianEisel marked this conversation as resolved
Julian Eisel added 1 commit 2023-09-13 19:21:44 +02:00
Julian Eisel requested review from Pablo Vazquez 2023-09-13 19:23:33 +02:00
Julian Eisel added 2 commits 2023-09-14 15:49:37 +02:00
Julian Eisel added 1 commit 2023-09-14 16:20:06 +02:00
Pablo Vazquez approved these changes 2023-09-15 18:18:02 +02:00
Pablo Vazquez left a comment
Member

+1 looks wise 👌

+1 looks wise 👌

When toggling it off (via the piemenu), I see a big artifact showing up:
image

When toggling it off (via the piemenu), I see a big artifact showing up: ![image](/attachments/6df54c23-ea8a-4afc-b2d3-725c96daee6f)
254 KiB
Julian Eisel added 2 commits 2023-09-21 14:15:57 +02:00
Member

Meeting yesterday agreed on having this but also combined with the style applied to the top-bar for consistency.

Meeting yesterday agreed on having this but also combined with the style applied to the top-bar for consistency.
Julian Eisel added 1 commit 2023-09-25 15:19:49 +02:00
Julian Eisel added 1 commit 2023-09-25 16:38:50 +02:00
Setting the hidden flag on the header breaks some (fair) assumptions in
the region blending code, it manages these flags itself.
Author
Member

When toggling it off (via the piemenu), I see a big artifact showing up:
image

Fixed in the last commit.

> When toggling it off (via the piemenu), I see a big artifact showing up: > ![image](/attachments/6df54c23-ea8a-4afc-b2d3-725c96daee6f) Fixed in the last commit.
Campbell Barton approved these changes 2023-09-26 16:25:46 +02:00
Campbell Barton left a comment
Owner

LGTM, only minor issues noted inline.

LGTM, only minor issues noted inline.
@ -506,3 +507,3 @@
update_active_shelf(*C, *space_type, *shelf_regiondata);
ED_region_header(C, region);
ED_region_header_layout(C, region);

Might it make sense to add a ED_region_header_with_button_sections ? Since practically all other region functions use ED_region_header(C, region).

Might it make sense to add a `ED_region_header_with_button_sections` ? Since practically all other region functions use `ED_region_header(C, region)`.
JulianEisel marked this conversation as resolved
@ -842,0 +843,4 @@
/* Separator line between regions if the #uiButtonSectionsAlign is not #None. */
#define UI_BUTTON_SECTION_SEPERATOR_LINE_WITH (U.pixelsize * 2)
enum class uiButtonSectionsAlign : int16_t { None, Top, Bottom };

picky I have a slight preference to set the first value to 1, so it's clear when debugging what the values are and so a zeroed value isn't implicitly initializing in a non obvious way.

Also, why not uint8_t? (if the size is given at all, may as well not use a larger value then is needed.)

*picky* I have a slight preference to set the first value to `1`, so it's clear when debugging what the values are and so a zeroed value isn't implicitly initializing in a non obvious way. Also, why not `uint8_t`? (if the size is given at all, may as well not use a larger value then is needed.)
JulianEisel marked this conversation as resolved
@ -3594,0 +3603,4 @@
const ARegion *region,
const uiButtonSectionsAlign align)
{
const ThemeColorID bgcolorid = region_background_color_id(C, region);

Worth mentioning this follows ED_region_header_draw closely, it might make sense to but this directly below that function too so changes to one aren't as likely to be missed in the other.

Worth mentioning this follows `ED_region_header_draw` closely, it might make sense to but this directly below that function too so changes to one aren't as likely to be missed in the other.
JulianEisel marked this conversation as resolved
@ -3594,0 +3606,4 @@
const ThemeColorID bgcolorid = region_background_color_id(C, region);
/* Clear and draw button sections background when using region overlap. Otherwise clear using the
* background color like normally. */

*picky *normally -> normal.

*picky *normally -> normal.
JulianEisel marked this conversation as resolved
Julian Eisel added 1 commit 2023-09-26 16:52:07 +02:00
Julian Eisel added 1 commit 2023-09-26 17:01:27 +02:00
Julian Eisel added 1 commit 2023-09-26 17:02:20 +02:00
Julian Eisel merged commit 73460903fa into main 2023-09-26 17:12:45 +02:00
Julian Eisel deleted branch temp-asset-shelf-button-sections 2023-09-26 17:12:47 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#112241
No description provided.