diff options
author | Julian Eisel <julian@blender.org> | 2020-08-07 15:34:11 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-08-07 16:17:52 +0300 |
commit | 49f088e2d0936ed3b5f08881a14ad83c19951791 (patch) | |
tree | e0d64f096345e3cda1e18a248a09a52869e37407 /source/blender/editors/include/UI_interface.h | |
parent | 48e089375ebe4aeb30d60e9d8ef6f467280cf07d (diff) |
UI Code Quality: Use derived structs for search buttons and decorators
The current on-size-fits-all `uiBut` creates quite a mess, where it's
hard to reason about which members are free for use, under which
conditions they are used and how.
`uiBut` also has members that aren't used at times, violating the "don't
pay for what you don't use" principle.
To address this, we want to move to typed buttons, where `uiBut` is just
a base struct and each type extends it as needed. That structures data
better and type specific data is only available if it's actually used by
a button type.
Two trade-offs:
* Many casts to the derived type have to be done.
* Sometimes we change the button type after it's created. So I had to
add logic to reallocate the button for use with the new, possibly
derived struct. Ideally that wouldn't be needed, but for now that's
what we have.
Part of T74432.
Differential Revision: https://developer.blender.org/D7610
Reviewed by: Brecht Van Lommel, Campbell Barton
Diffstat (limited to 'source/blender/editors/include/UI_interface.h')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 184032df3c6..4a98d72a463 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -57,6 +57,7 @@ struct bNodeSocket; struct bNodeTree; struct bScreen; struct rcti; +struct uiButSearch; struct uiFontStyle; struct uiList; struct uiStyle; @@ -371,6 +372,7 @@ typedef enum { UI_BTYPE_SEPR_SPACER = 56 << 9, /** Resize handle (resize uilist). */ UI_BTYPE_GRIP = 57 << 9, + UI_BTYPE_DECORATOR = 58 << 9, } eButType; #define BUTTYPE (63 << 9) @@ -500,7 +502,7 @@ typedef int (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg); /* Search types. */ typedef struct ARegion *(*uiButSearchCreateFn)(struct bContext *C, struct ARegion *butregion, - uiBut *but); + struct uiButSearch *search_but); typedef void (*uiButSearchUpdateFn)(const struct bContext *C, void *arg, const char *str, @@ -537,7 +539,7 @@ typedef bool (*uiMenuStepFunc)(struct bContext *C, int direction, void *arg1); bool UI_but_has_tooltip_label(const uiBut *but); bool UI_but_is_tool(const uiBut *but); bool UI_but_is_utf8(const uiBut *but); -#define UI_but_is_decorator(but) ((but)->func == ui_but_anim_decorate_cb) +#define UI_but_is_decorator(but) ((but)->type == UI_BTYPE_DECORATOR) bool UI_block_is_empty_ex(const uiBlock *block, const bool skip_title); bool UI_block_is_empty(const uiBlock *block); @@ -1929,8 +1931,6 @@ uiLayout *uiLayoutGridFlow(uiLayout *layout, uiLayout *uiLayoutBox(uiLayout *layout); uiLayout *uiLayoutListBox(uiLayout *layout, struct uiList *ui_list, - struct PointerRNA *ptr, - struct PropertyRNA *prop, struct PointerRNA *actptr, struct PropertyRNA *actprop); uiLayout *uiLayoutAbsolute(uiLayout *layout, bool align); |