diff options
author | Julian Eisel <julian@blender.org> | 2021-10-05 15:25:40 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-10-05 17:10:27 +0300 |
commit | dbe3981b0a805c1a40f42f57dc7ccc3d28270fda (patch) | |
tree | c646101190ece7bf46ee025b79c261b792abb08e /source/blender/editors/space_file/asset_catalog_tree_view.cc | |
parent | 9a0850c8c25ea0c28f6ac313f076fd6a8563d0b4 (diff) |
Cleanup: Better way to pass activate callbacks to Tree-View items
The `ui::BasicTreeViewItem` took a function-like object to execute on
item activation via the constructor. This was mainly intended to be used
with lambdas. However, it's confusing to just have this lambda there,
with no indication of what it's for (activation).
Instead, assign the function-like object via an explicit `on_activate()`
function.
Diffstat (limited to 'source/blender/editors/space_file/asset_catalog_tree_view.cc')
-rw-r--r-- | source/blender/editors/space_file/asset_catalog_tree_view.cc | 22 |
1 files changed, 13 insertions, 9 deletions
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 9d6af5136d9..ff8775155c2 100644 --- a/source/blender/editors/space_file/asset_catalog_tree_view.cc +++ b/source/blender/editors/space_file/asset_catalog_tree_view.cc @@ -165,11 +165,12 @@ void AssetCatalogTreeView::add_all_item() { FileAssetSelectParams *params = params_; - ui::AbstractTreeViewItem &item = add_tree_item<AssetCatalogTreeViewAllItem>( - IFACE_("All"), ICON_HOME, [params](ui::BasicTreeViewItem & /*item*/) { - params->asset_catalog_visibility = FILE_SHOW_ASSETS_ALL_CATALOGS; - WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr); - }); + AssetCatalogTreeViewAllItem &item = add_tree_item<AssetCatalogTreeViewAllItem>(IFACE_("All"), + ICON_HOME); + item.on_activate([params](ui::BasicTreeViewItem & /*item*/) { + params->asset_catalog_visibility = FILE_SHOW_ASSETS_ALL_CATALOGS; + WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr); + }); if (params->asset_catalog_visibility == FILE_SHOW_ASSETS_ALL_CATALOGS) { item.activate(); } @@ -180,10 +181,13 @@ void AssetCatalogTreeView::add_unassigned_item() FileAssetSelectParams *params = params_; AssetCatalogTreeViewUnassignedItem &item = add_tree_item<AssetCatalogTreeViewUnassignedItem>( - IFACE_("Unassigned"), ICON_FILE_HIDDEN, [params](ui::BasicTreeViewItem & /*item*/) { - params->asset_catalog_visibility = FILE_SHOW_ASSETS_WITHOUT_CATALOG; - WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr); - }); + IFACE_("Unassigned"), ICON_FILE_HIDDEN); + + item.on_activate([params](ui::BasicTreeViewItem & /*item*/) { + params->asset_catalog_visibility = FILE_SHOW_ASSETS_WITHOUT_CATALOG; + WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr); + }); + if (params->asset_catalog_visibility == FILE_SHOW_ASSETS_WITHOUT_CATALOG) { item.activate(); } |