Commit Graph

6931 Commits

Author SHA1 Message Date
Campbell Barton
ea99acb6a2 Fix #107021: Knife cursor lost after status bar pan
Check the modal cursor isn't set before overwriting it for 2D viewport
operators.

Match behavior for image & movie-clip navigation.
2025-07-24 04:37:34 +00:00
Campbell Barton
5e3db5fbb0 Cleanup: consistent use of back-ticks in code-comments 2025-07-23 20:59:16 +10:00
Clément Foucault
32d64d35bb Refactor: GPU: Texture: Replace eGPUTextureFormat by TextureFormat
This offers better semantic and safety of the API.

Part of #130632

Pull Request: https://projects.blender.org/blender/blender/pulls/142818
2025-07-22 14:58:54 +02:00
Clément Foucault
f0254c2dcf Refactor: GPU: Remove unnecessary C wrappers for textures
This is the first step into merging `DRW_gpu_wrapper.hh` into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/142732
2025-07-22 09:48:10 +02:00
Campbell Barton
5f6a07240f Cleanup: avoid redundant string formatting 2025-07-22 15:53:14 +10:00
Guillermo Venegas
3816c665a5 Cleanup: UI: Slightly optimize uiBut memory layout
This saves up to 56 bytes (896 vs 952).

Pull Request: https://projects.blender.org/blender/blender/pulls/142379
2025-07-18 22:28:44 +02:00
Falk David
99f3beb63f Refactor: VSE: Use new scene context function
This PR switches out the internal scene context function
used from the sequencer. This is done in preparation for
#140271.

Using a separate context function allows us to keep the
existing `context.scene` to refer to the active scene
and use a separate context member to refer to the
sequencer scene in the workspace (which is added in #140271).

Previous attempts simply overrode the `context.scene`
to refer to a different scene than the active one in the window.
This has two issues:
1) Any operator that wants to use the active scene in the window
  can't do it in the context of the sequencer. This is a problem for
  example for poll functions of operators that don't have anything to
  do with the sequencer.
2) For better or for worse, Blender expects the `context.scene` to
  always exist. For the sequencer, we'd like to possibly have no
  sequence selected.

Using a different context member for the sequencer has some
advantages:
1) Although we have to change quite a few places, it's limited to the
  sequencer. We don't have to change other parts of Blender to make
  things work.
2) It allows us to prepare for the future when we might want to
 separate the VSE from the scene. This is a step in that direction.
 Having a different context function makes it easy to find the places
 that would need to be refactored.

Pull Request: https://projects.blender.org/blender/blender/pulls/141271
2025-07-18 16:17:47 +02:00
Guillermo Venegas
9c98ea1a18 Refactor: UI: Make button type params typed enums
This converts `eButType` and `eButPointerType` as typed enums.

This improves a bit `uiDefBut` self-documentation by taking an
struct with `ButType` and `ButPointerType` types, instead of
using a single `int` to write both enum types and bit index.

Almost all other `uiDefBut*` functions take just a `ButType`
parameter now.

`uiDefButI` for example is equivalent to:
`uiDefBut({ButType(type), ButPointerType::Int},...);`

Pull Request: https://projects.blender.org/blender/blender/pulls/142132
2025-07-18 13:12:16 +02:00
Campbell Barton
751cfe4a74 GHOST/Wayland: invert cursor color, pre-multiply alpha
- Cursors in wayland are expected to use pre-multiplied alpha.
  Note that cursor generators create straight alpha,
  pre multiplier in the wayland backend.
- Invert cursor colors on Wayland since dark cursors are often default,
  this could use dark theme settings in the future.
2025-07-18 14:13:38 +10:00
Campbell Barton
c52c8874e9 GHOST/Wayland: scalable vector cursor support via cursor-generators
Support showing vector cursors at the appropriate size based on each
monitors DPI.

This solves incorrectly sized cursors with Hi-DPI outputs as well as
supporting outputs with different DPI's.

Instead of passing pixel data, pass an object that can generate cursors,
GHOST/Wayland can then ensure the correct size is used based on the
display the cursor is shown on.

