Commit Graph

104 Commits

Author SHA1 Message Date
Julian Eisel
e425faf696 Cleanup: Replace term "radial" with "pie menu" in UI code
Code was often referring to pie menus using the term "radial" which just
obfuscates that it relates to pie menus. Just call it what it is
directly.

Doesn't replace usages of the term for names that are not strictly tied
to pie menus. Also doesn't change instances of the term in the Python
API to keep compatibility, noted in #110461.

Pull Request: https://projects.blender.org/blender/blender/pulls/122825
2024-06-06 14:55:23 +02:00
Pratik Borhade
25351738f7 UI: Add title to tree view context menus
Add new string member in `AbstractView` class to store title/header of
tree view. Later use this to set title (`pup->title`) of context menu.

Pull Request: https://projects.blender.org/blender/blender/pulls/120694
2024-06-05 11:28:44 +02:00
Pablo Vazquez
068e624ebc UI: Make sidebars slightly wider
The default width for sidebars was last updated for 2.80 when columns
didn't have headings and checkboxes were right-aligned.

Some strings no longer fit especially when using headings, and in
translations. Make it slightly wider while still being relatively out of
the way in a 1920 × 1080 setup.

Detailed images in the pull request description.

Pull Request: https://projects.blender.org/blender/blender/pulls/121795
2024-06-03 19:21:31 +02:00
Julian Eisel
2fbf206491 UI: Allow passing named strings via context
Sometimes it is necessary to pass additional data through generic UI entities,
to specific implementations. For example to pass additional options to panel
polling & drawing when instantiating a panel through its panel type. Or storing
additional data in a button, without hardcoding it in the button struct/class.

Passing data via context is a simple solution to this, however so far this only
works using hardcoded context queries or RNA pointers. For passing arbitrary
strings we've used workarounds like creating an RNA type to wrap it already.
For example `RNA_AssetCatalogPath`, which is used to dynamically populate menu
items based on an asset catalog path, via a generic menu type.
type instantiation. This makes it possible to invoke specific asset shelves as
popover panels.

Idea is simply to let `bContextStore` entries hold copies of the string (as
`std::string`), avoiding lifetime issues. Context APIs are extended to support
setting/querying strings via a context member name.

Pull Request: https://projects.blender.org/blender/blender/pulls/122113
2024-05-27 18:46:19 +02:00
Julian Eisel
717389887b Cleanup: Keep panel functions internal to UI code
These were added/exposed in aa03646a74.

There's no need to expose them in the public UI API, and they don't seem
like functions that should be used outside of the UI internals.
2024-05-24 20:29:37 +02:00
Julian Eisel
46f5079f11 Fix: Various crashes and issues with popups
Fixes #121902, #121865, #121905 and some other reports that were closed
as duplicates.

Reverts a change done as part of 7d80fde033.

Reverting this change breaks the yet-to-be-used asset shelf popup a bit,
in that refreshing it won't work propery anymore. Think that's fair
given that 1) the popup isn't in use yet, 2) its refreshing implementation
causes a bunch of high priority bugs, and 3) #122068 is in review with a
better solution to handle refreshing. Namely, it converts the popup to a
popover, which handles refreshing differently, and thus makes the change
being reverted here unnecessary anyway.
2024-05-23 13:22:39 +02:00
Julian Eisel
7d80fde033 UI: Popup version of the asset shelf
Developed as part of the brush assets project, see #106303. No user visible
changes at this point.

Makes it possible to display asset shelves as popups. These popup asset shelves
use static storage for their settings, mainly to remember the active catalog
and filter string, while keeping them separate from the permanent asset shelf
region. Further, the popup can be displayed in any editor, making asset
selectors possible to add anywhere in the UI. When an asset is chosen, an
operator passed to the asset shelf as bl_activate_operator is called, with an
asset weak-reference to refer to the activated asset stored in the operator
properties.

Adds UILayout.template_asset_shelf_popover() to insert asset shelf popup
buttons, taking an asset shelf idname and some normal UI parameters.
2024-05-16 00:11:47 +02:00
Campbell Barton
9ed5ed1a2b Fix #121686: Regression: Context Menu has many operations disabled
Resolve own regression in [0] which caused operators poll functions
in context menus to fail because the menus own region was set
causing the button clicked on not to be detected as the active button.

Resolve by passing "can_refresh" as an argument to ui_popup_block_create
which only sets the "region_popup" context item for popups that can
refresh. This is done because previously "region_popup" was only ever
set for temporary regions that refreshed (details in code-comments).

[0]: 38d11482f5
2024-05-14 14:08:28 +10:00
Campbell Barton
bc5b77b390 Cleanup: rename Context::wm::menu to popup_region
The term "menu" was misleading as this is used for all temporary popups.
2024-05-10 11:27:03 +10:00
Julian Eisel
952bc075ae Fix #121490: Unable to access asset from context in asset shelf
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.
2024-05-07 17:45:15 +02:00
Harley Acheson
c4e5a70e07 UI: Optional Complex Layout for Workspace Status
Optionally allow complex layout instead of just plain text when using
ED_workspace_status_text.

