4 Commits

Author SHA1 Message Date
Julian Eisel
728d47f3e4 Asset shelf: Use asset representation for asset shelf BPY methods
Changes the `asset_poll()` and `draw_context_menu()` methods for asset
shelves to use the `AssetRepresentation` type, instead of `AssetHandle`.
The latter should be removed, so it's better to avoid using it in the
asset shelf BPY to avoid future compatibility breakage. This is possible
now with d421ebac5e.
2023-09-15 16:17:44 +02:00
Julian Eisel
d5bac0421f Fix warning print when running asset shelf UI template
Was printing the following warning:
  Warning: 'MyAssetShelf' does not contain '_AST_' with prefix and suffix

I followed some other template for the naming, apparently the "Ui Tool
Simple" one, but that doesn't print the warning.
2023-08-30 16:26:55 +02:00
Julian Eisel
e57726594d Fix missing context attribute access in asset shelf polls
When creating a new main window, the `context.object` attribute wouldn't
exist, causing an error message to be printed.

Rather than checking if the attribute extists, query the mode from
context directly (this is always available), rather than querying it
through the active object.
2023-08-25 19:38:09 +02:00
Julian Eisel
6764e69491 UI: Add asset shelf Python UI template
Adds a new "Ui Asset Shelf" template to the script editor, demonstrating
how scripts can register own asset shelves. The asset shelf is designed
as a new standard UI element that add-ons, application templates and the
like can use, so this is useful. It's also useful as a quick way to test
and customize the asset shelf.

The script is only available in the UI if the "Asset Shelf" experimental
feature is enabled in the Preferences.
2023-08-03 17:16:10 +02:00