While may sound overly complicated it actually simplifies displaying
cursors on Wayland, especially for multiple monitors at different DPI's.
Showing cursors at higher or lower resolutions than the monitor's DPI
also behaves differently on GNOME & Plasma, resulting in situations
where the cursor would show larger/smaller than expected.

Details:

- Take advantage of the recently added SVG cursors & BLF time cursor
  !140990 & !141367.
- Setting bitmap cursors via GHOST_SetCustomCursorShape is now a no-op
  for Wayland since it's no longer used. This was supported in an
  earlier version of this PR and could be restored if needed.
- While fractional scaling works it relies on the compositor downscaling
  the cursors. Ideally they would be rendered at the target size but
  this isn't a priority as the difference isn't noticeable.

Ref !141597
2025-07-18 12:38:52 +10:00
Campbell Barton
98dcd0c91e Build: unbreak WITH_HEADLESS, !WITH_PYTHON configurations 2025-07-18 12:01:43 +10:00
Campbell Barton
c034c928fe Cleanup: correct spelling, typos & remove outdated comment 2025-07-17 12:30:37 +10:00
Christoph Neuhauser
a889aa9e38 WM: Switch to high-resolution timers on Windows for sleeping
This PR introduces a more precise sleep function `BLI_time_sleep_duration`
using high-resolution timers on Windows. By default, Windows only has a
resolution of 15.25ms for the regular `Sleep` function. Using more precise
timers makes sure that Blender can wake from sleep quicker and improves
performance at high frame rates.

High-resolution timers may have better energy efficiency than using
`timeBeginPeriod`/`timeEndPeriod` that change the timer resolution globally
on some versions of Windows.

Pull Request: https://projects.blender.org/blender/blender/pulls/140221
2025-07-15 10:02:09 +02:00
Campbell Barton
f62422884b Fix: correction to recent WM_cursor_time fix
Recent fix to ensure cursors never display negative numbers [0]
didn't work when the input value was std::numeric_limits<int>::min().

Resolve using an unsigned cast before negating.

[0]: 747ab523c3
2025-07-15 15:27:01 +10:00
Campbell Barton
747ab523c3 Fix: crash displaying negative numbers in WM_cursor_time
Displaying negative numbers would attempt to read from a negative
array index on systems that don't support RGBA cursors.
Resolving by making the value absolute before displaying.
2025-07-15 14:33:50 +10:00
Campbell Barton
3a55348492 WM: various improvements to text cursors
- Use a bounding box based on the fonts dimensions to fix jittering
  as numbers change because of differences in glyph bounds.
- Always show a cursor even if the text is empty.
- Use integer arithmetic to simplify bounds calculations and avoid
  having to round the resulting values.
- Increase the maximum width of the text to twice the cursor size
  since the text could be quite small when limited to the cursor size.
- Extract buffer flip-Y into a function.
- Define CURSOR_HARDWARE_SIZE_MAX and reuse this constant.
2025-07-15 13:55:22 +10:00
Guillermo Venegas
1a247fbaa8 Refactor: WM: Make OperatorCallContext an enum class, move to namespace
This allows forward declaring `OpCallContext`, avoiding the
transitive include `WM_Types.hh` in `UI_interface_layout.hh`

Pull Request: https://projects.blender.org/blender/blender/pulls/141804
2025-07-15 03:08:04 +02:00
Jacques Lucke
00c81f5113 Merge branch 'blender-v4.5-release' 2025-07-14 16:30:38 +02:00
YimingWu
4096309753 Fix #141819: Interface Use a flag for WM_set_locked_interface
Different operations may need to lock different part of the interface,
e.g. for rendering, the image editor may still need refreshing while the
interface is locked, but when baking data into a scene, the image editor
needs to be locked because it is not thread safe to get data from a
partially evaluated depsgraph.

This is a better fix on top of 7c8b8b2457
that addresses the root cause with more flexibility for future
operations that requires different interface locking strategy as
well.

Pull Request: https://projects.blender.org/blender/blender/pulls/141866
2025-07-14 16:17:46 +02:00
Hans Goudey
14e2876b73 Core: Replace BLI_buffer.hh with blender::Vector
The C++ Vector container has the benefits of the older C type,
along with improved performance, better type and memory safety,
and significantly improved ergonomics.