Pull Request: https://projects.blender.org/blender/blender/pulls/120595
2024-05-06 23:52:37 +02:00
Campbell Barton
bb172dae61 Cleanup: use const variables & arguments 2024-05-06 09:20:03 +10:00
Julian Eisel
a700c90ec3 Asset Shelf: Add callback to get active asset
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
2024-05-03 15:27:35 -04:00
Harley Acheson
49bd285529 UI: Collapse XYZ Operations in Status Bar
Reduce the number of duplicated modal operator keymap entries by just
showing "XYZ Axis" rather than "X X Axis", "Y Y Azis", etc. This allows
more items to be shown on the status bar. Note this only does so if the
keymap contains all of X, Y, & Z.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/120148
2024-04-22 20:03:11 +02:00
Harley Acheson
d8f6ae7919 UI: Outliner "File Mode" Manage User Count
In Outliner "Blender File Mode" view, show user counts, and allow
removing and adding fake user, requested in #118655.

Pull Request: https://projects.blender.org/blender/blender/pulls/118691
2024-04-20 02:50:12 +02:00
Campbell Barton
01101dcaf9 Cleanup: use const references instead of copy-by-value 2024-04-17 11:36:44 +10:00
Brecht Van Lommel
07922a99e9 UI: Tweaks to collection export
* Remove embossing from preset / export / delete buttons.
   For example modifiers also don't have emboss for X, and presets
   never do. So it seems consistent.
* Remove duplicated preset buttons, only have the one in the header
  like other panels in properties editor.
* Use property separate layout without boxes for file path.
* Show info message when exporting a single or all collections,
  otherwise it's not obvious that something happened when clicking
  the button.

Pull Request: https://projects.blender.org/blender/blender/pulls/120667
2024-04-16 15:02:33 +02:00
Jacques Lucke
d1634b2a4a UI: support adding a search weight to menu entries for menu-search
The goal is to support better search experience in the cases where we want to
explicitly influence the ordering instead of relying only on general heuristics.
We used to support this already at some point I think, but not anymore since we
started using menu-search.

The implementation is fairly straight forward. It mainly just forwards the
search weight from the menu definition to the search code through various
required steps. The main annoying thing is that changing the signature of e.g.
`uiItemFullO_ptr` is fairly involved. Even using default parameters for these
functions is a bit annoying and becomes fairly unreadable and error-prone on the
call-site. For now, I worked around this by storing the search weight on the
`uiLayout` and to copy it to the `uiBut` from there. That seems preferable until
we have a better solution for adding parameters to all the `uiItem*` functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/120572
2024-04-16 12:18:45 +02:00
Jesse Yurkovich
509a7870c3 Collection Exporters: Enable file exporters to be specified on Collections
This implements the ability to have file exporters added and configured on Collections.

Exporting is reachable from several locations:
- Individually on each exporter configuration: The `Export` button in each panel header
- For all exporters on the collection: The `Export All` button in the main panel interface
- For all exporters on all collections in the scene: The `File`->`Export All Collections` button

Visibility of which collections currently have exporters configured is done by ways of an icon added to the Collection row in the Outliner.

Adding multiple exporters for the same file type is permitted. The user is free to setup several exports of the same format but with different file locations or settings etc.

Notes:
Only USD and Wavefront OBJ are enabled for the initial commit. Additional formats, including those implemented in Python will be added as separate commits after this.

Ref #115690
Pull Request: https://projects.blender.org/blender/blender/pulls/116646
2024-04-08 22:10:39 +02:00
Brecht Van Lommel
d99f2e8eb7 Refactor: Add ability for UI block to own operator
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
2024-03-29 14:52:35 +01:00
Hans Goudey
acd1b0b7f9 Refactor: Use C++ Vector for RNA/context collection retrieval
Previously retrieving a collection from the context like "selected_ids"
would give a linked list of allocated items. Now it returns a vector of
RNA pointers. Though the number of items is typically fairly small,
using contiguous memory and avoiding many small allocations are
typical performance improvements that could still be beneficial
when there are many items. Iteration also becomes much simpler.

Pull Request: https://projects.blender.org/blender/blender/pulls/119939
2024-03-27 00:47:39 +01:00
Julian Eisel
b1db1702c6 Cleanup: Deduplicate UI list filtering checks
Followup to 303014bfac.
2024-03-22 16:04:03 +01:00
Guillermo Venegas
aa03646a74 UI: support layout panels in popups
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
2024-03-21 10:31:05 +01:00
Harley Acheson
061a9ee885 UI: Add Optional Flags for Tooltip Image Fields
Add more flexibility to tooltip images by adding the ability to specify
if (one of two) checkerboards are added, border, premultiplied
blending, or recoloring.

