148 Commits

Author SHA1 Message Date
Brecht Van Lommel
a4e9e4869d Refactor: Add foreach_working_space_color to ID type
Left for future work:
* Freestyle modifiers, dynamic paint, legacy texture mapping
* Editor colors: should be changed to sRGB?
* Studio light preferences: also sRGB, though less clear

Pull Request: https://projects.blender.org/blender/blender/pulls/145476
2025-09-05 19:03:32 +02:00
Campbell Barton
649b89781e Cleanup: ensure UTF8 string copy for DNA & screen data
Use `BLI_strncpy_utf8` & `BLI_snprintf_utf8` for fixed size buffers in
DNA and screen data structures such as panels, menus & operators.

This could be considered a fix as copying a UTF8 string into a smaller
buffer without proper truncation can create an invalid UTF8 sequence.
However identifying which of these users are likely to run into would
be time consuming and not especially useful.
2025-07-26 12:33:15 +00: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
Guillermo Venegas
d600b1002a Refactor: UI: Add uiLayout use_property_split methods
This replaces uiLayout use_property_split API with uiLayout methods,
following uiLayout refactors and the Python API naming.

Pull Request: https://projects.blender.org/blender/blender/pulls/140874
2025-06-23 19:07:09 +02:00
Guillermo Venegas
cc5ba71114 Refactor: UI: Add uiLayout fixed_size, red_alert, root_panel, search_weight and width methods
This replaces API for accessing the uiLayout fixed_size,
red_alert, root_panel, search_weight and width properties
with methods, following uiLayout refactors and the
Python API naming

Pull Request: https://projects.blender.org/blender/blender/pulls/140673
2025-06-23 06:55:01 +02:00
Guillermo Venegas
091db9d52b Cleanup: UI: Use UI_interface_layout.hh instead of UI_interface.hh
This removes the include `UI_interface_layout.hh` from
`UI_interface_c.hh`, and in many places this swaps the include
from `UI_interface.hh` to `UI_interface_layout.hh`.

Also, cleanups some `UI_interface.hh` includes with
`UI_interface_icons.hh` or `UI_interface_types.hh`
2025-06-20 18:07:47 +02:00
Guillermo Venegas
aa1dcddb3d Refactor: UI: Add uiLayout context_store methods
This replaces uiLayout context_store API with uiLayout methods,
following uiLayout refactors, following the Python API naming.

Pull Request: https://projects.blender.org/blender/blender/pulls/140566
2025-06-18 06:32:40 +02:00
Guillermo Venegas
ba55e16532 Refactor: UI: Add uiLayout block get method
This replaces API for obtaining the uiLayout block with a method,
following uiLayout refactors.

Pull Request: https://projects.blender.org/blender/blender/pulls/140549
2025-06-17 19:30:11 +02:00
Guillermo Venegas
b03e64223c Refactor: UI: Add active_default, activated_init, enabled methods
This replaces API for accessing the uiLayout  active_default,
acviated_init, enabled properties with methods, following uiLayout
refactors and the Python API naming.

Pull Request: https://projects.blender.org/blender/blender/pulls/140226
2025-06-16 20:23:28 +02:00
Guillermo Venegas
ff9c883154 Refactor: UI: Add uiLayout active get and set methods
This replaces API for accessing the uiLayout active state
with methods, following uiLayout refactors and the Python
API naming.

Part of #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/139963
2025-06-10 19:12:00 +02:00
Guillermo Venegas
69d2a43b7a Refactor: UI: Add uiLayout scale and ui_units get and set methods
This replaces API for accessing layout scale and ui-units with methods,
following uiLayout refactors and the Python API naming.
Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/139944
2025-06-06 20:17:56 +02:00
Guillermo Venegas
df75f965d0 Refactor: UI: Add uiLayout default operator call context get and set methods
This converts `uiLayoutSetOperatorContext` and
`uiLayoutGetOperatorContext` function APIs to objects methods
following recent `uiLayout` refactors.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/139890
2025-06-06 06:38:09 +02:00
Guillermo Venegas
25873ccf53 Refactor: UI: Replace uiLayoutSetEmboss and uiLayoutGetEmboss with uiLayout methods
This converts `uiLayoutSetEmboss` and `uiLayoutGetEmboss` function APIs
to objects methods following recent `uiLayout` refactors.
Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/139811
2025-06-05 06:00:02 +02:00
Guillermo Venegas
44160a0524 Refactor: UI: Replace uiItemFullO with class method uiLayout::op
This converts the public `uiItemFullO` function to an object oriented
API (an `uiLayout::op` overload), matching recents changes in the API.

Changes includes the removal of the paramether `IDProperty *properties`
that seems unused (all places just sets `nullptr`, can be added as last
argument with `nullptr` as default value though), and instead of using a
return paramether the function now returns the pointer to write properties.

Pull Request: https://projects.blender.org/blender/blender/pulls/138961
2025-05-20 15:19:34 +02: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
a017a6cc54 Refactor: UI: Replace uiItemO with class method uiLayout::op
This converts the public `uiItemO` function to an object oriented
API (`uiLayout::op`).
Also this rearranges `idname` paramether, since this the only one
required, and to make format similar to `uiItemFullO`

