diff options
author | Julian Eisel <julian@blender.org> | 2021-07-14 17:01:53 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-07-15 17:12:36 +0300 |
commit | 788d38046032736531cb77507e397cbea7993549 (patch) | |
tree | f13c551bb2f95a0b3b7481d4b8dc211b20e106cf /source/blender/makesdna | |
parent | 6e01b52100f3f9674c49127cbcc445e7e5c987d2 (diff) |
UI: UI list refactor & preparations for asset view template
This is more of a first-pass refactor for the UI list template. More
improvements could be done, but that's better done separately. Main
purpose of this is to make the UI list code more manageable and ready
for the asset view template.
No functional changes for users.
* Split the huge template function into more manageable functions, with
clear names and a few structs with high coherency.
* Move runtime data management to the template code, with a free
callback called from BKE. This is UI data and should be managed at
that level.
* Replace boolean arguments with bit-flags (easily extendable and more
readable from the caller).
* Allow passing custom-data to the UI list for callbacks to access.
* Make list grip button for resizing optional.
* Put logic for generating the internal UI list identifier (stored in
.blends) into function. This is a quite important bit and a later
commit adds a related function. Good to have a clear API for this.
* Improve naming, comments, etc.
As part of further cleanups I'd like to move this to an own file.
Diffstat (limited to 'source/blender/makesdna')
-rw-r--r-- | source/blender/makesdna/DNA_screen_types.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 670e84e0c7a..840685b81f6 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -43,6 +43,7 @@ struct SpaceLink; struct SpaceType; struct uiBlock; struct uiLayout; +struct uiList; struct wmDrawBuffer; struct wmTimer; struct wmTooltipState; @@ -246,11 +247,16 @@ typedef struct PanelCategoryStack { char idname[64]; } PanelCategoryStack; +typedef void (*uiListFreeRuntimeDataFunc)(struct uiList *ui_list); + /* uiList dynamic data... */ /* These two Lines with # tell makesdna this struct can be excluded. */ # # typedef struct uiListDyn { + /** Callback to free UI data when freeing UI-Lists in BKE. */ + uiListFreeRuntimeDataFunc free_runtime_data_fn; + /** Number of rows needed to draw all elements. */ int height; /** Actual visual height of the list (in rows). */ @@ -258,6 +264,9 @@ typedef struct uiListDyn { /** Minimal visual height of the list (in rows). */ int visual_height_min; + /** Number of columns drawn for grid layouts. */ + int columns; + /** Number of items in collection. */ int items_len; /** Number of items actually visible after filtering. */ @@ -270,6 +279,9 @@ typedef struct uiListDyn { int resize; int resize_prev; + /* Allocated custom data. Free'ed together with the uiList (and when re-assigning). */ + void *customdata; + /* Filtering data. */ /** Items_len length. */ int *items_filter_flags; |