Commit Graph

184 Commits

Author SHA1 Message Date
Campbell Barton
8f1cd941ce UI: show an icon in the "slots" menu for
A small quality of life change to indicate which slots are used.

This only applies to the slots menu, the UI List could show these too
however this requires extending the RNA API.

Ref: !138651
2025-05-21 11:09:25 +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
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
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
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
Leon Schittek
d66b171996 Fix #112402: Improve search menu layout
Several small improvements to the layout of the search menu:
* Avoid the separator arrow on highlighted items being cutoff
* Properly center and prevent overlap of the scroll indicator
  arrows at the top and bottom
* Improve robustness with different zoom levels
* Overall more unified spacing and margins
This patch was originally authored by Yevgeny Makarov (@jenkm).

Pull Request: https://projects.blender.org/blender/blender/pulls/112422
2025-05-07 02:32:13 +02:00
Campbell Barton
e8f1473da6 Refactor: add "filepath" property to CollectionExport to avoid hacks
Fixes for #137856 & #137507 were workarounds to ignore the
PROP_PATH_SUPPORTS_BLEND_RELATIVE for CollectionExport however they
were error prone - especially #137856 as it relied on the surrounding
buttons.

Instead of adding logic to ignore the flag for this specific case,
add a property to the CollectionExport which can have it's flags
and use this instead of the operators "filepath" property.

Internally this wraps the same IDProperty data used by the operator.

Ref !137883
2025-04-30 11:15:38 +00:00
Julian Eisel
a8b031dcc6 UI: Use two lines for Asset/File Browser file names under previews
Part of #134755 / #134766

Makes asset and file browser use up to two lines to display the name of the asset or file under
preview images. Lines are wrapped using our existing wrapping algorithm at characters like spaces,
hyphens, under-scores, etc.

This leads to much less information loss because of clipped labels in common cases. When displaying
assets or files as previews the labels would become rather useless in many cases. Especially with
smaller preview sizes.

When there's still not enough space to display the full asset or file name, the second line is
truncated in the middle, leaving the beginning, and some of the end of the label visible. This
produced best results in testing.

Pull Request: https://projects.blender.org/blender/blender/pulls/136907
2025-04-24 18:03:26 +02:00
Julian Eisel
dd3f2ef36b Fix #137939: Collection Exporter properties no longer respond to Undo
The collection exporter UI template uses operator property drawing to
add buttons in the Properties editor. It creates a sort of mock operator
to be able to do that.

