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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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