Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.c
| Show First 20 Lines • Show All 747 Lines • ▼ Show 20 Lines | #endif | ||||
| else { | else { | ||||
| if (oldbut->str != oldbut->strdata) { | if (oldbut->str != oldbut->strdata) { | ||||
| MEM_freeN(oldbut->str); | MEM_freeN(oldbut->str); | ||||
| oldbut->str = oldbut->strdata; | oldbut->str = oldbut->strdata; | ||||
| } | } | ||||
| BLI_strncpy(oldbut->strdata, but->strdata, sizeof(oldbut->strdata)); | BLI_strncpy(oldbut->strdata, but->strdata, sizeof(oldbut->strdata)); | ||||
| } | } | ||||
| if (but->dragpoin && (but->dragflag & UI_BUT_DRAGPOIN_FREE)) { | |||||
| SWAP(void *, but->dragpoin, oldbut->dragpoin); | |||||
| } | |||||
| BLI_remlink(&block->buttons, but); | BLI_remlink(&block->buttons, but); | ||||
| ui_but_free(C, but); | ui_but_free(C, but); | ||||
| /* note: if layout hasn't been applied yet, it uses old button pointers... */ | /* note: if layout hasn't been applied yet, it uses old button pointers... */ | ||||
| } | } | ||||
| else { | else { | ||||
| const int flag_copy = UI_BUT_DRAG_MULTI; | const int flag_copy = UI_BUT_DRAG_MULTI; | ||||
| ▲ Show 20 Lines • Show All 1,750 Lines • ▼ Show 20 Lines | if (but->str && but->str != but->strdata) { | ||||
| MEM_freeN(but->str); | MEM_freeN(but->str); | ||||
| } | } | ||||
| ui_free_link(but->link); | ui_free_link(but->link); | ||||
| if ((but->type == UI_BTYPE_IMAGE) && but->poin) { | if ((but->type == UI_BTYPE_IMAGE) && but->poin) { | ||||
| IMB_freeImBuf((struct ImBuf *)but->poin); | IMB_freeImBuf((struct ImBuf *)but->poin); | ||||
| } | } | ||||
| if (but->dragpoin && (but->dragflag & UI_BUT_DRAGPOIN_FREE)) { | |||||
| MEM_freeN(but->dragpoin); | |||||
| } | |||||
| BLI_assert(UI_butstore_is_registered(but->block, but) == false); | BLI_assert(UI_butstore_is_registered(but->block, but) == false); | ||||
| MEM_freeN(but); | MEM_freeN(but); | ||||
| } | } | ||||
| /* can be called with C==NULL */ | /* can be called with C==NULL */ | ||||
| void UI_block_free(const bContext *C, uiBlock *block) | void UI_block_free(const bContext *C, uiBlock *block) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 1,510 Lines • ▼ Show 20 Lines | |||||
| int UI_but_return_value_get(uiBut *but) | int UI_but_return_value_get(uiBut *but) | ||||
| { | { | ||||
| return but->retval; | return but->retval; | ||||
| } | } | ||||
| void UI_but_drag_set_id(uiBut *but, ID *id) | void UI_but_drag_set_id(uiBut *but, ID *id) | ||||
| { | { | ||||
| but->dragtype = WM_DRAG_ID; | but->dragtype = WM_DRAG_ID; | ||||
| if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) { | |||||
| MEM_SAFE_FREE(but->dragpoin); | |||||
| but->dragflag &= ~UI_BUT_DRAGPOIN_FREE; | |||||
| } | |||||
| but->dragpoin = (void *)id; | but->dragpoin = (void *)id; | ||||
| } | } | ||||
| void UI_but_drag_set_rna(uiBut *but, PointerRNA *ptr) | void UI_but_drag_set_rna(uiBut *but, PointerRNA *ptr) | ||||
| { | { | ||||
| but->dragtype = WM_DRAG_RNA; | but->dragtype = WM_DRAG_RNA; | ||||
| if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) { | |||||
| MEM_SAFE_FREE(but->dragpoin); | |||||
| but->dragflag &= ~UI_BUT_DRAGPOIN_FREE; | |||||
| } | |||||
| but->dragpoin = (void *)ptr; | but->dragpoin = (void *)ptr; | ||||
| } | } | ||||
| void UI_but_drag_set_path(uiBut *but, const char *path) | void UI_but_drag_set_path(uiBut *but, const char *path, const bool use_free) | ||||
| { | { | ||||
| but->dragtype = WM_DRAG_PATH; | but->dragtype = WM_DRAG_PATH; | ||||
| if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) { | |||||
| MEM_SAFE_FREE(but->dragpoin); | |||||
| but->dragflag &= ~UI_BUT_DRAGPOIN_FREE; | |||||
| } | |||||
| but->dragpoin = (void *)path; | but->dragpoin = (void *)path; | ||||
| if (use_free) { | |||||
| but->dragflag |= UI_BUT_DRAGPOIN_FREE; | |||||
| } | |||||
| } | } | ||||
| void UI_but_drag_set_name(uiBut *but, const char *name) | void UI_but_drag_set_name(uiBut *but, const char *name) | ||||
| { | { | ||||
| but->dragtype = WM_DRAG_NAME; | but->dragtype = WM_DRAG_NAME; | ||||
| if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) { | |||||
| MEM_SAFE_FREE(but->dragpoin); | |||||
| but->dragflag &= ~UI_BUT_DRAGPOIN_FREE; | |||||
| } | |||||
| but->dragpoin = (void *)name; | but->dragpoin = (void *)name; | ||||
| } | } | ||||
| /* value from button itself */ | /* value from button itself */ | ||||
| void UI_but_drag_set_value(uiBut *but) | void UI_but_drag_set_value(uiBut *but) | ||||
| { | { | ||||
| but->dragtype = WM_DRAG_VALUE; | but->dragtype = WM_DRAG_VALUE; | ||||
| } | } | ||||
| void UI_but_drag_set_image(uiBut *but, const char *path, int icon, struct ImBuf *imb, float scale) | void UI_but_drag_set_image(uiBut *but, const char *path, int icon, struct ImBuf *imb, float scale, const bool use_free) | ||||
| { | { | ||||
| but->dragtype = WM_DRAG_PATH; | but->dragtype = WM_DRAG_PATH; | ||||
| ui_def_but_icon(but, icon, 0); /* no flag UI_HAS_ICON, so icon doesnt draw in button */ | ui_def_but_icon(but, icon, 0); /* no flag UI_HAS_ICON, so icon doesnt draw in button */ | ||||
| if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) { | |||||
| MEM_SAFE_FREE(but->dragpoin); | |||||
| but->dragflag &= ~UI_BUT_DRAGPOIN_FREE; | |||||
| } | |||||
| but->dragpoin = (void *)path; | but->dragpoin = (void *)path; | ||||
| if (use_free) { | |||||
| but->dragflag |= UI_BUT_DRAGPOIN_FREE; | |||||
| } | |||||
| but->imb = imb; | but->imb = imb; | ||||
| but->imb_scale = scale; | but->imb_scale = scale; | ||||
| } | } | ||||
| PointerRNA *UI_but_operator_ptr_get(uiBut *but) | PointerRNA *UI_but_operator_ptr_get(uiBut *but) | ||||
| { | { | ||||
| if (but->optype && !but->opptr) { | if (but->optype && !but->opptr) { | ||||
| but->opptr = MEM_callocN(sizeof(PointerRNA), "uiButOpPtr"); | but->opptr = MEM_callocN(sizeof(PointerRNA), "uiButOpPtr"); | ||||
| ▲ Show 20 Lines • Show All 564 Lines • Show Last 20 Lines | |||||