Commit Graph

310 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
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
Campbell Barton
64a43fff20 Fix #138652: Crash editing an ID name after undo
Regression in [0] which missed updating the old-buttons data,
causing it to reference freed Main & ID pointers after undo.

Apply the same fix for uiBut::pushed_state_func.

[0]: 3e03576b09
2025-05-13 09:48:11 +10:00
Sergey Sharybin
7ceb4495c5 Refactor: OpenColorIO integration
Briefly about this change:
- OpenColorIO C-API is removed.
- The information about color spaces in ImBuf module is removed.
  It was stored in global ListBase in colormanagement.cc.
- Both OpenColorIO and fallback implementation supports GPU drawing.
- Fallback implementation supports white point, RGB curves, etc.
- Removed check for support of GPU drawing in IMB.

Historically it was implemented in a separate library with C-API, this
is because way back C++ code needed to stay in intern. This causes all
sort of overheads, and even calls that are strictly considered bad
level.

This change moves OpenColorIO integration into a module within imbuf,
next to movie, and next to IMB_colormanagement which is the main user
of it. This allows to avoid copy of color spaces, displays, views etc
in the ImBuf: they were used to help quickly querying information to
be shown on the interface. With this change it can be stored in the
same data structures as what is used by the OpenColorIO integration.
While it might not be fully avoiding duplication it is now less, and
there is no need in the user code to maintain the copies.

In a lot of cases this change also avoids allocations done per access
to the OpenColorIO. For example, it is not needed anymore to allocate
image descriptor in a heap.

The bigger user-visible change is that the fallback implementation now
supports GLSL drawing, with the whole list of supported features, such
as curve mapping and white point. This should help simplifying code
which relies on color space conversion on GPU: there is no need to
figure out fallback solution in such cases. The only case when drawing
will not work is when there is some actual bug, or driver issue, and
shader has failed to compile.

The change avoids having an opaque type for color space, and instead
uses forward declaration. It is a bit verbose on declaration, but helps
avoiding unsafe type-casts. There are ways to solve this in the future,
like having a header for forward declaration, or to flatten the name
space a bit.

There should be no user-level changes under normal operation.
When building without OpenColorIO or the configuration has a typo or
is missing a fuller set of color management tools is applies (such as the
white point correction).

Pull Request: https://projects.blender.org/blender/blender/pulls/138433
2025-05-09 14:01:43 +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
Guillermo Venegas
e5dcd0de99 Refactor: UI: Replace uiItemL with class method uiLayout::label
This converts the public `uiItemL` function to an object oriented
API (`uiLayout::label`), 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/138608
2025-05-08 17:21:08 +02:00
Jacques Lucke
156a405dd5 Nodes: support searching for specific math operations in Add menu
Previously, it was possible to search for specific math operations in
link-drag-search but not in the normal add menu. This patch adds support for
searching for specific operations in various math nodes.

A good trick for adding e.g. a vector add node is to search for `vadd`
(similarly with `iadd`).

The menu itself looks unchanged. This patch only adds additional elements to the
search.

Pull Request: https://projects.blender.org/blender/blender/pulls/138534
2025-05-08 04:28:22 +02:00
Guillermo Venegas
9e5151d294 Refactor: UI: Replace uiLayoutSplit with class method uiLayout::split
This converts the public `uiLayoutSplit` function to an object oriented
API (`uiLayout::split`), 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.

`uiLayout::split` now returns an `uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Pull Request: https://projects.blender.org/blender/blender/pulls/138361
2025-05-03 20:51:42 +02:00
Guillermo Venegas
2d896877d1 Refactor: UI: Replace uiLayoutColumn with class method uiLayout::column
This converts the public `uiLayoutColumn` function to an object oriented
API (`uiLayout::column`), 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.

`uiLayout::column` now returns an `uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Pull Request: https://projects.blender.org/blender/blender/pulls/138034
2025-04-26 21:07:34 +02:00
Campbell Barton
c90e8bae0b Cleanup: spelling in comments & replace some use of single quotes
Previously spell checker ignored text in single quotes however this
meant incorrect spelling was ignored in text where it shouldn't have
been.

