Commit Graph

151 Commits

Author SHA1 Message Date
Bastien Montagne
48e26c3afe MEM_guardedalloc: Refactor to add more type-safety.
The main goal of these changes are to improve static (i.e. build-time)
checks on whether a given data can be allocated and freed with `malloc`
and `free` (C-style), or requires proper C++-style construction and
destruction (`new` and `delete`).

* Add new `MEM_malloc_arrayN_aligned` API.
* Make `MEM_freeN` a template function in C++, which does static assert on
  type triviality.
* Add `MEM_SAFE_DELETE`, similar to `MEM_SAFE_FREE` but calling
  `MEM_delete`.

The changes to `MEM_freeN` was painful and useful, as it allowed to fix a bunch
of invalid calls in existing codebase already.

It also highlighted a fair amount of places where it is called to free incomplete
type pointers, which is likely a sign of badly designed code (there should
rather be an API to destroy and free these data then, if the data type is not fully
publicly exposed). For now, these are 'worked around' by explicitly casting the
freed pointers to `void *` in these cases - which also makes them easy to search for.
Some of these will be addressed separately (see blender/blender!134765).

Finally, MSVC seems to consider structs defining new/delete operators (e.g. by
using the `MEM_CXX_CLASS_ALLOC_FUNCS` macro) as non-trivial. This does not
seem to follow the definition of type triviality, so for now static type checking in
`MEM_freeN` has been disabled for Windows. We'll likely have to do the same
with type-safe `MEM_[cm]allocN` API being worked on in blender/blender!134771

Based on ideas from Brecht in blender/blender!134452

Pull Request: https://projects.blender.org/blender/blender/pulls/134463
2025-02-20 10:37:10 +01:00
Sean Kim
0dd326592a Undo: Add explicit filtering for IDs and RNA structs marked as skippable
In the past, around the time that 2.80 was released, 4a08b974f4
introduced the idea of filtering out certain editor changes inside
the paint modes and edit mode (e.g. changing brush sizes in the editor).

This commit is the first in a series to attempt to refine this behavior
so that only certain editor settings are filtered out from the undo
stack.

In total, it does the following:
* Adds the Brush datablock to the list of IDs that do not have undo
  pushes.
* Adds support to filter out RNA structs that do not have the
  `STRUCT_UNDO` property applied (currently, just the 3D Cursor).

This has the following effects:
* Changing brush settings inside the Image Editor no longer causes
  undo pushes, becoming consistent with the other paint modes.
* Changing brush settings while in object mode in the outliner data
  block view no longer causes undo pushes.

Co-authored-by: Campbell Barton <campbell@blender.org>
2025-02-20 07:12:56 +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
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
Harley Acheson
497f2884e8 UI: Decrease Alert Dialog Icon Size
Decrease the size of the icons shown on the large dialogs and
confirmations from 64 pixels (at 1X resolution scale) to 40.

Pull Request: https://projects.blender.org/blender/blender/pulls/134302
2025-02-12 18:30:52 +01:00
Bastien Montagne
87a4c0d3a8 Refactor: Make Library.runtime an allocated pointer.
Move `Library.runtime` to be a pointer, move the related
`LibraryRuntime` struct to `BKE_library.hh`. Similar to e.g.
Mesh.runtime, that pointer is expected to always be valid, and is
allocated at readtime or when creating a new Library ID.

Related smaller changes:
* Write code now uses standard ID writing codepath for Library IDs too.
  * Runtime pointer is reset to nullptr before writing.
* Looking up a library by its absolute path is now handled through a
  dedicated utils, `search_filepath_abs`, instead of using
  `BLI_findstring`.

Pull Request: https://projects.blender.org/blender/blender/pulls/134188
2025-02-07 17:47:16 +01:00
Guillermo Venegas
5a1e8de77b Fix: Pointer reseted to nullptr
The pointer is de-referenced few lines below

Pull Request: https://projects.blender.org/blender/blender/pulls/134154
2025-02-06 00:23:01 +01:00
Hans Goudey
190ea95ae6 Fix: Radial control operator crash after PointerRNA change
Caused by 45f231141d.