Pull Request: https://projects.blender.org/blender/blender/pulls/119437
2024-03-18 22:17:45 +01:00
Hans Goudey
1050d6147f Cleanup: Remove unnecessary C wrappers for UI view classes 2024-03-08 09:16:07 -05:00
Hans Goudey
744f3b2823 Cleanup: Grammar in comments: Fix uses of "own"
"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.
2024-03-07 16:23:35 -05:00
Hans Goudey
ce80cc1526 Cleanup: Remove unused UI button creation function
Last used over 11 years ago apparently.
2024-03-04 12:22:50 -05:00
Hans Goudey
aab9ecc396 Cleanup: Remove very old hack to fix linking in interface module
Pull Request: https://projects.blender.org/blender/blender/pulls/118988
2024-03-01 23:47:18 +01:00
Hans Goudey
d29ce3d531 UI: Remove uiBut a1 and a2 values
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.
2024-03-01 14:27:57 -05:00
Hans Goudey
365966d51d Cleanup: UI: Use derived struct for label buttons, remove a1, a2 usage 2024-03-01 14:27:56 -05:00
Hans Goudey
f4e670af2c Refactor: UI: Use regular button callbacks for curve, color ramp templates
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.
2024-03-01 14:27:56 -05:00
Hans Goudey
e1023b22f1 Cleanup: UI: Remove more uses of a1 and a2 arguments
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.
2024-02-29 22:39:37 -05:00
Hans Goudey
aabd5de1f9 Cleanup: Remove unused UI button creation function 2024-02-29 22:39:37 -05:00
Hans Goudey
121ded625f Cleanup: Remove unnecessary a1 and a2 arguments for some UI functions 2024-02-29 22:39:37 -05:00
Hans Goudey
0e2fed5a57 Refactor: UI: Avoid a1 and a1 values for search button preview grid size 2024-02-29 22:39:37 -05:00
Campbell Barton
7db790c4b7 Cleanup: spelling in comments 2024-02-28 12:13:20 +11:00
Campbell Barton
a9803765dc Cleanup: remove colon after "return" doxy command 2024-02-28 12:13:17 +11:00
Hans Goudey
eb484188dd Cleanup: Move asset filter settings out of DNA
There's no reason for this struct to be declared in DNA when it isn't
saved to files.

Pull Request: https://projects.blender.org/blender/blender/pulls/118285
2024-02-21 14:23:17 +01:00
Campbell Barton
64213e6c24 Cleanup: use std::string for manual_id access 2024-02-19 12:18:30 +11:00
Campbell Barton
eafecb2bc3 Cleanup: remove unused WM_DRAG_VALUE 2024-02-16 14:26:56 +11:00
Harley Acheson
4c50e6992f UI: Configurable Layout Separators
Ability to create vertical bar separators in horizontal layouts,
horizontal lines in popovers, and vertical (non-line) spacers in menus.

Pull Request: https://projects.blender.org/blender/blender/pulls/117310
2024-02-09 17:38:36 +01:00
Hans Goudey
fbf47b9a12 Refactor: Use std::string for keymap string return values
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
2024-02-07 14:22:54 +01:00
Campbell Barton
9996d95ab9 Cleanup: spelling in comments 2024-02-06 22:28:10 +11:00
Hans Goudey
df8c85d3f9 Cleanup: UI Remove more unnecessary a1 and a2 parameters
Similar to 5155feeeb8. These had values without any meeting,
almost completely just 0 or -1 (which meant "find good values if possible"
anyway).
2024-02-05 14:38:11 -05:00
Hans Goudey
266230dd88 Refactor: UI: Pass StringRef to more button definition functions
Similar to 9c3aa8b824. This time there is one null argument
that has to be changed. It was simple to just move the logic to that one
caller.
2024-02-01 14:40:40 -05:00
Hans Goudey
5155feeeb8 Cleanup: UI: Remove a1 and a2 unused arguments from uiDefButF function
These were removed in previous commits like e6f0b60c2e.
2024-02-01 13:09:09 -05:00
Hans Goudey
809499a3d0 Refactor: UI: Use derived struct for number slider buttons
Similar to d204830107. This is the last real use of
the a1 and a2 arguments for many button definition functions.
2024-02-01 13:08:50 -05:00
Hans Goudey
9c3aa8b824 Cleanup: Use StringRef arguments for some UI button functions
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.
2024-01-31 17:16:25 -05:00
Hans Goudey
e89b4927e4 Cleanup: UI: Remove unused button creation functions 2024-01-31 13:45:26 -05:00
Hans Goudey
f04bc75f8c Cleanup: Use std::string for some RNA function return values
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
2024-01-31 17:08:09 +01:00