Commit Graph

3513 Commits

Author SHA1 Message Date
Damien Picard
ba45498955 I18n: Use context for node panel translation in material properties
This is a follow-up to 9ce0a2d1d5 and uses the same logic. It allows
translation of node panel labels inside the material properties, using
their specified translation context. Not in use currently, but may be
needed in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/139367
2025-05-26 09:36:04 +02:00
Habib Gahbiche
8485d8a33c Compositor: Rename default node tree to "Compositing Node Tree"
Currently only visible in the tree path, but will be more noticeable
when node trees are not embedded anymore (outline and node editor).

Pull Request: https://projects.blender.org/blender/blender/pulls/139358
2025-05-26 08:24:56 +02:00
Jacques Lucke
024f8a9595 Fix #139388: Nodes: Frame node with text has wrong margins and line breaks
This was caused by an oversight in ae5b83e4ef.
It first removed the `aspect` and then brought it back later on, but forgot
to use it in all cases.
2025-05-26 06:01:53 +02:00
Jacques Lucke
d35351fdc8 Fix #139364: FileHandler example for shader editor does not work 2025-05-24 18:46:42 +02:00
Hans Goudey
9ffb474e07 Fix #139330: Incorrect offset grouping nodes inside frame
Similar to c52da69dfb
2025-05-24 09:17:39 -04:00
Jacques Lucke
680e53fcee Cleanup: Geometry Nodes: rename GeoModifierLog to GeoNodesLog
Nowadays, Geometry Nodes is not only evaluated by a modifier, but also by an
operator and in the future potentially by brushes. Therefore, the old name was
misleading because it sounded like it was specific to the modifier.

Pull Request: https://projects.blender.org/blender/blender/pulls/139378
2025-05-24 10:39:36 +02:00
Jacques Lucke
70ce733b8c Refactor: Nodes: add general NodeComputeContext
This is used as base class for the compute contexts for group and evaluate
closure nodes. Furthermore, in the future this can be used for the compute
context that is passed into field evaluation.

Pull Request: https://projects.blender.org/blender/blender/pulls/139377
2025-05-24 10:39:24 +02:00
Hans Goudey
8fdf37cd50 Fix #139114: Node insert auto offset broken with frames
Caused by 4bf34d9591.

Quite a bit of complexity used to avoid moving both nodes and their
frame parents is redundant now, since all connected nodes should
be moved and moving frames doesn't also affect the nodes inside
anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/139306
2025-05-23 14:18:09 +02:00
Pratik Borhade
23bddef11a Fix #139179: Shader node panels are not translated in the material properties
Missed in 613bb9771b. To fix translation of panel header, use `IFACE_` macro).

Pull Request: https://projects.blender.org/blender/blender/pulls/139262
2025-05-23 12:18:17 +02:00
Jacques Lucke
1307137f27 Nodes: clarify socket visibility methods
Node sockets have many different aspects that affect their visibility and
whether they are grayed out. This patch cleans up the methods used to check if
sockets are visible and adds descriptions that should make it more obvious which
ones should be used.

This also fixes a few places where the wrong method was used which is more
obvious now.

Pull Request: https://projects.blender.org/blender/blender/pulls/139251
2025-05-23 06:10:03 +02:00
Habib Gahbiche
eb51e0a206 Compositor: gizmo for Split node
The gizmo is a line (implemented as a 2d cage gizmo) that can be
dragged accross the image vertically or horizontally.

Pull Request: https://projects.blender.org/blender/blender/pulls/139107
2025-05-22 11:19:09 +02:00
Jacques Lucke
5457cca3de Nodes: auto-hide unused inputs if usage depends on menu
Previously, when a socket was detected to be unused, it was just grayed out.
This patch adds support for automatically hiding unused sockets based on this
convention: Menu inputs control visibility while other inputs only control
whether something is grayed out.

More specifically, an input is visible if any of these conditions is met:
* It affects the output currently.
* It never affects the output. In this case its usage does not depend on any
  menu input.
* It is used if all non-menu inputs are considered to be unknown.

In the future, we could support customizing which inputs are allowed to control
visibility. For now it's good to use the convention that Blender generally
follows itself.

As before, panels are grayed out if they only contain grayed out sockets and
panels are hidden when they don't contain any visible sockets.

Hiding inputs works in group nodes, the Geometry Nodes modifier and node
operators. In theory it will work for all node tree types, but since only
Geometry Nodes supports the Menu Switch node currently, this patch currently
only makes a difference there.

The implementation reuses the existing `SocketUsageInferencer` with a different
sets of inputs. So no new core-inferencing logic was needed.