In cases single quotes were used for literal strings
(such as variables, code & compiler flags),
replace these with back-ticks.

In cases they were used for UI labels,
replace these with double quotes.

In cases they were used to reference symbols,
replace them with doxygens symbol link syntax (leading hash).

Apply some spelling corrections & tweaks (for check_spelling_* targets).
2025-04-26 11:17:13 +00:00
Campbell Barton
d5b254216b Cleanup: correct references to UI_interface_c.hh 2025-04-23 05:29:14 +00:00
Brecht Van Lommel
388a21e260 Refactor: Eliminate various void pointers passed to MEM_freeN
It's safer to pass a type so that it can be checked if delete should be
used instead. Also changes a few void pointer casts to const_cast so that
if the data becomes typed it's an error.

Pull Request: https://projects.blender.org/blender/blender/pulls/137404
2025-04-21 17:59:41 +02:00
Brecht Van Lommel
637c6497e9 Refactor: Use more typed MEM_calloc<>, avoid unnecessary size_t cast
Handle some cases that were missed in previous refactor. And eliminate
unnecessary size_t casts as these could hide issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/137404
2025-04-21 17:59:41 +02:00
Julian Eisel
071a6d4221 UI: Include button type in button comparisons to preserve UI state
Only consider buttons with matching types as matching, when comparing
them between redraws to preserve active button state.

We could have avoided a bunch of issues in the past with this. They are
becoming quite common since we use more spacers and invisible elements
to enable certain behavior. Especially with nodes this caused some issues
recently.

Further code in `ui_but_update_old_active_from_new()` assumed matching
button types resulting in undefined behavior.

Fixes heap-buffer-overflow ASAN crash since 8ec9c62d3e.

Steps to reproduce were:
- Open [emitter-closures.blend](/attachments/e7689016-064c-4390-9f02-c2665b2a6a6b)
- Ctrl+Shift+Click on the header of the "Evaluate Closure" node

Pull Request: https://projects.blender.org/blender/blender/pulls/136943
2025-04-10 20:42:10 +02: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
5e2b421996 WM: support the "Hyper" modifier key on Linux
Add support for a 5th modifier key called "hyper",
this is a modifier supported on Wayland & X11 although
other platforms could support an additional modifier too.

Both GNOME and KDE can map CapsLock to Hyper.
Other compositors can use the XKB_DEFAULT_OPTIONS environment variable.

This allows users to have an additional modifier for their own use
that doesn't conflict with other keys.

Ref !136340
2025-03-26 10:39:55 +11:00
Campbell Barton
93bf29a851 Cleanup: correct values for wmKeyMapItem modifiers, use smaller types
- Document values to use for modifiers in code-comments.
- Only compare modifier values with KM_ANY/NOTHING/MOD_HELD.
- Use smaller integer sizes where possible.
2025-03-25 11:40:53 +11:00
Campbell Barton
3e5de94c8e Fix #136188: Invalid read clicking on a menu socket button in modifier
Clicking the drop-down button for a Menu-type socket in geometry
modifier panel crashes with ASAN error.

Resolve by skipping the check for ID properties & assert the property
is an RNA property.
2025-03-22 08:06:42 +00:00
Harley Acheson
d61e4d0930 Fix #136206: Clamp Max Row Calculation in Enum Lists
For very large scales with very small windows the enum list calculation
of how many rows might fit can result in zero, causing problems with a
later division. clamping this to a minimum of one fixes this and causes
no harm. This calculation is just a hint on how to behave, whether to
show lists in columns or not, etc. Lists still display fine even when
this variable reaches this minimum.

Pull Request: https://projects.blender.org/blender/blender/pulls/136265
2025-03-20 17:35:25 +01:00
Guillermo Venegas
cb11e23605 Fix #93504: Text moving in status bar
When flexiable spacing clamp the floating point widths to whole pixels
in ui_update_flexible_spacing to remove the random jiggling that can
occur, notable seen on the status bar at the right edge.

