Refactor: UI: Use regular button callbacks for curve, color ramp templates

Previously these used a special "menu func" that used an argument value
passed through each menu button's a2 value. This was more complex than
necessary given the existence of generic button callbacks.

So use std::function in these remaining cases, and remove the now-unused
`butm_func` and `butm_func_arg` values in the uiBlock.
This commit is contained in:
Hans Goudey 2024-03-01 13:20:17 -05:00
parent 2223130b16
commit f4e670af2c
5 changed files with 350 additions and 454 deletions

View file

@ -1689,7 +1689,6 @@ void UI_but_number_slider_precision_set(uiBut *but, float precision);
void UI_but_search_preview_grid_size_set(uiBut *but, int rows, int cols);
void UI_block_func_handle_set(uiBlock *block, uiBlockHandleFunc func, void *arg);
void UI_block_func_butmenu_set(uiBlock *block, uiMenuHandleFunc func, void *arg);
void UI_block_func_set(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);
void UI_block_funcN_set(uiBlock *block, uiButHandleNFunc funcN, void *argN, void *arg2);

View file

@ -5840,12 +5840,6 @@ void UI_block_func_handle_set(uiBlock *block, uiBlockHandleFunc func, void *arg)
block->handle_func_arg = arg;
}
void UI_block_func_butmenu_set(uiBlock *block, uiMenuHandleFunc func, void *arg)
{
block->butm_func = func;
block->butm_func_arg = arg;
}
void UI_block_func_set(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2)
{
block->func = func;

View file

@ -479,10 +479,6 @@ struct uiAfterFunc {
void *handle_func_arg;
int retval;
uiMenuHandleFunc butm_func;
void *butm_func_arg;
int a2;
wmOperator *popup_op;
wmOperatorType *optype;
wmOperatorCallContext opcontext;
@ -810,9 +806,7 @@ static void popup_check(bContext *C, wmOperator *op)
static bool ui_afterfunc_check(const uiBlock *block, const uiBut *but)
{
return (but->func || but->apply_func || but->funcN || but->rename_func || but->optype ||
but->rnaprop || block->handle_func ||
(but->type == UI_BTYPE_BUT_MENU && block->butm_func) ||
(block->handle && block->handle->popup_op));
but->rnaprop || block->handle_func || (block->handle && block->handle->popup_op));
}
/**
@ -853,12 +847,6 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
after->handle_func_arg = block->handle_func_arg;
after->retval = but->retval;
if (but->type == UI_BTYPE_BUT_MENU) {
after->butm_func = block->butm_func;
after->butm_func_arg = block->butm_func_arg;
after->a2 = but->a2;
}
if (block->handle) {
after->popup_op = block->handle->popup_op;
}
@ -1067,9 +1055,6 @@ static void ui_apply_but_funcs_after(bContext *C)
if (after.handle_func) {
after.handle_func(C, after.handle_func_arg, after.retval);
}
if (after.butm_func) {
after.butm_func(C, after.butm_func_arg, after.a2);
}
if (after.rename_func) {
after.rename_func(C, after.rename_arg1, static_cast<char *>(after.rename_orig));

View file

@ -561,9 +561,6 @@ struct uiBlock {
uiButHandleNFunc funcN;
void *func_argN;
uiMenuHandleFunc butm_func;
void *butm_func_arg;
uiBlockHandleFunc handle_func;
void *handle_func_arg;

File diff suppressed because it is too large Load diff