Note: One of the benefits of moving from a public function to class
method is to reduce API usage difference between C++ and Python. In
Python this method is called `UILayout::operator`, however `operator`
is a reserved keyword in C++.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138776
2025-05-12 22:14:38 +02:00
Guillermo Venegas
858abf43c3 Refactor: UI: Replace uiItemFullR with class method uiLayout::prop
This converts the public `uiItemFullR` function to an object oriented
API (an overload of `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/138683
2025-05-10 03:39:31 +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
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
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
f0f0361254 Refactor: UI: Replace uiLayoutRowWithHeading with class method uiLayout::row
This converts the public `uiLayoutRowWithHeading` function to an object oriented
API (an `uiLayout::row` overloaded version), 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.

Same as the original `uiLayout::row`, this overloaded version also 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/138014
2025-04-26 02:17:31 +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
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
Bastien Montagne
83a2e34654 Cleanup: shader_fx & simulation: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.

This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.

MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.

NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.

Pull Request: https://projects.blender.org/blender/blender/pulls/135744
2025-03-10 16:39:38 +01:00
Brecht Van Lommel
4786fbe774 Refactor: Remove extern "C" from most headers
The only remaining code in source/blender that must be compiled as C
is now datatoc generated code and the DNA defaults that use designated
initializers.

Pull Request: https://projects.blender.org/blender/blender/pulls/134469
2025-02-13 18:58: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
3bbafc5a9a Cleanup: Various clang-tidy warnings in shader_fx
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:18 +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
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
Ray Molenkamp
5783950ac5 Revert: 0dc484f9cc bf_rna modernisation
This caused build errors on the docs builder, I can't seem to reproduce
locally, so revert for now and have another look at some point in the
future.

Sadly as these changes usually go, this took 5c515e26bb and
2f0fc7fc9f with it as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/132559
2025-01-02 19:56:24 +01:00
Campbell Barton
5c515e26bb Cleanup: remove trailing space, ensure a newline at EOF 2025-01-02 15:11:18 +11:00
Ray Molenkamp
0dc484f9cc Cleanup: CMake: Modernize bf_rna dependencies
Pretty straightforward

- Remove any bf_rna paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132413
2024-12-31 18:23:25 +01:00
Ray Molenkamp
16eb4430f5 Cleanup: CMake: Modernize bf_render dependencies
Pretty straightforward

- Remove any bf_render paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132355
2024-12-26 18:50:53 +01:00
Ray Molenkamp
c331c6b50e Cleanup: CMake: Modernize bf_blentranslation dependencies
Pretty straightforward

- Remove any bf_blentranslation paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132311
2024-12-25 17:40:25 +01:00
Ray Molenkamp
54604efdfd Cleanup: CMake: Modernize bf_windowmanager dependencies
Pretty straightforward

- Remove any bf_windowmanager paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132310
2024-12-24 22:40:38 +01:00
Ray Molenkamp
a7c39896c6 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any bf_blenkernel paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132282
2024-12-23 20:08:37 +01:00
Ray Molenkamp
2992c63bc3 Cleanup: CMake: Modernize bf_bmesh dependencies
Pretty straightforward

- Remove any bf_bmesh paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132203
2024-12-23 17:47:25 +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
Hans Goudey
953c4f1599 Cleanup: Remove references to legacy Grease Pencil object
These are converted on startup to the new type. There are still
some references left, mostly where it looked like there still needs
to be changes to properly deal with the new object type.
2024-11-27 09:17:16 -05:00
Campbell Barton
0f3fdd25bc Cleanup: various non-functional changes for C++
- Remove redundant parenthesis
- Use strings macros
- NULL -> nullptr
2024-10-02 15:47:05 +10: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
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
Campbell Barton
08b3db500f Cleanup: correct asserts
Also remove redundant assert.
2024-04-25 12:02:14 +10:00
Falk David
cf59d2a385 GPv3: Expose Shader FX in the UI
Enables GPv3 in the UI poll functions for shader FX.
2024-04-22 18:26:00 +02: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
Bastien Montagne
45e7827898 Clenup: Move BLT headers to Cpp.
Noisy but fairly straight forward.
2024-02-09 18:59:42 +01:00
Bastien Montagne
03c1cc4310 Cleanup: Move BKE_lib_query header to Cpp era. 2024-01-18 12:21:19 +01:00
Damien Picard
3bd41cf9bc I18n: Go over TIP_ and IFACE_ usages, change to RPT_ when relevant
The previous commit introduced a new `RPT_()` macro to translate
strings which are not tooltips or regular interface elements, but
longer reports or statuses.

This commit uses the new macro to translate many strings all over the
UI.

Most of it is a simple replace from `TIP_()` or `IFACE_()` to
`RPT_()`, but there are some additional changes:
- A few translations inside `BKE_report()` are removed altogether
  because they are already handled by the translation system.
- Messages inside `UI_but_disable()` are no longer translated
  manually, but they are handled by a new regex in the translation
  system.

Pull Request: https://projects.blender.org/blender/blender/pulls/116804

Pull Request: https://projects.blender.org/blender/blender/pulls/116804
2024-01-12 13:37:32 +01:00
Ray Molenkamp
6b70c04724 Cleanup: CMake: Modernize bf_depsgraph dependencies
Pretty straightforward

- Remove any bf_depsgraph paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115422
2023-11-25 22:51:59 +01:00