Nodes: Add PanelDeclarationBuilder for panels in builtin nodes #111695
No reviewers
Labels
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111695
Loading…
Reference in New Issue
No description provided.
Delete Branch "LukasTonne/blender:panels-for-builtin-nodes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Node groups already have panels, but they modify the node declaration
directly, which is not something we want to do for builtin nodes. For
those the
PanelDeclarationBuilder
should be used.PanelDeclarationBuilder
hasadd_input
/add_output
methods just likeNodeDeclarationBuilder
. Adding sockets to a panel increases its size by one. All sockets must be added in order: Adding sockets or panels to the rootNodeDeclarationBuilder
after a panel will complete the panel and adding more sockets to it after that will fail. This is to enforce a stable item order where indices don't change after adding a socket, which is important for things like field dependencies.Example:
Not that it will be used too much, but I think it might be nice to have an API which is a bit more obvious:
Something like this might be clearer:
or even
I'm undecided on what the API should look like in this area. Being able to "assign" a panel to a socket seems nice, but it also adds complexity because socket order may not be immediately obvious. If i add a socket to an earlier panel it can move above other sockets. Items appearing in the order they are declared is straightforward. Then again, defining panel content purely via size is also not great.
Utilizing C++ scopes was suggested by Jacques and i quite like that. I'll put this PR as WIP and see if i can make scoped panel declarations work.
Add a PanelDeclarationBuilder for adding panels to builtin nodesto WIP: Add a PanelDeclarationBuilder for adding panels to builtin nodesAdding sockets directly to
PanelDeclaration
instead ofNodeDeclaration
is also nice, especially since it's so familiar from the way we useuiLayout
.I'm trying to figure out if/how to add sockets to panel declarations, at least as an API function that could still store a flattened list internally. One problem is the use of indices throughout socket declarations (e.g. for field dependencies), which requires that the index remains stable once a socket has been declared because subsequent declarations might depend on it. Adding sockets to a panel declaration can break this easily because the panel child item can be inserted higher up than the previous declarations.
A simple solution would be to just disallow adding stuff to panels once they are done, i.e. once a new panel is started or a socket added outside a panel (*) you'd get an error trying to add more sockets to it. This is what 99% of node declarations would do anyway.
(*) Adding sockets after panels is also not allowed because of our "panels after sockets" rule.
I've changed the API so sockets can be directly added to a
PanelDeclarationBuilder
(see updated snippet in the description). This is not 100% fool-proof, but should catch the most common mistakes and adds only minor changes to declarations.WIP: Add a PanelDeclarationBuilder for adding panels to builtin nodesto Nodes: Add PanelDeclarationBuilder for panels in builtin nodesHi Lukas, this is great progress. I have an issue though.
The moment I enable
b.use_custom_socket_order()
I can no longer have the properties between the outputs and inputs.This is not blocking to this patch as long as we don't use this feature for nodes that have properties.
So I'm fine to have it in as incremental change towards our final tests and validations before we get the rules enforced on the API level. But should be used carefully.
Generally seems fine. I think we should use the convention that we put panels into a separate nested
{ ... }
block.@ -808,3 +876,4 @@
return socket_decl_builder_ref;
}
inline PanelDeclarationBuilder &NodeDeclarationBuilder::add_panel(StringRef name, int identifier)
This doesn't have to be in the header.
@ -516,2 +516,4 @@
using Self = PanelDeclarationBuilder;
NodeDeclarationBuilder *node_decl_builder_ = nullptr;
PanelDeclaration *decl_;
/* Panel is complete once items are added after it.
Proper doxygen syntax for multi-line class variable documentation (just for consistency)
This does not currently enforce the "panels below sockets" rule (that's only done by the node group interfaces). Panel above sockets has some side effects in drawing, e.g. the panel background extends to all the bottom sockets when the panel is open.
I think we could just have an assert that checks for invalid declarations after declarations have been created.
Yeah as a convention that's fine, it helps make sure a panel builder is not used accidentally when it's not valid any more. I've tried to think of ways of using C++ syntax for a scoped builder, but wouldn't know how to prevent adding to the root interface while a panel is being built just by means of syntax. Don't want to get too fancy - as long as most simple errors are prevented it should be ok.
It's fine to use the convention. If there is an assert somewhere that can catch bad declarations, that's a great addition as well, even if it's not guaranteed at compile time.
@blender-bot build