Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.c
| Show First 20 Lines • Show All 2,367 Lines • ▼ Show 20 Lines | if (but->str) { | ||||
| } | } | ||||
| /* must call 'ui_but_string_set_internal' after */ | /* must call 'ui_but_string_set_internal' after */ | ||||
| but->str = NULL; | but->str = NULL; | ||||
| } | } | ||||
| } | } | ||||
| bool ui_but_string_set(bContext *C, uiBut *but, const char *str) | bool ui_but_string_set(bContext *C, uiBut *but, const char *str) | ||||
| { | { | ||||
| if (but->rnaprop && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) { | if (but->rnaprop && but->rnapoin.data && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) { | ||||
| if (RNA_property_editable(&but->rnapoin, but->rnaprop)) { | if (RNA_property_editable(&but->rnapoin, but->rnaprop)) { | ||||
| PropertyType type; | PropertyType type; | ||||
| type = RNA_property_type(but->rnaprop); | type = RNA_property_type(but->rnaprop); | ||||
| if (type == PROP_STRING) { | if (type == PROP_STRING) { | ||||
| /* RNA string */ | /* RNA string */ | ||||
| RNA_property_string_set(&but->rnapoin, but->rnaprop, str); | RNA_property_string_set(&but->rnapoin, but->rnaprop, str); | ||||
| Show All 30 Lines | if (RNA_property_editable(&but->rnapoin, but->rnaprop)) { | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (but->type == UI_BTYPE_TEXT) { | else if (but->type == UI_BTYPE_TEXT) { | ||||
| /* string */ | /* string */ | ||||
| if (ui_but_is_utf8(but)) BLI_strncpy_utf8(but->poin, str, but->hardmax); | if (!but->poin || (str[0] == '\0')) { | ||||
| else BLI_strncpy(but->poin, str, but->hardmax); | str = ""; | ||||
| } | |||||
| else if (ui_but_is_utf8(but)) { | |||||
| BLI_strncpy_utf8(but->poin, str, but->hardmax); | |||||
| } | |||||
| else { | |||||
| BLI_strncpy(but->poin, str, but->hardmax); | |||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| else if (but->type == UI_BTYPE_SEARCH_MENU) { | else if (but->type == UI_BTYPE_SEARCH_MENU) { | ||||
| /* string */ | /* string */ | ||||
| BLI_strncpy(but->poin, str, but->hardmax); | BLI_strncpy(but->poin, str, but->hardmax); | ||||
| return true; | return true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | static void ui_but_free(const bContext *C, uiBut *but) | ||||
| if (but->func_argN) { | if (but->func_argN) { | ||||
| MEM_freeN(but->func_argN); | MEM_freeN(but->func_argN); | ||||
| } | } | ||||
| if (but->tip_argN) { | if (but->tip_argN) { | ||||
| MEM_freeN(but->tip_argN); | MEM_freeN(but->tip_argN); | ||||
| } | } | ||||
| if (!but->editstr && but->free_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) { | ||||
| ui_but_active_free(C, but); | ui_but_active_free(C, but); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 856 Lines • ▼ Show 20 Lines | if (icon) { | ||||
| ui_def_but_icon(but, icon, UI_HAS_ICON); | ui_def_but_icon(but, icon, UI_HAS_ICON); | ||||
| } | } | ||||
| 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; | ||||
| } | } | ||||
| const char *info; | const char *info; | ||||
| if (!RNA_property_editable_info(&but->rnapoin, prop, &info)) { | if (but->rnapoin.data && !RNA_property_editable_info(&but->rnapoin, prop, &info)) { | ||||
| ui_def_but_rna__disable(but, info); | ui_def_but_rna__disable(but, info); | ||||
| } | } | ||||
| if (but->flag & UI_BUT_UNDO && (ui_but_is_rna_undo(but) == false)) { | if (but->flag & UI_BUT_UNDO && (ui_but_is_rna_undo(but) == false)) { | ||||
| but->flag &= ~UI_BUT_UNDO; | but->flag &= ~UI_BUT_UNDO; | ||||
| } | } | ||||
| /* If this button uses units, calculate the step from this */ | /* If this button uses units, calculate the step from this */ | ||||
| ▲ Show 20 Lines • Show All 1,006 Lines • ▼ Show 20 Lines | else if (type == BUT_GET_TIP) { | ||||
| type = BUT_GET_RNA_TIP; /* Fail-safe solution... */ | type = BUT_GET_RNA_TIP; /* Fail-safe solution... */ | ||||
| } | } | ||||
| if (type == BUT_GET_RNAPROP_IDENTIFIER) { | if (type == BUT_GET_RNAPROP_IDENTIFIER) { | ||||
| if (but->rnaprop) | if (but->rnaprop) | ||||
| tmp = BLI_strdup(RNA_property_identifier(but->rnaprop)); | tmp = BLI_strdup(RNA_property_identifier(but->rnaprop)); | ||||
| } | } | ||||
| else if (type == BUT_GET_RNASTRUCT_IDENTIFIER) { | else if (type == BUT_GET_RNASTRUCT_IDENTIFIER) { | ||||
| if (but->rnaprop) | if (but->rnaprop && but->rnapoin.data) | ||||
| tmp = BLI_strdup(RNA_struct_identifier(but->rnapoin.type)); | tmp = BLI_strdup(RNA_struct_identifier(but->rnapoin.type)); | ||||
| else if (but->optype) | else if (but->optype) | ||||
| tmp = BLI_strdup(but->optype->idname); | tmp = BLI_strdup(but->optype->idname); | ||||
| else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) { | else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) { | ||||
| MenuType *mt = UI_but_menutype_get(but); | MenuType *mt = UI_but_menutype_get(but); | ||||
| if (mt) | if (mt) | ||||
| tmp = BLI_strdup(mt->idname); | tmp = BLI_strdup(mt->idname); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines | |||||