diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 9 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 10 |
4 files changed, 26 insertions, 3 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index fc824dc58df..108fcdda613 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -361,6 +361,13 @@ typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event); typedef void (*uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1); typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event); +/** + * Used for cycling menu values without opening the menu (Ctrl-Wheel). + * \param direction: forward or backwards [1 / -1]. + * \param arg1: uiBut.poin (as with #uiMenuCreateFunc). + * \return true when the button was changed. + */ +typedef bool (*uiMenuStepFunc)(struct bContext *C, int direction, void *arg1); /* Popup Menus * @@ -693,6 +700,8 @@ void UI_but_func_drawextra_set( void (*func)(const struct bContext *C, void *, void *, void *, struct rcti *rect), void *arg1, void *arg2); +void UI_but_func_menu_step_set(uiBut *but, uiMenuStepFunc func); + void UI_but_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *argN); void UI_but_tooltip_timer_remove(struct bContext *C, uiBut *but); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 69e5f407fa2..8199ce038ed 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1804,7 +1804,8 @@ bool ui_but_supports_cycling(const uiBut *but) { return ((ELEM(but->type, UI_BTYPE_ROW, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, UI_BTYPE_LISTBOX)) || (but->type == UI_BTYPE_MENU && ui_but_menu_step_poll(but)) || - (but->type == UI_BTYPE_COLOR && but->a1 != -1)); + (but->type == UI_BTYPE_COLOR && but->a1 != -1) || + (but->menu_step_func != NULL)); } double ui_but_value_get(uiBut *but) @@ -4130,6 +4131,11 @@ void UI_but_func_complete_set(uiBut *but, uiButCompleteFunc func, void *arg) but->autofunc_arg = arg; } +void UI_but_func_menu_step_set(uiBut *but, uiMenuStepFunc func) +{ + but->menu_step_func = func; +} + void UI_but_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *argN) { but->tip_func = func; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 58ac8955c21..158497b7201 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -281,6 +281,8 @@ struct uiBut { /* UI_BTYPE_PULLDOWN/UI_BTYPE_MENU data */ uiMenuCreateFunc menu_create_func; + uiMenuStepFunc menu_step_func; + /* RNA data */ struct PointerRNA rnapoin; struct PropertyRNA *rnaprop; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 40e4da2de94..f62cb4ee68d 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -111,13 +111,19 @@ bool ui_but_menu_step_poll(const uiBut *but) BLI_assert(but->type == UI_BTYPE_MENU); /* currenly only RNA buttons */ - return (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM); + return ((but->menu_step_func != NULL) || + (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM)); } int ui_but_menu_step(uiBut *but, int direction) { if (ui_but_menu_step_poll(but)) { - return rna_property_enum_step(but->block->evil_C, &but->rnapoin, but->rnaprop, direction); + if (but->menu_step_func) { + return but->menu_step_func(but->block->evil_C, direction, but->poin); + } + else { + return rna_property_enum_step(but->block->evil_C, &but->rnapoin, but->rnaprop, direction); + } } printf("%s: cannot cycle button '%s'\n", __func__, but->str); |