The non-trivial nature of `RadialControl` was hidden behind
C-style allocation. Now write the default values for `RadialControl`
explicitly since it isn't allocated by calloc anymore.
2025-02-05 13:54:11 -05:00
Brecht Van Lommel
ae28102c3f Cleanup: Various clang-tidy warnings in windowmanager
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
Falk David
b9f253564e VSE: Python API: Deprecate sequence properties and replace with new ones
This PR adds new RNA properties that deprecate and replace any `sequence` property.
The old prooperties are still there and fully functional, but the description is changed
to indicate that these will be removed in the future and that the new properties should
be used instead.

| Deprecated property | Replacement property |
| --------------------------------- | ----------------------------------- |
| `context.active_sequence_strip` | `context.active_strip` |
| `context.selected_editable_sequences` | `context.selected_editable_strips` |
| `context.selected_sequences` | `context.selected_strips` |
| `context.sequences` | `context.strips` |
| `SequenceEditor.sequences` | `SequenceEditor.strips` |
| `SequenceEditor.sequences_all` |  `SequenceEditor.strips_all` |
| `MetaStrip.sequences` | `MetaStrip.strips` |

Previously, rna paths for animation data on strips started with `sequence_editor.sequences`.
This PRadds versioning for the rna paths to make sure to use
the new naming scheme. This does mean that in previous versions of blender,
the animations don't show but the data is not lost (even if the file is saved in the older version).

Also do some cleanup of existing python scripts inside the source to use the
new properties.

Part of #132963.

Pull Request: https://projects.blender.org/blender/blender/pulls/133156
2025-01-21 11:30:20 +01:00
Falk David
d413b0064f Cleanup: Move BKE_material.h to C++
The `BKE_material.h` is only renamed to `.hh` to preserve
the history of the file. Changes to the file are done in
the following commit.
2025-01-09 18:11:46 +01:00
Campbell Barton
7e8dcf77db Cleanup: pass UnitSettings as a const reference 2025-01-08 21:22:45 +11:00
Brecht Van Lommel
920e709069 Refactor: Make header files more clangd and clang-tidy friendly
When using clangd or running clang-tidy on headers there are
currently many errors. These are noisy in IDEs, make auto fixes
impossible, and break features like code completion, refactoring
and navigation.

This makes source/blender headers work by themselves, which is
generally the goal anyway. But #includes and forward declarations
were often incomplete.

* Add #includes and forward declarations
* Add IWYU pragma: export in a few places
* Remove some unused #includes (but there are many more)
* Tweak ShaderCreateInfo macros to work better with clangd

Some types of headers still have errors, these could be fixed or
worked around with more investigation. Mostly preprocessor
template headers like NOD_static_types.h.

Note that that disabling WITH_UNITY_BUILD is required for clangd to
work properly, otherwise compile_commands.json does not contain
the information for the relevant source files.

For more details see the developer docs:
https://developer.blender.org/docs/handbook/tooling/clangd/

Pull Request: https://projects.blender.org/blender/blender/pulls/132608
2025-01-07 12:39:13 +01:00
Falk David
655a17a6ab Refactor: VSE: Rename Sequence to Strip
This renames the struct `Sequence` to `Strip`.

While the motivation for this partially comes from
the "Sequence Design" #131329, it seems like this
is a good refactor whether the design gets implemented
or not.

The `Sequence` represents what users see as strips in the
VSE. Many places in the code already refere to a `Sequence`
as "strip". It's the C-style "base class" of all strip types.

This also renames the python RNA type `bpy.types.Sequence`
to `bpy.types.Strip` which means that this technically breaks
the python API.

