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.
This commit is contained in:
@@ -351,6 +351,13 @@ typedef struct uiButTreeRow {
|
||||
int indentation;
|
||||
} uiButTreeRow;
|
||||
|
||||
/** Derived struct for #UI_BTYPE_GRID_TILE. */
|
||||
typedef struct uiButGridTile {
|
||||
uiBut but;
|
||||
|
||||
uiGridViewItemHandle *view_item;
|
||||
} uiButGridTile;
|
||||
|
||||
/** Derived struct for #UI_BTYPE_HSVCUBE. */
|
||||
typedef struct uiButHSVCube {
|
||||
uiBut but;
|
||||
@@ -1365,6 +1372,7 @@ void ui_but_anim_decorate_update_from_flag(uiButDecorator *but);
|
||||
bool ui_but_is_editable(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
bool ui_but_is_editable_as_text(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
bool ui_but_is_toggle(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
bool ui_but_is_view_item(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
/**
|
||||
* Can we mouse over the button or is it hidden/disabled/layout.
|
||||
* \note ctrl is kind of a hack currently,
|
||||
@@ -1396,6 +1404,8 @@ uiBut *ui_list_row_find_mouse_over(const struct ARegion *region, const int xy[2]
|
||||
uiBut *ui_list_row_find_from_index(const struct ARegion *region,
|
||||
int index,
|
||||
uiBut *listbox) ATTR_WARN_UNUSED_RESULT;
|
||||
uiBut *ui_view_item_find_mouse_over(const struct ARegion *region, const int xy[2])
|
||||
ATTR_NONNULL(1, 2);
|
||||
uiBut *ui_tree_row_find_mouse_over(const struct ARegion *region, const int xy[2])
|
||||
ATTR_NONNULL(1, 2);
|
||||
uiBut *ui_tree_row_find_active(const struct ARegion *region);
|
||||
@@ -1533,8 +1543,10 @@ void ui_interface_tag_script_reload_queries(void);
|
||||
/* interface_view.cc */
|
||||
|
||||
void ui_block_free_views(struct uiBlock *block);
|
||||
uiTreeViewHandle *ui_block_view_find_matching_in_old_block(const uiBlock *new_block,
|
||||
const uiTreeViewHandle *new_view);
|
||||
uiTreeViewHandle *ui_block_tree_view_find_matching_in_old_block(const uiBlock *new_block,
|
||||
const uiTreeViewHandle *new_view);
|
||||
uiGridViewHandle *ui_block_grid_view_find_matching_in_old_block(
|
||||
const uiBlock *new_block, const uiGridViewHandle *new_view_handle);
|
||||
uiButTreeRow *ui_block_view_find_treerow_in_old_block(const uiBlock *new_block,
|
||||
const uiTreeViewItemHandle *new_item_handle);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user