Nodes: panel buttons, short names and material properties #112591

Manually merged
Brecht Van Lommel merged 4 commits from brecht/blender:node-panel-shorten-name into main 2023-09-21 18:47:16 +02:00

This is a set of changes to improve the Principled BSDF panels.

Short socket names

Shortening names based on context is something we do in the user
interface throughout Blender. This is a simple automatic mechanism to do
it for node panels as well, which significantly improves the Principled
BSDF layout.

We want the properties and sockets to be identifiable outside of the
panel context, for example in the animation editor, API docs, or
when exposing a single socket as a group input. So making the actual
name shorter is not an option.

The alternative would be to add manual control over this, perhaps by
giving sockets both a "label" and "short label". But I'm not sure it's
worth doing that.

Buttons inside panels

With a callback to node panels similar to the one for nodes. Used in the
Principled BSDF to place enums in the relevant panels.

Longer term we want to make enums into sockets, but even then there are
still potentially some types of buttons we want to have in panels.

Panels in material properties

The layout for this is not great but consistent with existing
collapse/expand functionality there. There are ideas to replace this
entire material properties drawing longer term, but for 4.0 it's
important to show the panels in some way.

This is a set of changes to improve the Principled BSDF panels. ### Short socket names Shortening names based on context is something we do in the user interface throughout Blender. This is a simple automatic mechanism to do it for node panels as well, which significantly improves the Principled BSDF layout. We want the properties and sockets to be identifiable outside of the panel context, for example in the animation editor, API docs, or when exposing a single socket as a group input. So making the actual name shorter is not an option. The alternative would be to add manual control over this, perhaps by giving sockets both a "label" and "short label". But I'm not sure it's worth doing that. ### Buttons inside panels With a callback to node panels similar to the one for nodes. Used in the Principled BSDF to place enums in the relevant panels. Longer term we want to make enums into sockets, but even then there are still potentially some types of buttons we want to have in panels. ### Panels in material properties The layout for this is not great but consistent with existing collapse/expand functionality there. There are ideas to replace this entire material properties drawing longer term, but for 4.0 it's important to show the panels in some way.
Brecht Van Lommel requested review from Lukas Tönne 2023-09-19 19:05:45 +02:00
Brecht Van Lommel requested review from Hans Goudey 2023-09-19 19:05:45 +02:00
Iliya Katushenock reviewed 2023-09-19 19:10:52 +02:00
@ -401,0 +407,4 @@
/* Shorten socket label if it begins with the panel label. */
if (translated_panel_label &&
STREQLEN(translated_socket_label, translated_panel_label, len_prefix) &&

StringRef::startswith(...), StringRef::trim(...), ...?

`StringRef::startswith(...)`, `StringRef::trim(...)`, ...?
Author
Owner

I don't really see the point, the resulting code is more complicated. If we were using StringRef throughout the UI code then it would make sense, but using it in places like this does not seem useful to me.

I don't really see the point, the resulting code is more complicated. If we were using `StringRef` throughout the UI code then it would make sense, but using it in places like this does not seem useful to me.
mod_moder marked this conversation as resolved
Brecht Van Lommel force-pushed node-panel-shorten-name from ef26ee1b73 to 50e81b9211 2023-09-20 18:46:56 +02:00 Compare
Brecht Van Lommel changed title from UI: shorten node socket labels when they start with the panel name to Nodes: panel buttons, short names and material properties 2023-09-20 18:47:30 +02:00
Brecht Van Lommel force-pushed node-panel-shorten-name from 50e81b9211 to 07279b8c8e 2023-09-20 18:56:31 +02:00 Compare
Author
Owner

I added more changes for the Principled BSDF and update the screenshots. I could separate it into separate PRs, but the 3 commits depend on each other so I think it's easier to test this way.

I added more changes for the Principled BSDF and update the screenshots. I could separate it into separate PRs, but the 3 commits depend on each other so I think it's easier to test this way.
Hans Goudey requested changes 2023-09-20 19:11:15 +02:00
Hans Goudey left a comment
Member

This looks pretty straightforward, I like the choices you've made here. Just have some inline comments.

For sockets like "Specular" in the "Specular" panel, it would they be nice if they had names like "Specular Strength" so they just show as "Strength" inside the panel. What do you think about that?

This looks pretty straightforward, I like the choices you've made here. Just have some inline comments. For sockets like "Specular" in the "Specular" panel, it would they be nice if they had names like "Specular Strength" so they just show as "Strength" inside the panel. What do you think about that?
@ -398,9 +402,28 @@ static bool node_update_basis_buttons(
return true;
}
const char *node_socket_get_label(bNodeSocket *socket, const char *panel_label)
Member

bNodeSocket *socket -> const bNodeSocket *socket

`bNodeSocket *socket` -> `const bNodeSocket *socket`
brecht marked this conversation as resolved
@ -401,0 +415,4 @@
{
return translated_socket_label + len_prefix + 1;
}
else {
Member

else after return

else after return
brecht marked this conversation as resolved
@ -569,6 +572,8 @@ class SocketDeclarationBuilder : public BaseSocketDeclarationBuilder {
using SocketDeclarationPtr = std::unique_ptr<SocketDeclaration>;
typedef void (*PanelDrawButtonsFunction)(uiLayout *, bContext *, PointerRNA *);
Member

using PanelDrawButtonsFunction = void (*)(uiLayout *, bContext *, PointerRNA *);

Also: bContext * -> const bContext *

`using PanelDrawButtonsFunction = void (*)(uiLayout *, bContext *, PointerRNA *);` Also: `bContext *` -> `const bContext *`
Author
Owner

I kept the callback the same as the existing draw_buttons one so I could share the node_update_basis_socket implementation. I'd prefer to change both after this PR.

I kept the callback the same as the existing `draw_buttons` one so I could share the `node_update_basis_socket` implementation. I'd prefer to change both after this PR.
@ -56,2 +66,3 @@
/* Panel for Subsurface scattering settings. */
PanelDeclarationBuilder &sss = b.add_panel("Subsurface").default_closed(true);
PanelDeclarationBuilder &sss =
b.add_panel("Subsurface").default_closed(true).draw_buttons(node_buts_subsurface);
Member

A lambda with no captures can be passed as a function pointer:

  PanelDeclarationBuilder &sss =
      b.add_panel("Subsurface")
          .default_closed(true)
          .draw_buttons([](uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) {
            uiItemR(layout, ptr, "subsurface_method", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
          });
A lambda with no captures can be passed as a function pointer: ``` PanelDeclarationBuilder &sss = b.add_panel("Subsurface") .default_closed(true) .draw_buttons([](uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) { uiItemR(layout, ptr, "subsurface_method", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); }); ```
brecht marked this conversation as resolved
Author
Owner

For sockets like "Specular" in the "Specular" panel, it would they be nice if they had names like "Specular Strength" so they just show as "Strength" inside the panel. What do you think about that?

We are considering this. The name compatible with Standard Surface would be "Weight" instead of "Strength". But that decision can be made separate from this PR.

> For sockets like "Specular" in the "Specular" panel, it would they be nice if they had names like "Specular Strength" so they just show as "Strength" inside the panel. What do you think about that? We are considering this. The name compatible with Standard Surface would be "Weight" instead of "Strength". But that decision can be made separate from this PR.
Brecht Van Lommel added 1 commit 2023-09-20 19:51:41 +02:00
Hans Goudey approved these changes 2023-09-20 23:33:01 +02:00
Brecht Van Lommel manually merged commit a4a5ac545c into main 2023-09-21 18:47:16 +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
3 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#112591
No description provided.