Commit Graph

111 Commits

Author SHA1 Message Date
Guillermo Venegas
eed8e10b91 Refactor: UI: Remove uiItemIntO API
This function has not python equivalent, using the
returned pointer to write properties seems enough
as equivalent as how is done in python.

Also, this removes the unused `uiItemFloatO` API.

Pull Request: https://projects.blender.org/blender/blender/pulls/139355
2025-05-24 16:15:51 +02:00
Guillermo Venegas
b3eb84f624 Refactor: UI: Remove uiLayout::op id properties parameter
This was an alternative way to write properties for layout operator buttons,
for the most cases are more than enough to use the returned pointer.

There were just 2 cases where this was useful, the quick access menu
that reuses operator property values, this now overrides the id property group
data pointer generated for the operator, also for `uiItemsFullEnumO_items`.

Pull Request: https://projects.blender.org/blender/blender/pulls/139242
2025-05-22 20:19:18 +02:00
Guillermo Venegas
5b82ee11df Refactor: UI: Replace uiItemFullO_ptr with class method uiLayout::op
This converts the public `uiItemFullO_ptr` function to an object
oriented API (an `uiLayout::op` overload), matching recents changes
in the API.

Changes include rearranging the `IDProperty *properties` parameter to be
the last parameter. Now is optional (but will be removed), also instead
of using a return parameter the function now returns the pointer to
write properties.

