Brush Assets: Save As, Delete, Revert and Update operators #117513

Merged
Brecht Van Lommel merged 10 commits from mont29/blender:bap-saveas-asset into brush-assets-project 2024-01-28 00:01:17 +01:00

10 Commits

Author SHA1 Message Date
Brecht Van Lommel 410a73e6d3 Merge branch 'brush-assets-project' into HEAD 2024-01-27 23:32:11 +01:00
Brecht Van Lommel 0253a00187 Merge branch 'brush-assets-project' into HEAD 2024-01-27 23:18:49 +01:00
Brecht Van Lommel 631a2f89e4 Brush Assets: various improvements to operators
* Delete Asset now also works on local brushes
* Save Asset As automatically adds asset metadata if not present
* Fix Save Asset As failing without existing asset directory
* Fix missing refresh of asset library on save and delete
* Revert to Asset actually implemented
* Improve poll functions and graying out
* Better error reporting
2024-01-27 22:56:30 +01:00
Brecht Van Lommel 6158907827 Merge branch 'brush-assets-project' into HEAD 2024-01-26 21:24:36 +01:00
Brecht Van Lommel e2715a35fa Naming and UI organization changes for brush asset operators
This is quite heavily WIP.
2024-01-26 20:38:37 +01:00
Brecht Van Lommel 16e04f8b4b Fix ID template not respecting hide_buttons regarding overrides 2024-01-26 20:38:09 +01:00
Brecht Van Lommel bfe7be8e96 Add TODO comments regarding file saving 2024-01-26 20:38:09 +01:00
Brecht Van Lommel 142936c2cc Make brush asset operators work with all paint modes 2024-01-26 17:30:47 +01:00
Brecht Van Lommel 0ddfe81a81 Merge branch 'brush-assets-project' into HEAD 2024-01-26 16:59:01 +01:00
Bastien Montagne ed42cf3270 WIP 'save as', 'save' and 'delete' brush assets library editing prototype.
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
DISCLAIMER: This is a highly quickly hacked code to get these basic
features testable. A lot more work will be required to get this code
'good'.

Also, while functionality itself work (from quick testing), the UI
updates of the Asset Shelf does not. User need to manually reload (from
the shelf's top-left menu) to see addition/removals of assets.

This adds three new operators (to Curves Sculpt mode only currently) to
`Save As`, `Save` and `Delete` a brush asset.
* **Save As** can be called with any active brush asset, it creates a new
  copy of it in the 'default user library'. This operator always create
  a new asset (and asset file) in that library.
* **Save** can only be called on an active brush from the 'default user
  library'. It will replace the source library file by a new one with
  current brush settings.
* **Delete** can only be called on an active brush from the 'default
  user library'. It will delete the source library file, but keep the
  current brush data in the editing session.

These operators are in the drop-down menu next to the Brush
icon/selector, in the `Tool` tab of the properties panel in the 3DView,
when in Curves Sculpt mode.

---------------------

_There are most likely more issues than listed below, and topics like
naming, actual desired behaviors, UI etc. also need to be evaluated._

* The desired behavior when deleting an edtable asset is unclear. Do
  we want to keep the current session data, or not ?
  * If yes, it gives a way to undo the asset deletion.
  * If yes, how to represent that (since this brush is not an asset
    enaymore)?
  * If not, how to choose the new active Brush?

* No automatic update of the Asset Shelf. Manual update is also
  worryingly slow for me (takes several seconds for the 'all' library to
  refresh its content). AFAIK this is already known issue with the
  current asset system.

* No way to say to the Asset Shelf which is the active asset?

* The 'write partial' code needs to be fully refactored, it's current
  behavior is beyond bad (editing of IDs in Main, modification of Main
  list of IDs even...). Orthogonal topic though, needs its own task
  (also affects the `library` python API, and copy/paste code, at
  least).
  * Somewhat related, current PR will keep linked dependencies linked.
    These should be rather 'made local' in the written library file.

* Current PR only check that a source library blendfile is in the
  'editable' area of the 'default user library' and that the file name
  ends with `.asset.blend` to consider that source file as editable.
  Maybe we rather want to also check the file content itself, to b e
  sure it was not manually edited by the user?

* Current PR made several 'quick hacks' that need proper
  (re-)implementation.

* This code needs to be made generic to all sculpt/paint modes (known
  TODO).
2024-01-25 17:29:44 +01:00