diff options
author | Julian Eisel <julian@blender.org> | 2022-07-21 15:55:18 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-07-21 18:16:10 +0300 |
commit | 3a97c4056f8b9f663150a988b9aa9647517c33ed (patch) | |
tree | c4a2f6eecefb9a09b092e162284c8aba79674d90 /source/blender/editors/interface/views/grid_view.cc | |
parent | 9dbcefb10e53cc809eb2e99333376b2a881c0863 (diff) |
Proof of Concept: File Browser thumbnail mode using grid viewfile-browser-grid-view
This was meant as an experiment to see how tangible it is to rewrite the
File Browser UI code to be based on views, starting with the grid view
for thumbnail mode. See T99890.
My initial conclusion is that porting to views is quite doable, but
we'll need some further UI code features to make certain things
possible. Like big "composed" icons, where a file type icon is displayed
on top of a big, generic file icon.
There is a fair bit of stuff here that I'm not happy with. Plus things
like selection, double clicking to open and renaming don't work yet.
It's a start, a proof of concept even :)
Diffstat (limited to 'source/blender/editors/interface/views/grid_view.cc')
-rw-r--r-- | source/blender/editors/interface/views/grid_view.cc | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/source/blender/editors/interface/views/grid_view.cc b/source/blender/editors/interface/views/grid_view.cc index 52ff1460cbd..edc33fcf944 100644 --- a/source/blender/editors/interface/views/grid_view.cc +++ b/source/blender/editors/interface/views/grid_view.cc @@ -8,6 +8,7 @@ #include <stdexcept> #include "BLI_index_range.hh" +#include "BLI_math_vector.h" #include "WM_types.h" @@ -410,29 +411,26 @@ PreviewGridItem::PreviewGridItem(StringRef identifier, StringRef label, int prev { } -void PreviewGridItem::build_grid_tile(uiLayout &layout) const +uiBut *PreviewGridItem::add_preview_button(uiLayout &layout, + const int preview_icon_id, + const uchar mono_color[4]) const { const GridViewStyle &style = get_view().get_style(); uiBlock *block = uiLayoutGetBlock(&layout); - uiBut *but = uiDefBut(block, - UI_BTYPE_PREVIEW_TILE, - 0, - label.c_str(), - 0, - 0, - style.tile_width, - style.tile_height, - nullptr, - 0, - 0, - 0, - 0, - ""); - ui_def_but_icon(but, - preview_icon_id, - /* NOLINTNEXTLINE: bugprone-suspicious-enum-usage */ - UI_HAS_ICON | UI_BUT_ICON_PREVIEW); + return uiDefButPreviewTile(block, + preview_icon_id, + label.c_str(), + 0, + 0, + style.tile_width, + style.tile_height, + mono_color); +} + +void PreviewGridItem::build_grid_tile(uiLayout &layout) const +{ + add_preview_button(layout, preview_icon_id); } void PreviewGridItem::set_on_activate_fn(ActivateFn fn) |