Page Menu
Home
Search
Configure Global Search
Log In
Files
F2189
interface_c_multiline_tip.patch
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.patch
View Options
Index: source/blender/src/interface.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/interface.c,v
retrieving revision 1.227
diff -u -u -r1.227 interface.c
--- source/blender/src/interface.c 13 Mar 2006 02:22:48 -0000 1.227
+++ source/blender/src/interface.c 29 Apr 2006 10:58:02 -0000
@@ -4549,12 +4549,28 @@
return retval;
}
+
static uiOverDraw *ui_draw_but_tip(uiBut *but)
{
uiOverDraw *od;
float x1, x2, y1, y2;
-
-#ifdef INTERNATIONAL
+
+ /* Vars for multiline */
+ int multiline=0, 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+1]= i+1; /* store the char of the newline */
+ multiline++;
+ }
+ }
+ newline_idxs[multiline+1]= i; /* last char index */
+
+ #ifdef INTERNATIONAL
if(G.ui_international == TRUE) {
float llx,lly,llz,urx,ury,urz; //for FTF_GetBoundingBox()
@@ -4577,7 +4593,7 @@
x1= (but->x1+but->x2)/2; x2= 10+x1+ but->aspect*BMF_GetStringWidth(but->font, but->tip);
y1= but->y1-30; y2= but->y1-12;
#endif
-
+
/* for pulldown menus it doesnt work */
if(mywinget()==G.curscreen->mainwin);
else {
@@ -4593,7 +4609,72 @@
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
+
+ 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);
+
+ /* Get max line width */
+ if (multiline) {
+ for(i=multiline; i>=0; i--) {
+ ui_rasterpos_safe( x1+3, (12*(multiline-i) + y1)+5.0/but->aspect, but->aspect);
+ BLI_strncpy(temp_line, but->tip+newline_idxs[i], (newline_idxs[i+1] - newline_idxs[i])-1);
+ line_width= MAX2(line_width, BMF_GetStringWidth(but->font, temp_line));
+ }
+ } else {
+ line_width= BMF_GetStringWidth(but->font, but->tip);
+ }
+
+
+ x1= (but->x1+but->x2)/2; x2= 10+x1+ but->aspect*line_width;
+ y1= but->y1-30; y2= but->y1-12;
+
+ /*multiline, will do nothing if not multiline.*/
+ y2+= (multiline)*14;
+
+ /* for pulldown menus it doesnt work */
+ if(mywinget()==G.curscreen->mainwin);
+ else {
+ ui_graphics_to_window(mywinget(), &x1, &y1);
+ ui_graphics_to_window(mywinget(), &x2, &y2);
+ }
+
+ if(x2 > G.curscreen->sizex) {
+ x1 -= x2-G.curscreen->sizex;
+ x2= G.curscreen->sizex;
+ }
+ if(y1 < 0) {
+ y1 += 36;
+ y2 += 36;
+ }
+
+
// adjust tooltip heights
if(mywinget()==G.curscreen->mainwin)
y2 -= G.ui_international ? 4:1; //tip is from pulldownmenu
@@ -4622,14 +4703,28 @@
glRectf(x1, y1, x2, y2);
glColor3ub(0,0,0);
+
+ BIF_SetScale(1.0); /*test with international fonmts*/
+
ui_rasterpos_safe( x1+3, y1+5.0/but->aspect, but->aspect);
- BIF_SetScale(1.0);
-
- BIF_DrawString(but->font, but->tip, (U.transopts & USER_TR_TOOLTIPS));
+
+ /* Draw String Multi or single line */
+ if (multiline) {
+ for(i=multiline; i>=0; i--) {
+ ui_rasterpos_safe( x1+3, (14*(multiline-i) + y1)+5.0/but->aspect, but->aspect);
+ BIF_SetScale(1.0); /*test with international fonmts*/
+ BLI_strncpy(temp_line, but->tip+newline_idxs[i], (newline_idxs[i+1] - newline_idxs[i])-1);
+ /* Insert check for python end of line "%p"? here for changed colour */
+ BIF_DrawString(but->font, temp_line, (U.transopts & USER_TR_TOOLTIPS));
+ }
+ } else {
+ BIF_DrawString(but->font, but->tip, (U.transopts & USER_TR_TOOLTIPS));
+ }
ui_flush_overdraw(od); /* to show it in the frontbuffer */
return od;
}
+
/* inside this function no global UIbuttip... qread is not safe */
static void ui_do_but_tip(uiBut *buttip)
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
70/c4/94b5920cbf75479eb8a941340f54
Event Timeline
Log In to Comment