Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.cc
| Show First 20 Lines • Show All 1,855 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| #endif | #endif | ||||
| bool ui_but_context_poll_operator_ex(bContext *C, | bool ui_but_context_poll_operator_ex(bContext *C, | ||||
| const uiBut *but, | const uiBut *but, | ||||
| const wmOperatorCallParams *optype_params) | const wmOperatorCallParams *optype_params) | ||||
| { | { | ||||
| bool result; | bool result; | ||||
| int old_but_flag = 0; | |||||
| if (but && but->context) { | if (but) { | ||||
| old_but_flag = but->flag; | |||||
| /* Temporarily make this button override the active one, in case the poll acts on the active | |||||
| * button. */ | |||||
| const_cast<uiBut *>(but)->flag |= UI_BUT_ACTIVE_OVERRIDE; | |||||
| if (but->context) { | |||||
| CTX_store_set(C, but->context); | CTX_store_set(C, but->context); | ||||
| } | } | ||||
| } | |||||
| result = WM_operator_poll_context(C, optype_params->optype, optype_params->opcontext); | result = WM_operator_poll_context(C, optype_params->optype, optype_params->opcontext); | ||||
| if (but && but->context) { | if (but) { | ||||
| BLI_assert_msg((but->flag & ~UI_BUT_ACTIVE_OVERRIDE) == | |||||
| (old_but_flag & ~UI_BUT_ACTIVE_OVERRIDE), | |||||
| "Operator polls shouldn't change button flags"); | |||||
| const_cast<uiBut *>(but)->flag = old_but_flag; | |||||
| if (but->context) { | |||||
| CTX_store_set(C, nullptr); | CTX_store_set(C, nullptr); | ||||
| } | } | ||||
| } | |||||
| return result; | return result; | ||||
| } | } | ||||
| bool ui_but_context_poll_operator(bContext *C, wmOperatorType *ot, const uiBut *but) | bool ui_but_context_poll_operator(bContext *C, wmOperatorType *ot, const uiBut *but) | ||||
| { | { | ||||
| const wmOperatorCallContext opcontext = but ? but->opcontext : WM_OP_INVOKE_DEFAULT; | const wmOperatorCallContext opcontext = but ? but->opcontext : WM_OP_INVOKE_DEFAULT; | ||||
| wmOperatorCallParams params = {}; | wmOperatorCallParams params = {}; | ||||
| ▲ Show 20 Lines • Show All 5,031 Lines • Show Last 20 Lines | |||||