Cleanup: remove unused operator arguments to UI_popup_block_invoke_ex

Add optional can_refresh argument, useful to prevent text field
from exiting on refresh.
This commit is contained in:
Campbell Barton 2020-05-07 21:35:36 +10:00
parent 8d1e3594fe
commit b9491476e5
4 changed files with 8 additions and 17 deletions

View File

@ -621,8 +621,7 @@ void UI_popup_block_invoke_ex(struct bContext *C,
uiBlockCreateFunc func,
void *arg,
void (*arg_free)(void *arg),
const char *opname,
int opcontext);
bool can_refresh);
void UI_popup_block_ex(struct bContext *C,
uiBlockCreateFunc func,
uiBlockHandleFunc popup_func,

View File

@ -10764,9 +10764,6 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata)
if (temp.popup_func) {
temp.popup_func(C, temp.popup_arg, temp.retvalue);
}
if (temp.optype) {
WM_operator_name_call_ptr(C, temp.optype, temp.opcontext, NULL);
}
}
else if (temp.cancel_func) {
temp.cancel_func(C, temp.popup_arg);

View File

@ -597,10 +597,8 @@ struct uiPopupBlockHandle {
/* for operator popups */
struct wmOperator *popup_op;
struct wmOperatorType *optype;
ScrArea *ctx_area;
ARegion *ctx_region;
int opcontext;
/* return values */
int butretval;

View File

@ -581,21 +581,18 @@ int UI_popup_menu_invoke(bContext *C, const char *idname, ReportList *reports)
/** \name Popup Block API
* \{ */
void UI_popup_block_invoke_ex(bContext *C,
uiBlockCreateFunc func,
void *arg,
void (*arg_free)(void *arg),
const char *opname,
int opcontext)
void UI_popup_block_invoke_ex(
bContext *C, uiBlockCreateFunc func, void *arg, void (*arg_free)(void *arg), bool can_refresh)
{
wmWindow *window = CTX_wm_window(C);
uiPopupBlockHandle *handle;
handle = ui_popup_block_create(C, NULL, NULL, func, NULL, arg, arg_free);
handle->popup = true;
handle->can_refresh = true;
handle->optype = (opname) ? WM_operatortype_find(opname, 0) : NULL;
handle->opcontext = opcontext;
/* It can be useful to disable refresh (even though it will work)
* as this exists text fields which can be disruptive if refresh isn't needed. */
handle->can_refresh = can_refresh;
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
UI_block_active_only_flagged_buttons(C, handle->region, handle->region->uiblocks.first);
@ -607,7 +604,7 @@ void UI_popup_block_invoke(bContext *C,
void *arg,
void (*arg_free)(void *arg))
{
UI_popup_block_invoke_ex(C, func, arg, arg_free, NULL, WM_OP_INVOKE_DEFAULT);
UI_popup_block_invoke_ex(C, func, arg, arg_free, true);
}
void UI_popup_block_ex(bContext *C,