Pull Request: https://projects.blender.org/blender/blender/pulls/132179
2025-01-06 14:19:24 +01:00
Harley Acheson
df57beb676 UI: Improved User Feedback for Animation Playback Timer
The "Blender" menu contains seven items in "System / "Redraw Timer"
that are for troubleshooting and testing.  Six of the items take far
less than a second, but one takes a long time. "Animation Play" times
how long it takes to play through your current animation ten times. But
there is no way to guess this and some users have run it accidentally
by finding it in menu search. It gives no feedback at all, and there
are no hints on how long it will take. Once it plays through your
animation once you might guess that it runs forever.  This PR shows
the test name and where it is in its ten runs. On platforms that
support it this also shows an app progress bar (on the taskbar icon for
Windows).

Pull Request: https://projects.blender.org/blender/blender/pulls/132648
2025-01-05 02:00:37 +01:00
Sybren A. Stüvel
efd2e762f7 Refactor: Core, give the IDWALK_CB_… enum an explicit name
Give the `IDWALK_CB_…` enum an explicit name:
`LibraryForeachIDCallbackFlag`. This way the flags are type-safe, and
it's known where values come from. This is much preferred (at least by
me) to just having `int flags`.

Uses of `0` have been replaced with `IDWALK_CB_NOP` as that has the same
value and is of the right type.

One invalid use of `IDWALK_NOP` was detected by this change, and is
replaced by `IDWALK_CB_NOP`.

This change might be incomplete; I gave the enum a name, fixed the
compiler errors, and then also updated assignments like `int cb_flag =
cb_data->cb_flag`. I might have missed some assignments to `int` though.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/131865
2024-12-13 17:32:24 +01:00
Sybren A. Stüvel
7d5143e94c Revert "Refactor: Core, give the IDWALK_… enums an explicit name"
This reverts commit 3ef748789d. It was
landed too hastily, my apologies.

Pull Request: https://projects.blender.org/blender/blender/pulls/131813
2024-12-12 20:03:27 +01:00
Sybren A. Stüvel
3ef748789d Refactor: Core, give the IDWALK_… enums an explicit name
Two commits that basically do the same thing for two `enum`s: give
them a name.

- the `IDWALK_…` enum → `LibraryForeachIDFlag`.
- the `IDWALK_CB_…` enum → `LibraryForeachIDCallbackFlag`.

This way the flags are type-safe, and it's known where values come
from. This is much preferred (at least by me) to just having `int
flags`.

Uses of `0` have been replaced with `IDWALK_NOP` and `IDWALK_CB_NOP`,
as those have the same value and are of the right type.

One invalid use of `IDWALK_NOP` was detected by this change, and is
replaced by `IDWALK_CB_NOP`. And another one in the opposite
direction.

This change might be incomplete; I gave the enum a name, fixed the
compiler errors, and then also updated assignments like `int cb_flag =
cb_data->cb_flag`. I might have missed some assignments to `int`
though.

No functional changes.

----------

I intend to land this PR as its two separate commits. I just put them in the same PR so the buildbot can handle them in one go, and we don't have a stack of highly relatled PRs.

In the future this could also apply to the `IDWALK_RET_…` enum. This one I left out, though, because a proper cleanup there would also have to include their ambiguity on whether they are bitflags (like the enums in this PR) or not. Their values and the code in `BKE_lib_query_foreachid_process()` implies they are bitflags, but in practice they are never or'ed together and just used as discrete values.

Pull Request: https://projects.blender.org/blender/blender/pulls/131803
2024-12-12 17:28:28 +01:00
Falk David
612be514c6 Grease Pencil: Add lasso/box erase operators in draw mode
In Blender 4.2 in Grease Pencil draw mode it was possible to
erase strokes using box and lasso gestures.

Under the hood, these were just using the selection operators
that had special deletion handling if the object was in draw mode.

Rather than hacking this into the selection operations, this adds
two new operators:
* `grease_pencil.erase_lasso`
* `grease_pencil.erase_box`

When using one of the erase operations with auto-key, the previous
keyframe will be duplicated to the current frame (for the drawings
that are affected by the eraser).

They are mapped to the same shortcuts than the selection
operators in Blender 4.2.
* Lasso erase: `Ctrl`+`Alt`+`RMB`.
* Box erase: `B`.

