WIP: Brush assets project #106303
|
@ -17,6 +17,7 @@ extern "C" {
|
||||||
struct UserDef;
|
struct UserDef;
|
||||||
struct bUserExtensionRepo;
|
struct bUserExtensionRepo;
|
||||||
struct bUserAssetLibrary;
|
struct bUserAssetLibrary;
|
||||||
|
struct bUserAssetShelfSettings;
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name Assert Libraries
|
/** \name Assert Libraries
|
||||||
|
@ -105,6 +106,32 @@ int BKE_preferences_extension_repo_get_index(const UserDef *userdef,
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/** \name #bUserAssetShelvesSettings
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
bUserAssetShelfSettings *BKE_preferences_asset_shelf_settings_get(const UserDef *userdef,
|
||||||
|
const char *shelf_idname);
|
||||||
|
bool BKE_preferences_asset_shelf_settings_is_catalog_path_enabled(const UserDef *userdef,
|
||||||
|
const char *shelf_idname,
|
||||||
|
const char *catalog_path);
|
||||||
|
/**
|
||||||
|
* Enable a catalog path for a asset shelf identified by \a shelf_idname. Will create the shelf
|
||||||
|
* settings in the Preferences if necessary.
|
||||||
|
* \return Return true if the catalog was newly enabled. The Preferences should be tagged as dirty
|
||||||
|
* then.
|
||||||
|
*/
|
||||||
|
bool BKE_preferences_asset_shelf_settings_ensure_catalog_path_enabled(UserDef *userdef,
|
||||||
|
const char *shelf_idname,
|
||||||
|
const char *catalog_path);
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void BKE_preferences_asset_shelf_settings_clear_enabled_catalog_paths(const UserDef *userdef,
|
||||||
|
const char *shelf_idname);
|
||||||
|
void BKE_preferences_asset_shelf_settings_clear_enabled_catalog_paths(
|
||||||
|
bUserAssetShelfSettings *settings);
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "BKE_layer.hh"
|
#include "BKE_layer.hh"
|
||||||
#include "BKE_main.hh"
|
#include "BKE_main.hh"
|
||||||
#include "BKE_node.h"
|
#include "BKE_node.h"
|
||||||
|
#include "BKE_preferences.h"
|
||||||
#include "BKE_report.h"
|
#include "BKE_report.h"
|
||||||
#include "BKE_scene.h"
|
#include "BKE_scene.h"
|
||||||
#include "BKE_screen.hh"
|
#include "BKE_screen.hh"
|
||||||
|
@ -343,6 +344,12 @@ void BKE_blender_userdef_data_free(UserDef *userdef, bool clear_fonts)
|
||||||
BLI_freelistN(&userdef->script_directories);
|
BLI_freelistN(&userdef->script_directories);
|
||||||
BLI_freelistN(&userdef->asset_libraries);
|
BLI_freelistN(&userdef->asset_libraries);
|
||||||
BLI_freelistN(&userdef->extension_repos);
|
BLI_freelistN(&userdef->extension_repos);
|
||||||
|
LISTBASE_FOREACH_MUTABLE (bUserAssetShelfSettings *, settings, &userdef->asset_shelves_settings)
|
||||||
|
{
|
||||||
|
BKE_preferences_asset_shelf_settings_clear_enabled_catalog_paths(settings);
|
||||||
|
MEM_freeN(settings);
|
||||||
|
}
|
||||||
|
BLI_listbase_clear(&userdef->asset_shelves_settings);
|
||||||
|
|
||||||
BLI_freelistN(&userdef->uistyles);
|
BLI_freelistN(&userdef->uistyles);
|
||||||
BLI_freelistN(&userdef->uifonts);
|
BLI_freelistN(&userdef->uifonts);
|
||||||
|
|
|
@ -269,5 +269,98 @@ int BKE_preferences_extension_repo_get_index(const UserDef *userdef,
|
||||||
{
|
{
|
||||||
return BLI_findindex(&userdef->extension_repos, repo);
|
return BLI_findindex(&userdef->extension_repos, repo);
|
||||||
}
|
}
|
||||||
|
/** \} */
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/** \name #bUserAssetShelfSettings
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
bUserAssetShelfSettings *asset_shelf_settings_new(UserDef *userdef, const char *shelf_idname)
|
||||||
|
{
|
||||||
|
bUserAssetShelfSettings *settings = DNA_struct_default_alloc(bUserAssetShelfSettings);
|
||||||
|
BLI_addtail(&userdef->asset_shelves_settings, settings);
|
||||||
|
STRNCPY(settings->shelf_idname, shelf_idname);
|
||||||
|
BLI_assert(BLI_listbase_is_empty(&settings->enabled_catalog_paths));
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
bUserAssetShelfSettings *BKE_preferences_asset_shelf_settings_ensure(UserDef *userdef,
|
||||||
|
const char *shelf_idname)
|
||||||
|
{
|
||||||
|
if (bUserAssetShelfSettings *settings = BKE_preferences_asset_shelf_settings_get(userdef,
|
||||||
|
shelf_idname))
|
||||||
|
{
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
return asset_shelf_settings_new(userdef, shelf_idname);
|
||||||
|
}
|
||||||
|
|
||||||
|
bUserAssetShelfSettings *BKE_preferences_asset_shelf_settings_get(const UserDef *userdef,
|
||||||
|
const char *shelf_idname)
|
||||||
|
{
|
||||||
|
return static_cast<bUserAssetShelfSettings *>(
|
||||||
|
BLI_findstring(&userdef->asset_shelves_settings,
|
||||||
|
shelf_idname,
|
||||||
|
offsetof(bUserAssetShelfSettings, shelf_idname)));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool asset_shelf_settings_is_catalog_path_enabled(const bUserAssetShelfSettings *settings,
|
||||||
|
const char *catalog_path)
|
||||||
|
{
|
||||||
|
return BLI_findstring_ptr(
|
||||||
|
&settings->enabled_catalog_paths, catalog_path, offsetof(LinkData, data)) != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BKE_preferences_asset_shelf_settings_is_catalog_path_enabled(const UserDef *userdef,
|
||||||
|
const char *shelf_idname,
|
||||||
|
const char *catalog_path)
|
||||||
|
{
|
||||||
|
const bUserAssetShelfSettings *settings = BKE_preferences_asset_shelf_settings_get(userdef,
|
||||||
|
shelf_idname);
|
||||||
|
if (!settings) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return asset_shelf_settings_is_catalog_path_enabled(settings, catalog_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BKE_preferences_asset_shelf_settings_ensure_catalog_path_enabled(UserDef *userdef,
|
||||||
|
const char *shelf_idname,
|
||||||
|
const char *catalog_path)
|
||||||
|
{
|
||||||
|
if (BKE_preferences_asset_shelf_settings_is_catalog_path_enabled(
|
||||||
|
userdef, shelf_idname, catalog_path))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bUserAssetShelfSettings *settings = BKE_preferences_asset_shelf_settings_ensure(userdef,
|
||||||
|
shelf_idname);
|
||||||
|
|
||||||
|
char *path_copy = BLI_strdup(catalog_path);
|
||||||
|
BLI_addtail(&settings->enabled_catalog_paths, BLI_genericNodeN(path_copy));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BKE_preferences_asset_shelf_settings_clear_enabled_catalog_paths(
|
||||||
|
bUserAssetShelfSettings *settings)
|
||||||
|
{
|
||||||
|
LISTBASE_FOREACH_MUTABLE (LinkData *, path_link, &settings->enabled_catalog_paths) {
|
||||||
|
MEM_freeN(path_link->data);
|
||||||
|
BLI_freelinkN(&settings->enabled_catalog_paths, path_link);
|
||||||
|
}
|
||||||
|
BLI_assert(BLI_listbase_is_empty(&settings->enabled_catalog_paths));
|
||||||
|
}
|
||||||
|
|
||||||
|
void BKE_preferences_asset_shelf_settings_clear_enabled_catalog_paths(const UserDef *userdef,
|
||||||
|
const char *shelf_idname)
|
||||||
|
{
|
||||||
|
bUserAssetShelfSettings *settings = BKE_preferences_asset_shelf_settings_get(userdef,
|
||||||
|
shelf_idname);
|
||||||
|
if (!settings) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BKE_preferences_asset_shelf_settings_clear_enabled_catalog_paths(settings);
|
||||||
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
|
@ -3439,6 +3439,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
|
||||||
BLO_read_list(reader, &user->script_directories);
|
BLO_read_list(reader, &user->script_directories);
|
||||||
BLO_read_list(reader, &user->asset_libraries);
|
BLO_read_list(reader, &user->asset_libraries);
|
||||||
BLO_read_list(reader, &user->extension_repos);
|
BLO_read_list(reader, &user->extension_repos);
|
||||||
|
BLO_read_list(reader, &user->asset_shelves_settings);
|
||||||
|
|
||||||
LISTBASE_FOREACH (wmKeyMap *, keymap, &user->user_keymaps) {
|
LISTBASE_FOREACH (wmKeyMap *, keymap, &user->user_keymaps) {
|
||||||
keymap->modal_items = nullptr;
|
keymap->modal_items = nullptr;
|
||||||
|
@ -3486,6 +3487,13 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
|
||||||
IDP_BlendDataRead(reader, &addon->prop);
|
IDP_BlendDataRead(reader, &addon->prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LISTBASE_FOREACH (bUserAssetShelfSettings *, shelf_settings, &user->asset_shelves_settings) {
|
||||||
|
BLO_read_list(reader, &shelf_settings->enabled_catalog_paths);
|
||||||
|
LISTBASE_FOREACH (LinkData *, path_link, &shelf_settings->enabled_catalog_paths) {
|
||||||
|
BLO_read_data_address(reader, &path_link->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* XXX */
|
/* XXX */
|
||||||
user->uifonts.first = user->uifonts.last = nullptr;
|
user->uifonts.first = user->uifonts.last = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -933,6 +933,15 @@ static void write_userdef(BlendWriter *writer, const UserDef *userdef)
|
||||||
LISTBASE_FOREACH (const bUserExtensionRepo *, repo_ref, &userdef->extension_repos) {
|
LISTBASE_FOREACH (const bUserExtensionRepo *, repo_ref, &userdef->extension_repos) {
|
||||||
BLO_write_struct(writer, bUserExtensionRepo, repo_ref);
|
BLO_write_struct(writer, bUserExtensionRepo, repo_ref);
|
||||||
}
|
}
|
||||||
|
LISTBASE_FOREACH (
|
||||||
|
const bUserAssetShelfSettings *, shelf_settings, &userdef->asset_shelves_settings)
|
||||||
|
{
|
||||||
|
BLO_write_struct(writer, bUserAssetShelfSettings, shelf_settings);
|
||||||
|
LISTBASE_FOREACH (const LinkData *, path_link, &shelf_settings->enabled_catalog_paths) {
|
||||||
|
BLO_write_struct(writer, LinkData, path_link);
|
||||||
|
BLO_write_string(writer, (const char *)path_link->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LISTBASE_FOREACH (const uiStyle *, style, &userdef->uistyles) {
|
LISTBASE_FOREACH (const uiStyle *, style, &userdef->uistyles) {
|
||||||
BLO_write_struct(writer, uiStyle, style);
|
BLO_write_struct(writer, uiStyle, style);
|
||||||
|
|
|
@ -674,9 +674,10 @@ static uiBut *add_tab_button(uiBlock &block, StringRefNull name)
|
||||||
return but;
|
return but;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_catalog_tabs(AssetShelfSettings &shelf_settings, uiLayout &layout)
|
static void add_catalog_tabs(AssetShelf &shelf, uiLayout &layout)
|
||||||
{
|
{
|
||||||
uiBlock *block = uiLayoutGetBlock(&layout);
|
uiBlock *block = uiLayoutGetBlock(&layout);
|
||||||
|
AssetShelfSettings &shelf_settings = shelf.settings;
|
||||||
|
|
||||||
/* "All" tab. */
|
/* "All" tab. */
|
||||||
{
|
{
|
||||||
|
@ -694,7 +695,7 @@ static void add_catalog_tabs(AssetShelfSettings &shelf_settings, uiLayout &layou
|
||||||
|
|
||||||
/* Regular catalog tabs. */
|
/* Regular catalog tabs. */
|
||||||
settings_foreach_enabled_catalog_path(
|
settings_foreach_enabled_catalog_path(
|
||||||
shelf_settings, [&shelf_settings, block](const asset_system::AssetCatalogPath &path) {
|
shelf, [&shelf_settings, block](const asset_system::AssetCatalogPath &path) {
|
||||||
uiBut *but = add_tab_button(*block, path.name());
|
uiBut *but = add_tab_button(*block, path.name());
|
||||||
|
|
||||||
UI_but_func_set(but, [&shelf_settings, path](bContext &C) {
|
UI_but_func_set(but, [&shelf_settings, path](bContext &C) {
|
||||||
|
@ -730,9 +731,8 @@ static void asset_shelf_header_draw(const bContext *C, Header *header)
|
||||||
uiItemS(layout);
|
uiItemS(layout);
|
||||||
|
|
||||||
PointerRNA shelf_ptr = active_shelf_ptr_from_context(C);
|
PointerRNA shelf_ptr = active_shelf_ptr_from_context(C);
|
||||||
AssetShelf *shelf = static_cast<AssetShelf *>(shelf_ptr.data);
|
if (AssetShelf *shelf = static_cast<AssetShelf *>(shelf_ptr.data)) {
|
||||||
if (shelf) {
|
add_catalog_tabs(*shelf, *layout);
|
||||||
add_catalog_tabs(shelf->settings, *layout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uiItemSpacer(layout);
|
uiItemSpacer(layout);
|
||||||
|
|
|
@ -52,20 +52,20 @@ void regiondata_blend_read_data(BlendDataReader *reader, RegionAssetShelf **shel
|
||||||
void settings_blend_write(BlendWriter *writer, const AssetShelfSettings &settings);
|
void settings_blend_write(BlendWriter *writer, const AssetShelfSettings &settings);
|
||||||
void settings_blend_read_data(BlendDataReader *reader, AssetShelfSettings &settings);
|
void settings_blend_read_data(BlendDataReader *reader, AssetShelfSettings &settings);
|
||||||
|
|
||||||
void settings_clear_enabled_catalogs(AssetShelfSettings &settings);
|
|
||||||
void settings_set_active_catalog(AssetShelfSettings &settings,
|
void settings_set_active_catalog(AssetShelfSettings &settings,
|
||||||
const asset_system::AssetCatalogPath &path);
|
const asset_system::AssetCatalogPath &path);
|
||||||
void settings_set_all_catalog_active(AssetShelfSettings &settings);
|
void settings_set_all_catalog_active(AssetShelfSettings &settings);
|
||||||
bool settings_is_active_catalog(const AssetShelfSettings &settings,
|
bool settings_is_active_catalog(const AssetShelfSettings &settings,
|
||||||
const asset_system::AssetCatalogPath &path);
|
const asset_system::AssetCatalogPath &path);
|
||||||
bool settings_is_all_catalog_active(const AssetShelfSettings &settings);
|
bool settings_is_all_catalog_active(const AssetShelfSettings &settings);
|
||||||
bool settings_is_catalog_path_enabled(const AssetShelfSettings &settings,
|
void settings_clear_enabled_catalogs(const AssetShelf &shelf);
|
||||||
|
bool settings_is_catalog_path_enabled(const AssetShelf &shelf,
|
||||||
const asset_system::AssetCatalogPath &path);
|
const asset_system::AssetCatalogPath &path);
|
||||||
void settings_set_catalog_path_enabled(AssetShelfSettings &settings,
|
void settings_set_catalog_path_enabled(const AssetShelf &shelf,
|
||||||
const asset_system::AssetCatalogPath &path);
|
const asset_system::AssetCatalogPath &path);
|
||||||
|
|
||||||
void settings_foreach_enabled_catalog_path(
|
void settings_foreach_enabled_catalog_path(
|
||||||
const AssetShelfSettings &settings,
|
const AssetShelf &shelf,
|
||||||
FunctionRef<void(const asset_system::AssetCatalogPath &catalog_path)> fn);
|
FunctionRef<void(const asset_system::AssetCatalogPath &catalog_path)> fn);
|
||||||
|
|
||||||
} // namespace blender::ed::asset::shelf
|
} // namespace blender::ed::asset::shelf
|
||||||
|
|
|
@ -74,7 +74,7 @@ class AssetCatalogSelectorTree : public ui::AbstractTreeView {
|
||||||
Item &build_catalog_items_recursive(ui::TreeViewOrItem &parent_view_item,
|
Item &build_catalog_items_recursive(ui::TreeViewOrItem &parent_view_item,
|
||||||
asset_system::AssetCatalogTreeItem &catalog_item) const
|
asset_system::AssetCatalogTreeItem &catalog_item) const
|
||||||
{
|
{
|
||||||
Item &view_item = parent_view_item.add_tree_item<Item>(catalog_item, shelf_settings_);
|
Item &view_item = parent_view_item.add_tree_item<Item>(catalog_item, shelf_);
|
||||||
|
|
||||||
catalog_item.foreach_child([&view_item, this](asset_system::AssetCatalogTreeItem &child) {
|
catalog_item.foreach_child([&view_item, this](asset_system::AssetCatalogTreeItem &child) {
|
||||||
build_catalog_items_recursive(view_item, child);
|
build_catalog_items_recursive(view_item, child);
|
||||||
|
@ -92,11 +92,11 @@ class AssetCatalogSelectorTree : public ui::AbstractTreeView {
|
||||||
char catalog_path_enabled_ = false;
|
char catalog_path_enabled_ = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Item(asset_system::AssetCatalogTreeItem &catalog_item, AssetShelfSettings &shelf_settings)
|
Item(asset_system::AssetCatalogTreeItem &catalog_item, AssetShelf &shelf)
|
||||||
: ui::BasicTreeViewItem(catalog_item.get_name()),
|
: ui::BasicTreeViewItem(catalog_item.get_name()),
|
||||||
catalog_item_(catalog_item),
|
catalog_item_(catalog_item),
|
||||||
catalog_path_enabled_(
|
catalog_path_enabled_(
|
||||||
settings_is_catalog_path_enabled(shelf_settings, catalog_item.catalog_path()))
|
settings_is_catalog_path_enabled(shelf, catalog_item.catalog_path()))
|
||||||
{
|
{
|
||||||
disable_activatable();
|
disable_activatable();
|
||||||
}
|
}
|
||||||
|
@ -169,11 +169,11 @@ class AssetCatalogSelectorTree : public ui::AbstractTreeView {
|
||||||
|
|
||||||
void AssetCatalogSelectorTree::update_shelf_settings_from_enabled_catalogs()
|
void AssetCatalogSelectorTree::update_shelf_settings_from_enabled_catalogs()
|
||||||
{
|
{
|
||||||
settings_clear_enabled_catalogs(shelf_settings_);
|
settings_clear_enabled_catalogs(shelf_);
|
||||||
foreach_item([this](ui::AbstractTreeViewItem &view_item) {
|
foreach_item([this](ui::AbstractTreeViewItem &view_item) {
|
||||||
const auto &selector_tree_item = dynamic_cast<AssetCatalogSelectorTree::Item &>(view_item);
|
const auto &selector_tree_item = dynamic_cast<AssetCatalogSelectorTree::Item &>(view_item);
|
||||||
if (selector_tree_item.is_catalog_path_enabled()) {
|
if (selector_tree_item.is_catalog_path_enabled()) {
|
||||||
settings_set_catalog_path_enabled(shelf_settings_, selector_tree_item.catalog_path());
|
settings_set_catalog_path_enabled(shelf_, selector_tree_item.catalog_path());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "BLI_string.h"
|
#include "BLI_string.h"
|
||||||
#include "BLI_string_ref.hh"
|
#include "BLI_string_ref.hh"
|
||||||
|
|
||||||
|
#include "BKE_preferences.h"
|
||||||
|
|
||||||
#include "asset_shelf.hh"
|
#include "asset_shelf.hh"
|
||||||
|
|
||||||
using namespace blender;
|
using namespace blender;
|
||||||
|
@ -45,18 +47,11 @@ AssetShelfSettings &AssetShelfSettings::operator=(const AssetShelfSettings &othe
|
||||||
if (active_catalog_path) {
|
if (active_catalog_path) {
|
||||||
active_catalog_path = BLI_strdup(other.active_catalog_path);
|
active_catalog_path = BLI_strdup(other.active_catalog_path);
|
||||||
}
|
}
|
||||||
BLI_listbase_clear(&enabled_catalog_paths);
|
|
||||||
|
|
||||||
LISTBASE_FOREACH (LinkData *, catalog_path_item, &other.enabled_catalog_paths) {
|
|
||||||
LinkData *new_path_item = BLI_genericNodeN(BLI_strdup((char *)catalog_path_item->data));
|
|
||||||
BLI_addtail(&enabled_catalog_paths, new_path_item);
|
|
||||||
}
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetShelfSettings::~AssetShelfSettings()
|
AssetShelfSettings::~AssetShelfSettings()
|
||||||
{
|
{
|
||||||
shelf::settings_clear_enabled_catalogs(*this);
|
|
||||||
MEM_delete(active_catalog_path);
|
MEM_delete(active_catalog_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,33 +60,14 @@ namespace blender::ed::asset::shelf {
|
||||||
void settings_blend_write(BlendWriter *writer, const AssetShelfSettings &settings)
|
void settings_blend_write(BlendWriter *writer, const AssetShelfSettings &settings)
|
||||||
{
|
{
|
||||||
BLO_write_struct(writer, AssetShelfSettings, &settings);
|
BLO_write_struct(writer, AssetShelfSettings, &settings);
|
||||||
|
|
||||||
LISTBASE_FOREACH (LinkData *, catalog_path_item, &settings.enabled_catalog_paths) {
|
|
||||||
BLO_write_struct(writer, LinkData, catalog_path_item);
|
|
||||||
BLO_write_string(writer, (const char *)catalog_path_item->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
BLO_write_string(writer, settings.active_catalog_path);
|
BLO_write_string(writer, settings.active_catalog_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_blend_read_data(BlendDataReader *reader, AssetShelfSettings &settings)
|
void settings_blend_read_data(BlendDataReader *reader, AssetShelfSettings &settings)
|
||||||
{
|
{
|
||||||
BLO_read_list(reader, &settings.enabled_catalog_paths);
|
|
||||||
LISTBASE_FOREACH (LinkData *, catalog_path_item, &settings.enabled_catalog_paths) {
|
|
||||||
BLO_read_data_address(reader, &catalog_path_item->data);
|
|
||||||
}
|
|
||||||
BLO_read_data_address(reader, &settings.active_catalog_path);
|
BLO_read_data_address(reader, &settings.active_catalog_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_clear_enabled_catalogs(AssetShelfSettings &settings)
|
|
||||||
{
|
|
||||||
LISTBASE_FOREACH_MUTABLE (LinkData *, catalog_path_item, &settings.enabled_catalog_paths) {
|
|
||||||
MEM_freeN(catalog_path_item->data);
|
|
||||||
BLI_freelinkN(&settings.enabled_catalog_paths, catalog_path_item);
|
|
||||||
}
|
|
||||||
BLI_assert(BLI_listbase_is_empty(&settings.enabled_catalog_paths));
|
|
||||||
}
|
|
||||||
|
|
||||||
void settings_set_active_catalog(AssetShelfSettings &settings,
|
void settings_set_active_catalog(AssetShelfSettings &settings,
|
||||||
const asset_system::AssetCatalogPath &path)
|
const asset_system::AssetCatalogPath &path)
|
||||||
{
|
{
|
||||||
|
@ -116,30 +92,40 @@ bool settings_is_all_catalog_active(const AssetShelfSettings &settings)
|
||||||
return !settings.active_catalog_path || !settings.active_catalog_path[0];
|
return !settings.active_catalog_path || !settings.active_catalog_path[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool settings_is_catalog_path_enabled(const AssetShelfSettings &settings,
|
void settings_clear_enabled_catalogs(const AssetShelf &shelf)
|
||||||
const asset_system::AssetCatalogPath &path)
|
|
||||||
{
|
{
|
||||||
LISTBASE_FOREACH (LinkData *, catalog_path_item, &settings.enabled_catalog_paths) {
|
BKE_preferences_asset_shelf_settings_clear_enabled_catalog_paths(&U, shelf.idname);
|
||||||
if (StringRef((const char *)catalog_path_item->data) == path.str()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_set_catalog_path_enabled(AssetShelfSettings &settings,
|
bool settings_is_catalog_path_enabled(const AssetShelf &shelf,
|
||||||
|
const asset_system::AssetCatalogPath &path)
|
||||||
|
{
|
||||||
|
return BKE_preferences_asset_shelf_settings_is_catalog_path_enabled(
|
||||||
|
&U, shelf.idname, path.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void settings_set_catalog_path_enabled(const AssetShelf &shelf,
|
||||||
const asset_system::AssetCatalogPath &path)
|
const asset_system::AssetCatalogPath &path)
|
||||||
{
|
{
|
||||||
char *path_copy = BLI_strdupn(path.c_str(), path.length());
|
if (BKE_preferences_asset_shelf_settings_ensure_catalog_path_enabled(
|
||||||
BLI_addtail(&settings.enabled_catalog_paths, BLI_genericNodeN(path_copy));
|
&U, shelf.idname, path.c_str()))
|
||||||
|
{
|
||||||
|
U.runtime.is_dirty = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_foreach_enabled_catalog_path(
|
void settings_foreach_enabled_catalog_path(
|
||||||
const AssetShelfSettings &settings,
|
const AssetShelf &shelf,
|
||||||
FunctionRef<void(const asset_system::AssetCatalogPath &catalog_path)> fn)
|
FunctionRef<void(const asset_system::AssetCatalogPath &catalog_path)> fn)
|
||||||
{
|
{
|
||||||
LISTBASE_FOREACH (LinkData *, catalog_path_item, &settings.enabled_catalog_paths) {
|
const bUserAssetShelfSettings *pref_settings = BKE_preferences_asset_shelf_settings_get(
|
||||||
fn(asset_system::AssetCatalogPath((char *)catalog_path_item->data));
|
&U, shelf.idname);
|
||||||
|
if (!pref_settings) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LISTBASE_FOREACH (LinkData *, path_link, &pref_settings->enabled_catalog_paths) {
|
||||||
|
fn(asset_system::AssetCatalogPath((char *)path_link->data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -786,7 +786,6 @@ typedef struct AssetShelfSettings {
|
||||||
|
|
||||||
AssetLibraryReference asset_library_reference;
|
AssetLibraryReference asset_library_reference;
|
||||||
|
|
||||||
ListBase enabled_catalog_paths; /* #LinkData */
|
|
||||||
/** If not set (null or empty string), all assets will be displayed ("All" catalog behavior). */
|
/** If not set (null or empty string), all assets will be displayed ("All" catalog behavior). */
|
||||||
const char *active_catalog_path;
|
const char *active_catalog_path;
|
||||||
|
|
||||||
|
|
|
@ -40,4 +40,16 @@
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/** \name bUserExtensionRepo Struct
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
#define _DNA_DEFAULT_bUserAssetShelfSettings \
|
||||||
|
{ \
|
||||||
|
.shelf_idname = {'\0'}, \
|
||||||
|
.enabled_catalog_paths = {NULL, NULL}, \
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
|
@ -739,6 +739,20 @@ typedef struct bUserScriptDirectory {
|
||||||
char dir_path[768]; /* FILE_MAXDIR */
|
char dir_path[768]; /* FILE_MAXDIR */
|
||||||
} bUserScriptDirectory;
|
} bUserScriptDirectory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings for an asset shelf, stored in the Preferences. Most settings are still stored in the
|
||||||
|
* asset shelf instance in #AssetShelfSettings. This is just for the options that should be shared
|
||||||
|
* as Preferences.
|
||||||
|
*/
|
||||||
|
typedef struct bUserAssetShelfSettings {
|
||||||
|
struct bUserAssetShelfSettings *next, *prev;
|
||||||
|
|
||||||
|
/** Identifier that matches the #AssetShelfType.idname of the shelf these settings apply to. */
|
||||||
|
char shelf_idname[64]; /* MAX_NAME */
|
||||||
|
|
||||||
|
ListBase enabled_catalog_paths; /* #LinkData */
|
||||||
|
} bUserAssetShelfSettings;
|
||||||
|
|
||||||
typedef struct UserDef {
|
typedef struct UserDef {
|
||||||
DNA_DEFINE_CXX_METHODS(UserDef)
|
DNA_DEFINE_CXX_METHODS(UserDef)
|
||||||
|
|
||||||
|
@ -861,6 +875,7 @@ typedef struct UserDef {
|
||||||
struct ListBase asset_libraries;
|
struct ListBase asset_libraries;
|
||||||
/** #bUserExtensionRepo */
|
/** #bUserExtensionRepo */
|
||||||
struct ListBase extension_repos;
|
struct ListBase extension_repos;
|
||||||
|
struct ListBase asset_shelves_settings; /* #bUserAssetShelfSettings */
|
||||||
|
|
||||||
char keyconfigstr[64];
|
char keyconfigstr[64];
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,7 @@ SDNA_DEFAULT_DECL_STRUCT(Tex);
|
||||||
/* DNA_userdef_types.h */
|
/* DNA_userdef_types.h */
|
||||||
SDNA_DEFAULT_DECL_STRUCT(bUserAssetLibrary);
|
SDNA_DEFAULT_DECL_STRUCT(bUserAssetLibrary);
|
||||||
SDNA_DEFAULT_DECL_STRUCT(bUserExtensionRepo);
|
SDNA_DEFAULT_DECL_STRUCT(bUserExtensionRepo);
|
||||||
|
SDNA_DEFAULT_DECL_STRUCT(bUserAssetShelfSettings);
|
||||||
|
|
||||||
/* DNA_view3d_defaults.h */
|
/* DNA_view3d_defaults.h */
|
||||||
SDNA_DEFAULT_DECL_STRUCT(View3D);
|
SDNA_DEFAULT_DECL_STRUCT(View3D);
|
||||||
|
@ -476,6 +477,7 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
|
||||||
SDNA_DEFAULT_DECL_EX(WalkNavigation, UserDef.walk_navigation),
|
SDNA_DEFAULT_DECL_EX(WalkNavigation, UserDef.walk_navigation),
|
||||||
SDNA_DEFAULT_DECL(bUserAssetLibrary),
|
SDNA_DEFAULT_DECL(bUserAssetLibrary),
|
||||||
SDNA_DEFAULT_DECL(bUserExtensionRepo),
|
SDNA_DEFAULT_DECL(bUserExtensionRepo),
|
||||||
|
SDNA_DEFAULT_DECL(bUserAssetShelfSettings),
|
||||||
|
|
||||||
/* DNA_view3d_defaults.h */
|
/* DNA_view3d_defaults.h */
|
||||||
SDNA_DEFAULT_DECL(View3D),
|
SDNA_DEFAULT_DECL(View3D),
|
||||||
|
|
Loading…
Reference in New Issue