Pull Request: https://projects.blender.org/blender/blender/pulls/135899
2025-03-18 23:57:47 +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
Sebastian Parborg
ec29eb6580 Refactor: Make it more obvious that wm_event_add is not a static function
By renaming it to WM_ follow the other public functions.
2025-03-11 14:39:18 +01:00
Bastien Montagne
dd168a35c5 Refactor: Replace MEM_cnew with a type-aware template version of MEM_callocN.
The general idea is to keep the 'old', C-style MEM_callocN signature, and slowly
replace most of its usages with the new, C++-style type-safer template version.

* `MEM_cnew<T>` allocation version is renamed to `MEM_callocN<T>`.
* `MEM_cnew_array<T>` allocation version is renamed to `MEM_calloc_arrayN<T>`.
* `MEM_cnew<T>` duplicate version is renamed to `MEM_dupallocN<T>`.

Similar templates type-safe version of `MEM_mallocN` will be added soon
as well.

Following discussions in !134452.

NOTE: For now static type checking in `MEM_callocN` and related are slightly
different for Windows MSVC. This compiler seems to consider structs using the
`DNA_DEFINE_CXX_METHODS` macro as non-trivial (likely because their default
copy constructors are deleted). So using checks on trivially
constructible/destructible instead on this compiler/system.

Pull Request: https://projects.blender.org/blender/blender/pulls/134771
2025-03-05 16:35:09 +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
Julian Eisel
73ff81db8a Merge branch 'blender-v4.4-release' 2025-02-18 16:09:55 +01:00
Julian Eisel
2e28865ece Fix (unreported): Mismatching MEM_new/MEM_freeN on button handling data
New version of b22670d927 (which was reverted with 9d33dd88d5).

I rather keep `uiHandleButtonData` private to the handling code. It
does the allocation as part of its implementation details, so it should
also handle freeing.
2025-02-18 15:57:38 +01:00
Bastien Montagne
6c1b231310 Merge branch 'blender-v4.4-release' 2025-02-18 15:47:27 +01:00
Bastien Montagne
9d33dd88d5 Revert "Fix (unreported) invalid mismatch MEM_new/MEM_freeN on but->active."
This reverts commit b22670d927.
2025-02-18 15:39:18 +01:00
Bastien Montagne
37ecf6d03f Merge branch 'blender-v4.4-release' 2025-02-18 15:12:45 +01:00
Bastien Montagne
b22670d927 Fix (unreported) invalid mismatch MEM_new/MEM_freeN on but->active.
Found by @brecht while reviewing !134463.
2025-02-18 15:10:39 +01:00
Harley Acheson
c3a2af00be Merge branch 'blender-v4.4-release' 2025-02-17 20:27:18 -08:00
Harley Acheson
9aeb97ccea Cleanup: Improved Comments in ui_def_but_rna__menu
Nothing but improvements to comments in this area of code to better
explain the complexity of Emum list row and column calculation. These
things change wrapping and column count to suit available space and
needs better explanation.

Pull Request: https://projects.blender.org/blender/blender/pulls/134719
2025-02-18 05:26:12 +01:00
Harley Acheson
f1514b45e3 Merge branch 'blender-v4.4-release' 2025-02-17 18:13:17 -08:00
Harley Acheson
b39bb42b3a Fix #134271: Reflow Non-Categorized Enum Lists Only If Necessary
For non-categorized lists, rather than always trying to find optimal
rows and columns, revert to prior behavior and only reflow if needed,
when the calculated rows are greater than maximum rows. This is less
disruptive, has less changes at small sizes where this doesn't matter.
Yet still does the job when things get too large to fit, or the list
is very long.

Pull Request: https://projects.blender.org/blender/blender/pulls/134713
2025-02-18 03:12:10 +01:00
Guillermo Venegas
f2b6b6c232 UI: Prevent button vector reallocations on redraws
A bunch of reallocations can be avoided this way, usually the amount of buttons
is quite similar over redraws.

