Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.c
| Show First 20 Lines • Show All 2,943 Lines • ▼ Show 20 Lines | static void ui_but_free(const bContext *C, uiBut *but) | ||||
| if (but->tip_argN) { | if (but->tip_argN) { | ||||
| MEM_freeN(but->tip_argN); | MEM_freeN(but->tip_argN); | ||||
| } | } | ||||
| if (but->hold_argN) { | if (but->hold_argN) { | ||||
| MEM_freeN(but->hold_argN); | MEM_freeN(but->hold_argN); | ||||
| } | } | ||||
| if (!but->editstr && but->free_search_arg) { | if (but->free_search_arg) { | ||||
| MEM_SAFE_FREE(but->search_arg); | MEM_SAFE_FREE(but->search_arg); | ||||
| } | } | ||||
| if (but->active) { | if (but->active) { | ||||
| /* XXX solve later, buttons should be free-able without context ideally, | /* XXX solve later, buttons should be free-able without context ideally, | ||||
| * however they may have open tooltips or popup windows, which need to | * however they may have open tooltips or popup windows, which need to | ||||
| * be closed using a context pointer */ | * be closed using a context pointer */ | ||||
| if (C) { | if (C) { | ||||
| ▲ Show 20 Lines • Show All 1,751 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * \param search_func, bfunc: both get it as \a arg. | * \param search_func, bfunc: both get it as \a arg. | ||||
| * \param arg: user value, | * \param arg: user value, | ||||
| * \param active: when set, button opens with this item visible and selected. | * \param active: when set, button opens with this item visible and selected. | ||||
| */ | */ | ||||
| void UI_but_func_search_set( | void UI_but_func_search_set( | ||||
| uiBut *but, | uiBut *but, | ||||
| uiButSearchCreateFunc search_create_func, | uiButSearchCreateFunc search_create_func, | ||||
| uiButSearchFunc search_func, void *arg, | uiButSearchFunc search_func, void *arg, bool free_arg, | ||||
| uiButHandleFunc bfunc, void *active) | uiButHandleFunc bfunc, void *active) | ||||
| { | { | ||||
| /* needed since callers don't have access to internal functions | /* needed since callers don't have access to internal functions | ||||
| * (as an alternative we could expose it) */ | * (as an alternative we could expose it) */ | ||||
| if (search_create_func == NULL) { | if (search_create_func == NULL) { | ||||
| search_create_func = ui_searchbox_create_generic; | search_create_func = ui_searchbox_create_generic; | ||||
| } | } | ||||
| if (but->free_search_arg) { | |||||
| MEM_SAFE_FREE(but->search_arg); | |||||
| } | |||||
| but->search_create_func = search_create_func; | but->search_create_func = search_create_func; | ||||
| but->search_func = search_func; | but->search_func = search_func; | ||||
| but->search_arg = arg; | but->search_arg = arg; | ||||
| but->free_search_arg = free_arg; | |||||
| if (bfunc) { | if (bfunc) { | ||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| if (but->func) { | if (but->func) { | ||||
| /* watch this, can be cause of much confusion, see: T47691 */ | /* watch this, can be cause of much confusion, see: T47691 */ | ||||
| printf("%s: warning, overwriting button callback with search function callback!\n", __func__); | printf("%s: warning, overwriting button callback with search function callback!\n", __func__); | ||||
| } | } | ||||
| #endif | #endif | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | uiBut *uiDefSearchButO_ptr( | ||||
| void *arg, int retval, int icon, int maxlen, int x, int y, | void *arg, int retval, int icon, int maxlen, int x, int y, | ||||
| short width, short height, float a1, float a2, const char *tip) | short width, short height, float a1, float a2, const char *tip) | ||||
| { | { | ||||
| uiBut *but; | uiBut *but; | ||||
| but = uiDefSearchBut(block, arg, retval, icon, maxlen, x, y, width, height, a1, a2, tip); | but = uiDefSearchBut(block, arg, retval, icon, maxlen, x, y, width, height, a1, a2, tip); | ||||
| UI_but_func_search_set( | UI_but_func_search_set( | ||||
| but, ui_searchbox_create_generic, operator_enum_search_cb, | but, ui_searchbox_create_generic, operator_enum_search_cb, | ||||
| but, operator_enum_call_cb, NULL); | but, false, operator_enum_call_cb, NULL); | ||||
| but->optype = ot; | but->optype = ot; | ||||
| but->opcontext = WM_OP_EXEC_DEFAULT; | but->opcontext = WM_OP_EXEC_DEFAULT; | ||||
| if (properties) { | if (properties) { | ||||
| PointerRNA *ptr = UI_but_operator_ptr_get(but); | PointerRNA *ptr = UI_but_operator_ptr_get(but); | ||||
| /* Copy idproperties. */ | /* Copy idproperties. */ | ||||
| ptr->data = IDP_CopyProperty(properties); | ptr->data = IDP_CopyProperty(properties); | ||||
| ▲ Show 20 Lines • Show All 250 Lines • Show Last 20 Lines | |||||