Pull Request: https://projects.blender.org/blender/blender/pulls/139166
2025-05-21 02:55:04 +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
Guillermo Venegas
89a3478e35 Refactor: UI: Replace uiItemMenuF and uiItemMenuFN with uiLayout methods
This converts the public `uiItemMenuF` and `uiItemMenuFN`
functions to an object oriented API (an `uiLayout::menu_fn`
and `uiLayout::menu_fn_argN_free` respectively), following
recent uiLayout changes.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138902
2025-05-15 21:26:49 +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
Guillermo Venegas
dafdced6ab Refactor: UI: Replace uiItemR with class method uiLayout::prop
This converts the public `uiItemR` function to an object oriented
API (`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/138617
2025-05-08 20:45:37 +02:00
Philipp Oeser
8409a5081b Fix #137998: Crash calling editmode_toggle overriding view_layer.objects.active
If the viewlayer active object was set to None, editmode toggle poll
would still be permissive (it checked `CTX_data_active_object`, exec was
checking `BKE_view_layer_active_object_get`...)

These two need to be in sync.

For this PR, just go with `BKE_view_layer_active_object_get`...

NOTE: other mode switching operators seem to have the same "problem".
Pull Request: https://projects.blender.org/blender/blender/pulls/138083
2025-04-30 15:54:27 +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
Guillermo Venegas
90644b30b2 Refactor: UI: Replace uiLayoutRow with class method uiLayout::row
This converts the public `uiLayoutRow` function to an object oriented
API (`uiLayout::row`), 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::row` now returns an `uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/137979
2025-04-25 19:45:25 +02:00
Campbell Barton
8ccdea1934 Cleanup: typos & references to variable names from recent refactor 2025-04-24 02:43:52 +00:00
Campbell Barton
85913eb58a Fix #137380: Exiting edit-mode while transforming crashes
Python scripts could call operators to change the objects mode while
transforming. Report an error instead of crashing.
2025-04-24 12:28:49 +10:00
Campbell Barton
d6825c863f Cleanup: remove redundant PropertyFlag casts which can hide errors 2025-04-11 12:02:07 +10:00
Eitan Traurig
a952f5dda6 UI: Rename "Hide Collection" operator to "Hide Other Collections"
The current naming of the Hide Collection operator is counterintuitive.
Hide collection implies that it hides the selected collection, but it hides
all the collections that are not selected.

Pull Request: https://projects.blender.org/blender/blender/pulls/129682
2025-04-04 10:56:27 +02: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
Campbell Barton
5b856ba447 Merge branch 'blender-v4.4-release' 2025-03-06 10:35:59 +11:00
Campbell Barton
b85fc32cae Cleanup: spelling & repeated words in comments
Address warnings from check_spelling.py
2025-03-06 10:33:21 +11:00
Dalai Felinto
1584cd9aa5 Cleanup: Rename point cloud to pointcloud / POINT_CLOUD to POINTCLOUD
Though "Point Cloud" written as two words is technically correct and should be used in the UI, as one word it's typically easier to write and parse when reading. We had a mix of both before this patch, so better to unify this as well.

This commit also renames the editor/intern/ files to remove pointcloud_ prefix.
point_cloud was only preserved on the user facing strings:

* is_type_point_cloud
* use_new_point_cloud_type

Pull Request: https://projects.blender.org/blender/blender/pulls/134803
2025-02-19 17:11:08 +01:00
Campbell Barton
640e70b6e8 Cleanup: various non-functional changes for C++ 2025-02-13 13:33:09 +11: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
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
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
Jacques Lucke
9e8b3e035a Fix #133633: crash because of edited Smooth by Angle node group
This adds a shallow check to see if the node group has been changed. If it has
been changed, the weak library reference is removed so that the node group will
be loaded from the source file again. This should become unnecessary once we
have asset embedding.

There are probably still ways to make Blender behave unexpectedly when editing
the Smooth by Angle node group, but this should already cover common edits. More
precise checks could be added as necessary.

Pull Request: https://projects.blender.org/blender/blender/pulls/133654
2025-01-27 15:31:22 +01:00
Christoph Lendenfeld
e4f34453e3 Refactor: pass Vector instead of ListBase to motion path functions
This changes the `ListBase` argument for certain motion path functions
to `Vector<MPathTarget *>`. (and `Span`)

To better describe what the function is doing,
`animviz_get_object_motionpaths` has been renamed
to `animviz_build_motionpath_targets`.

Since `BLI_freelistN` can no longer be used, I added
`animviz_free_motionpath_targets`.

Note that the Vector is of `MPathTarget *` which
are allocated the C way. Because the `MPathTarget` struct is defined
in the .cc file, that's the only way for it to work atm.
Other refactors may mitigate that in the future, but I wanted to keep
the scope small.

Pull Request: https://projects.blender.org/blender/blender/pulls/133212
2025-01-24 12:43:20 +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
YimingWu
1bacb0de62 Fix #132987: Grease Pencil: Ensure selection domain when switching modes
Grease Pencil tool settings could have different selection modes for
different object modes (like edit mode and sculpt mode). This fix
ensures when switching object modes, the selection domain is updated to
match the selection mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/133030
2025-01-14 16:46:23 +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
Gilberto.R
8ceaaafde8 UI: Use consistent naming for mode toggle on undo history
Change name of OBJECT_OT_editmode_toggle to "Edit Mode" and name of
PAINT_OT_texture_paint_toggle to "Texture Paint Mode" to display in a
more consistent manner in Undo History.

Pull Request: https://projects.blender.org/blender/blender/pulls/112703
2024-12-11 21:29:43 +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
Harley Acheson
7c81ec922c UI: Calm Warning in #130617 About Variable Mismatch
Fix compiler warning about variable mismatch (int versus uint) in
commit bc5fcbe1c3.

Pull Request: https://projects.blender.org/blender/blender/pulls/130633
2024-11-20 22:58:43 +01:00
Harley Acheson
bc5fcbe1c3 UI: Notification When Hiding Objects
This shows a "2 object(s) hidden" notification on the status bar when
hiding objects, the same as we do when deleting objects.  Pressing "H"
can be done accidentally so this is at least some indication of what
happened, both on the status bar in Info Editor. Obviously does nothing
if nothing is selected when you press "H"

Pull Request: https://projects.blender.org/blender/blender/pulls/130617
2024-11-20 20:10:51 +01:00
Bastien Montagne
b325142d17 Merge branch 'blender-v4.3-release' 2024-11-12 16:55:40 +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
Hans Goudey
a804320138 Cleanup: Remove unused grease pencil legacy handling in some operators
See #123468.
2024-11-02 23:14:41 +01:00
Hans Goudey
d832bf3ae4 Fix #122096: Crash after editing multi-user mesh with two scenes
In this case there are two dependency graphs, each with a separate
object containing the original mesh. Leaving edit mode modifies the
original mesh by deleting the edit mesh data. The active dependency
graph's object was tagged for that change, but the other dependency
graph didn't know about the change because its object wasn't tagged.
The solution is to tag the original mesh which will cause any
dependency graph using it to properly reevaluate.

Pull Request: https://projects.blender.org/blender/blender/pulls/128192
2024-09-27 04:29:53 +02:00
Pratik Borhade
912c6d9a3c Fix #127620: Disable smooth operator for linked objects
Shade flat/smooth operators are callable when linked but greyed out if
objects are overridden. Disable these operators in UI for linked objects.

Pull Request: https://projects.blender.org/blender/blender/pulls/127681
2024-09-19 12:53:22 +02:00
YimingWu
11bf2b9a62 Fix #127539: Prevent multi-object editing in GPv3
Multi-object editing is not supported in GPv3 right now,
do not allow multiple GPv3 objects to go into edit mode
at the same time.

Pull Request: https://projects.blender.org/blender/blender/pulls/127796
2024-09-19 11:22:15 +02:00
Bastien Montagne
9506fed905 Refactor: Move some Editors' data allocation from C alloc/free to C++ new/delete.
Part of the effort to make PointerRNA non-trivial (#122431).
2024-08-29 14:20:37 +02:00
Andrej730
74c796e057 UI: Add property description for show hidden objects operator
Clarify `selection` property with description.

Pull Request: https://projects.blender.org/blender/blender/pulls/126221
2024-08-12 13:32:01 +02:00
Harley Acheson
9a26bfcd5f Fix: Shade Smooth Removal Notification When Needed
Only send `NC_OBJECT | ND_DRAW` notification if the smooth by angle
modifier has been removed, not on all changes. This is a slight
adjustment to #124330.

Pull Request: https://projects.blender.org/blender/blender/pulls/124362
2024-07-08 21:35:26 +02:00
Pratik Borhade
e8f0dabc7e Fix #124302: Crash when clicking arrow button in outliner
This is due to missing rebuild of outliner tree. Auto smooth operator
is cleared with shade flat execution but outliner is unaware of this and
the modifier tree element remains intact. This add a notifier.

Pull Request: https://projects.blender.org/blender/blender/pulls/124330
2024-07-08 18:42:06 +02:00
Campbell Barton
61e4d1818e Cleanup: follow operator callback & argument naming 2024-05-24 14:08:33 +10:00
Brecht Van Lommel
a926f5b67d Refactor: Replace ID_IS_LINKED by !ID_IS_EDITABLE
Add new ID_IS_EDITABLE macro that checks if the ID can be edited in the
user interface. Replace usage of ID_IS_LINKED where it is used with this
meaning.

Also add a corresponding ID.is_editable property for Python.

This prepares for the ability to edit some linked datablocks for brush
assets.

Pull Request: https://projects.blender.org/blender/blender/pulls/121838
2024-05-16 14:53:09 +02:00
Jacques Lucke
2f289857af Object: add Shade Auto Smooth operator
Based on the design in #120230.
* Replaces the `Shade Smooth by Angle` operator with `Shade Auto Smooth`
  in the object context menu menu.
* The new operator automatically adds and removes the modifier instead
  of being a destructive operation.
* The `Shade Smooth` and `Shade Flat` operators now remove the
  `Smooth by Angle` modifier automatically.
* Add a pin option to modifiers, which limits dragging and keeps the
  modifier after newly added modifiers in the list.

Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/121494
2024-05-08 20:24:10 +02:00
Hans Goudey
d95b1f120b Mesh: Store BMEditMesh in shared pointer
The main motivation for this is that it's part of a fix for #113377,
where I want to propagate the edit mesh pointers through copied
meshes in modifiers and geometry nodes, instead of just setting the
edit mesh pointer at the end of the modifier stack. That would have
two main benefits:
1. We avoid the need to write to the evaluated mesh, after evaluation
  which means it can be shared directly among evaluated objects.
2. When an object's mesh is completely replaced by the mesh from another
   object during evaluation (with the object info node), the final edit
   mesh pointer will not be "wrong", allowing us to skip index-mapped
   GPU data extraction.

Beyond that, using a shared pointer just makes things more automatic.
Handling of edit mesh data is already complicated enough, this way some
of the worry and complexity can be handled by RAII.

One thing to keep in mind is that the edit mesh's BMesh is still freed
manually with `EDBM_mesh_free_data` when leaving edit mode. I figured
that was a more conservative approach for now. Maybe eventually that
could be handled automatically with RAII too.

Pull Request: https://projects.blender.org/blender/blender/pulls/120276
2024-04-18 13:52:20 +02:00
Hans Goudey
c91449836a Cleanup: Move BKE_workspace.h to C++ 2024-04-12 17:03:18 -04:00
Hans Goudey
c28db1f0a0 Cleanup: Use C++ namespace for object editors module
Move the public functions from the editors/object (`ED_object.hh`)
header to the `blender::ed::object` namespace, and move all of the
implementation files to the namespace too. This provides better code
completion, makes it easier to use other C++ code, removes unnecessary
redundancy and verbosity from local uses of public functions, and more
cleanly separates different modules.

See the diff in `ED_object.hh` for the main renaming changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/119947
2024-03-28 01:30:38 +01:00
Hans Goudey
b8b745ae1e Cleanup: Move remaining editors internal headers to C++ 2024-03-27 02:45:27 +01:00
Hans Goudey
acd1b0b7f9 Refactor: Use C++ Vector for RNA/context collection retrieval
Previously retrieving a collection from the context like "selected_ids"
would give a linked list of allocated items. Now it returns a vector of
RNA pointers. Though the number of items is typically fairly small,
using contiguous memory and avoiding many small allocations are
typical performance improvements that could still be beneficial
when there are many items. Iteration also becomes much simpler.

Pull Request: https://projects.blender.org/blender/blender/pulls/119939
2024-03-27 00:47:39 +01:00
Hans Goudey
c72d6100ba Cleanup: Remove unrelated change added in previous commit
WIP change unrelated to anything else. Sorry for the noise!
2024-03-26 16:00:00 -04:00