Brush Assets: Highlight first brush on type to search, activate with enter #123853

Closed
Julian Eisel wants to merge 12 commits from JulianEisel/blender:temp-asset-shelf-search-highligh-on-type into brush-assets-project

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

This is implemented as a general view feature now. Whenever filtering is used, we attempt to highlight the first item so enter can activate it. Note that this still only works in the asset shelf popup so far though, because of the whole "semi-modal" text button that allows events to be passed to other buttons.

Moving the mouse makes the highlight jump back to the brush under the cursor again. This is how search menus behave too.

Technical changes:

  • Refactors view item filtering, so it's built in deeper into the general view code and happens via an explicit function call. This way the highlighting logic can be handled in a well defined manner.
  • Assign brush activation operator to the view-item instead of the preview tile button. Otherwise handling the enter key through the view item wouldn't call it.
  • Makes preview-tile buttons non-interactive so all events are passed through to the overlapped view item button. This way "Assign Shortcut" and the like keep working with the operator assigned to the view item instead of the preview tile. I think this makes sense conceptually.
  • Ensure the optimization to only create view item buttons for items scrolled into view forces the highlighted button to be visible. The view scrolling should be reset on text input.
This is implemented as a general view feature now. Whenever filtering is used, we attempt to highlight the first item so enter can activate it. Note that this still only works in the asset shelf popup so far though, because of the whole "semi-modal" text button that allows events to be passed to other buttons. Moving the mouse makes the highlight jump back to the brush under the cursor again. This is how search menus behave too. Technical changes: - Refactors view item filtering, so it's built in deeper into the general view code and happens via an explicit function call. This way the highlighting logic can be handled in a well defined manner. - Assign brush activation operator to the view-item instead of the preview tile button. Otherwise handling the enter key through the view item wouldn't call it. - Makes preview-tile buttons non-interactive so all events are passed through to the overlapped view item button. This way "Assign Shortcut" and the like keep working with the operator assigned to the view item instead of the preview tile. I think this makes sense conceptually. - Ensure the optimization to only create view item buttons for items scrolled into view forces the highlighted button to be visible. The view scrolling should be reset on text input.
Julian Eisel added 6 commits 2024-06-27 19:05:58 +02:00
Julian Eisel added 1 commit 2024-06-27 19:09:32 +02:00
Julian Eisel added 1 commit 2024-06-28 12:31:29 +02:00
Julian Eisel added 1 commit 2024-06-28 17:25:19 +02:00
Fixes operators like "Assign Shortcut" not showing up correctly in the
context menu.
Julian Eisel added 1 commit 2024-06-28 17:28:16 +02:00
The operator is now always set on the view item button (the preview tile
button passes all events to it) through a proper API call.
Julian Eisel changed title from WIP: Highlight first brush on type to search, activate with enter to Brush Assets: Highlight first brush on type to search, activate with enter 2024-06-28 18:26:24 +02:00
Julian Eisel requested review from Hans Goudey 2024-06-28 18:26:33 +02:00
Julian Eisel added this to the Brush Assets & Asset Shelf project 2024-06-28 18:27:21 +02:00
Julian Eisel added 1 commit 2024-07-01 14:29:05 +02:00
Hans Goudey reviewed 2024-07-01 15:30:24 +02:00
Hans Goudey left a comment
Member

It all seems reasonable, just noticed a few smaller style things.

However it seems like it would make more sense to commit this to main than the branch?

It all seems reasonable, just noticed a few smaller style things. However it seems like it would make more sense to commit this to main than the branch?
@ -514,0 +515,4 @@
{
return ui_but_find(
region,
[](const uiBut *but, const void *) {
Member

Use /*named_argument*/

Use `/*named_argument*/`
JulianEisel marked this conversation as resolved
@ -514,0 +520,4 @@
return false;
}
const uiButViewItem *view_item_but = (const uiButViewItem *)but;
Member

Use reinterpret_cast

Use `reinterpret_cast`
JulianEisel marked this conversation as resolved
@ -33,0 +34,4 @@
{
const AbstractViewItem *found_item = nullptr;
foreach_view_item([&](const AbstractViewItem &item) {
Member

this->foreach_view_item

`this->foreach_view_item`
JulianEisel marked this conversation as resolved
@ -118,0 +145,4 @@
prev_filter_string_ = *filter_str;
bool has_search_highlight = false;
foreach_view_item([&](AbstractViewItem &item) {
Member

this->

`this->`
JulianEisel marked this conversation as resolved
@ -166,0 +212,4 @@
void AbstractView::clear_search_highlight()
{
foreach_view_item([](AbstractViewItem &item) { item.is_highlighted_search_ = false; });
Member

this->

`this->`
JulianEisel marked this conversation as resolved
@ -409,2 +449,3 @@
const View2D &v2d,
uiLayout &layout)
uiLayout &layout,
std::optional<StringRef> search_string)
Member

I'd put this search string argument before layout to group "const/input" arguments before "outputs" (the layout).

I'd put this search string argument before `layout` to group "const/input" arguments before "outputs" (the layout).
Author
Member

This is an optional argument, and I'd prefer to keep it that way since it's only used in a few cases.

This is an optional argument, and I'd prefer to keep it that way since it's only used in a few cases.
Author
Member

However it seems like it would make more sense to commit this to main than the branch?

There might be some conflicts, can try though. Working in the branch is easiest & most efficient for me right now, I can still split off individual changes later. I try to focus on getting through the remaining tasks currently.

> However it seems like it would make more sense to commit this to main than the branch? There might be some conflicts, can try though. Working in the branch is easiest & most efficient for me right now, I can still split off individual changes later. I try to focus on getting through the remaining tasks currently.
Julian Eisel added 1 commit 2024-07-01 17:43:07 +02:00
Hans Goudey approved these changes 2024-07-01 18:13:09 +02:00
Hans Goudey left a comment
Member

There might be some conflicts, can try though. Working in the branch is easiest & most efficient for me right now, I can still split off individual changes later. I try to focus on getting through the remaining tasks currently.

Okay, that's fine, I was just thinking about this not ending up in the final brush assets commit. Thanks.

>There might be some conflicts, can try though. Working in the branch is easiest & most efficient for me right now, I can still split off individual changes later. I try to focus on getting through the remaining tasks currently. Okay, that's fine, I was just thinking about this not ending up in the final brush assets commit. Thanks.
Author
Member

Committed to main with 4a9e8087a7.

Committed to main with 4a9e8087a7.
Julian Eisel closed this pull request 2024-07-01 20:42:19 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
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 Assignees
2 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#123853
No description provided.