Pull Request: https://projects.blender.org/blender/blender/pulls/141759
2025-07-13 17:13:59 +02:00
Campbell Barton
ec8751f826 Cleanup: white-space around C-style comment blocks
Also use C++ style comments for disabling code.
2025-07-13 21:58:53 +10:00
Campbell Barton
a34c943e37 WM: correct own regression in recent cursor size clamping
When calculating the font size clamp by the requested cursor size
instead of 256.

This will often make the cursor smaller since allowing 256px wide
cursors is quite large.

Also de-duplicate size checks & round the text size to an integer to
avoid fractional scaling from subtle changes to the text.
2025-07-13 13:44:10 +10:00
Campbell Barton
4820bcc7cc Cleanup: doc-strings for currsor rasterization
Also add a safeguard to ensure the resulting cursor
never exceeds the requested size.
2025-07-13 12:28:32 +10:00
Campbell Barton
566afb8201 WM: access the windows DPI directly to calculate the mouse-cursor scaling
Instead of relying on the the `U.ui_scale` being set when activating
the window, calculate the cursor size from the windows DPI.

This also de-duplicates cursor scale calculation.
2025-07-13 11:57:29 +10:00
Campbell Barton
41fc42697c Cleanup: rename WM_window_{set_dpi => dpi_set_userdef}
The name read as if it was setting the DPI however the window DPI
was being calculated and written into the #UserDef (U).
2025-07-13 11:31:41 +10:00
Campbell Barton
a3d30afca1 Cleanup: move cursor details into struct doc-strings 2025-07-13 11:25:09 +10:00
Campbell Barton
10fab706f5 Cleanup: pass the cursor size to cursor_bitmap_from_text
Rename cursor_size() to wm_cursor_size() to allow this to be used
as an argument name without shadowing.
2025-07-12 20:54:27 +10:00
Campbell Barton
31ac70e6c2 Refactor: extract cursor rasterization into separate function calls
Prepare for dynamic cursor generation from !141597.
2025-07-12 20:36:01 +10:00
Campbell Barton
deda15f386 Cleanup: minor changes to wm_cursors.cc
- Use "g_" prefix for cursors to signify that it's global but local to
  the file.
- Use `const` cast passing pixel data to GHOST_SetCustomCursorShape.
- Remove redundant cast.
2025-07-12 19:24:14 +10:00
Campbell Barton
420a6a5bb6 WM: restore test code from previous commit
Restore UI_SCALE_FAC use for disabled testing logic.
2025-07-12 19:10:35 +10:00
Campbell Barton
eb836d8ae1 WM: use the systems DPI for cursor scale instead of the UI scale
Cursor size calculation now uses the GHOST DPI without the UI scale
since the UI scale doesn't impact system cursors.
2025-07-12 19:01:32 +10:00
Harley Acheson
bea1dbfab0 UI: Cursor Time for RGBA Platforms
The Windows and Wayland platforms can both create antialiased mouse
cursors from SVG sources. Platforms with WM_CAPABILITY_CURSOR_RGBA
can therefore show a better version of "WM_cursor_time". Instead of
four blocky digits in two rows this displays beautiful digits in a
single row.

Pull Request: https://projects.blender.org/blender/blender/pulls/141367
2025-07-12 05:22:41 +02:00
Hans Goudey
8f198a85b4 Refactor: Add RNA_string_get function returning a string
This can replace most uses `RNA_string_get_alloc` and give us
better type safety and generally simpler code.

Internally, this uses the function added in 50076993f3.

Pull Request: https://projects.blender.org/blender/blender/pulls/141358
2025-07-11 16:24:13 +02:00
Guillermo Venegas
1f34dc9155 Refactor: UI: Replace uiItemsEnumO with class method uiLayout::op_enum
This converts the public uiItemsEnumO and uiItemsFullEnumO functions
to an object-oriented API (as uiLayout::op_enum overloads), matching
recent changes in the API.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/141748
2025-07-11 15:25:30 +02:00
Campbell Barton
6a2a999173 Merge branch 'blender-v4.5-release' 2025-07-11 15:48:27 +10:00
Campbell Barton
29a7b60a40 Fix #141667: Erratic behavior with orthographic camera gizmo
Regression in 3.6 caused the orthographic camera gizmo to enter a
feedback loop where the gizmo range was changed while being interacted
with.