Pull Request: https://projects.blender.org/blender/blender/pulls/134580
2025-02-17 16:03:45 +01:00
Campbell Barton
69e63d190d Cleanup: use "at_most" RNA array access functions for simplicity 2025-02-16 18:39:35 +11: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
Harley Acheson
c1866764b0 Merge branch 'blender-v4.4-release' 2025-02-14 09:42:48 -08:00
Harley Acheson
99d028cd7d Fix #134492: Do Not Assign Toggle Accelerators on First Pass
With ba9417470e we are assigning keyboard accelerator shortcuts to
menu items containing toggles. This PR makes the assignment to these
new items not occur on the first pass of doing so. This is less
disruptive in that first-letter shortcuts will remain the same from
prior versions, with only mid-word shortcuts possibly changing.

Pull Request: https://projects.blender.org/blender/blender/pulls/134526
2025-02-14 18:41:33 +01:00
Guillermo Venegas
7682258ff9 Refactor: UI: Use a Vector to store buttons in UI blocks
This changes the ui-blocks buttons storage from Listbase to Vector.

Major changes that might cause a performance considerations are
in `ui_but_update_from_old_block` that requires to track buttons when restoring
button state between block redraws or in  `uiItemFullR` that may needs to insert
uiButs in the middle of the vector to add decorators. This might not be as fast as
removing or inserting elements in the middle of a listbase container. Also buttons currently
don't know its position in the container, so to get the previous and next
button its required to make a lookup of the button in the container.

`UI_block_update_from_old> ui_but_update_from_old_block` restores the state
of buttons between frames, this is done by sequentially testing if a button is the
same as an old button, however since UI can be created procedurally some old buttons
may not be drawn while editing other button data, this requires an extra track of what
buttons may not match to a new button while comparing for restoring state, but still
this buttons may be candidates to match to an new button.

Not functional changes expected.
Ref: #117604

Co-authored-by: Julian Eisel <julian@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/127128
2025-02-14 15:29:26 +01:00
Hans Goudey
4f833b0b5f Refactor: Add StringRef overloads to translation functions
Currently UI code always has to use char pointers when interacting with
the translation system. This makes benefiting from the use C++ strings
and StringRef more difficult. That means we're leaving some type safety
and performance on the table. This PR adds StringRef overloads to the
translation API functions and removes the few calls to `.c_str()` that
are now unnecessary.

Pull Request: https://projects.blender.org/blender/blender/pulls/133887
2025-02-06 17:47:52 +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
Campbell Barton
4ed5776990 Cleanup: avoid double precision loss when converting to/from floats 2025-02-05 14:38:56 +11:00
Brecht Van Lommel
3725fad82f Cleanup: Various clang-tidy warnings in editors
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:17 +01:00
Bastien Montagne
9c237af041 Refactor: RNA: add discrete suffix to RNA_pointer_create.
This is a noisy preliminary step to the 'RNA ancestors' change. The
rename helps clearly tell what each `pointer_create` function does.

Pull Request: https://projects.blender.org/blender/blender/pulls/133475
2025-01-24 16:45:32 +01:00
Hans Goudey
c6f5c44350 Cleanup: Remove unused includes in editors modules
Pull Request: https://projects.blender.org/blender/blender/pulls/133166
2025-01-16 23:17:51 +01:00
Harley Acheson
ba9417470e Fix #126409: Allow Menu Accelerators for Toggles
When menus (that are not type-to-search) open we add underlines to
most items so they can be selected quickly. We currently don't do this
for items that are toggles.  This PR adds accelerators to toggles.

Pull Request: https://projects.blender.org/blender/blender/pulls/132309
2025-01-13 19:14:12 +01:00
Harley Acheson
fe071cd076 Fix #124814: Correctly Collapse Long Non-Categorized Lists
Multi-column lists are supposed to collapse to single-column when they
are estimated to be wider than the available window width. However,
current code has two errors. First the calculation of the maximum
number of possible rows is based on entire screen height when the most
available is a bit less than half. This too-large value was used in
the calculation of widths, yet the maximum rows is actually clamped
to about 24 for uncategorized lists. Whenever the former is greater
than the latter this could cause collapsing to not occur. This issue is
only really noticeable for lists in Nodes as these can be shown much
smaller than regular size.  This PR fixes the max-row calculation and
uses this correctly when breaking lists without categories.

Pull Request: https://projects.blender.org/blender/blender/pulls/132881
2025-01-10 00:56:33 +01:00