This is part of #130518.

Pull Request: https://projects.blender.org/blender/blender/pulls/131504
2024-12-10 11:50:05 +01: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
Bastien Montagne
4bf5a2f5cb Cleanup: PointerRNA: Remove 'C-style' zero-initializations.
These are useless now that PointerRNA has explicit default values, and
become a problem when real constructors are added to this struct. Simply
use the default empty value initialization instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/130927
2024-11-25 19:09:56 +01:00
Hans Goudey
129a2aa0f4 Refactor: Move region runtime data out of DNA
Pull Request: https://projects.blender.org/blender/blender/pulls/130303
2024-11-21 19:34:53 +01:00
Bastien Montagne
b863369ae9 Refactor: BKE_image: Allow to load or find existing also in a Library.
This commit refactors `BKE_image_load` and `BKE_image_load_exists` APIs:
* Remove the `_ex` versions (the 'exist' boolean return pointer can have
  default `nullptr` value instead).
* Add `_in_lib` versions, which match signature and behavior of the
  generic ID creation code to allow to find or create a new image ID
  directly in a library 'namespace' (as linked data).

This is required by upcommig fixes for Brush Assets, which are using
linked but editable data-blocks.

Fix #130194: When trying to add a new image from the UI (e.g. for a new
texture) for a local ID, if that same exact image was already loaded by
a linked ID, it would trigger an assert in `BKE_id_move_to_same_lib`,
because `BKE_image_load_exists` would return the matching linked Image ID
instead of creating a new local one. In release builds with no assert,
it would result in making a linked ID 'local', while still being used by
original other linked data.

Passing around the intended final destination of the new Image (local or
in a given library) allows `BKE_image_load_exists` to be more specific
when searching for an already loaded matching image ID, and ensures that
a new local Image ID is created in the case described above.

Pull Request: https://projects.blender.org/blender/blender/pulls/130195
2024-11-13 15:29:29 +01:00
Bastien Montagne
0b3a7cbe69 Cleanup: Move BKE_image.h and related headers to C++.
NOTE: This also required some changes to Cycles code itself, who is now
directly including `BKE_image.hh` instead of declaring a few prototypes
of these functions in its `blender/utils.h` header (due to C++ functions
names mangling, this was not working anymore).

Pull Request: https://projects.blender.org/blender/blender/pulls/130174
2024-11-12 16:53:54 +01:00
Falk David
783f69343a Cleanup: Remove unused variable 2024-10-16 18:09:33 +02:00
Casey Bianco-Davis
b2cff223a1 Fix: #126515: Brush radius sensitivity not consisted at different zoom levels
The problem was that the screen space size of the brush was not updated.
This was not fully noticeable because the radius control operator was using
a not working scale correction.
The solution remove the scale correction and just update the brush size.

Note: This update currently happens when the cursor is drawn.

Pull Request: https://projects.blender.org/blender/blender/pulls/126773
2024-10-16 12:09:52 +02:00
Falk David
5f5b1b83d0 GPv3: Rename mode enum names and python identifiers
This renames the mode identifiers to be consistent with e.g. the context mode identifiers and other names used for the new Grease Pencil.

For `object.mode`:
* `PAINT_GPENCIL` -> `PAINT_GREASE_PENCIL`
* `SCULPT_GPENCIL` -> `SCULPT_GREASE_PENCIL`
* `VERTEX_GPENCIL` -> `VERTEX_GREASE_PENCIL`
* `WEIGHT_GPENCIL` -> `WEIGHT_GREASE_PENCIL`

For the internal `ob->mode` flag:
* `OB_MODE_PAINT_GPENCIL_LEGACY` -> `OB_MODE_PAINT_GREASE_PENCIL`
* `OB_MODE_SCULPT_GPENCIL_LEGACY` -> `OB_MODE_SCULPT_GREASE_PENCIL`
* `OB_MODE_VERTEX_GPENCIL_LEGACY` -> `OB_MODE_VERTEX_GREASE_PENCIL`
* `OB_MODE_WEIGHT_GPENCIL_LEGACY` -> `OB_MODE_WEIGHT_GREASE_PENCIL`