Design task: #132706.

Pull Request: https://projects.blender.org/blender/blender/pulls/138186
2025-05-22 04:48:43 +02:00
Damien Picard
9ce0a2d1d5 I18n: Add translation contexts to node panels
Node UIs can now have panels. Some of those may need to have their
labels translated using translation contexts. PanelDeclarations
already had a translation_context member, this commit adds a way to
specify this context, and to use it for translation on drawing the
node.

Pull Request: https://projects.blender.org/blender/blender/pulls/139124
2025-05-21 13:54:11 +02:00
Hans Goudey
c0afb85a2c Fix: Menu search crash outside of node editor
Caused by c6995d03dd.
2025-05-20 13:25:15 -04:00
Jacques Lucke
c55ffb5258 Nodes: improve implicit inputs
This improves implicit node inputs in multiple ways:
* Fix crash when switching a group input socket type from e.g. vector to
  integer, while the default input is set to "position". Now, the default input
  type is reset automatically if it's invalid.
* Add Left/Right Handle as possible implicit vector inputs (next to Position and
  Normal). Those were the only ones that we used internally that were not
  exposed yet.
* When creating a new group input from an existing socket, also initialize the
  default input based on the socket. E.g. when grouping a `Set Position` node,
  the `Position` input of the group will now also use the position attribute by
  default.

In addition to these user-level changes, some internal changes were done too:
* Use unified `NodeDefaultInputType` in node declaration instead of function
  pointers which were hard to propagate to node groups.
* Use a new reusable `socket_type_supports_default_input_type` function in rna
  to filter the list of possible input items.

Pull Request: https://projects.blender.org/blender/blender/pulls/139139
2025-05-20 17:54:49 +02:00
Guillermo Venegas
44160a0524 Refactor: UI: Replace uiItemFullO with class method uiLayout::op
This converts the public `uiItemFullO` function to an object oriented
API (an `uiLayout::op` overload), matching recents changes in the API.

Changes includes the removal of the paramether `IDProperty *properties`
that seems unused (all places just sets `nullptr`, can be added as last
argument with `nullptr` as default value though), and instead of using a
return paramether the function now returns the pointer to write properties.

Pull Request: https://projects.blender.org/blender/blender/pulls/138961
2025-05-20 15:19:34 +02:00
Habib Gahbiche
c6995d03dd Nodes: Show error when image node cannot be added
Currently, if a user drags an image file into a node editor with
no node tree, then the operator silently fails.

This patch adds an error to warn the user that adding an image is
only possible if a node tree exists already.

Pull Request: https://projects.blender.org/blender/blender/pulls/138997
2025-05-20 13:44:08 +02:00
Omar Emara
c9dc4a0f69 Fix: Crash when all inputs inside panel are unavailable
Blender crashes when a node has a panel whose children input sockets are
all unavailable. This happens when marking sockets as collapsed, where
the non-initialized header_center_y members of such panels are accessed,
causing asserts or crashes.

The update_collapsed_sockets_recursive function has a check that should
avoid such accesses, but it seems wrong due to the negation of the
visibility check.

To fix this, we move the visibility check to a guard condition in the
marking function instead, and simplify the collapsed check in the update
function.

Pull Request: https://projects.blender.org/blender/blender/pulls/139104
2025-05-20 08:26:36 +02:00
Campbell Barton
4c794e8e2e Cleanup: early return in node gizmo poll functions
Avoid multiple null checks for SpaceNode, check & return early.
2025-05-20 11:50:35 +10:00
Hans Goudey
6562033a4a Cleanup: Use StringRef for some UI string arguments
Instead of StringRefNull.

Pull Request: https://projects.blender.org/blender/blender/pulls/139095
2025-05-19 17:25:52 +02:00
Jacques Lucke
f3294bbd06 Nodes: improve drawing with invalid zone links
Previously, whenever the zone detection algorithm could not find a result, zones
were just not drawn at all. This can be very confusing because it's not
necessarily obvious that something is wrong in this case.

Now, invalid zones and links that made them invalid have an error.

Note, we can't generally detect the "valid part" of zones when there are invalid
links, because it's ambiguous which links are valid. However, the solution here
is to remember the last valid zones, and to look at which links would invalidate
those. Since the zone-detection results in runtime-only data currently, the
error won't show when reopening the file for now.

