WM: Add WM_menutype_poll function
Wraps menutype poll, no functional changes.
This commit is contained in:
parent
f36c803e55
commit
6618852b7f
@ -214,9 +214,10 @@ int UI_pie_menu_invoke(struct bContext *C, const char *idname, const wmEvent *ev
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (mt->poll && mt->poll(C, mt) == 0)
|
||||
if (WM_menutype_poll(C, mt) == false) {
|
||||
/* cancel but allow event to pass through, just like operators do */
|
||||
return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
|
||||
}
|
||||
|
||||
pie = UI_pie_menu_begin(C, IFACE_(mt->label), ICON_NONE, event);
|
||||
layout = UI_pie_menu_layout(pie);
|
||||
|
@ -518,9 +518,10 @@ int UI_popup_menu_invoke(bContext *C, const char *idname, ReportList *reports)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (mt->poll && mt->poll(C, mt) == 0)
|
||||
if (WM_menutype_poll(C, mt) == false) {
|
||||
/* cancel but allow event to pass through, just like operators do */
|
||||
return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
|
||||
}
|
||||
|
||||
pup = UI_popup_menu_begin(C, IFACE_(mt->label), ICON_NONE);
|
||||
layout = UI_popup_menu_layout(pup);
|
||||
|
@ -378,6 +378,7 @@ struct MenuType *WM_menutype_find(const char *idname, bool quiet);
|
||||
bool WM_menutype_add(struct MenuType *mt);
|
||||
void WM_menutype_freelink(struct MenuType *mt);
|
||||
void WM_menutype_free(void);
|
||||
bool WM_menutype_poll(struct bContext *C, struct MenuType *mt);
|
||||
|
||||
/* wm_gesture_ops.c */
|
||||
int WM_gesture_border_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
||||
|
@ -337,6 +337,14 @@ void WM_menutype_free(void)
|
||||
menutypes_hash = NULL;
|
||||
}
|
||||
|
||||
bool WM_menutype_poll(bContext *C, MenuType *mt)
|
||||
{
|
||||
if (mt->poll != NULL) {
|
||||
return mt->poll(C, mt);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
void WM_keymap_init(bContext *C)
|
||||
|
Loading…
Reference in New Issue
Block a user