[Bf-blender-cvs] [43ed1ceeaf8] temp-asset-browser-catalogs-ui: Merge branch 'master' into temp-asset-browser-catalogs-ui

Julian Eisel noreply at git.blender.org
Fri Sep 24 20:31:51 CEST 2021


Commit: 43ed1ceeaf8124731ef36ce26c6507ea7ea34d8a
Author: Julian Eisel
Date:   Fri Sep 24 20:20:41 2021 +0200
Branches: temp-asset-browser-catalogs-ui
https://developer.blender.org/rB43ed1ceeaf8124731ef36ce26c6507ea7ea34d8a

Merge branch 'master' into temp-asset-browser-catalogs-ui

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



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

diff --cc source/blender/blenkernel/intern/asset_catalog.cc
index 589142eb0af,4f1de09e148..65fde665190
--- a/source/blender/blenkernel/intern/asset_catalog.cc
+++ b/source/blender/blenkernel/intern/asset_catalog.cc
@@@ -324,56 -334,7 +333,56 @@@ int AssetCatalogTreeItem::count_parents
    return i;
  }
  
 -void AssetCatalogTree::foreach_item(const AssetCatalogTreeItem::ItemIterFn callback) const
 +bool AssetCatalogTreeItem::has_children() const
 +{
 +  return !children_.empty();
 +}
 +
 +/* ---------------------------------------------------------------------- */
 +
 +void AssetCatalogTree::insert_item(AssetCatalog &catalog)
 +{
 +  const AssetCatalogTreeItem *parent = nullptr;
 +  AssetCatalogTreeItem::ChildMap *insert_to_map = &children_;
 +
 +  BLI_assert_msg(!ELEM(catalog.path[0], '/', '\\'),
-                  "Malformed catalog path: Path should be formatted like a relative path");
++                 "Malformed catalog path; should not start with a separator");
 +
 +  CatalogID unset_id = bke::bUUID();
 +  const char *next_slash_ptr;
 +  /* Looks more complicated than it is, this just iterates over path components. E.g.
 +   * "just/some/path" iterates over "just", then "some" then "path". */
 +  for (const char *name_begin = catalog.path.data(); name_begin && name_begin[0];
 +       /* Jump to one after the next slash if there is any. */
 +       name_begin = next_slash_ptr ? next_slash_ptr + 1 : nullptr) {
 +    next_slash_ptr = BLI_path_slash_find(name_begin);
 +
 +    const bool is_last_component = next_slash_ptr == nullptr;
 +    /* Note that this won't be null terminated. */
 +    StringRef component_name = is_last_component ?
 +                                   name_begin :
 +                                   StringRef(name_begin, next_slash_ptr - name_begin);
 +
 +    /* Insert new tree element - if no matching one is there yet! */
 +    auto [key_and_item, was_inserted] = insert_to_map->emplace(
 +        component_name,
 +        AssetCatalogTreeItem(
 +            component_name, is_last_component ? catalog.catalog_id : unset_id, parent));
 +    AssetCatalogTreeItem &item = key_and_item->second;
 +
 +    /* If full path of this catalog already exists as parent path of a previously read catalog, we
 +     * can ensure this tree item's UUID is set here. */
 +    if (is_last_component && (item.catalog_id_ == unset_id)) {
 +      item.catalog_id_ = catalog.catalog_id;
 +    }
 +
 +    /* Walk further into the path (no matter if a new item was created or not). */
 +    parent = &item;
 +    insert_to_map = &item.children_;
 +  }
 +}
 +
 +void AssetCatalogTree::foreach_item(AssetCatalogTreeItem::ItemIterFn callback)
  {
    AssetCatalogTreeItem::foreach_item_recursive(children_, callback);
  }
diff --cc source/blender/editors/interface/tree_view.cc
index 609252aef83,ee50126f974..01a921cb759
--- a/source/blender/editors/interface/tree_view.cc
+++ b/source/blender/editors/interface/tree_view.cc
@@@ -314,15 -309,8 +309,15 @@@ uiBut *BasicTreeViewItem::button(
  
  using namespace blender::ui;
  
- bool UI_tree_view_item_is_active(const uiTreeViewItemHandle *item_)
+ bool UI_tree_view_item_is_active(uiTreeViewItemHandle *item_)
  {
-   const uiAbstractTreeViewItem &item = reinterpret_cast<const uiAbstractTreeViewItem &>(*item_);
+   AbstractTreeViewItem &item = reinterpret_cast<AbstractTreeViewItem &>(*item_);
    return item.is_active();
  }
 +
 +bool UI_tree_view_item_matches(const uiTreeViewItemHandle *a_, const uiTreeViewItemHandle *b_)
 +{
 +  const uiAbstractTreeViewItem &a = reinterpret_cast<const uiAbstractTreeViewItem &>(*a_);
 +  const uiAbstractTreeViewItem &b = reinterpret_cast<const uiAbstractTreeViewItem &>(*b_);
 +  return a.matches(b);
 +}



More information about the Bf-blender-cvs mailing list