Commit Graph

69 Commits

Author SHA1 Message Date
Guillermo Venegas
ad50ee6bf6 Refactor: UI: Make layout estimate functions as virtual methods
Following the uiLayout refactor, this converts each layout estimate
function as virtuals methods, so w_ and y_ properties can become
protected. This includes missing structs for each layout type in
`uiItemType`, but without the `ui` prefix (they eventually will be
moved to the to the `blender::ui` namespace instead)

Pull Request: https://projects.blender.org/blender/blender/pulls/146049
2025-09-12 03:40:17 +02:00
Guillermo Venegas
6f85f3be2e Cleanup: UI: Make some uiLayout members private
This makes child_items_layout_, scale_, align, active_,
active_default_, activate_init_, enabled_, redalert_,
variable_size_, alignment_, emboss_, units_ & search_weight_
private members as follow up from recent UI refactors.

Pull Request: https://projects.blender.org/blender/blender/pulls/145844
2025-09-07 00:26:22 +02:00
Guillermo Venegas
7959156876 Cleanup: UI: Make some uiLayout members private
Make root_, context_ , parent_  ,items_ and heading_ uiLayout into
private members. Follow up from recent UI refactors.
Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/145698
2025-09-05 16:46:42 +02:00
Guillermo Venegas
ead9643fe4 Cleanup: UI: Remove uiItem::flag_ public access
Follow up from recent UI refactors.
Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/143724
2025-08-15 21:50:39 +02:00
Guillermo Venegas
0cc1c212a8 Cleanup: UI: Remove public access to uiItem::type_
Follow up from recent UI refactors.
Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/143324
2025-07-30 07:17:00 +02:00
Guillermo Venegas
52403b686f UI: Move block layout methods to namespace
Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/143232
2025-07-25 19:33:15 +02:00
Hans Goudey
63a3499674 Cleanup: Use StringRef, std::string for node panel toggles
Just a slight simplification of this code to make a null
check unnecessary and avoid using char arrays.

Pull Request: https://projects.blender.org/blender/blender/pulls/141939
2025-07-16 20:22:55 +02:00
Julian Eisel
c2497d16e3 Cleanup: Remove redundant parameter in new UI layout function
Mistake in 2658754324.

This was changed from a free standing to a member function during review. But
forgot to update the parameters accordingly. This can be confusing since you
can call the function on one layout, but pass it another one that it will
actually operate on.
2025-07-16 17:10:11 +02:00
Jacques Lucke
9e1168bdfb Fix: add missing include 2025-07-16 13:13:44 +02:00
Julian Eisel
2658754324 UI: New internal API function to add a simple button
For blender/blender!141292, we need a simple icon and text button that
executes a callback on click. The size should be determined based on the
text and icon, as it's typically done with the `UI_interface_layout.hh`
API. Trying to do this with `uiDefIconTextBut()` is annoyingly
complicated, mostly because we'd have to duplicate size calculations.

Instead expand the `UI_interface_layout.hh` API to cover this.

* Allow passing a button type to `uiItemL_()` and rename it to
  `uiItem_simple()`. The code in this function is commonly useful, not
  just for label buttons. It's a convenient way to add a single button
  with normal size calculations. The function stays internal to
  `interface_layout.cc`.
* Add `uiItemBut()` as public API function to call this and assign an
  on-click callback.

No user visible changes expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/141900
2025-07-16 13:10:22 +02:00
Jacques Lucke
fc05a70dcd UI: support fully custom layout tooltips
The goal is to be able to build fully custom tooltips for entire layouts (e.g.
for all `uiBut` for a socket). We already support tooltip callbacks for layouts
and fully custom tooltips for `uiBut`, however not fully custom tooltips for an
entire layout.

This will be used by #140540.

The main noteworthy thing here is that now `uiBut` is passed into the custom
tooltip function. This is necessary when the tooltip still has to be customized
for the exact hovered `uiBut`. For example, we generate a tooltip that applies
to an entire vector socket, but when hovering over e.g. the X input value, the
Python tooltip should show the path for that specific property.

This also fixes a bug in `ui_but_is_interactive_ex` which didn't consider custom
and quick tooltips before.

`uiLayoutSetTooltipCustomFunc` is pretty much the same as its non-custom
counterpart.

Pull Request: https://projects.blender.org/blender/blender/pulls/142044
2025-07-16 13:09:29 +02: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
c97195cd63 Refactor: UI: Replace uiItemMenuEnumFullO* with class methods
This converts the public uiItemMenuEnumFullO* functions to an
object-oriented API (as uiLayout::op_menu_enum overloads),
matching recent changes in the API.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/141797
2025-07-11 19:52:58 +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
Guillermo Venegas
f22ea2e0ae Refactor: UI: Remove uiItemEnumO* functions
Similar to other removed UI layout functions, this removes uiItemEnumO*
functions and replaces them by calling `uiLayout::op` and writing enum
properties to the returned RNA pointer.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/141632
2025-07-10 07:57:21 +02:00
Guillermo Venegas
5cc4b4322a Refactor: UI: Move UI_block_layout_resolve to C++ namespace, rename
This renames UI_block_layout API as blender::ui::block_layout_resolve,
following uiLayout refactors.

