Asset Browser: Adjust header pulldowns to be Asset Browser specific
So far the Asset Browser just showed the same menus as the File Browser. Not all of their entries made sense for the Asset Browser though. I decided to just give them entirely different classes to avoid confusing if-else checks everywhere. I think the code duplication this adds is a minor issue, it's better to keep things seperated clearly IMO. * View menu: Add "Asset Details" toggle for the sidebar region. * View menu: Remove recursion sub-menu * View menu: Remove "File Path" region toggle, which doesn't apply for the Asset Browser. Differential Revision: https://developer.blender.org/D12057
This commit is contained in:
parent
0e4f7b4a4b
commit
d8bf332f86
Notes:
blender-bot
2023-02-14 09:09:43 +01:00
Referenced by issue #90451, The removal of "Recursion" in asset browser removes functionality. Referenced by issue #90297, Remove Inapplicable Menus, Popups & Options Referenced by issue #89987, Recurse Into Nested Folders of an Asset Library
|
@ -84,12 +84,12 @@ class FILEBROWSER_HT_header(Header):
|
|||
if space_data.active_operator is None:
|
||||
layout.template_header()
|
||||
|
||||
FILEBROWSER_MT_editor_menus.draw_collapsible(context, layout)
|
||||
|
||||
if SpaceAssetInfo.is_asset_browser(space_data):
|
||||
ASSETBROWSER_MT_editor_menus.draw_collapsible(context, layout)
|
||||
layout.separator()
|
||||
self.draw_asset_browser_buttons(context)
|
||||
else:
|
||||
FILEBROWSER_MT_editor_menus.draw_collapsible(context, layout)
|
||||
layout.separator_spacer()
|
||||
|
||||
if not context.screen.show_statusbar:
|
||||
|
@ -477,7 +477,14 @@ class FILEBROWSER_PT_directory_path(Panel):
|
|||
).region_type = 'TOOL_PROPS'
|
||||
|
||||
|
||||
class FILEBROWSER_MT_editor_menus(Menu):
|
||||
class FileBrowserMenu:
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
space_data = context.space_data
|
||||
return space_data and space_data.type == 'FILE_BROWSER' and space_data.browse_mode == 'FILES'
|
||||
|
||||
|
||||
class FILEBROWSER_MT_editor_menus(FileBrowserMenu, Menu):
|
||||
bl_idname = "FILEBROWSER_MT_editor_menus"
|
||||
bl_label = ""
|
||||
|
||||
|
@ -488,7 +495,7 @@ class FILEBROWSER_MT_editor_menus(Menu):
|
|||
layout.menu("FILEBROWSER_MT_select")
|
||||
|
||||
|
||||
class FILEBROWSER_MT_view(Menu):
|
||||
class FILEBROWSER_MT_view(FileBrowserMenu, Menu):
|
||||
bl_label = "View"
|
||||
|
||||
def draw(self, context):
|
||||
|
@ -510,7 +517,7 @@ class FILEBROWSER_MT_view(Menu):
|
|||
layout.menu("INFO_MT_area")
|
||||
|
||||
|
||||
class FILEBROWSER_MT_select(Menu):
|
||||
class FILEBROWSER_MT_select(FileBrowserMenu, Menu):
|
||||
bl_label = "Select"
|
||||
|
||||
def draw(self, _context):
|
||||
|
@ -572,6 +579,60 @@ class FILEBROWSER_MT_context_menu(Menu):
|
|||
layout.prop_menu_enum(params, "sort_method")
|
||||
|
||||
|
||||
class AssetBrowserMenu:
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
from bpy_extras.asset_utils import SpaceAssetInfo
|
||||
return SpaceAssetInfo.is_asset_browser_poll(context)
|
||||
|
||||
|
||||
class ASSETBROWSER_MT_editor_menus(AssetBrowserMenu, Menu):
|
||||
bl_idname = "ASSETBROWSER_MT_editor_menus"
|
||||
bl_label = ""
|
||||
|
||||
def draw(self, _context):
|
||||
layout = self.layout
|
||||
|
||||
layout.menu("ASSETBROWSER_MT_view")
|
||||
layout.menu("ASSETBROWSER_MT_select")
|
||||
|
||||
|
||||
class ASSETBROWSER_MT_view(AssetBrowserMenu, Menu):
|
||||
bl_label = "View"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
st = context.space_data
|
||||
params = st.params
|
||||
|
||||
layout.prop(st, "show_region_toolbar", text="Source List")
|
||||
layout.prop(st, "show_region_tool_props", text="Asset Details")
|
||||
layout.operator("file.view_selected")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.prop_menu_enum(params, "display_size")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.menu("INFO_MT_area")
|
||||
|
||||
|
||||
class ASSETBROWSER_MT_select(AssetBrowserMenu, Menu):
|
||||
bl_label = "Select"
|
||||
|
||||
def draw(self, _context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("file.select_all", text="All").action = 'SELECT'
|
||||
layout.operator("file.select_all", text="None").action = 'DESELECT'
|
||||
layout.operator("file.select_all", text="Inverse").action = 'INVERT'
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("file.select_box")
|
||||
|
||||
|
||||
class ASSETBROWSER_PT_navigation_bar(asset_utils.AssetBrowserPanel, Panel):
|
||||
bl_label = "Asset Navigation"
|
||||
bl_region_type = 'TOOLS'
|
||||
|
@ -694,6 +755,9 @@ classes = (
|
|||
FILEBROWSER_MT_view,
|
||||
FILEBROWSER_MT_select,
|
||||
FILEBROWSER_MT_context_menu,
|
||||
ASSETBROWSER_MT_editor_menus,
|
||||
ASSETBROWSER_MT_view,
|
||||
ASSETBROWSER_MT_select,
|
||||
ASSETBROWSER_PT_navigation_bar,
|
||||
ASSETBROWSER_PT_metadata,
|
||||
ASSETBROWSER_PT_metadata_preview,
|
||||
|
|
|
@ -778,6 +778,19 @@ static void rna_Space_show_region_toolbar_update(bContext *C, PointerRNA *ptr)
|
|||
rna_Space_bool_from_region_flag_update_by_type(C, ptr, RGN_TYPE_TOOLS, RGN_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
static bool rna_Space_show_region_tool_props_get(PointerRNA *ptr)
|
||||
{
|
||||
return !rna_Space_bool_from_region_flag_get_by_type(ptr, RGN_TYPE_TOOL_PROPS, RGN_FLAG_HIDDEN);
|
||||
}
|
||||
static void rna_Space_show_region_tool_props_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
rna_Space_bool_from_region_flag_set_by_type(ptr, RGN_TYPE_TOOL_PROPS, RGN_FLAG_HIDDEN, !value);
|
||||
}
|
||||
static void rna_Space_show_region_tool_props_update(bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
rna_Space_bool_from_region_flag_update_by_type(C, ptr, RGN_TYPE_TOOL_PROPS, RGN_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
/* Channels Region. */
|
||||
static bool rna_Space_show_region_channels_get(PointerRNA *ptr)
|
||||
{
|
||||
|
@ -3196,6 +3209,10 @@ static void rna_def_space_generic_show_region_toggles(StructRNA *srna, int regio
|
|||
region_type_mask &= ~(1 << RGN_TYPE_TOOLS);
|
||||
DEF_SHOW_REGION_PROPERTY(show_region_toolbar, "Toolbar", "");
|
||||
}
|
||||
if (region_type_mask & (1 << RGN_TYPE_TOOL_PROPS)) {
|
||||
region_type_mask &= ~(1 << RGN_TYPE_TOOL_PROPS);
|
||||
DEF_SHOW_REGION_PROPERTY(show_region_tool_props, "Toolbar", "");
|
||||
}
|
||||
if (region_type_mask & (1 << RGN_TYPE_CHANNELS)) {
|
||||
region_type_mask &= ~(1 << RGN_TYPE_CHANNELS);
|
||||
DEF_SHOW_REGION_PROPERTY(show_region_channels, "Channels", "");
|
||||
|
@ -6546,7 +6563,8 @@ static void rna_def_space_filebrowser(BlenderRNA *brna)
|
|||
RNA_def_struct_sdna(srna, "SpaceFile");
|
||||
RNA_def_struct_ui_text(srna, "Space File Browser", "File browser space data");
|
||||
|
||||
rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_TOOLS) | (1 << RGN_TYPE_UI));
|
||||
rna_def_space_generic_show_region_toggles(
|
||||
srna, (1 << RGN_TYPE_TOOLS) | (1 << RGN_TYPE_UI) | (1 << RGN_TYPE_TOOL_PROPS));
|
||||
|
||||
prop = RNA_def_property(srna, "browse_mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, rna_enum_space_file_browse_mode_items);
|
||||
|
|
Loading…
Reference in New Issue