Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-07-14 17:01:53 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-07-15 17:12:36 +0300
commit788d38046032736531cb77507e397cbea7993549 (patch)
treef13c551bb2f95a0b3b7481d4b8dc211b20e106cf /source/blender/editors/include
parent6e01b52100f3f9674c49127cbcc445e7e5c987d2 (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/editors/include')
-rw-r--r--source/blender/editors/include/UI_interface.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 802c175492f..55d0c5c4342 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -25,6 +25,7 @@
#include "BLI_compiler_attrs.h"
#include "BLI_sys_types.h" /* size_t */
+#include "BLI_utildefines.h"
#include "UI_interface_icons.h"
#ifdef __cplusplus
@@ -2194,6 +2195,17 @@ void uiTemplateCacheFile(uiLayout *layout,
/* Default UIList class name, keep in sync with its declaration in bl_ui/__init__.py */
#define UI_UL_DEFAULT_CLASS_NAME "UI_UL_list"
+enum uiTemplateListFlags {
+ UI_TEMPLATE_LIST_FLAG_NONE = 0,
+ UI_TEMPLATE_LIST_SORT_REVERSE = (1 << 0),
+ UI_TEMPLATE_LIST_SORT_LOCK = (1 << 1),
+ /* Don't allow resizing the list, i.e. don't add the grip button. */
+ UI_TEMPLATE_LIST_NO_GRIP = (1 << 2),
+
+ UI_TEMPLATE_LIST_FLAGS_LAST
+};
+ENUM_OPERATORS(enum uiTemplateListFlags, UI_TEMPLATE_LIST_FLAGS_LAST);
+
void uiTemplateList(uiLayout *layout,
struct bContext *C,
const char *listtype_name,
@@ -2207,8 +2219,23 @@ void uiTemplateList(uiLayout *layout,
int maxrows,
int layout_type,
int columns,
- bool sort_reverse,
- bool sort_lock);
+ enum uiTemplateListFlags flags);
+struct uiList *uiTemplateList_ex(uiLayout *layout,
+ struct bContext *C,
+ const char *listtype_name,
+ const char *list_id,
+ struct PointerRNA *dataptr,
+ const char *propname,
+ struct PointerRNA *active_dataptr,
+ const char *active_propname,
+ const char *item_dyntip_propname,
+ int rows,
+ int maxrows,
+ int layout_type,
+ int columns,
+ enum uiTemplateListFlags flags,
+ void *customdata);
+
void uiTemplateNodeLink(uiLayout *layout,
struct bContext *C,
struct bNodeTree *ntree,