This isn't something we usually do. In all other cases where operator
properties are drawn, we don't want them to send undo pushes. Think it's
fine to make that an option of the template. It's opt in though, since
it's an unusual need.
2025-04-24 17:51:24 +02:00
Campbell Barton
3bc3453c38 Fix #137856: "Relative Path" missing from Collection>Exporters browser
Add another exception for collection exporting (similar to #137507).

It's possible to avoid these workaround but this involves bigger changes
which are likely API breaking.
2025-04-23 15:17:09 +10:00
Guillermo Venegas
7002f16992 Refactor: UI: Split uiLayout API into separate header
Move most `uiLayout` and `uiItem` functions to a separate
`UI_interface_layout.hh` header file. `uiItem` and `uiLayout` structs
are moved from `interface_layout.cc` to `UI_interface_Layout.hh` in
preparation for switching to an object oriented API style.

`UI_block_layout*` functions are moved to `UI_interface_Layout.hh` too,
since their implementation is also in `interface_layout.cc`

Types shared by `UI_interface_Layout.hh` and `UI_interface_c.hh`
are moved to `UI_interface_types.hh`.

Ref: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/136717
2025-04-22 22:14:57 +02:00
Campbell Barton
58d80f281a Fix #137507: collection exporter shows relative paths unsupported
This error is technically correct when the operators path doesn't
support relative paths.

The collection exporter allows relative paths and expands them before
passing the value to the operator.

Resolve by suppressing the warning.

Ref: !137510
2025-04-16 01:16:32 +00:00
Campbell Barton
c49e6a7dd4 Cleanup: reference operators as symbols, spelling in comments 2025-04-15 15:22:53 +10:00
Guillermo Venegas
6397a4fb9a Refactor: UI: Use typed enum class for eUIEmbossType enum
Part of incoming refactors in interface layout c++ code, this enables
forward declaring this enum type. Enum is renamed as `EmbossType` and
moved to `blender::ui` namespace. No user visible changes expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/136725
2025-03-31 00:36:46 +02:00
Campbell Barton
241f626015 Cleanup: use a define for the number of modifiers for key-maps & events 2025-03-26 10:38:08 +11:00
Campbell Barton
e1f91c2dba Cleanup: replace int with wmOperatorStatus, consistent naming
- Manually check over all direct calls to operator callbacks
  ensuring the result isn't assigned to an int.
- OPERATOR_RETVAL_CHECK() now fails unless a wmOperatorStatus is used.
- Check the return values of direct calls to callbacks.
- Remove invalid check for the return value of rna_operator_check_cb.
- Use the variable name `retval` as it's most widely used.
- Move the assignment of `retval` out of the `if` statement in
  sculpt/paint operators because it prevents assigning the result
  `const` variable.
2025-03-21 00:13:30 +00:00
Campbell Barton
10233e95dd Cleanup: use a typed enum for operator & gizmo callbacks
Callbacks: exec invoke & modal now use a typed enum wmOperatorStatus.

This helps avoid mistakes returning incompatible booleans or other
values which don't make sense for operators to return.

It also makes it more obvious functions in the WM API are intended
to be used to calculate return values for operator callbacks.

Operator enums have been moved into DNA_windowmanager_enums.h
so this can be used in other headers without loading other includes
indirectly.

No functional changes expected.

Ref !136227
2025-03-20 21:11:06 +00:00
Julian Eisel
6c1c5e8923 Asset browser import settings popover with collection instancing option
Part of #134755 / #134766.

Adds options to the new Import Settings popover (added in 7a6beb65f4)
to toggle collection instancing for dragging in collections. It can be
toggled separately for linking and appending, since it's typical to use
instancing for linking, but not appending (current default, also with
this change).

Previously, toggling collection instancing was only possible via the
Adjust Last Operation panel but this wasn't obvious, many people were
not aware. Adding this option based on feedback by the Blender Studio.

Pull Request: https://projects.blender.org/blender/blender/pulls/135996
2025-03-20 18:44:24 +01:00
Julian Eisel
4499fad40e UI: Horizontal list view for asset browser
Part of #134755 / #134766.

The asset browser currently lacks a compact view that leaves names
readable. Especially when managing asset libraries (e.g. to prepare it
for sharing or set up a production library), this is quite a usability
issue. A column view like the file browser has can solve this, allowing
a quick overview and fast browsing of libraries, while keeping names
readable.

Adds a new "Horizontal List" display mode to the asset browser that
distributes assets over multiple columns, with horizontal scrolling.
Asset previews are shown in this mode, plus an asset type icon if
there's enough space. The size of previews and the columns can be
configured next to the display mode, for optimizing the display.

Pull Request: https://projects.blender.org/blender/blender/pulls/135306
2025-03-14 16:43:12 +01:00
Harley Acheson
1a6eb39fed Merge branch 'blender-v4.4-release' 2025-03-10 17:11:59 -07:00
John Kiril Swenson
d8f3f8cc61 Fix: UI: Improve scrollbar hotspot region
Mouse and action zone interaction for scrollbars depend on `v2d->vert`
and `v2d->hor`, which are updated through `view2d_masks`. However,
scrollbar drawing through `UI_view2d_scrollers_draw` calls
`view2d_scrollers_calc`, which pads these sizes further, meaning that
drawn scrollbars are slightly out of sync with their hotspots. This is
noticeable at track edges for shrinking scrollers or when tracks are
opaque. Fix by moving the extra (noticeable) padding code from
`view2d_scrollers_calc` to `view2d_masks`.

Pull Request: https://projects.blender.org/blender/blender/pulls/135021
2025-03-11 01:10:48 +01:00
Hans Goudey
c560cdc8cc Cleanup: Use StringRef for layout panel API functions 2025-03-04 14:29:15 -05:00
Jacques Lucke
53d8390c1b Cleanup: remove redundant layout panel function
While using the other function is a little more verbose, it's also more
explicit and having two functions this similar is confusing.
2025-02-28 19:33:07 +01:00
Falk David
2822777f13 Nodes: support boolean inputs as toggles in panel headers
Adds the option to create a boolean socket that can be used as a panel toggle.
This allows creating simpler and more compact node group UIs when a panel
can be "disabled".

The toggle input is a normal input socket that is just drawn a bit differently in
the UI. Whether a boolean is a toggle input or not does not affect evaluation.

Also see #133936 for guides on how to add and remove panel toggles.

Pull Request: https://projects.blender.org/blender/blender/pulls/133936
2025-02-28 19:07:02 +01:00
Harley Acheson
67ffad53aa Merge branch 'blender-v4.4-release' 2025-02-24 18:51:52 -08:00
Harley Acheson
130c074487 Fix #131779: Display "inf" / "-inf" for Correct Range of UI Values
Our UI code is currently showing the text "inf" when a numerical input
contains _exactly_ the value of FLT_MAX. But this is the max value for
doubles and we enforce a maximum float precision of 6 digits.  This
means that a property can start with "inf" by default but it is
impossible edit, or even keep the same value, by editing in the UI
and show as "inf".  This PR defines values that are the actual minimum
and maximums currently usable in the UI and values greater than or
equal to are shown as "inf" (equivalent for "-inf").

Pull Request: https://projects.blender.org/blender/blender/pulls/131876
2025-02-25 03:50:23 +01:00
Hans Goudey
568c791e22 Cleanup: Use StringRef for uiBut tooltips
And replace nullptr arguments for tooltips in UI button
creation functions with std::nullopt. Though the distinction
between "no tooltip" and "empty tooltip" doesn't seem to exist,
it seems safer to keep the distinction since it existed with null before.
2025-02-14 15:12:48 -05:00
Hans Goudey
4727dfd627 Cleanup: Remove unnecessary const qualifiers in function declarations 2025-02-14 14:32:57 -05:00
Brecht Van Lommel
c7a33a62a2 Cleanup: Directly include DNA_userdef_types.h and BLI_listbase.h
Instead of relying on them being included indirectly.

Pull Request: https://projects.blender.org/blender/blender/pulls/134406
2025-02-12 23:01:08 +01:00
Hans Goudey
d216476458 Cleanup: Use StringRef for UI search menu code
Also use Vector to store menu search items instead of a linked
list. And extend the change into the autocomplete API slightly.
The main benefit is to avoid measuring the length of strings over
and over, but the code also gets simpler.
2025-02-05 18:27:44 -05:00
Hans Goudey
73b25ba12e Cleanup: Use StringRef for some WM and UI APIs
Instead of const char * or StringRefNull.

Pull Request: https://projects.blender.org/blender/blender/pulls/134004
2025-02-04 13:53:30 +01:00
Jonas Holzman
22582bf6f0 UI: Node Editor Color Drag & Drop Support
This patch adds support for drag and dropping colors (from color buttons) into
the Compositing, Shading and Geometry node trees.

Additional support was added for dragging and dropping colors with an Alpha
component (which was previously ignored), both in the context of the Node Editor
and for Color Buttons in general. This handles cases like drag and dropping a
color from an RGB to an RGBA button, which recreates the color with a default
Alpha value of 1.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/129026
2025-01-30 12:37:15 +01:00
Hans Goudey
ca64f2f7e7 Cleanup: Use StringRef instead of StringRefNull 2025-01-29 12:49:41 -05:00
Julian Eisel
f5b1a4625d UI: Allow drawing icons as drag previews, use for dragging assets
Instead of requiring an image buffer to draw a bigger preview image
while dragging, allow passing an icon ID and draw that as preview. This
is also how we draw previews elsewhere. Use this for attaching the asset
previews to draggable buttons.

A small user visible change is that previews from the asset browser will
always draw at the default size (multiplied by the interface scale)
while dragging. Previously it used the same size as the asset browser
preview size, which I don't think was useful really. With small sizes
the preview while dragging got unnecessarily small too, with big sizes
it got in the way.

Needed for #131871.
2025-01-24 22:32:27 +01:00
Harley Acheson
de95daaadf Fix #130171: Stop Panel Animation When Removing Regions
When removing areas ensure that none of its panels are currently
running open/close animations. If so turn them off.

Pull Request: https://projects.blender.org/blender/blender/pulls/131998
2025-01-14 19:43:42 +01:00
Pratik Borhade
eb57878bec Grease Pencil: Support Boolean property in modifier panel header
A separate function is declared/defined `uiLayoutPanelPropWithBoolHeader`,
it will add a boolean property to the panel.header.
Clear decorate and separator flag, otherwise they will offset the panel
header horizontally and also adds animate decorator on the right side.

Resolves #131623.

Pull Request: https://projects.blender.org/blender/blender/pulls/132726
2025-01-10 14:51:19 +01:00
Julian Eisel
11b006e01a UI: Don't spawn asset shelf popup by hovering button
Papercut reported in #132293.

Allow explicitly disabling this behavior for a button, and do so for the
big preview asset shelf popup button. It gets more in the way than it's
useful in this case.
2025-01-06 17:42:29 +01:00
Campbell Barton
d2d754be3f Cleanup: spelling in comments (make check_spelling*)
- Back-tick quote math expressions so differentiate them
  from English.
- Use doxygen code blocks for TEX expressions.
2025-01-04 16:26:39 +11:00
Julian Eisel
f6a4d01703 UI: Allow passing named integers via context
Similar to 2fbf206491, but for integers (not strings). Essentially this
allows passing named integer values through UI abstractions in a clean
way.

I used 64 bit integers here, since space isn't an issue here, and it
fits common integer types (so we don't have to add APIs for multiple
integer types).

Planned to be used to fix #111463 (following commit).
2024-12-11 13:39:24 +01:00
Hans Goudey
7a8a58e7e5 Cleanup: Remove unused UI layout function 2024-12-06 14:48:28 -05:00
Hans Goudey
21aef81714 Cleanup: Use StringRef and std::optional for UI string arguments
- Gives O(1) access to string length in more cases
- Convenient string manipulation functions
- Clarify difference between "no string" and "empty string"
- Avoid the need for raw pointers in the API
- Shows which API string arguments are optional

Pull Request: https://projects.blender.org/blender/blender/pulls/131473
2024-12-06 14:08:10 +01:00
Hans Goudey
f7089519e0 Cleanup: Remove unused UI function declaration 2024-12-05 21:31:25 -05:00
Julian Eisel
f0db870822 UI: Support persistent view state, write tree-view height to files
Adds support for saving some view state persistently and uses this to keep the
height of a tree-view, even as the region containing it is hidden, or the file
re-loaded.

Fixes #129058.

Basically the design is to have state stored in the region, so it can be saved
to files. Views types (tree-view, grid-view, etc) can decide themselves if they
have state to be preserved, and what state that is. If a view wants to preserve
state, it's stored in a list inside the region, identified by the view's idname.

Limitation is that multiple instances of the same view would share these bits of
state, in practice I don't think that's ever an issue.

More state can be added to be preserved as needed. Since different kinds of
views may require different state, I was thinking we could add ID properties to
`uiViewState` even, making it much more dynamic.

Pull Request: https://projects.blender.org/blender/blender/pulls/130292
2024-11-18 18:19:48 +01:00
Hans Goudey
6c3ac28eb3 Nodes: Slightly improve editor drawing performance with large node trees
Avoid retrieving context data for every single node which can be
expensive when there are thousands of nodes. In the "Mouse House"
test file I observed a 13% improvement in drawing timings.

Pull Request: https://projects.blender.org/blender/blender/pulls/130239
2024-11-14 16:04:33 +01:00
Julian Eisel
a641001207 Fix: UI previews don't refresh outside of properties editor
The preview template (`UILayout.template_preview()`) to display previews
for materials, textures or similar would only work correctly in the
Properties editor. This had explicit logic to trigger rerendering on
changes. When displaying such previews elsewhere (e.g. in the 3D View
sidebar), the only way to have changes reflected would be by resizing
the preview.

This fix makes sure such previews are tagged as dirty and refreshed on
changes to the underlying ID. We do this the same way as tagging the ID
previews as dirty, through a function called by the dependency graph for
such updates.

Pull Request: https://projects.blender.org/blender/blender/pulls/129641
2024-11-01 15:25:24 +01:00
Campbell Barton
952e1d46d1 Cleanup: match declaration names, avoid shadowing & clear trailing space 2024-10-03 12:12:08 +10:00
Julian Eisel
f57b9b12d2 UI: Increase size of active asset highlight in asset shelf
Generally increases padding of preview widgets a bit (while keeping the
preview size the same), and increases the size of the highlight surface
a bit. The default grease pencil brushes from the essentials asset
library use an opaque background, so the highlight was barely visible
before. It was difficult to identify the active brush from that. Now
it's a lot easier to identify visually.

See PR for comparison screenshots.

Pull Request: https://projects.blender.org/blender/blender/pulls/128432
2024-10-01 15:33:15 +02:00
Bastien Montagne
3e03576b09 Add more control over ID renaming behavior.
This commit adds low-level logic in BKE to support three behaviors in
case of name conflict when renaming an ID:
1. Always tweak new name of the renamed ID (never modify the other ID
  name).
2. Always set requested name in renamed ID, modifying as needed the
  other ID name.
3. Only modify the other ID name if it shares the same root name with the
  current renamed ID's name.

It also adds quite some changes to IDTemplate, Outliner code, and
RNA-defined UILayout code, and the lower-level UI button API, to allow
for the new behavior defined in the design (i.e. option three from above list).

When renaming from the UI either 'fails' (falls back to adjusted name) or forces
renaming another ID, an INFO report is displayed.

This commit also fixes several issues in existing code, especially
regarding undo handling in rename operations (which could lead to saving
the wrong name in undo step, and/or over-generating undo steps).

API wise, the bahavior when directly assigning a name to the `ID.name`
property remains unchanged (option one from the list above). But a new
API call `ID.rename` has been added, which offers all three behaviors.

Unittests were added to cover the new implemented behaviors (both at
BKE level, and the RNA/Py API).

This commit implements #119139 design.

Pull Request: https://projects.blender.org/blender/blender/pulls/126996
2024-09-20 13:36:50 +02:00
Julian Eisel
439d4dfc3c Fix: UI: Small layout glitch with search template and decorators
Button layout wouldn't be entirely correct with split layout was
enabled, but decorators disabled (`uiLayout.use_property_split = True`,
`uiLayout.use_property_decorate = False`).

See https://projects.blender.org/blender/blender/pulls/127751#issuecomment-1298468.
2024-09-20 13:06:21 +02:00
Julian Eisel
7d97f99dfc Refactor: UI: Avoid confusing layout property split return value
The function would return two very different layouts in different code
paths, making it not clear to the caller what to expect. For one code
path the return value was rather useless, and in fact unused, so I was
able to just remove this. Also clarified behavior and return values in
the function API comment.
2024-09-20 12:33:56 +02:00