Implementation wise, this works by keeping a potentially outdated version of the
last valid zones around, even when the zone detection failed. For that to work,
I had to change some node pointers to node identifiers in the zone structs, so
that it is safe to access them even if the nodes have been removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/139044
2025-05-19 17:25:36 +02:00
Jacques Lucke
d9317046b2 Nodes: initialize node name from group name
Previously, when adding a group node it was always called `Group`. This is not
particularly useful. Also it's inconsistent with many other places like adding
modifiers where the name of the modifier depends on what modifier is added.

Now, newly added group node will have the same name as the group that it calls.
Node names still have to be unique though, so e.g. `.001` is still added.

Pull Request: https://projects.blender.org/blender/blender/pulls/139093
2025-05-19 15:39:44 +02:00
Habib Gahbiche
4b207be8f9 Cleanup: replace tree type by tree_idname
Pull Request: https://projects.blender.org/blender/blender/pulls/139018
2025-05-17 13:25:59 +02:00
Campbell Barton
b3dfde88f3 Cleanup: spelling in comments (check_spelling_* target)
Also uppercase acronyms: API, UTF & ASCII.
2025-05-17 10:17:37 +10:00
Jacques Lucke
8ec093a2d8 Nodes: new operator to simplify adding named frames
Currently, the steps required to add a named frame in the node editor are quite
cumbersome:
* Press ctrl+J, which is hard to reach.
* Press F2, to rename.

This is bad, because frames are a key part of making node trees understandable.
Therefore, we should lower the barrier to adding them as much as possible.
Additionally, named frames help significantly more with readability. Therefore,
it's good to lower the barrier to adding those even more. Of course it's still
possible to click in empty space to avoid having to give a frame a name.

This patch adds a new operator to join nodes in a named frame. When triggered,
it adds the frame and automatically opens the rename menu to set the name.

Keymap changes:
* Remove `ctrl+J` which was creating a frame without label.
* Move existing functionality of `F` key to `J` key
  (including `shift+F -> shift+J`).
* Use `F` for this new operator to create a named frame.

Pull Request: https://projects.blender.org/blender/blender/pulls/138390
2025-05-15 20:51:54 +02:00
Habib Gahbiche
df6e65dd93 Compositor: add viewer node to the default node tree
Users almost always need a viewer node, so add one to the default node
tree.

