typedef struct AutoComplete AutoComplete;
-AutoComplete *autocomplete_begin(const char *startname, int maxlen);
+AutoComplete *autocomplete_begin(const char *startname, size_t maxlen);
void autocomplete_do_name(AutoComplete *autocpl, const char *name);
void autocomplete_end(AutoComplete *autocpl, char *autoname);
}
/* str will be overwritten */
-void ui_convert_to_unit_alt_name(uiBut *but, char *str, int maxlen)
+void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen)
{
if(ui_is_but_unit(but)) {
UnitSettings *unit= but->block->unit;
}
-void ui_get_but_string(uiBut *but, char *str, int maxlen)
+void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
{
if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
PropertyType type;
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
}
else {
- strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
+ BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
}
break;
break;
case KEYEVT:
- strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
+ BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
if (but->flag & UI_SELECT) {
strcat(but->drawstr, "Press a key");
}
strcat(but->drawstr, "Press a key ");
}
else
- strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
+ BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
break;
case BUT_TOGDUAL:
/* trying to get the dual-icon to left of text... not very nice */
if(but->str[0]) {
- strncpy(but->drawstr, " ", UI_MAX_DRAW_STR);
- strncpy(but->drawstr+2, but->str, UI_MAX_DRAW_STR-2);
+ BLI_strncpy(but->drawstr, " ", UI_MAX_DRAW_STR);
+ BLI_strncpy(but->drawstr+2, but->str, UI_MAX_DRAW_STR-2);
}
break;
case HSVCIRCLE:
break;
default:
- strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
+ BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
}
/* if we are doing text editing, this will override the drawstr */
if(but->editstr)
- strncpy(but->drawstr, but->editstr, UI_MAX_DRAW_STR);
+ BLI_strncpy(but->drawstr, but->editstr, UI_MAX_DRAW_STR);
/* text clipping moved to widget drawing code itself */
}
/* autocomplete helper functions */
struct AutoComplete {
- int maxlen;
+ size_t maxlen;
char *truncate;
const char *startname;
};
-AutoComplete *autocomplete_begin(const char *startname, int maxlen)
+AutoComplete *autocomplete_begin(const char *startname, size_t maxlen)
{
AutoComplete *autocpl;
}
}
-int ui_but_anim_expression_get(uiBut *but, char *str, int maxlen)
+int ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
{
FCurve *fcu;
ChannelDriver *driver;
extern void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my);
-extern void ui_get_but_string(uiBut *but, char *str, int maxlen);
-extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, int maxlen);
+extern void ui_get_but_string(uiBut *but, char *str, size_t maxlen);
+extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen);
extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str);
extern int ui_get_but_string_max_length(uiBut *but);
void ui_but_anim_paste_driver(struct bContext *C);
void ui_but_anim_add_keyingset(struct bContext *C);
void ui_but_anim_remove_keyingset(struct bContext *C);
-int ui_but_anim_expression_get(uiBut *but, char *str, int maxlen);
+int ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen);
int ui_but_anim_expression_set(uiBut *but, const char *str);
int ui_but_anim_expression_create(uiBut *but, const char *str);
void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, float cfra);
} MenuEntry;
typedef struct MenuData {
- char *instr;
+ const char *instr;
const char *title;
int titleicon;
int nitems, itemssize;
} MenuData;
-static MenuData *menudata_new(char *instr)
+static MenuData *menudata_new(const char *instr)
{
MenuData *md= MEM_mallocN(sizeof(*md), "MenuData");
static void menudata_free(MenuData *md)
{
- MEM_freeN(md->instr);
+ MEM_freeN((void *)md->instr);
if (md->items)
MEM_freeN(md->items);
MEM_freeN(md);
* @param str String to be parsed.
* @retval new menudata structure, free with menudata_free()
*/
-static MenuData *decompose_menu_string(char *str)
+static MenuData *decompose_menu_string(const char *str)
{
char *instr= BLI_strdup(str);
MenuData *md= menudata_new(instr);
uiBut *bt;
MenuData *md;
MenuEntry *entry;
- char *instr= arg_str;
+ const char *instr= arg_str;
int columns, rows, a, b;
uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT);
return hash;
}
-static int ui_popup_menu_hash(char *str)
+static int ui_popup_menu_hash(const char *str)
{
return BLI_ghashutil_strhash(str);
}
{
uiBlock *block;
uiBut *bt;
- ScrArea *sa;
- ARegion *ar;
uiPopupMenu *pup= arg_pup;
int offset[2], direction, minwidth, width, height, flip;
else {
/* for a header menu we set the direction automatic */
if(!pup->slideout && flip) {
- sa= CTX_wm_area(C);
- ar= CTX_wm_region(C);
-
+ ScrArea *sa= CTX_wm_area(C);
if(sa && sa->headertype==HEADERDOWN) {
+ ARegion *ar= CTX_wm_region(C);
if(ar && ar->regiontype == RGN_TYPE_HEADER) {
uiBlockSetDirection(block, UI_TOP);
uiBlockFlipOrder(block);
/* prepares shade colors */
-static void shadecolors4(char *coltop, char *coldown, const char *color, short shadetop, short shadedown)
+static void shadecolors4(char coltop[4], char *coldown, const char *color, short shadetop, short shadedown)
{
coltop[0]= CLAMPIS(color[0]+shadetop, 0, 255);
/* ************ button callbacks, state ***************** */
-static void widget_state_blend(char *cp, const char *cpstate, const float fac)
+static void widget_state_blend(char cp[3], const char cpstate[3], const float fac)
{
if(fac != 0.0f) {
cp[0]= (int)((1.0f-fac)*cp[0] + fac*cpstate[0]);