From 23d2e77a54f4f813d7ee38ddb06c14ecc0943e4e Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 16 Jun 2022 11:29:20 +0200 Subject: UI: Add initial "grid view" Part of T98560. See https://wiki.blender.org/wiki/Source/Interface/Views Adds all the basic functionality needed for grid views. They display items in a grid of rows and columns, typically with a preview image and a label underneath. Think of the main region in the Asset Browser. Current features: - Active item - Notifier listening (also added this to the tree view) - Performance: Skip adding buttons that are not scrolled into view (solves performance problems for big asset libraries, for example). - Custom item size - Preview items (items that draw a preview with a label underneath) - Margins between items scale so the entire region width is filled with column, rather than leaving a big empty block at the right if there's not enough space for another column (like the File and current Asset Browser does it). - "Data-View Item" theme colors. Not shown in the UI yet. No user visible changes expected since the grid views aren't used for anything yet. This was developed as part of a rewrite of the Asset Browser UI (`asset-browser-grid-view` branch), see T95653. There's no reason to keep this part in a branch, continuing development in master makes things easier. Grid and tree views have a lot of very similar code, so I'm planning to unify them to a degree. I kept things separate for the start to first find out how much and what exactly makes sense to override. --- source/blender/editors/space_file/filesel.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/editors/space_file') diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index ce36e3e4e4f..e42e1e98660 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -983,6 +983,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *region) if (params->display == FILE_IMGDISPLAY) { const float pad_fac = compact ? 0.15f : 0.3f; + /* Matches UI_preview_tile_size_x()/_y() by default. */ layout->prv_w = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_X; layout->prv_h = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_Y; layout->tile_border_x = pad_fac * UI_UNIT_X; @@ -1009,6 +1010,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *region) else if (params->display == FILE_VERTICALDISPLAY) { int rowcount; + /* Matches UI_preview_tile_size_x()/_y() by default. */ layout->prv_w = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_X; layout->prv_h = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_Y; layout->tile_border_x = 0.4f * UI_UNIT_X; @@ -1030,6 +1032,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *region) layout->flag = FILE_LAYOUT_VER; } else if (params->display == FILE_HORIZONTALDISPLAY) { + /* Matches UI_preview_tile_size_x()/_y() by default. */ layout->prv_w = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_X; layout->prv_h = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_Y; layout->tile_border_x = 0.4f * UI_UNIT_X; -- cgit v1.2.3