Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.c
| Show First 20 Lines • Show All 3,231 Lines • ▼ Show 20 Lines | #ifdef WITH_PYTHON | ||||
| if (UI_editsource_enable_check()) { | if (UI_editsource_enable_check()) { | ||||
| UI_editsource_active_but_test(but); | UI_editsource_active_but_test(but); | ||||
| } | } | ||||
| #endif | #endif | ||||
| return but; | return but; | ||||
| } | } | ||||
| void ui_def_but_icon(uiBut *but, const int icon, const int flag) { | |||||
| if (icon) { | |||||
| ui_icon_ensure_deferred(but->block->evil_C, icon, (flag & UI_BUT_ICON_PREVIEW) != 0); | |||||
| } | |||||
| but->icon = (BIFIconID)icon; | |||||
| but->flag |= flag; | |||||
| if (but->str && but->str[0]) { | |||||
| but->drawflag |= UI_BUT_ICON_LEFT; | |||||
| } | |||||
| } | |||||
| static void ui_def_but_rna__disable(uiBut *but) | static void ui_def_but_rna__disable(uiBut *but) | ||||
| { | { | ||||
| but->flag |= UI_BUT_DISABLED; | but->flag |= UI_BUT_DISABLED; | ||||
| but->lock = true; | but->lock = true; | ||||
| but->lockstr = ""; | but->lockstr = ""; | ||||
| } | } | ||||
| static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *but_p) | static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *but_p) | ||||
| ▲ Show 20 Lines • Show All 247 Lines • ▼ Show 20 Lines | #endif | ||||
| but->rnaprop = prop; | but->rnaprop = prop; | ||||
| if (RNA_property_array_check(but->rnaprop)) | if (RNA_property_array_check(but->rnaprop)) | ||||
| but->rnaindex = index; | but->rnaindex = index; | ||||
| else | else | ||||
| but->rnaindex = 0; | but->rnaindex = 0; | ||||
| if (icon) { | if (icon) { | ||||
| but->icon = (BIFIconID)icon; | ui_def_but_icon(but, icon, UI_HAS_ICON); | ||||
| but->flag |= UI_HAS_ICON; | |||||
| if (str[0]) { | |||||
| but->drawflag |= UI_BUT_ICON_LEFT; | |||||
| } | |||||
| } | } | ||||
| if ((type == UI_BTYPE_MENU) && (but->dt == UI_EMBOSS_PULLDOWN)) { | if ((type == UI_BTYPE_MENU) && (but->dt == UI_EMBOSS_PULLDOWN)) { | ||||
| but->flag |= UI_BUT_ICON_SUBMENU; | but->flag |= UI_BUT_ICON_SUBMENU; | ||||
| } | } | ||||
| if (!RNA_property_editable(&but->rnapoin, prop)) { | if (!RNA_property_editable(&but->rnapoin, prop)) { | ||||
| ui_def_but_rna__disable(but); | ui_def_but_rna__disable(but); | ||||
| ▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | int UI_autocomplete_end(AutoComplete *autocpl, char *autoname) | ||||
| MEM_freeN(autocpl->truncate); | MEM_freeN(autocpl->truncate); | ||||
| MEM_freeN(autocpl); | MEM_freeN(autocpl); | ||||
| return match; | return match; | ||||
| } | } | ||||
| static void ui_but_update_and_icon_set(uiBut *but, int icon) | static void ui_but_update_and_icon_set(uiBut *but, int icon) | ||||
| { | { | ||||
| if (icon) { | if (icon) { | ||||
| but->icon = (BIFIconID) icon; | ui_def_but_icon(but, icon, UI_HAS_ICON); | ||||
| but->flag |= UI_HAS_ICON; | |||||
| } | } | ||||
| ui_but_update(but); | ui_but_update(but); | ||||
| } | } | ||||
| static uiBut *uiDefButBit(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) | static uiBut *uiDefButBit(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) | ||||
| { | { | ||||
| int bitIdx = findBitIndex(bit); | int bitIdx = findBitIndex(bit); | ||||
| ▲ Show 20 Lines • Show All 357 Lines • ▼ Show 20 Lines | |||||
| 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) | ||||
| { | { | ||||
| but->dragtype = WM_DRAG_PATH; | but->dragtype = WM_DRAG_PATH; | ||||
| but->icon = icon; /* 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 */ | ||||
| but->dragpoin = (void *)path; | but->dragpoin = (void *)path; | ||||
| 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) { | ||||
| ▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip) | ||||
| ui_but_update(but); | ui_but_update(but); | ||||
| return but; | return but; | ||||
| } | } | ||||
| uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip) | uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip) | ||||
| { | { | ||||
| uiBut *but = ui_def_but(block, UI_BTYPE_PULLDOWN, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); | uiBut *but = ui_def_but(block, UI_BTYPE_PULLDOWN, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); | ||||
| but->icon = (BIFIconID) icon; | ui_def_but_icon(but, icon, UI_HAS_ICON); | ||||
| but->flag |= UI_HAS_ICON; | |||||
| but->drawflag |= UI_BUT_ICON_LEFT; | but->drawflag |= UI_BUT_ICON_LEFT; | ||||
| but->flag |= UI_BUT_ICON_SUBMENU; | but->flag |= UI_BUT_ICON_SUBMENU; | ||||
| but->menu_create_func = func; | but->menu_create_func = func; | ||||
| ui_but_update(but); | ui_but_update(but); | ||||
| return but; | return but; | ||||
| } | } | ||||
| uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x, int y, short width, short height, const char *tip) | uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x, int y, short width, short height, const char *tip) | ||||
| { | { | ||||
| uiBut *but = ui_def_but(block, UI_BTYPE_PULLDOWN, 0, "", x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); | uiBut *but = ui_def_but(block, UI_BTYPE_PULLDOWN, 0, "", x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); | ||||
| but->icon = (BIFIconID) icon; | ui_def_but_icon(but, icon, UI_HAS_ICON); | ||||
| but->flag |= UI_HAS_ICON; | |||||
| but->drawflag &= ~UI_BUT_ICON_LEFT; | but->drawflag &= ~UI_BUT_ICON_LEFT; | ||||
| but->menu_create_func = func; | but->menu_create_func = func; | ||||
| ui_but_update(but); | ui_but_update(but); | ||||
| return but; | return but; | ||||
| } | } | ||||
| /* Block button containing both string label and icon */ | /* Block button containing both string label and icon */ | ||||
| uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip) | uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip) | ||||
| { | { | ||||
| uiBut *but = ui_def_but(block, UI_BTYPE_BLOCK, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); | uiBut *but = ui_def_but(block, UI_BTYPE_BLOCK, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); | ||||
| /* XXX temp, old menu calls pass on icon arrow, which is now UI_BUT_ICON_SUBMENU flag */ | /* XXX temp, old menu calls pass on icon arrow, which is now UI_BUT_ICON_SUBMENU flag */ | ||||
| if (icon != ICON_RIGHTARROW_THIN) { | if (icon != ICON_RIGHTARROW_THIN) { | ||||
| but->icon = (BIFIconID) icon; | ui_def_but_icon(but, icon, 0); | ||||
| but->drawflag |= UI_BUT_ICON_LEFT; | but->drawflag |= UI_BUT_ICON_LEFT; | ||||
| } | } | ||||
| but->flag |= UI_HAS_ICON; | but->flag |= UI_HAS_ICON; | ||||
| but->flag |= UI_BUT_ICON_SUBMENU; | but->flag |= UI_BUT_ICON_SUBMENU; | ||||
| but->block_create_func = func; | but->block_create_func = func; | ||||
| ui_but_update(but); | ui_but_update(but); | ||||
| return but; | return but; | ||||
| } | } | ||||
| /* Block button containing icon */ | /* Block button containing icon */ | ||||
| uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x, int y, short width, short height, const char *tip) | uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x, int y, short width, short height, const char *tip) | ||||
| { | { | ||||
| uiBut *but = ui_def_but(block, UI_BTYPE_BLOCK, retval, "", x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); | uiBut *but = ui_def_but(block, UI_BTYPE_BLOCK, retval, "", x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); | ||||
| but->icon = (BIFIconID) icon; | ui_def_but_icon(but, icon, UI_HAS_ICON); | ||||
| but->flag |= UI_HAS_ICON; | |||||
| but->drawflag |= UI_BUT_ICON_LEFT; | but->drawflag |= UI_BUT_ICON_LEFT; | ||||
| but->block_create_func = func; | but->block_create_func = func; | ||||
| ui_but_update(but); | ui_but_update(but); | ||||
| return but; | return but; | ||||
| } | } | ||||
| Show All 16 Lines | |||||
| /* arg is pointer to string/name, use UI_but_func_search_set() below to make this work */ | /* arg is pointer to string/name, use UI_but_func_search_set() below to make this work */ | ||||
| /* here a1 and a2, if set, control thumbnail preview rows/cols */ | /* here a1 and a2, if set, control thumbnail preview rows/cols */ | ||||
| uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip) | uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip) | ||||
| { | { | ||||
| uiBut *but = ui_def_but(block, UI_BTYPE_SEARCH_MENU, retval, "", x, y, width, height, arg, 0.0, maxlen, a1, a2, tip); | uiBut *but = ui_def_but(block, UI_BTYPE_SEARCH_MENU, retval, "", x, y, width, height, arg, 0.0, maxlen, a1, a2, tip); | ||||
| but->icon = (BIFIconID) icon; | ui_def_but_icon(but, icon, UI_HAS_ICON); | ||||
| but->flag |= UI_HAS_ICON; | |||||
| but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT; | but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT; | ||||
| ui_but_update(but); | ui_but_update(but); | ||||
| return but; | return but; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 310 Lines • Show Last 20 Lines | |||||