* Added from tuhopuu: icons in ok/confirmation popups

( http://mke3.net/blender/interface/controls/error_ok_icons.png )

A bit nicer and quick to visually recognise at a glance
This commit is contained in:
2005-10-04 20:17:30 +00:00
parent 5b25951013
commit b6817b55e8
2 changed files with 36 additions and 11 deletions

View File

@@ -955,6 +955,7 @@ typedef struct {
typedef struct {
char *instr;
char *title;
int titleicon;
MenuEntry *items;
int nitems, itemssize;
@@ -965,15 +966,18 @@ static MenuData *menudata_new(char *instr) {
md->instr= instr;
md->title= NULL;
md->titleicon= NULL;
md->items= NULL;
md->nitems= md->itemssize= 0;
return md;
}
static void menudata_set_title(MenuData *md, char *title) {
static void menudata_set_title(MenuData *md, char *title, int titleicon) {
if (!md->title)
md->title= title;
if (!md->titleicon)
md->titleicon= titleicon;
}
static void menudata_add_item(MenuData *md, char *str, int retval, int icon) {
@@ -1041,6 +1045,8 @@ static MenuData *decompose_menu_string(char *str)
s++;
} else if (s[1]=='i') {
nicon= atoi(s+2);
*s= '\0';
s++;
}
} else if (c=='|' || c=='\0') {
@@ -1048,7 +1054,7 @@ static MenuData *decompose_menu_string(char *str)
*s= '\0';
if (nitem_is_title) {
menudata_set_title(md, nitem);
menudata_set_title(md, nitem, nicon);
nitem_is_title= 0;
} else {
menudata_add_item(md, nitem, nretval, nicon);
@@ -1169,9 +1175,14 @@ static int ui_do_but_MENU(uiBut *but)
if(md->title) {
uiBut *bt;
uiSetCurFont(block, block->font+1);
bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+rows*boxh), (short)width, (short)boxh, NULL, 0.0, 0.0, 0, 0, "");
if (md->titleicon) {
uiDefIconTextBut(block, LABEL, 0, md->titleicon, md->title, startx, (short)(starty+rows*boxh), (short)width, (short)boxh, NULL, 0.0, 0.0, 0, 0, "");
} else {
bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+rows*boxh), (short)width, (short)boxh, NULL, 0.0, 0.0, 0, 0, "");
bt->flag= UI_TEXT_LEFT;
}
uiSetCurFont(block, block->font);
bt->flag= UI_TEXT_LEFT;
}
for(a=0; a<md->nitems; a++) {
@@ -5205,9 +5216,17 @@ short pupmenu(char *instr)
/* here we go! */
if(md->title) {
uiBut *bt;
char titlestr[256];
uiSetCurFont(block, UI_HELVB);
bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+height), width, boxh, NULL, 0.0, 0.0, 0, 0, "");
bt->flag= UI_TEXT_LEFT;
if (md->titleicon) {
width+= 20;
sprintf(titlestr, " %s", md->title);
uiDefIconTextBut(block, LABEL, 0, md->titleicon, titlestr, startx, (short)(starty+height), width, boxh, NULL, 0.0, 0.0, 0, 0, "");
} else {
bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+height), width, boxh, NULL, 0.0, 0.0, 0, 0, "");
bt->flag= UI_TEXT_LEFT;
}
uiSetCurFont(block, UI_HELV);
}

View File

@@ -1068,9 +1068,12 @@ int okee(char *str, ...)
{
va_list ap;
int ret;
char titlestr[256];
sprintf(titlestr, "OK? %%i%d", ICON_HELP);
va_start(ap, str);
ret= vconfirm("OK?", str, ap);
ret= vconfirm(titlestr, str, ap);
va_end(ap);
return ret;
@@ -1089,15 +1092,18 @@ void error(char *fmt, ...)
{
va_list ap;
char nfmt[256];
sprintf(nfmt, "ERROR: %s", fmt);
char titlestr[256];
sprintf(titlestr, "Error %%i%d", ICON_ERROR);
sprintf(nfmt, "%s", fmt);
va_start(ap, fmt);
if (G.background || !G.curscreen || (R.flag & R_RENDERING)) {
vprintf(nfmt, ap);
printf("\n");
} else {
vconfirm(NULL, nfmt, ap);
vconfirm(titlestr, nfmt, ap);
}
va_end(ap);
}