UI: support context dependent menus (aka assets) in menu search #111752

Merged
Jacques Lucke merged 4 commits from JacquesLucke/blender:menu-search-contexts into main 2023-08-31 18:57:04 +02:00
Member

The node add menu contains assets. The position of an asset in the menu is determined by the catalog it's in. Submenus are generated automatically. This works by having a context dependent menu (NODE_MT_node_add_catalog_assets). The current catalog path is passed in as context. If the menu has submenus, the sub-catalog paths are passed as context into those.

This generally works fine when using the menu. However, menu-search (F3) does not support context dependent menus yet, so those menu entries are just skipped. With this patch, the previously skipped context dependent menu entries are also taken into account.

Note, when opening the search directly after opening Blender, the assets might still be loading and therefor don't show up in the search.

The node add menu contains assets. The position of an asset in the menu is determined by the catalog it's in. Submenus are generated automatically. This works by having a context dependent menu (`NODE_MT_node_add_catalog_assets`). The current catalog path is passed in as context. If the menu has submenus, the sub-catalog paths are passed as context into those. This generally works fine when using the menu. However, menu-search (F3) does not support context dependent menus yet, so those menu entries are just skipped. With this patch, the previously skipped context dependent menu entries are also taken into account. Note, when opening the search directly after opening Blender, the assets might still be loading and therefor don't show up in the search.
Jacques Lucke added 1 commit 2023-08-31 17:25:50 +02:00
Jacques Lucke added 1 commit 2023-08-31 17:26:09 +02:00
Jacques Lucke added 2 commits 2023-08-31 18:41:04 +02:00
Jacques Lucke requested review from Hans Goudey 2023-08-31 18:42:15 +02:00
Jacques Lucke changed title from UI: support context based menus (aka assets) in menu search to UI: support context dependent menus (aka assets) in menu search 2023-08-31 18:42:28 +02:00
Hans Goudey reviewed 2023-08-31 18:48:25 +02:00
@ -200,6 +200,7 @@ MenuType add_catalog_assets_menu_type()
type.poll = node_add_menu_poll;
type.draw = node_add_catalog_assets_draw;
type.listener = asset::asset_reading_region_listen_fn;
type.context_dependent = true;
Member

Is it possible to do this automatically when the owner button has a non-empty context store or something? Or would that lead to false positives?

Is it possible to do this automatically when the owner button has a non-empty context store or something? Or would that lead to false positives?
Author
Member

I think that could too easily lead to false positives, especially because the context is set per layout. I actually did what you suggest at first, but I preferred it to be more explicit.

I think that could too easily lead to false positives, especially because the context is set per layout. I actually did what you suggest at first, but I preferred it to be more explicit.
Hans Goudey approved these changes 2023-08-31 18:54:23 +02:00
Hans Goudey left a comment
Member

This works great, nice job!

This works great, nice job!
Jacques Lucke merged commit 41bf578182 into main 2023-08-31 18:57:04 +02:00
Jacques Lucke deleted branch menu-search-contexts 2023-08-31 18:57:05 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
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#111752
No description provided.