From 17a67bf778b87d0d24adfac3bd89bc8d3300c741 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 30 Jun 2021 17:27:54 +0200 Subject: UI: custom free function improvements This changes `UI_but_func_tooltip_set` so that it allows passing a custom free function, which has two benefits: * The caller can pass `null` to indicate that the value should not be freed. * Arbitrary c++ data can be passed to the callback (before the struct had to be trivially destructible). I added `uiFreeArgFunc` and used it in other places where appropriate. Differential Revision: https://developer.blender.org/D11738 --- source/blender/editors/include/UI_interface.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/include') diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index b23f3e29551..47e3dc84503 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -504,7 +504,6 @@ typedef void (*uiButSearchUpdateFn)(const struct bContext *C, const char *str, uiSearchItems *items, const bool is_first); -typedef void (*uiButSearchArgFreeFn)(void *arg); typedef bool (*uiButSearchContextMenuFn)(struct bContext *C, void *arg, void *active, @@ -533,6 +532,8 @@ typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event); */ typedef bool (*uiMenuStepFunc)(struct bContext *C, int direction, void *arg1); +typedef void (*uiFreeArgFunc)(void *arg); + /* interface_query.c */ bool UI_but_has_tooltip_label(const uiBut *but); bool UI_but_is_tool(const uiBut *but); @@ -619,11 +620,11 @@ typedef void (*uiBlockCancelFunc)(struct bContext *C, void *arg1); void UI_popup_block_invoke(struct bContext *C, uiBlockCreateFunc func, void *arg, - void (*arg_free)(void *arg)); + uiFreeArgFunc arg_free); void UI_popup_block_invoke_ex(struct bContext *C, uiBlockCreateFunc func, void *arg, - void (*arg_free)(void *arg), + uiFreeArgFunc arg_free, bool can_refresh); void UI_popup_block_ex(struct bContext *C, uiBlockCreateFunc func, @@ -1599,7 +1600,7 @@ void UI_but_func_search_set(uiBut *but, uiButSearchUpdateFn search_update_fn, void *arg, const bool free_arg, - uiButSearchArgFreeFn search_arg_free_fn, + uiFreeArgFunc search_arg_free_fn, uiButHandleFunc search_exec_fn, void *active); void UI_but_func_search_set_context_menu(uiBut *but, uiButSearchContextMenuFn context_menu_fn); @@ -1644,7 +1645,7 @@ void UI_but_func_drawextra_set( 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_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *arg, uiFreeArgFunc free_arg); void UI_but_tooltip_refresh(struct bContext *C, uiBut *but); void UI_but_tooltip_timer_remove(struct bContext *C, uiBut *but); -- cgit v1.2.3