Page Menu
Home
Search
Configure Global Search
Log In
Files
F2190
interface_c_multiline_tip_finc.txt
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Campbell Barton (campbellbarton)
Nov 13 2013, 1:02 PM
Size
4 KB
Subscribers
None
interface_c_multiline_tip_finc.txt
View Options
static uiOverDraw *ui_draw_but_tip(uiBut *but)
{
uiOverDraw *od;
float x1, x2, y1, y2;
/* Vars for multiline */
int multiline=1, i, line_width=0;
unsigned char newline_idxs[64]; /*store an array of newline indicies*/
char temp_line[255];
/* Check for multiline */
newline_idxs[0]= 0;
for (i=1; but->tip[i] != '\0'; i++) {
if (but->tip[i-1]=='\\' && but->tip[i]=='n') {
newline_idxs[multiline]= i+1; /* store thThats e char of the newline */
BLI_strncpy(temp_line, but->tip+newline_idxs[multiline-1], (newline_idxs[multiline]-newline_idxs[multiline-1])-1);
line_width= MAX2(line_width, BMF_GetStringWidth(but->font, temp_line));
//printf("%s\n", temp_line);
//printf("\tline_width %i, multiline %i\n", line_width, multiline);
multiline++;
}
}
if (multiline>1) {
newline_idxs[multiline]= i+2; /* +2? last char index */
/* Must get check the last line length*/
BLI_strncpy(temp_line, but->tip+newline_idxs[multiline-1], (newline_idxs[multiline]-newline_idxs[multiline-1])-1);
line_width= MAX2(line_width, BMF_GetStringWidth(but->font, temp_line));
//printf("%s\n", temp_line);
//printf("\tline_width %i, multiline %i\n", line_width, multiline);
} else {
multiline= 0;
line_width= BMF_GetStringWidth(but->font, but->tip);
}
#ifdef INTERNATIONAL - TODO, MULTILINE, INTERNATIONAL FONTS
if(G.ui_international == TRUE) {
float llx,lly,llz,urx,ury,urz; //for FTF_GetBoundingBox()
if(U.transopts & USER_TR_TOOLTIPS) {
FTF_GetBoundingBox(but->tip, &llx,&lly,&llz,&urx,&ury,&urz, FTF_USE_GETTEXT | FTF_INPUT_UTF8);
x1= (but->x1+but->x2)/2; x2= 10+x1+ but->aspect*FTF_GetStringWidth(but->tip, FTF_USE_GETTEXT | FTF_INPUT_UTF8); //BMF_GetStringWidth(but->font, but->tip);
y1= but->y1-(ury+FTF_GetSize())-12; y2= but->y1-12;
} else {
FTF_GetBoundingBox(but->tip, &llx,&lly,&llz,&urx,&ury,&urz, FTF_NO_TRANSCONV | FTF_INPUT_UTF8);
x1= (but->x1+but->x2)/2; x2= 10+x1+ but->aspect*FTF_GetStringWidth(but->tip, FTF_NO_TRANSCONV | FTF_INPUT_UTF8); //BMF_GetStringWidth(but->font, but->tip);
y1= but->y1-(ury+FTF_GetSize())-12; y2= but->y1-12;
}
} else {
x1= (but->x1+but->x2)/2; x2= 10+x1+ but->aspect*line_width;
y1= but->y1-30; y2= but->y1-12;
}
#else
x1= (but->x1+but->x2)/2; x2= 10+x1+ but->aspect*line_width;
y1= but->y1-30; y2= but->y1-12;
#endif
/* for pulldown menus it doesnt work */
if(mywinget()==G.curscreen->mainwin) {
/* Pull Down Menu */
//printf("\tPulldown Menu\n");
} else {
/* Normal Button */
//printf("\tui_graphics_to_window(mywinget(), &x1, &y1);\n");
ui_graphics_to_window(mywinget(), &x1, &y1);
ui_graphics_to_window(mywinget(), &x2, &y2);
}
if(x2 > G.curscreen->sizex) {
//printf("\tif(x2 > G.curscreen->sizex) {;\n");
x1 -= x2-G.curscreen->sizex;
x2= G.curscreen->sizex;
}
if(y1 < 0) {
//printf("\tif(y1 < 0) {\n");
y1 += 36;
y2 += 36;
}
// adjust tooltip heights
if(mywinget()==G.curscreen->mainwin)
y2 -= G.ui_international ? 4:1; //tip is from pulldownmenu
else if(curarea->win != mywinget())
y2 -= G.ui_international ? 5:1; //tip is from a windowheader
// else y2 += 1; //tip is from button area
/*multiline, will do nothing if not multiline.*/
if (multiline)
y2+= (multiline-1)*14;
od= ui_begin_overdraw((int)(x1-1), (int)(y1-2), (int)(x2+4), (int)(y2+4));
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glColor4ub(0, 0, 0, 20);
gl_round_box(GL_POLYGON, x1+3, y1-1, x2+1, y2-2, 2.0);
gl_round_box(GL_POLYGON, x1+3, y1-2, x2+2, y2-2, 3.0);
glColor4ub(0, 0, 0, 8);
gl_round_box(GL_POLYGON, x1+3, y1-3, x2+3, y2-3, 4.0);
gl_round_box(GL_POLYGON, x1+3, y1-4, x2+4, y2-3, 5.0);
glDisable(GL_BLEND);
glColor3ub(0xFF, 0xFF, 0xDD);
glRectf(x1, y1, x2, y2);
glColor3ub(0,0,0);
/* Draw String Multi or single line */
BIF_SetScale(1.0); /*test with international fonts*/
if (multiline) {
for(i=multiline-1; i>=0; i--) {
BLI_strncpy(temp_line, but->tip+newline_idxs[i], (newline_idxs[i+1] - newline_idxs[i])-1);
ui_rasterpos_safe( x1+3, (12*(multiline-i) + y1)-5.0/but->aspect, but->aspect);
/* Insert check for python end of line "%p"? here for changed colour */
BIF_DrawString(but->font, temp_line, (U.transopts & USER_TR_TOOLTIPS));
}
} else {
ui_rasterpos_safe( x1+3, y1+5.0/but->aspect, but->aspect);
BIF_DrawString(but->font, but->tip, (U.transopts & USER_TR_TOOLTIPS));
}
ui_flush_overdraw(od); /* to show it in the frontbuffer */
//printf("\t%i\n", multiline);
return od;
}
File Metadata
Details
Mime Type
text/plain
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
56/62/8e971014bf079eeda59d5c04cf2b
Event Timeline
Log In to Comment