Previously, we were drawing the context path in the header of the spreadsheet.
However, that had some problems:
* When using a viewer that's somewhere deep in a node group, the viewer path
wouldn't fit.
* Standard editor menus didn't fit in. Also we wanted to add spreadsheet
specific operators that should be in a new menu.
* Couldn't fit more useful data for the context path (like the inspection index
for repeat zones).
This patch solves this by moving the entire context path to the left side bar.
This frees up the header for menus.
The new context panel information is added at the top of the side bar because
then there is a proper hierarchy: `Object > Evaluation State > Viewer Path
(optional) > Instance Selection > Domain Selection`
This patch also adds information about the current inspection index for for-each
and repeat zones. They are not editable yet, but that can be implemented
separately as it might require a few more changes for everything to update
correctly.
The new Viewer Path panel is only displayed when actually showing viewer data.
Pull Request: https://projects.blender.org/blender/blender/pulls/138477
Previously, when reordering a tree view item to the end, one had to move it drop
it fairly precisely on the lower half of the last item in the list. This patch
makes it possible to just drop it below the last item too. The outliner has the
same functionality.
Pull Request: https://projects.blender.org/blender/blender/pulls/139025
Currently, nothing happens when trying to scroll while hovering a tree view that
is fully visible (i.e. does not have a scroll bar). This patch makes it so that
the scroll event is passed through in this case so that one can scroll the
entire region even when hovering the tree view. If the tree view does have a
scrollbar, then the scroll-event is still captured by that even if scroll all
the way up/down already.
Pull Request: https://projects.blender.org/blender/blender/pulls/138930
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
This converts the public `uiLayoutListBox ` and `uiLayoutOverlap `
functions to an object oriented API (an `uiLayout::list_box` and
`uiLayout::overlap` respectively), following recent uiLayout changes.
Both functions 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/138559
This converts the public `uiLayoutBox` function to an object oriented
API (`uiLayout::box`), 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::box` 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/138334
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
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
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
The general idea is to keep the 'old', C-style MEM_callocN signature, and slowly
replace most of its usages with the new, C++-style type-safer template version.
* `MEM_cnew<T>` allocation version is renamed to `MEM_callocN<T>`.
* `MEM_cnew_array<T>` allocation version is renamed to `MEM_calloc_arrayN<T>`.
* `MEM_cnew<T>` duplicate version is renamed to `MEM_dupallocN<T>`.
Similar templates type-safe version of `MEM_mallocN` will be added soon
as well.
Following discussions in !134452.
NOTE: For now static type checking in `MEM_callocN` and related are slightly
different for Windows MSVC. This compiler seems to consider structs using the
`DNA_DEFINE_CXX_METHODS` macro as non-trivial (likely because their default
copy constructors are deleted). So using checks on trivially
constructible/destructible instead on this compiler/system.
Pull Request: https://projects.blender.org/blender/blender/pulls/134771
This changes the drawing in the tree interface panel so that panels always show
the icon to collapse it, even if it is empty. This makes it more obvious when an
item is a panel and not just a socket.
Right now, this is not strictly necessary, because sockets can also be
identified by their socket icon. However, that changes with #133936 where a
panel can also have a (boolean) socket.
Pull Request: https://projects.blender.org/blender/blender/pulls/135207
Move the code dealing with converting float3 to GPU normals
out of the vertex format header into a separate header. Use a
proper C++ namespace and remove duplication by only using
the more recently added C++ templated conversions.
Most of the diff comes from the removal of the indirect includes
from GPU_vertex_format.hh. A lot of files ended up mistakenly
depending on that.
Pull Request: https://projects.blender.org/blender/blender/pulls/134873
This changes the ui-blocks buttons storage from Listbase to Vector.
Major changes that might cause a performance considerations are
in `ui_but_update_from_old_block` that requires to track buttons when restoring
button state between block redraws or in `uiItemFullR` that may needs to insert
uiButs in the middle of the vector to add decorators. This might not be as fast as
removing or inserting elements in the middle of a listbase container. Also buttons currently
don't know its position in the container, so to get the previous and next
button its required to make a lookup of the button in the container.
`UI_block_update_from_old> ui_but_update_from_old_block` restores the state
of buttons between frames, this is done by sequentially testing if a button is the
same as an old button, however since UI can be created procedurally some old buttons
may not be drawn while editing other button data, this requires an extra track of what
buttons may not match to a new button while comparing for restoring state, but still
this buttons may be candidates to match to an new button.
Not functional changes expected.
Ref: #117604
Co-authored-by: Julian Eisel <julian@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/127128
f0db870822 added support for tree-views to remember state, but only to
remember their custom height for the start. This change makes the scroll
offset be remembered too.
Not remembering the scroll offset can be very annoying in some cases,
e.g. when working with bone collections and changing the active tab in
the properties editor often. In realistic, non-trivial bone collection
set ups this can lead to a lot of repeated scrolling.
Currently UI code always has to use char pointers when interacting with
the translation system. This makes benefiting from the use C++ strings
and StringRef more difficult. That means we're leaving some type safety
and performance on the table. This PR adds StringRef overloads to the
translation API functions and removes the few calls to `.c_str()` that
are now unnecessary.
Pull Request: https://projects.blender.org/blender/blender/pulls/133887
Show a dimmed loading icon while previews are being loaded in a
background thread. The asset shelf and asset/file browsers do this
similarly already.
This is implemented in drawing code, so the loading icon will always
appear when an in-progress preview is being drawn. I experimented with
doing this in `ui_def_but_icon()`, but this won't update correctly with
popups that don't support full refreshing.
This also makes any normal icon that is drawn as preview use the normal
icon size. These icons are usually made for smaller sizes and look very
outblown when displayed at the size of a preview. Yet it's useful to
sometimes pass a normal icon. E.g. for the asset shelf we would already
draw the data-block type icon in place of the preview if there was no
preview to display, and we'd use the normal, smaller size already.
Larger can still be drawn differently.
I don't know of any current cases this would affect though.
Pull Request: https://projects.blender.org/blender/blender/pulls/133880
As the local zoom in changed, scale the vertical start and end of the
hierarchy lines by the 2D aspect value so they remain lining up with
the other content.
Pull Request: https://projects.blender.org/blender/blender/pulls/132817
Scrolling a tree view could result in incorrectly drawn hierarchy lines, see
https://projects.blender.org/blender/blender/issues/132386#issuecomment-1384663
Two issues:
- The index of the last descendant of an item was off by one
- When a hierarchy line was skipped because it was scrolled out of view, the
following indices would be wrong.
Adds support for saving some view state persistently and uses this to keep the
height of a tree-view, even as the region containing it is hidden, or the file
re-loaded.
Fixes#129058.
Basically the design is to have state stored in the region, so it can be saved
to files. Views types (tree-view, grid-view, etc) can decide themselves if they
have state to be preserved, and what state that is. If a view wants to preserve
state, it's stored in a list inside the region, identified by the view's idname.
Limitation is that multiple instances of the same view would share these bits of
state, in practice I don't think that's ever an issue.
More state can be added to be preserved as needed. Since different kinds of
views may require different state, I was thinking we could add ID properties to
`uiViewState` even, making it much more dynamic.
Pull Request: https://projects.blender.org/blender/blender/pulls/130292
Previously, we had to fetch all asset previews at once. However the preview
caching system was limited at 8192 previews, so with large asset libraries, many
previews would get dropped. Instead, allow selectively requesting previews and
only request previews of items displayed on screen. This should fix the issue,
and reduce the time it takes to display brush assets in general, especially with
bigger libraries. This should also reduce memory usage quite a lot when
displaying the asset shelf, since not all asset previews are loaded anymore.
Pull Request: https://projects.blender.org/blender/blender/pulls/130105
For C/C++ doc-strings should be located in headers,
move function comments into the headers, in some cases merging
with existing doc-strings, in other cases, moving implementation
notes into the function body.
Implements scrolling support for tree-views, as well as changing the size of the
scroll-able tree-view. This is important to be able to place them in many places
in the UI, where a compact layout is preferred over an every expanding one
(causing following contents to be scrolled out of view). UI-lists would use
scrolling and resizing to ensure this, now tree-views are on par.
Enables scrolling and resizing for:
- Bone collection UI (`UILayout.template_bone_collection_tree()`)
- Grease Pencil layer UI (`UILayout.template_grease_pencil_layer_tree()`)
- Light link collection UI (`UILayout.template_light_linking_collection()`)
- UI to define a node tree interface (`UILayout.template_node_tree_interface()`)
These are all cases where compact UIs make more sense than expanding ones.
Internally this is enabled by calling the `set_default_rows()` method of the
tree-view, although the API might change still. It shouldn't be quite simple to
implement this for grid-views too if necessary, or other potential view types.
Although I'd like to do some smaller code quality improvements still, this
feature is important for some other modules (e.g. grease pencil module for the
layers UI in grease pencil v3), so I decided to prioritize merging this.
Pull Request: https://projects.blender.org/blender/blender/pulls/119668
Previously, mapping old to new items was O(n^2) because each new item was
compared to all old items until the corresponding one was found. This patch
introduces a pre-filter to the old elements that have to be checked. Instead of
comparing all old items, only the ones with the same label are compared now.
This reduces the time complexity to O(n), making the tree view much more
usable with many items.
Add a utility function to add horizontal padding to the left and right
of items in UI lists and tree views to make them more consistent with
other buttons like menu entries.
Pull Request: https://projects.blender.org/blender/blender/pulls/125498
Previously, it was not possible to see detailed information about instances in
the spreadsheet. Only the attributes on the top level instances were shown. Now,
all nested instances can be inspected too.
Combined with #114910 this will make inspecting more complex geometry with the
spreadsheet much more feasible. It's also an important part of integrating
grease pencil into geometry nodes because it makes it more obvious how layers
are converted to curve instances.
The data-selection is split into two separate tree views now. One that selects
the geometry from the instance tree, and one that's used to select the geometry
component and domain within that geometry. We found that this works better than
combining both tree views into one (we tried that in #124186).
Pull Request: https://projects.blender.org/blender/blender/pulls/125293
Shortcut and quick favorite operators wouldn't show up in the regular asset
shelf. In the popup the shortcut operators would but they crashed with use
after frees.
Basic issue is that activating view-items by applying the button didn't work
well. That messes with button storage, but also the operator data (like
`uiBut.optype`) is unset after applying, in this case before the context menu
was built.
Instead, activate the view-item directly, and call the activate operator in its
`on_activate()` callback. The button shouldn't call this operator again, so
added a way to attach operators to buttons without calling them.
Seems generally useful to be able to attach an operator to buttons for
tooltips, "Assign Shortcut" and the like, without it being called on button
apply.
Pull Request: https://projects.blender.org/blender/blender/pulls/124466
Since 4a9e8087a7, preview-tile buttons are non-interactive by default,
so tooltip handling is not triggered. Instead, attach the tooltip to the
underlying view-item button.
In particular, this makes the asset shelf popup search highlight the
first asset when changing the search filter using text input. Pressing
Enter will activate this asset then. The feature is implemented
generally for grid and tree views, but only the asset shelf implements
filtering so far. Plus, it requires the
`UI_BUT2_FORCE_SEMI_MODAL_ACTIVE` behavior on the filter text button,
otherwise it captures all input. Only the popup version of the asset
shelf uses this currently. Moving the mouse makes the highlight jump
back to the brush under the cursor again. This is how search menus
behave too.
Part of the brush assets project, see blender/blender!123853. It's made
so it's possible to quickly spawn the brush asset shelf popup, input
text to search a brush and press Enter to activate it. Based on user
feedback this is an important workflow to support well.
More info about the changes in the pull request.
Pull Request: https://projects.blender.org/blender/blender/pulls/123853
No user visible change expected.
There's no good way to identify items from their base class which is
annoying for development/debugging. I ended up adding a helper like this
a few times, so makes sense to just add this to the API.
When a new item is active, other items are only deactivated in the
`set_state_active` method. This doesn't run if the new item is not
displayed by the shelf for whatever reason (e.g. catalog filters).
To fix this, just set the item inactive. This may be redundant with
the deactivation in `set_state_active`, or it might not be, depending
on whether the active item is visible.
Pull Request: https://projects.blender.org/blender/blender/pulls/121589
Fixed layout widths would previously be ignored, resulting in incorrectly sized
grid view items. This is especially relevant for displaying grid views in
popups, where these fixed width are commonly used.
Necessary for the brush assets project which adds a popup version of the asset
shelf, see #116337.
The optimization to only add grid view items to the layout that are actually in
view relied on View2D information on scrolling. Popups don't use View2D, so
with this change the optimization will be skipped when View2D is not used.
Necessary for the brush assets project which adds a popup version of the asset
shelf, see #116337.
Displaying an operator in the context menu that would access the asset
via context would fail.
3 issues here in fact:
- 798219225d removed code to attach the asset to the button's context.
Brought this back.
- If the `AssetShelf.get_active_asset()` method (in Python) isn't set,
`AssetViewItem::should_be_active()` would always return false, making
it impossible to lookup the active item. Instead it should return an
empty value so the view's internal active state is used instead.
Mistake in a700c90ec3.
- These kind of context queries can't rely on cursor coordinates, it's
not well defined what state they are in. In fact `wmWindow.eventstate`
is unset in debug builds to help enforce this. Also an issue from
a700c90ec3. With the above two corrections this change can be
undone so the query doesn't depend on cursor coordinates anymore.
Add a function for asset shelves, `get_active_asset` in RNA, that
can be used to sync the active item of an asset shelf with an asset
reference elsewhere in Blender. In the brush asset system this is
used to retrieve the asset reference from the active `Paint` struct.
Pull Request: https://projects.blender.org/blender/blender/pulls/121405
The operator stored when registering the asset shelf will be called
with properties that reference the asset (a weak reference, split into
three properties already used in other asset-related operators). The
operator is called whenever a grid view item is activated, and is
meant to do things like import and activate a brush asset.
Previously Reviewed: https://projects.blender.org/blender/blender/pulls/117861
Pull Request: https://projects.blender.org/blender/blender/pulls/121402
Since 427bdc8dcf there is some trickery going on to make the underlying
view-item button slightly bigger, but that unintentionally also scaled
up the layout drawn on top of it. This would be visible whenever the
background is drawn, e.g. by using a different emboss type or when an
animated property was displayed.
Animation state of any property is not colored in tree-view structure.
This is due to wrong emboss value. `widget_color_blend_from_flags`
returns correct theme value if emboss is not `UI_EMBOSS_NONE`.
`UI_EMBOSS_NONE_OR_STATUS` is preferred for animating properties.
Pull Request: https://projects.blender.org/blender/blender/pulls/120298