This simplifies usage by returning block layout size as C++ int2 instead
of using return parameters, in fact some places were providing
unused variables.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/141432
2025-07-08 21:16:57 +02:00
Guillermo Venegas
b36e5b4b06 Refactor: UI: Replace UI_block_layout with blender::ui::block_layout
This renames `UI_block_layout` API as `blender::ui::block_layout`,
following uiLayout refactors.
This function now returns a layout reference instead of pointer,
this changes applies this return type where the layout can be used
as such reference.

Changes includes the use of `blender::ui::LayoutDirection` and
`blender::ui::LayoutType` as typed enum parameters.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/141401
2025-07-03 22:00:46 +02:00
Guillermo Venegas
d00a0f29b4 UI: Make uiLayout NonCopyable and NonMovable
Almost all uiLayout methods that creates sub-layouts returns a uiLayout
reference, API users must use the returned sub-layout to add items,
this prevents a accidental copy that could break Blender.

Pull Request: https://projects.blender.org/blender/blender/pulls/141051
2025-07-02 18:31:04 +02:00
Guillermo Venegas
a0f9e25682 Refector: UI: Add uiLayout decorator, menu_contents and progress_indicator methods
This replaces uiItemMContents, uiItemDecoratorR* and
uiItemProgressIndicator API with uiLayout methods following
uiLayout refactors and the Python API.

`eButProgressType` is changed to a typed enum class
`blender::ui::ButProgressType`

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/141189
2025-07-02 10:06:48 +02:00
Guillermo Venegas
86d6855ee8 Refactor: UI: Add uiLayout op_menu_hold, popover and separator_spacer
This replaces `uiItemFullOMenuHold_ptr`, `uiItemFullR_with_popover`,
`uiItemFullR_with_menu`, `uiItemPopoverPanel`* and `uiItemSpacer` API
with methods following uiLayout refactors and the Python API.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/141050
2025-06-26 21:48:52 +02:00
Guillermo Venegas
e460ae24cb Refactor: UI: Replace uiItemEnumR* funtions with uiLayout methods
This converts the public functions to add enum specific property buttons
with uiLayout methods matching the python API.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/140941
2025-06-25 22:03:31 +02:00
Julian Eisel
69eab999e0 Refactor: UI: Warn when not using result from UI layout getter functions
These functions were refactored recently, e.g. see e300d44e69. In some cases
it's less clear now which functions are getters and which are setters. Case in
point, I first thought `layout.use_property_split()` would enable property
split (that's what the name suggests). Previous names like
`uiLayoutGetPropDecorate()` and `uiLayoutSetPropDecorate()` were more clear.

By using the `[[nodiscard]]` attribute for getters, the compiler will emit
warnings when using such functions like a setter, without using the returned
value.
2025-06-25 16:45:36 +02:00
Hans Goudey
8c71719dfd Refactor: UI: Use std::string for uiLayout heading string
Changes the size of uiLayout from 408 to 184 bytes.
2025-06-24 15:09:21 -04:00
Guillermo Venegas
2e5138fed8 Refactor: UI: Replace uiItemPointerR with uiLayout::prop_search
This converts the public uiItemPointerR and uiItemPointerR_prop
functions to an object-oriented API (uiLayout::prop_search overloads),
matching the python API.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/140930
2025-06-24 20:47:54 +02:00
Guillermo Venegas
e300d44e69 Refactor: UI: Add uiLayout use_property_decorate methods
This replaces uiLayout use_property_decorate API with uiLayout
methods, following uiLayout refactors and the Python API naming.

Pull Request: https://projects.blender.org/blender/blender/pulls/140887
2025-06-24 03:52:17 +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
ff9b80cc81 Cleanup: UI: Remove unused uiLayout::keepaspect_ property
Python API was removed since a78ef19054

Pull Request: https://projects.blender.org/blender/blender/pulls/140675
2025-06-19 18:39:51 +02:00
Guillermo Venegas
96dee123d1 Refactor: UI: Add uiLayout aligment methods
This replaces uiLayout aligment API with uiLayout methods,
following uiLayout refactors and the Python API naming.

Also this converts the layout aligment enum to a fixed enum class.

Pull Request: https://projects.blender.org/blender/blender/pulls/140622
2025-06-19 02:57:37 +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
390254c05f Refactor: UI: Remove uiItemStringO API
This function has no Python equivalent. Using the
returned pointer to write properties is enough, and
is equivalent to how it is done in Python.

Pull Request: https://projects.blender.org/blender/blender/pulls/139448
2025-05-28 14:38:54 +02:00
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
99e9b2522b Refactor: UI: Remove uiItemBooleanO API
This function has not python equivalent, using the
returned pointer to write properties seems enough,
equivalent to how it is done in Python.

Pull Request: https://projects.blender.org/blender/blender/pulls/139295
2025-05-23 01:07:12 +02:00
Hans Goudey
cb77f6fd14 Cleanup: UI: Remove unused arguments for operator buttons 2025-05-22 16:26:46 -04: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
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
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
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
351fbff95b Refactor: UI: Replace uiItemM_ptr and uiItemM with uiLayout::menu
This converts the public `uiItemM_ptr` and `uiItemM` functions
to an object oriented API (an `uiLayout::menu` overloads),
matching the python API.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138895
2025-05-14 23:22:56 +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