[Bf-blender-cvs] [bf4b2322be3] temp-asset-browser-catalogs-ui: Let UI show the active default catalog

Julian Eisel noreply at git.blender.org
Mon Sep 27 18:14:27 CEST 2021


Commit: bf4b2322be3ea929dd103b9c7a44f875cf8a5883
Author: Julian Eisel
Date:   Mon Sep 27 18:09:11 2021 +0200
Branches: temp-asset-browser-catalogs-ui
https://developer.blender.org/rBbf4b2322be3ea929dd103b9c7a44f875cf8a5883

Let UI show the active default catalog

Basically, rather than only letting the UI code set a new active
catalog, also always check what the current value is when constructing
the tree.
This makes the "All" catalog selected by default, but also let's the UI
update properly if the active catalog is changed from the outside (e.g.
via BPY).

===================================================================

M	source/blender/editors/space_file/asset_catalog_tree_view.cc

===================================================================

diff --git a/source/blender/editors/space_file/asset_catalog_tree_view.cc b/source/blender/editors/space_file/asset_catalog_tree_view.cc
index a66e286501a..5bf7ac885a2 100644
--- a/source/blender/editors/space_file/asset_catalog_tree_view.cc
+++ b/source/blender/editors/space_file/asset_catalog_tree_view.cc
@@ -59,8 +59,8 @@ class AssetCatalogTreeView : public ui::AbstractTreeView {
   void build_tree() override;
 
  private:
-  static ui::BasicTreeViewItem &build_recursive(ui::TreeViewItemContainer &view_parent_item,
-                                                AssetCatalogTreeItem &catalog);
+  ui::BasicTreeViewItem &build_recursive(ui::TreeViewItemContainer &view_parent_item,
+                                         AssetCatalogTreeItem &catalog);
 };
 /* ---------------------------------------------------------------------- */
 
@@ -137,13 +137,17 @@ AssetCatalogTreeView::AssetCatalogTreeView(bke::AssetLibrary *library,
 
 void AssetCatalogTreeView::build_tree()
 {
+  ui::AbstractTreeViewItem *item = nullptr;
   FileAssetSelectParams *params = params_;
 
-  add_tree_item<AssetCatalogTreeViewAllItem>(
+  item = &add_tree_item<AssetCatalogTreeViewAllItem>(
       IFACE_("All"), ICON_HOME, [params](ui::BasicTreeViewItem &) {
         params->asset_catalog_visibility = FILE_SHOW_ASSETS_ALL_CATALOGS;
         WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, NULL);
       });
+  if (params->asset_catalog_visibility == FILE_SHOW_ASSETS_ALL_CATALOGS) {
+    item->set_active();
+  }
 
   if (AssetCatalogTree *catalog_tree = library_ ? library_->catalog_service->get_catalog_tree() :
                                                   nullptr) {
@@ -155,11 +159,14 @@ void AssetCatalogTreeView::build_tree()
     });
   }
 
-  add_tree_item<ui::BasicTreeViewItem>(
+  item = &add_tree_item<ui::BasicTreeViewItem>(
       IFACE_("Unassigned"), ICON_FILE_HIDDEN, [params](ui::BasicTreeViewItem &) {
         params->asset_catalog_visibility = FILE_SHOW_ASSETS_WITHOUT_CATALOG;
         WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, NULL);
       });
+  if (params->asset_catalog_visibility == FILE_SHOW_ASSETS_WITHOUT_CATALOG) {
+    item->set_active();
+  }
 }
 
 ui::BasicTreeViewItem &AssetCatalogTreeView::build_recursive(
@@ -167,9 +174,13 @@ ui::BasicTreeViewItem &AssetCatalogTreeView::build_recursive(
 {
   ui::BasicTreeViewItem &view_item = view_parent_item.add_tree_item<AssetCatalogTreeViewItem>(
       catalog);
+  if ((params_->asset_catalog_visibility == FILE_SHOW_ASSETS_FROM_CATALOG) &&
+      (params_->catalog_id == catalog.get_catalog_id())) {
+    view_item.set_active();
+  }
 
   catalog.foreach_child(
-      [&view_item](AssetCatalogTreeItem &child) { build_recursive(view_item, child); });
+      [&view_item, this](AssetCatalogTreeItem &child) { build_recursive(view_item, child); });
   return view_item;
 }



More information about the Bf-blender-cvs mailing list