Resolves #127374.

Pull Request: https://projects.blender.org/blender/blender/pulls/128604
2024-10-04 19:20:00 +02:00
Lukas Tönne
3d6a142162 GPv3: Remove unused GPv2 operators
Removes many of the operators, panels, and menus used exclusively by Grease Pencil v2 that are no longer needed in v3.
No functional changes are expected.

Some operators are still used by the annotations system and have to be kept around. These may be renamed in future.

Pull Request: https://projects.blender.org/blender/blender/pulls/128521
2024-10-04 13:05:09 +02:00
Julian Eisel
622affe853 Fix #126521: Redo popup doesn't refresh layout on changes
98c92b9033 disabled refreshing for the redo popup, since that requires
passing an operator pointer to the UI to holding on to it while the popup is
visible. Usually operators are short lived and shouldn't be held by the UI, to
avoid dangling pointer accesses. In this case it's fine though, because the
operator will be kept alive in the window manager.

Partially reverts 98c92b9033, and adds a comment to note this special case.

Fixes: #126521, #127561

Pull Request: https://projects.blender.org/blender/blender/pulls/127795
2024-09-18 20:50:53 +02:00
Julian Eisel
a8c08e4a8c Refactor: Sculpt/Paint: Rename brush "tool" to "brush type"
The term "tool" is historic from before the actual tool system got
introduced. Since then the term was already a bit confusing, because it
wasn't directly related to the tool system, but there was still some
relationship between the two. Now brushes and their types are decoupled
much more from the tool system, with a single "Brush" tool supporting
all kinds of brushes (draw, grab, cloth, smooth, ...).

For a more clear terminology, use "brush type" instead of "tool".

For #126032 we need to write the brush type to the asset metadata (done
in !124618), so we can filter brushes based on the type (so the grease
pencil eraser tool only shows eraser brushes, for example). I'd like to
use future proof names for that to avoid versioning of asset metadata in
future, so I'd rather do the full naming change now.

RNA properties (thus BPY names) are not changed for compatibility
reasons. Can be done in 5.0, see blender/blender#124201.

Pull Request: https://projects.blender.org/blender/blender/pulls/126796
2024-09-03 15:20:34 +02:00
Bastien Montagne
0ade063f33 Refactor: Move KeyMaps and Operators PointerRNA storage to C++ allocations.
This commit essentially moves allocation of KeyMaps and Operators
PointerRNA data storage to use C++ new/delet, instead of C alloc/free.