Note that the backdrop is already enabled by default, so the backdrop
image will be visible as soon as a render is available (no need to
manually add viewer node or click `cltr+shift+LMB` to show a backdrop
image.

Pull Request: https://projects.blender.org/blender/blender/pulls/138890
2025-05-15 16:08:19 +02:00
Habib Gahbiche
eaa1e34eca Compositor: improve default node position
The node tree is partially covered by default. This patch updates the
position of the nodes to a better default.

Pull Request: https://projects.blender.org/blender/blender/pulls/138889
2025-05-15 15:13:19 +02:00
Jacques Lucke
e4e49e1634 Nodes: don't jump viewer node if it's still visible
The goal is to make the viewer node jump less often because each unnecessary
jump feels annoying. Previously, we already had a heuristic that would disable
the jumping if the new viewer location was further away than the old one. Now
the viewer never jumps when it's still visible in the node editor and already to
the right of the node-to-view.

As a byproduct this also fixes an issue where the initial viewer position does
not work properly, because the node does not have known draw-bounds yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/138744
2025-05-15 12:11:07 +02:00
Campbell Barton
3ec7748485 Cleanup: spelling in comments (make check_spelling_*)
Also replace term "playhead" with "current-frame".
2025-05-15 10:13:23 +10:00
Guillermo Venegas
351fbff95b Refactor: UI: Replace uiItemM_ptr and uiItemM with uiLayout::menu
This converts the public `uiItemM_ptr` and `uiItemM` functions
to an object oriented API (an `uiLayout::menu` overloads),
matching the python API.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138895
2025-05-14 23:22:56 +02:00
quackarooni
dd698d4f24 Fix: Geometry Nodes: Asset catalog "Unassigned" does not show in menu
The Node Editor Add menu has filters for not drawing asset catalogs in
the root level. This is done so that catalogs that share names with
built-in menus are appended to said menus.

There is no "Unassigned" built-in menu, just a root level asset menu for
unassigned assets. This menu does not currently have the behavior to
support appending catalogs to it, so assigning assets to a catalog named
"Unassigned" renders said assets unaccessible in the Add Menu.

This patch removes that filter as it was deemed better to just allow the
user to have a root level catalog menu named "Unassigned" instead of
mushing it with the menu for unassigned assets.

Pull Request: https://projects.blender.org/blender/blender/pulls/138874
2025-05-14 16:50:29 +02:00
quackarooni
8f232517f0 Fix: Nodes: Missing builtin categories for handling asset catalogs
The current behavior for the Node Editor's Add menu is to list the
user's asset catalogs at the root level of the menu. However, an
exception is made if the catalog has the same name as a builtin menu.
In such case, the asset catalog is appended to that builtin menu,
instead of being drawn at the root level.

How this is currently implemented right now is to have a hard-coded set
of builtin menus in `add_menu_assets.cc`. Certain menus are missing from
this set, particularly newer ones, which may be an oversight during the
creation of these menus.

This patch adds those menus to that list, which are as follows:
- Input/Gizmo
- Input/Import
- Grease Pencil (and all its submenus)
- Texture (in Compositor Nodes)

Pull Request: https://projects.blender.org/blender/blender/pulls/138870
2025-05-14 16:12:29 +02:00
Hans Goudey
1e1ac2bb9b Fix: Various asserts when creating GPU vertex formats
Caused by 617858e453.

These formats should use types aligned to 4 bytes. That's generally
required by modern GPUs. Uploading with these types also avoids
automatic conversion by the Vulkan backend which is something
we're hoping to remove fully.

In the end this PR removes a bunch of code related to supporting
the older single-byte formats.

Pull Request: https://projects.blender.org/blender/blender/pulls/138836
2025-05-13 19:07:01 +02:00
Guillermo Venegas
3b1e123361 Refactor: UI: Replace uiItemS and uiItemS_ex with uiLayout::separator
This merges the public `uiItemS` and `uiItemS_ex` functions into an
object oriented API (`uiLayout::separator`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code
(or vice-versa), making it almost seamless.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138826
2025-05-13 17:54:26 +02:00
Endor H
309ce182b8 Nodes: Allow dragging Group Inputs from the panel into the nodes editor
This patch adds support for creating Group Input nodes by dragging input sockets
and panels from the group interface tree-view in the side bar. This
significantly simplifies creating a Group Input node for a specific input when
there are lots of them.

These cases are supported:
* Dragging an input socket creates a Group Input node just for that socket.
* Dragging a panel without panel-toggle creates a Group Input node containing
  all sockets in the panel.
* Dragging a panel with panel-toggle creates a Group Input for the panel-toggle.
* Dragging a panel with panel-toggle while holding Ctrl creates a Group Input
  with the panel-toggle and all sockets in the panel.

This is supported in all node tree types.

Pull Request: https://projects.blender.org/blender/blender/pulls/137739
2025-05-13 07:17:48 +02:00
Jason C. Wenger
ae5b83e4ef Refactor: Nodes: frame node drawing
Removes an inconsistency where sometimes `bke::node_label` is used and sometimes
`node.label` to get the frame label.

Consolidates several duplicated formulas for computing the frame layout into a
single function.

Pull Request: https://projects.blender.org/blender/blender/pulls/138035
2025-05-13 05:17:09 +02:00
Jacques Lucke
87f0ab292f Geometry Nodes: support menu type in Menu Switch node
Previously, it was not possible to switch a menu based on another menu. This
patch adds support for this.

Usually, menu sockets are drawn without the label in nodes currently. Now there
is one exception: the Menu Switch node when it switches another menu. If the
label is not shown, the UI is missing crucial information.

Pull Request: https://projects.blender.org/blender/blender/pulls/138704
2025-05-13 04:57:19 +02:00
Guillermo Venegas
a017a6cc54 Refactor: UI: Replace uiItemO with class method uiLayout::op
This converts the public `uiItemO` function to an object oriented
API (`uiLayout::op`).
Also this rearranges `idname` paramether, since this the only one
required, and to make format similar to `uiItemFullO`

Note: One of the benefits of moving from a public function to class
method is to reduce API usage difference between C++ and Python. In
Python this method is called `UILayout::operator`, however `operator`
is a reserved keyword in C++.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138776
2025-05-12 22:14:38 +02:00
Jacques Lucke
dd47ee9e25 Nodes: show warning when a group output is unused
There are very rare use-cases for having multiple Group Output nodes. However,
it's something that's been supported for a long time and removing it may be a
regression for some. In practice, it's usually a mistake when someone has
multiple Group Output nodes.

This patch adds a simple warning on inactive Group Output nodes to help the user
notice this case.

Pull Request: https://projects.blender.org/blender/blender/pulls/138743
2025-05-12 16:13:57 +02:00
Jacques Lucke
ddbd880fa9 Fix: Nodes: missing update after activating different group output 2025-05-12 04:37:52 +02:00
Jacques Lucke
691a2be7f0 Nodes: improve frame label position
This changes two things:
* Take zone bounding box into account when computing frame dimensions.
* Move the label up a bit as it was too low before.

Pull Request: https://projects.blender.org/blender/blender/pulls/138705
2025-05-11 05:20:25 +02:00
Jacques Lucke
bf696320f6 UI: support detecting good width for searchbox
Sometimes, the default size of the search box is not wide enough for the items
it shows. Currently, we sometimes hardcode an extra width factor and rely on
automatic name shortening with `...`. Both options are not ideal because they
are either often too wide or are hard to read with shortened names.

This patch implements an alternative solution. It adds a new function that
computes a good width for the search box based on its content. A certain minimum
and maximum width are still enforced.

Right now, this feature is only used in the Ctrl+F search in node editors, but I
guess it makes sense in most search boxes.

This also fixes #138641. While it's nice to have ways to use shorter search
terms, the search box should generally be able to deal with long items too.

Pull Request: https://projects.blender.org/blender/blender/pulls/138653
2025-05-10 04:48:30 +02:00
Jacques Lucke
1e23f9235c Nodes: highlight frame that nodes will be attached to
Previously, it was somewhat difficult to know if a dragged node will be attached
to a frame or not. This patch highlights the frame that dragged nodes will be
attached to which removes the guesswork. This is similar to how we highlight the
link that a dragged node will be inserted onto.

Pull Request: https://projects.blender.org/blender/blender/pulls/138648
2025-05-10 04:44:23 +02:00
Jacques Lucke
99a2589217 Nodes: use alternating frame colors
Previously, nested frames were very hard to see and therefore to work with. This
patch solves this by alternating between two different frame colors depending on
the nesting depth.

Custom colors can still be used like before. There is still a single theme
option. The alternating color is derived from that.

Pull Request: https://projects.blender.org/blender/blender/pulls/138649
2025-05-10 04:37:21 +02:00
Guillermo Venegas
858abf43c3 Refactor: UI: Replace uiItemFullR with class method uiLayout::prop
This converts the public `uiItemFullR` function to an object oriented
API (an overload of `uiLayout::prop`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138683
2025-05-10 03:39:31 +02:00
Habib Gahbiche
58ebe99d9d Fix: Compositor: Incorrect viewer is activated
In some cases, multiple viewers can be active and the active viewer is
not the desired one. This is only a problem for the compositor

The fix has two parts:
1. Tag the node tree as changed after the output changes. This solves
 the issue of two viewers being active at the same time
2. Deactivate all other viewers before activating the desired viewer
node (similar to how `NODE_OT_activate_viewer()` works). This ensures
that the only active viewer is the one that the user just set.

Pull Request: https://projects.blender.org/blender/blender/pulls/138671
2025-05-09 18:07:05 +02:00
Jacques Lucke
4acd6d46d4 UI: rename Tooltip Label to Quick Tooltip
Change the mentions of "tooltip label" to "quick tooltip" to make this feature more
universally useful. The new name was suggested in #138583.

Pull Request: https://projects.blender.org/blender/blender/pulls/138639
2025-05-09 13:34:35 +02:00
Jacques Lucke
efefb16d4b Nodes: draw frame outline over zone backgrounds
Previously, the outline of frames was sometimes unexpectedly invisible.
The solution is to draw the frame outlines together with the zone outlines
after all the zone and frame backgrounds have been drawn already.

Pull Request: https://projects.blender.org/blender/blender/pulls/138645
2025-05-09 05:47:30 +02:00
Jacques Lucke
a03d0fd512 Nodes: show node errors tooltip faster
The idea here is to use `UI_but_func_tooltip_label_set` which has a shorter
duration until the tooltip shows (besides also being easier to use). It does
seem like it makes sense to use it here, because the only purpose of the error
icon is to hover over it. Therefore, one shouldn't have to wait for long until
the tooltip shows.

Pull Request: https://projects.blender.org/blender/blender/pulls/138583
2025-05-09 04:07:54 +02:00
Jacques Lucke
4a760c1a70 Nodes: show link errors directly on link
Previously, we had shown link errors on the target node as part of the node
warning system. While better than not showing any information about invalid
links (as was the state before that), it's still not ideal because it's easy to
miss when just looking at the link.

This patch adds an error icon in the middle of the invalid link. When hovering
over it, it shows the error text. When the middle of the link is not in view but
part of the link is, then the error icon will also stay visible.

Pull Request: https://projects.blender.org/blender/blender/pulls/138529
2025-05-09 04:06:00 +02:00