While valid, this isn't so common and cppcheck warns about this,
use explicit casts to suppress the warning, also correct "true"
being assigned to a float value.
Instead of only referencing an existing one. This will be used for
collection exporter and presets, to make sure the operator instance
stays alive long enough for the preset to be able to be applied.
Pull Request: https://projects.blender.org/blender/blender/pulls/120034
There are still a few places that are more complicated where the replacement
to `IDP_New` isn't obvious, but this commit replaces most uses of the ugly
`IDPropertyTemplate` usage.
Enables operators that uses `WM_operator_props_dialog_popup`
or `redo` popup to use layout panels.
Other popups would likely also support layout panels, only
they need to set its dummy panel with `UI_popup_dummy_panel_set`.
Popups don't normally use `Panel`, but that's the type that stores the
layout panel states. Therefore, to use layout panels in a popup, one
currently needs to create a dummy panel whose purpose is to store the
layout panel states for as long as the popup is open.
Alternatively, we could potentially also store the layout panel states
somewhere else in the future for popups, but that might be a more involved
change for now.
See #119519 for an example script that uses layout panels in a popup.
Pull Request: https://projects.blender.org/blender/blender/pulls/119519
"Own" (the adjective) cannot be used on its own. It should be combined
with something like "its own", "our own", "her own", or "the object's own".
It also isn't used separately to mean something like "separate".
Also, "its own" is correct instead of "it's own" which is a misues of the verb.
Over the last couple years (!) UI buttons have moved to derived classes,
meaning we don't need to use the same "a1" and "a2" variables to store
different information. At this point, that information is set specifically
by internal UI code, or functions like `UI_but_*_set`.
These values are only set to their default 0 values now (or -1 in some
non-meaningful cases). This commit removes the values from buttons
and removes the remaining a1 and a2 arguments from the UI API.
Previously these used a special "menu func" that used an argument value
passed through each menu button's a2 value. This was more complex than
necessary given the existence of generic button callbacks.
So use std::function in these remaining cases, and remove the now-unused
`butm_func` and `butm_func_arg` values in the uiBlock.
The line separator needs to know vertical or horizontal orientation
at draw time, and is independent of button rect. This PR removes the
use of uiBut->a1 for this in favor of a derived struct.
Pull Request: https://projects.blender.org/blender/blender/pulls/118969
Remove uses for `uiDefButS`. -1 was passed as a2 still in a few
places, but that was most likely just because of copy & paste,
it doesn't look like that's actually used anywhere.
I added a new BLO_userdef_default.h header to contain declarations of
two global variables that are still defined in C files. Use of designated
initializers for large structs make those files harder to change.
Arguably this is a better header for them anyway.
Pull Request: https://projects.blender.org/blender/blender/pulls/118015
RNA pointers should always have valid owner IDs. And most structs
using STRUCT_UNDO do not need it because the owner is a UI datablock
which already determines if undo is needed.
With this change, it is possible to have structs used both in UI and scene
datablocks and have undo work depending on the owner. This is needed for
collections storing operator properties for export (#116646).
Pull Request: https://projects.blender.org/blender/blender/pulls/117640
The main simplification is using return values rather than return
arguments, and the additional semantic clarity from std::optional.
Also use `fmt` for formatting and use lambdas instead of macros
as helpers in a few modal keymap formatting functions.
Similar commits:
- a1792e98a4
- f04bc75f8c
- 6abf43cef5
- 7ca4dcac5a
Pull Request: https://projects.blender.org/blender/blender/pulls/117785
The benefits are O(1) access to the string size, clearer ownership,
and easily accessible utility functions. For now, only change functions
where the string is clearly non-null. It's not clear in what cases some
other functions recieve null strings.
As discussed in the UI Module Meeting we don't have an acceptable use
case for dialogs that use the Blender logo. Removing this image from
the project since this is now exposed through dialog customization.
Pull Request: https://projects.blender.org/blender/blender/pulls/117676
When a string shouldn't be used or is invalid, use std::nullopt to
make it clear it's value shouldn't be used.
Without this it's possible to accidentally use an empty string
which will silently fail.
For some reason the "get" function actually allocates the button's
operator properties container. This may or may not make sense to
do, but while it happens, the function name might as well make
that clear.
Caused by 089c389b5c. Previously the draw string was created
by appending text inside the buffer multiple times. Now it's formatted
in one step. Part of that change was missing for factor display.