UI: Support asset shelves in 3D Views #110767
@ -309,6 +309,10 @@ const bTheme U_theme_default = {
|
||||
.back = RGBA(0x3d3d3dff),
|
||||
.sub_back = RGBA(0x0000001f),
|
||||
},
|
||||
.asset_shelf = {
|
||||
.header_back = RGBA(0x1d1d1dff),
|
||||
.back = RGBA(0x303030ff),
|
||||
},
|
||||
.grid = RGBA(0x54545480),
|
||||
.wire = RGBA(0x000000ff),
|
||||
.wire_edit = RGBA(0x000000ff),
|
||||
|
@ -1269,10 +1269,13 @@ class VIEW3D_MT_view(Menu):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
view = context.space_data
|
||||
prefs = context.preferences
|
||||
|
||||
layout.prop(view, "show_region_toolbar")
|
||||
layout.prop(view, "show_region_ui")
|
||||
layout.prop(view, "show_region_tool_header")
|
||||
if prefs.experimental.use_asset_shelf:
|
||||
layout.prop(view, "show_region_asset_shelf")
|
||||
layout.prop(view, "show_region_hud")
|
||||
|
||||
layout.separator()
|
||||
|
@ -554,4 +554,36 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!DNA_struct_find(fd->filesdna, "RegionAssetShelf")) {
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
if (sl->spacetype != SPACE_VIEW3D) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
|
||||
&sl->regionbase;
|
||||
|
||||
if (ARegion *new_shelf_region = do_versions_add_region_if_not_found(
|
||||
regionbase,
|
||||
RGN_TYPE_ASSET_SHELF,
|
||||
"asset shelf for view3d (versioning)",
|
||||
RGN_TYPE_TOOL_HEADER))
|
||||
{
|
||||
new_shelf_region->alignment = RGN_ALIGN_BOTTOM;
|
||||
}
|
||||
if (ARegion *new_shelf_header = do_versions_add_region_if_not_found(
|
||||
regionbase,
|
||||
RGN_TYPE_ASSET_SHELF_HEADER,
|
||||
"asset shelf header for view3d (versioning)",
|
||||
RGN_TYPE_ASSET_SHELF))
|
||||
{
|
||||
new_shelf_header->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +110,12 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
|
||||
FROM_DEFAULT_V4_UCHAR(space_node.node_zone_repeat);
|
||||
}
|
||||
|
||||
/* TODO version bump. */
|
||||
{
|
||||
FROM_DEFAULT_V4_UCHAR(space_view3d.asset_shelf.back);
|
||||
FROM_DEFAULT_V4_UCHAR(space_view3d.asset_shelf.header_back);
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
set(INC
|
||||
../include
|
||||
../asset
|
||||
../../asset_system
|
||||
../../blenfont
|
||||
../../blenkernel
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "BKE_viewer_path.h"
|
||||
#include "BKE_workspace.h"
|
||||
|
||||
#include "ED_asset_shelf.h"
|
||||
#include "ED_geometry.h"
|
||||
#include "ED_object.h"
|
||||
#include "ED_outliner.h"
|
||||
@ -279,6 +280,19 @@ static SpaceLink *view3d_create(const ScrArea * /*area*/, const Scene *scene)
|
||||
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
|
||||
region->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
|
||||
|
||||
/* asset shelf */
|
||||
region = MEM_cnew<ARegion>("asset shelf for view3d");
|
||||
|
||||
BLI_addtail(&v3d->regionbase, region);
|
||||
region->regiontype = RGN_TYPE_ASSET_SHELF;
|
||||
region->alignment = RGN_ALIGN_BOTTOM;
|
||||
|
||||
/* asset shelf header */
|
||||
region = MEM_cnew<ARegion>("asset shelf header for view3d");
|
||||
BLI_addtail(&v3d->regionbase, region);
|
||||
region->regiontype = RGN_TYPE_ASSET_SHELF_HEADER;
|
||||
region->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
|
||||
|
||||
/* tool shelf */
|
||||
region = MEM_cnew<ARegion>("toolshelf for view3d");
|
||||
|
||||
@ -1904,6 +1918,15 @@ static void view3d_tools_region_draw(const bContext *C, ARegion *region)
|
||||
ED_region_panels_ex(C, region, contexts);
|
||||
}
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void view3d_asset_shelf_region_init(wmWindowManager *wm, ARegion *region)
|
||||
{
|
||||
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0);
|
||||
WM_event_add_keymap_handler(®ion->handlers, keymap);
|
||||
|
||||
ED_asset_shelf_region_init(wm, region);
|
||||
}
|
||||
|
||||
/* area (not region) level listener */
|
||||
static void space_view3d_listener(const wmSpaceTypeListenerParams *params)
|
||||
{
|
||||
@ -2213,6 +2236,33 @@ void ED_spacetype_view3d()
|
||||
art->draw = view3d_header_region_draw;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: asset shelf */
|
||||
art = MEM_cnew<ARegionType>("spacetype view3d asset shelf region");
|
||||
art->regionid = RGN_TYPE_ASSET_SHELF;
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_ASSET_SHELF | ED_KEYMAP_FRAMES;
|
||||
art->duplicate = ED_asset_shelf_region_duplicate;
|
||||
art->free = ED_asset_shelf_region_free;
|
||||
art->listener = ED_asset_shelf_region_listen;
|
||||
art->poll = ED_asset_shelf_regions_poll;
|
||||
art->snap_size = ED_asset_shelf_region_snap;
|
||||
art->context = ED_asset_shelf_context;
|
||||
art->init = view3d_asset_shelf_region_init;
|
||||
art->layout = ED_asset_shelf_region_layout;
|
||||
art->draw = ED_asset_shelf_region_draw;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: asset shelf header */
|
||||
art = MEM_cnew<ARegionType>("spacetype view3d asset shelf header region");
|
||||
art->regionid = RGN_TYPE_ASSET_SHELF_HEADER;
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_ASSET_SHELF | ED_KEYMAP_VIEW2D | ED_KEYMAP_FOOTER;
|
||||
art->init = ED_asset_shelf_header_region_init;
|
||||
art->poll = ED_asset_shelf_regions_poll;
|
||||
art->draw = ED_asset_shelf_header_region;
|
||||
art->listener = ED_asset_shelf_header_region_listen;
|
||||
art->context = ED_asset_shelf_context;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
ED_asset_shelf_header_regiontype_register(art, SPACE_VIEW3D);
|
||||
|
||||
/* regions: hud */
|
||||
art = ED_area_type_hud(st->spaceid);
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
@ -4955,7 +4955,8 @@ static void rna_def_space_view3d(BlenderRNA *brna)
|
||||
|
||||
rna_def_space_generic_show_region_toggles(srna,
|
||||
((1 << RGN_TYPE_TOOL_HEADER) | (1 << RGN_TYPE_TOOLS) |
|
||||
(1 << RGN_TYPE_UI) | (1 << RGN_TYPE_HUD)));
|
||||
(1 << RGN_TYPE_UI) | (1 << RGN_TYPE_HUD) |
|
||||
(1 << RGN_TYPE_ASSET_SHELF)));
|
||||
|
||||
prop = RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_EDITABLE);
|
||||
|
@ -1968,7 +1968,7 @@ static void rna_def_userdef_theme_asset_shelf(BlenderRNA *brna)
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
|
||||
}
|
||||
|
||||
static void UNUSED_FUNCTION(rna_def_userdef_theme_spaces_asset_shelf_main)(StructRNA *srna)
|
||||
static void rna_def_userdef_theme_spaces_asset_shelf_main(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop = RNA_def_property(srna, "asset_shelf", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
||||
@ -2487,6 +2487,8 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Object Origin Size", "Diameter in pixels for object/light origin display");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
|
||||
|
||||
rna_def_userdef_theme_spaces_asset_shelf_main(srna);
|
||||
}
|
||||
|
||||
static void rna_def_userdef_theme_space_graph(BlenderRNA *brna)
|
||||
|
Loading…
Reference in New Issue
Block a user