Add an item to the context menu when right-clicking on an item in the
"Open Recent" file list for "Open File Location" that opens that
location in an OS Explorer/Finder window.
Pull Request: https://projects.blender.org/blender/blender/pulls/119988
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.
Use the Graph Editor icon for the "View in Graph Editor" operators,
to make a connection with the entry in the list of editors and the
View menu in the Dope Sheet.
Only use icon on the first item of the section, according to the HIG.
Regression in 427eed292d.
Root of the issue was that animation system was using a single same
check to decide if an F-Curve/driver was valid to use to animate some
data, and whether user can create/edit animation for that data.
Both cases are actually different, since e.g. linked data is not
user-editable, but it can still be animated (either by related linked
Actions, drivers defined in the linked data, or some more hackish
changes like py API/RNA scripting).
This commit now defines two checks:
* `RNA_property_animateable`: whether a RNA pointer & propoerty is
animateable, based on their types and definition.
* `RNA_property_anim_editable`: whether a specific data referenced by
the RNA pointer and property is effectively user-editable.
The new `driveable` check added by 427eed292d is also renamed to
`RNA_property_driver_editable` (since the basic type-based
`RNA_property_animateable` is also valid for drivers currently).
Pull Request: https://projects.blender.org/blender/blender/pulls/119089
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.
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
This significantly simplifies memory management, mostly by avoiding
the need to free the memory manually. It may also improve performance,
since std::string has an inline buffer that can prevent heap
allocations and it stores the size.
Pull Request: https://projects.blender.org/blender/blender/pulls/117695
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.
Instead of a single function with variadic arguments, a special enum
type containing which string to request, and a special struct to
contain the request and the result, just use separate functions for
each request, and return a std::string by value. Also change the enum
item string access to just give access to the enum item itself and add
const in a few places as necessary.
The callers of the API function get much clearer this way, and it's
much easier to see which information is used to create certain tooltip
strings.
While the shortcuts would be shown for menus & panels,
there was no way to edit them from the context menu.
This was reported as a bug since moving "Undo History" from an operator
to a menu meant it was no longer possible to assign a shortcut from
the context menu.
Resolves: #97431.
Along with the 4.1 libraries upgrade, we are bumping the clang-format
version from 8-12 to 17. This affects quite a few files.
If not already the case, you may consider pointing your IDE to the
clang-format binary bundled with the Blender precompiled libraries.
In the property context menu, the operator to View in Graph Editor can
apply to a single value or all values of a vector property.
Currently, these two options are presented in this order (Single, then
All), while all other operators (replace, delete, clear, add to keying
set, reset, copy to selected) follow the opposite order (All, then
Single).
This commit inverts this order for consistency's sake.
Pull Request: https://projects.blender.org/blender/blender/pulls/115962
This commit adds a new operator that allows to view an FCurve in the Graph Editor from the animated property.
# Features
* Frame a single property or a whole array property by right-clicking an animated property
* Works on a property anywhere in blender
* Framed FCurves are selected and set to visible
* Works on the selection. If an object/bone doesn't have a property it is ignored.
* Works with NLA offset and normalization
* Isolate curves. This is a property on the operator
# Caveats
* Frames on the first Graph Editor it finds
* Since it works on the selection but the n-panel works on the active object,
you can create a situation where nothing happens because you can have
an active object without it being selected.
* Assigning a shortcut doesn't work through right clicking the menu entry.
You have to go to the keymap and create a new entry manually (e.g. in the user interface category)
Pull Request: https://projects.blender.org/blender/blender/pulls/114407
Extract:
- "Attribute", when creating a new attribute with
`GEOMETRY_OT_attribute_add()`: make the default name in the operator
a null string, and set it to "Attribute" translated inside an invoke
method instead.
- Also for new attributes, from `BKE_id_attribute_calc_unique_name()`,
for instance to create a default vertex color layer when going into
Vertex Paint mode: use `DATA_()` instead of `IFACE_()`, since it
represents user data.
Disambiguate:
- "Weight" can be the thickness of font glyphs.
- "Mark as Asset" and "Clear Asset" are operator names already
extracted using the Operator context. They were recently added to a
manual translation in the UI, but the existing one can be reused.
- "Second" as a time unit in the context of frame snapping.
Some messages reported by Satoshi Yamasaki in #43295.
Pull Request: https://projects.blender.org/blender/blender/pulls/114159
Choosing "Mark as Asset" from the context menu of the ID selector (ID
template) would always use the selected objects instead of the ID set in
the ID selector. This is because since f22e2bab72, multiple selected IDs
have priority over a single active ID (to give batch editing priority),
and the 3D view context exposes both.
Adds variants of the mark and clear asset operators that only work on a
single ID ("id" context member). Context menus for buttons representing
an ID use this instead. Using an operator property resulted in too
complicated code. Plus the poll function would succeed in cases where
the operator wouldn't be able to succeed. Separate operators keep things
simple and more reliable.
Improvements to `ui_but_menu_add_path_operators` so that it properly
differentiates between files and directories even if the filepath is
not slash terminated. It will also not add the operators to the menu
if the filepath does not exist.
---
Right-clicking on a pathname input we get a context menu that might contain "Open File Externally" and/or "Open Location Externally". But the first problem is that it does not check if this location exists, and we do have times where the paths do not exist yet. This PR makes this function a bool so that can return false if the files do not exist.
The second problem is that the function does not properly differentiate between a file path and directory path. For a directory path that is not slash terminated it will assume it is a file path. This PR actually checks the path (BLI_is_dir) to see if it really is a directory path.
Pull Request: https://projects.blender.org/blender/blender/pulls/113216
Use the asset icon for the "Mark Asset" operator in menus.
Using icons is not only good for accessibility, but also to create
a connection with the Asset Browser and the icon shown in the
data-block template once marked as asset.
Pull Request: https://projects.blender.org/blender/blender/pulls/112111
There are a couple of functions that create rna pointers. For example
`RNA_main_pointer_create` and `RNA_pointer_create`. Currently, those
take an output parameter `r_ptr` as last argument. This patch changes
it so that the functions actually return a` PointerRNA` instead of using
the output parameters.
This has a few benefits:
* Output parameters should only be used when there is an actual benefit.
Otherwise, one should default to returning the value.
* It's simpler to use the API in the large majority of cases (note that this
patch reduces the number of lines of code).
* It allows the `PointerRNA` to be const on the call-site, if that is desired.
No performance regression has been measured in production files.
If one of these functions happened to be called in a hot loop where
there is a regression, the solution should be to use an inline function
there which allows the compiler to optimize it even better.
Pull Request: https://projects.blender.org/blender/blender/pulls/111976
Generally the context store is owned by `uiBlock`. Other pointers
to the store (in `bContext` and other operator data) shouldn't change
it, so those variables are now const. One exception is the pointer in
`uiLayout`, but that has a clearly short lifetime, so that's okay.
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.
While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.
Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.
Some directories in `./intern/` have also been excluded:
- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.
An "AUTHORS" file has been added, using the chromium projects authors
file as a template.
Design task: #110784
Ref !110783.
With the end goal of simplifying ownership and memory management,
and allowing the use of `get_name` in contexts without statically
allocated strings, use `std::string` for the return values of these two
operator type callbacks instead of `const char *` and `char *`.
In the meantime things get uglier in some places. I'd expect `std::string`
to be used more in the future elsewhere in Blender though.
Pull Request: https://projects.blender.org/blender/blender/pulls/110823
Needed for the asset shelf context menu to work, see #104831.
Ensures the view item button's context is passed on to the context menu.
Otherwise it cannot display operators relying on this context.
No user visible changes expected.
This function was added in 86b2cf4574 as a more type safe and more
convenient way of setting button callbacks. So use it for simple cases.
Issue here was that Quick Favorites use a property's **identifier** when
adding [which is the bare name without brackets etc. from id properties]
but when spawning the actual menu, `RNA_struct_find_property` expects
the identifier to already include the brackets to know these are id
properties (later on in `screen_user_menu_draw`).
So to solve this, now include the needed syntax when storing the
`bUserMenuItem_Prop` identfier.
Seems the quickest way to append the needed characters is using
`RNA_path_property_py` (not sure if there are better ways to do this).
Also note that we (need to) ignore the actual array index constructing
the string [always pass -1 here] since the index is handled separately [I
tested boolean arrays and these work].
Pull Request: https://projects.blender.org/blender/blender/pulls/108713
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.
This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.
Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.
Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:
https://reuse.software/faq/
Part of #59244
This was heavily requested since there are a lot of usages of
`operator_menu_enum` around in our UI [and these menus all cannot be
added to Quick Favorites atm.].
The following are just a small sample from the 3D viewport menus (object
mode), but there are many more.
- Object
-- Set Origin
-- Relations >> Make Local...
-- Convert To
- Add
-- Grease Pencil
-- Empty
-- Force Field
-- Collection Instance
- Select
-- Select All by Type
-- Select Grouped
-- Select Linked
- ...
So in order to make this work, `USER_MENU_TYPE_OPERATOR` /
`bUserMenuItem_Op` is reused (but extended with a string to the property
in question). (Alternatively, a new type could be introduced -- but
would share most of the code with the type that is reused in this
patch).
Depending on being used with an enum or not [detected by the usage of
that new string] we then either call `uiItemFullO_ptr` or
`uiItemMenuEnumFullO_ptr` in `screen_user_menu_draw`.
NOTE: support for other enums (property enums such as pivot point or
transform orientations) will follow in a separate commit (building upon
6a13b6324b, trying to solve the way these draw as menus)
NOTE: opening User Preferences with such "new" Quick Favorites even
works (just not drawn with a menu)
Pull Request: https://projects.blender.org/blender/blender/pulls/107616
The length passed to IDP_NewString included the nil terminator
unlike IDP_AssignString. Callers to IDP_AssignString from MOD_nodes.cc
passed in an invalid size for e.g. There where also callers passing in
the strlen(..) of the value unnecessarily.
Resolve with the following changes:
- Add `*MaxSize()` versions of IDP_AssignString & IDP_NewString which
take a size argument.
- Remove the size argument from the existing functions as most callers
don't need to clamp the length of the string, avoid calculating &
passing in length values when they're unnecessary.
- When clamping the size is needed, both functions now include the nil
byte in the size since this is the convention for BLI_string and other
BLI API's dealing with nil terminated strings,
it avoids having to pass in `sizeof(value) - 1`.