Resolve by preventing the range being updated during modal interaction.
2025-07-11 15:36:16 +10:00
Sergey Sharybin
93be12fde0 ImBuf: Linearize float buffers from FFmpeg
Blender expects float buffers to be in scene linear space, which was
violated bu the 1012bit movie reading code. While such image buffers
can be displayed correctly, performing operations in various areas
of Blender might lead to unexpected results.

The non-linear colorspace for ImBuf is expected to be "internal-only"
to a specific area, like VSE.

This is only done for Image and MovieClip data-blocks, sequencer still
reads movie files in their original colorspace as it helps performance and
sequencer can not be referenced from places where linear colorspace
for float buffer is really important.

Pull Request: https://projects.blender.org/blender/blender/pulls/141603
2025-07-10 17:39:00 +02:00
Brecht Van Lommel
bc507861f2 Logging: Some tweaks to capitalization and log levels
For NDOF, Vulkan context, operators and events.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:27 +02:00
Brecht Van Lommel
d7cc940825 Logging: Log GHOST backend, GPU backend and GPU device
Important information that could not be found directly in the logs yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:27 +02:00
Brecht Van Lommel
4653b65f7c Logging: Add DEBUG, TRACE severity, replace numeric levels
The numeric levels have no obvious meaning. This removes the distinction
between severity and levels, instead there is a single list of named levels
with defined meaning.

Debug means information that's mainly useful for developers, and trace is for
very verbose code execution tracing.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Brecht Van Lommel
8d8e61fefd Logging: Change various categories and log levels
* Remove bke, ed and wm prefixes
* Add prefixes like: geom, object, blend, lib.
* Shorten some category names
* A few log level changes to improve --log-level info output

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Harley Acheson
37f10aaa4a UI: Fix Cursor Size Truncation Issue
Mouse cursor size calculation must use round rather than trunc.
Otherwise there is a decrease in cursor size from 1X -> 1.01X scale.

Pull Request: https://projects.blender.org/blender/blender/pulls/141637
2025-07-08 23:59:47 +02:00
Campbell Barton
439253eab5 Cleanup: use consistent terms in capability flags
Consistently use terms "cursor" & "clipboard" as a prefix
so they auto-complete more usefully.

Previously both ordering was used.
2025-07-08 16:35:42 +10:00
Campbell Barton
7c41250916 Fix large software cursors with Hi-DPI display on Wayland
Since the cursors are now generated from SVG's at the correct size
there is no need to scale them up when drawing software cursors.
2025-07-08 16:35:42 +10:00
Campbell Barton
b054a4557b Cleanup: use an integer to represent the cursor size
The move to SVG cursors used a float for the cursor size which isn't
especially useful as the resulting cursor dimensions are pixels.
2025-07-08 11:43:06 +10:00
Campbell Barton
b2d6af6c2b Cleanup: use const reference for cursor data
Also remove redundant null check.
2025-07-08 11:26:48 +10:00
Campbell Barton
12f0e3ee78 Merge branch 'blender-v4.5-release' 2025-07-08 10:38:10 +10:00
Campbell Barton
4431d7a369 Fix #141514: Broken cryptomatte picking with multi-windows on Wayland
Only perform window under cursor checks for GHOST back-ends that
have the window positioning capability.
2025-07-08 10:36:10 +10:00
Germano Cavalcante
289adf8616 Merge branch 'blender-v4.5-release' 2025-07-07 11:56:35 -03:00
Germano Cavalcante
cd143ca900 Fix: Wrong depth status in gizmo selection
When selecting gizmos (such as one of the scale handles in the
Transform tool), the depth test state does not match what is shown in
the viewport. This can lead to unintuitive gizmo selection.

The issue is caused by the incorrect assumption that the depth state is
already `GPU_DEPTH_NONE` before rendering the gizmos for selection.

The solution is to ensure the status before rendering.

Pull Request: https://projects.blender.org/blender/blender/pulls/141412
2025-07-07 16:54:22 +02:00