UI: Asset Shelf (Experimental Feature) #104831

Closed
Julian Eisel wants to merge 399 commits from asset-shelf into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
7 changed files with 64 additions and 4 deletions
Showing only changes of commit 2acf304e14 - Show all commits

View File

@ -9,6 +9,7 @@ if "bpy" in locals():
del reload
_modules = [
"asset_shelf",
"node_add_menu",
"node_add_menu_geometry",
"properties_animviz",

View File

@ -0,0 +1,34 @@
# SPDX-License-Identifier: GPL-2.0-or-later
JulianEisel marked this conversation as resolved Outdated

Use updated copyright convention SPDX-FileCopyrightText.

# SPDX-FileCopyrightText: 2023 Blender Foundation
#
# SPDX-License-Identifier: GPL-2.0-or-later
Use updated copyright convention `SPDX-FileCopyrightText`. ``` # SPDX-FileCopyrightText: 2023 Blender Foundation # # SPDX-License-Identifier: GPL-2.0-or-later ```
import bpy
from bpy.types import (
Panel,
)
class ASSETSHELF_PT_display(Panel):
bl_label = "Display Settings"
bl_space_type = 'PREFERENCES'
bl_region_type = 'HEADER'
def draw(self, context):
layout = self.layout
shelf_settings = context.asset_shelf_settings
layout.prop(shelf_settings, "show_names")
@classmethod
def poll(cls, context):
return context.asset_shelf_settings is not None
classes = (
ASSETSHELF_PT_display,
)
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)

View File

@ -311,6 +311,10 @@ static void asset_shelf_footer_draw(const bContext *C, Header *header)
if (shelf_settings) {
add_catalog_toggle_buttons(*shelf_settings, *layout);
}
uiItemSpacer(layout);
uiItemPopoverPanel(layout, C, "ASSETSHELF_PT_display", "", ICON_IMGDISPLAY);
}
void ED_asset_shelf_footer_register(ARegionType *region_type,

View File

@ -157,11 +157,10 @@ void uiTemplateAssetShelf(uiLayout *layout,
uiLayoutSetScaleX(layout, 1.0f);
uiLayoutSetScaleY(layout, 1.0f);
const bool show_names = true;
const bool show_names = shelf_settings->display_flag & ASSETSHELF_SHOW_NAMES;
const int height = uiLayoutGetRootHeight(layout) - UI_style_get_dpi()->boxspace * 2;
/* Width is derived from the height. It's the height without the space for the name (if there is
* any). */
const int width = height - (show_names ? 0 : UI_UNIT_Y);
/* Keep the size square. */
const int width = height;
uiLayout *box = uiLayoutBox(layout);
uiLayout *row = uiLayoutRow(box, false);

View File

@ -7,6 +7,8 @@
#pragma once
#include "BLI_utildefines.h"
#include "DNA_defs.h"
#include "DNA_listBase.h"
#include "DNA_vec_types.h"
@ -765,8 +767,17 @@ typedef struct AssetShelfSettings {
ListBase enabled_catalog_paths; /* #LinkData */
/** If not set (null or empty string), all assets will be displayed ("All" catalog behavior). */
const char *active_catalog_path;
short display_flag; /* #AssetShelfSettings_DisplayFlag */
char _pad1[6];
} AssetShelfSettings;
/* #AssetShelfSettings.display_flag */
typedef enum AssetShelfSettings_DisplayFlag {
ASSETSHELF_SHOW_NAMES = (1 << 0),
} AssetShelfSettings_DisplayFlag;
ENUM_OPERATORS(AssetShelfSettings_DisplayFlag, ASSETSHELF_SHOW_NAMES);
#ifdef __cplusplus
}
#endif

View File

@ -2091,6 +2091,16 @@ static void rna_def_asset_shelf_settings(BlenderRNA *brna)
{
StructRNA *srna = RNA_def_struct(brna, "AssetShelfSettings", NULL);
RNA_def_struct_ui_text(srna, "Asset Shelf Settings", "");
PropertyRNA *prop;
prop = RNA_def_property(srna, "show_names", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "display_flag", ASSETSHELF_SHOW_NAMES);
RNA_def_property_ui_text(
prop,
"Show Names",
"Show the asset name together with the preview. Otherwise only the preview will be visible");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_ASSET_SHELF, NULL);
}
void RNA_def_ui(BlenderRNA *brna)

View File

@ -485,6 +485,7 @@ typedef struct wmNotifier {
#define ND_SPACE_CLIP (20 << 16)
#define ND_SPACE_FILE_PREVIEW (21 << 16)
#define ND_SPACE_SPREADSHEET (22 << 16)
/* Not a space itself, but a part of another space. */
#define ND_SPACE_ASSET_SHELF (23 << 16)
/* NC_ASSET */