diff options
author | Matt Ebb <matt@mke3.net> | 2005-10-05 00:17:30 +0400 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2005-10-05 00:17:30 +0400 |
commit | b6817b55e80f3e2ffa66a2cbdaf3a669a9d94e80 (patch) | |
tree | 272f212304ff6028b0c0e6523c3aa8fad7fe0821 /source | |
parent | 5b25951013caa841fb0bbcf2aeb78b74e80c0e50 (diff) |
* 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
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/src/interface.c | 31 | ||||
-rw-r--r-- | source/blender/src/toolbox.c | 16 |
2 files changed, 36 insertions, 11 deletions
diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index 039a349c54f..f147bf82dd8 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -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); } diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c index 5927820b30c..d270f3184ff 100644 --- a/source/blender/src/toolbox.c +++ b/source/blender/src/toolbox.c @@ -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); } |