Part of the effort to make PointerRNA non-trivial (#122431).

Pull Request: https://projects.blender.org/blender/blender/pulls/126935
2024-08-30 20:44:00 +02:00
Jacques Lucke
5861b078f7 Core: rename ID.flag and ID.tag values
Previously, values for `ID.flag` and `ID.tag` used the prefixes `LIB_` and
`LIB_TAG` respectively. This was somewhat confusing because it's not really
related to libraries in general. This patch changes the prefix to `ID_FLAG_` and
`ID_TAG_`. This makes it more obvious what they correspond to, simplifying code.

Pull Request: https://projects.blender.org/blender/blender/pulls/125811
2024-08-07 12:12:17 +02:00
Philipp Oeser
f53b6b89f8 Fix: Editor related RNA paths incomplete/wrong
The RNA path that is generated for Editor properties were mostly
incomplete (e.g. the viewport overlay settings).
- in python tooltips
- from the `Copy (Full) Data Path` operator
- python methods `path_from_id`, `path_resolve` returned incomplete paths

Since a space (editor) is ultimately owned by the screen, we now add the
missing "areas[x].spaces[x]" subpath to any editor.
Nested structs (like the viewport overlay) also need to include this
subpath.

Some editor related structs are not tied to a single space though (and
these cases are therefor not resolved yet):
- Dopesheet is referenced from SpaceGraph, SpaceAction and SpaceNla
- View3DShading is referenced from SpaceView3D but render engines as
well
- FileSelectParams / FileAssetSelectParams / FileAssetSelectIDFilter
need more investigation

NOTE: in case of the VSE, to make this work this also changes the
overlays to be tied to SpaceSeq (the only editor using them)
NOTE: since the above is now in place, adding VSE overlay props to Quick
favourites is now made possible as well (was a leftover from !116604)

Fixes #124527, #113489

Pull Request: https://projects.blender.org/blender/blender/pulls/125365
2024-08-05 16:54:34 +02:00
Julian Eisel
7fcd4e2429 Fix #123327: Crash when operator with properties opens render window
Essentially, the issue is that the Adjust Last Operation popup is
created in the new image editor window, before region polling was
executed for the new window. This region polling must be done first
because it can affect which regions are visible, and the
`ARegionType.on_poll_success()` callback may do additional set up.

Now make sure that region polling is always executed when a screen is
prepared for display, as part of the screen "refresh" code.

Note that the region polling is used for the asset shelf regions, which
are supported in the image editor since c60a1006e5.

Pull Request: https://projects.blender.org/blender/blender/pulls/123385
2024-07-30 11:17:12 +02:00
Harley Acheson
108b71047a UI: Remove "Widget Label" Text Style
This PR removes the "Widget Label" text style, found in Preferences /
Themes / Text Style. This results in both labels and the text found in
input boxes sharing settings. This results in a slight loss of
customization but it isn't that useful to have these things separate
and results in code complication and errors.

Pull Request: https://projects.blender.org/blender/blender/pulls/122898
2024-07-19 21:57:49 +02:00
Bastien Montagne
faf56cc3bf RNA generated code: Move extern'ed PropertyRNA from pointers to references.
Clang (at least on OSX) has optimization issues with the pointer
version, which seem to be 'fixed' by using references.

Note that using references here is not a bad thing anyway (none of these
pointers would ever be expected to be NULL).

Pull Request: https://projects.blender.org/blender/blender/pulls/124883
2024-07-17 15:19:54 +02:00
Bastien Montagne
c607ead4b7 Refactor: Makesrna: move generated code further in C++.
This commit moves generated `RNA_blender.h`, `RNA_prototype.h` and
`RNA_blender_cpp.h` headers to become C++ header files.

It also removes the now useless `RNA_EXTERN_C` defines, and just
directly use the `extern` keyword. We do not need anymore `extern "C"`
declarations here.

Pull Request: https://projects.blender.org/blender/blender/pulls/124469
2024-07-15 16:39:45 +02:00
Bastien Montagne
e25756cb62 RNA: Fix illegal types mismatch in extern'ed PropertyRNA data.
Previous code would declare properties as `extern PropertyRNA`, but
implement them as type-refined data (e.g. `FloatPropertyRNA`).

This is fully illegal thing, it happened to work 'fine' so far for two
main reasons:
* C-linking does not do type-checks on extern data.
* Code using these publicly exposed data would always use them as
  `PorpertyRNA *` pointers, and pass them to RNA API.

However, this (finally !) breaks when trying to move generated
`RNA_property.h` header to C++, since at least MSVC2022 does mangle the
type in the extern'ed symbol name, which makes linking fails epically.

This commit fixes the issue by only declaring `PointerRNA *` pointers in
the headers. These pointers are then defined in each implementation file
(the `rna_xxx_gen.cc` ones), and assinged to the address of a matching
local static variable. These static variables are type-refined, and
actually contain the property definition data.

Pull Request: https://projects.blender.org/blender/blender/pulls/124603
2024-07-15 11:34:27 +02:00
Campbell Barton
48dbda62a5 Merge branch 'blender-v4.2-release' 2024-07-09 19:49:44 +10:00
Campbell Barton
1cfc83d5f6 UI: add cancel_default option to WindowManager.invoke_props_dialog
Make it possible that the cancel option is default for operator
popups.
2024-07-09 19:26:25 +10:00
Julian Eisel
721dbfccfd UI: Turn asset shelf popup into a popover, add operator to call from shortcut
Turns the asset shelf into a popover which reduces some of the special
handling. An operator `WM_OT_call_asset_shelf_popover()` (similar to
`WM_OT_call_panel()`) is added to be able to call the popover from shortcuts.
Exactly this was an important aspect for the brush assets project, to allow
quick searching for brushes from the popup.

A custom shortcut can be added to asset shelf popovers using "Assign Shortcut"
in the context menu of buttons invoking it.

The popover is spawned with the mouse hovering the first asset and the search
button active using "semi modal" handling. That means while the popover is
open, any text input is captured by the search button, while the rest of the
popover stays interactive. So for example navigating through asset catalogs is
possible, a single click activates an asset and closes the popover.

Reviewed as part of the asset shelf project, see:
- https://projects.blender.org/blender/blender/issues/116337
- https://projects.blender.org/blender/blender/pulls/106303
2024-07-08 17:50:24 +02:00
Campbell Barton
04b7e8fe1d Merge branch 'blender-v4.2-release' 2024-07-06 15:00:40 +10:00
Campbell Barton
850e715682 UI: add UILayout.template_popup_confirm(..) function
This makes it possible for popups to have their confirm & cancel buttons
defined in the operator's draw callback.

When used with popups created by: `WindowManager::invoke_props_dialog()`
to override the default confirm/cancel buttons.

In the case of `WindowManager::popover(..)` & `bpy.ops.wm.call_panel()`
this can be used to add confirm/cancel buttons.

Details:

- When the confirm or cancel text argument is a blank string the button
  isn't shown, making it possible to only show a single button.
- The template is similar to UILayout::operator in that it returns the
  operator properties for the confirm action.
- MS-Windows alternate ordering of Confirm/Cancel is followed.

Needed to resolve #124098.

Ref !124139
2024-07-06 14:49:39 +10:00
Pratik Borhade
439c318098 Fix #98440: Confirm On Release in Radial Control doesn't work with RMB
Cancelling operator with RMB is hardcoded but some wants RMB to invoke
the operation as well. In such case, don't use RMB to cancel operator
and reset the radius, i.e. when both `rc->init_event` and `event->type` is RMB

Pull Request: https://projects.blender.org/blender/blender/pulls/123053
2024-07-03 14:24:02 +02:00
Falk David
c0ff8cf030 Fix #122158: Radial control for radius unit Scene not working correctly
This was due to the fact that the `scale_fac` was not set up correctly for
GPv3.

We now compute the right radius in pixels so we can set up the `scale_fac`.
Note that this removes the logic for GPv2, since it is no longer needed in
Blender 4.3.
2024-06-19 15:31:14 +02:00
Campbell Barton
5f5d851d13 WM: add extra check for Python operator names
Check the "." separator isn't at the beginning/end of the string.
2024-06-01 16:08:53 +10:00
Campbell Barton
8c542ce15f WM: assert operator names are valid when appending
Add WM_operator_bl_idname_is_valid utility function.
2024-06-01 16:08:51 +10:00
Sean Kim
025df21a0f Sculpt: Add Polyline Mask, Face Set, and Trim
This PR adds the *Polyline Mask*, *Polyline Face Set*, and
*Polyline Trim* tools.

## Limitations
* *Polyline Face Set* is not added to either of the *Sculpt*
or *Face Sets* menu as none of the other face set gestures are in
either.

Pull Request: https://projects.blender.org/blender/blender/pulls/122248
2024-05-28 18:33:45 +02:00
Sean Kim
7726e7f563 Sculpt: Add Line Face Set Tool
This PR adds the `Line Face Set` tool and adds it to the following
location:
* Sculpt Mode toolbar

## Limitations
None of the existing Face Set gesture operators exist in either the
Sculpt dropdown or the Face Set dropdown, this PR does not add the Line
Face set tool in either location as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/122245
2024-05-28 17:17:10 +02:00