[Plib-cvs] plib/src/pui pu.h,1.147,1.148 puBox.cxx,1.10,1.11 puFont.cxx,1.23,1.24 puInput.cxx,1.34,1
Brought to you by:
sjbaker
From: James J. <pu...@us...> - 2004-08-05 01:05:58
|
Update of /cvsroot/plib/plib/src/pui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19250 Modified Files: pu.h puBox.cxx puFont.cxx puInput.cxx puObject.cxx Log Message: (1) "puBox.cxx" - Change the amount and appearance of the "default-return" widget dashed lines (2) "pu.h", "puFont.cxx", "puInput.cxx", and "puObject.cxx" - Andy Ross' rendering fixes (related to the "fnt" library changes) Index: pu.h =================================================================== RCS file: /cvsroot/plib/plib/src/pui/pu.h,v retrieving revision 1.147 retrieving revision 1.148 diff -u -d -r1.147 -r1.148 --- pu.h 6 Apr 2004 12:53:16 -0000 1.147 +++ pu.h 5 Aug 2004 01:05:48 -0000 1.148 @@ -62,9 +62,11 @@ slant = sl ; } + float getPointSize ( ) const { return pointsize; } + int getStringDescender ( void ) const ; int getStringHeight ( const char *str ) const ; - int getStringHeight ( void ) const { return getStringHeight ( "K" ) ; } + int getStringHeight ( void ) const { return getStringHeight ( "" ) ; } float getFloatStringWidth ( const char *str ) const ; int getStringWidth ( const char *str ) const /* Deprecated ? */ Index: puBox.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puBox.cxx,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- puBox.cxx 2 Sep 2002 06:05:45 -0000 1.10 +++ puBox.cxx 5 Aug 2004 01:05:48 -0000 1.11 @@ -24,7 +24,7 @@ #include "puLocal.h" -#define PU_DFLT_OFFSET 8 +#define PU_DFLT_OFFSET 5 void puBox::extend ( puBox *bx ) { @@ -253,10 +253,10 @@ glLineStipple ( 1, 0xF0F0 ) ; glEnable ( GL_LINE_STIPPLE ) ; glBegin ( GL_LINE_LOOP ) ; - glVertex2i ( dx + min[0] + PU_DFLT_OFFSET, dy + min[1] + PU_DFLT_OFFSET ) ; - glVertex2i ( dx + min[0] + PU_DFLT_OFFSET, dy + max[1] - PU_DFLT_OFFSET ) ; - glVertex2i ( dx + max[0] - PU_DFLT_OFFSET, dy + max[1] - PU_DFLT_OFFSET ) ; - glVertex2i ( dx + max[0] - PU_DFLT_OFFSET, dy + min[1] + PU_DFLT_OFFSET ) ; + glVertex2f ( dx + min[0] + PU_DFLT_OFFSET + 0.5f, dy + min[1] + PU_DFLT_OFFSET + 0.5f ) ; + glVertex2f ( dx + min[0] + PU_DFLT_OFFSET + 0.5f, dy + max[1] - PU_DFLT_OFFSET - 0.5f ) ; + glVertex2f ( dx + max[0] - PU_DFLT_OFFSET - 0.5f, dy + max[1] - PU_DFLT_OFFSET - 0.5f ) ; + glVertex2f ( dx + max[0] - PU_DFLT_OFFSET - 0.5f, dy + min[1] + PU_DFLT_OFFSET + 0.5f ) ; glEnd () ; glDisable ( GL_LINE_STIPPLE ) ; } Index: puFont.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puFont.cxx,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- puFont.cxx 16 Feb 2004 13:49:03 -0000 1.23 +++ puFont.cxx 5 Aug 2004 01:05:48 -0000 1.24 @@ -75,15 +75,22 @@ int puFont::getStringHeight ( const char *s ) const { - /* Height *excluding* descender */ - - if ( s == NULL ) - return 0 ; + if (!s || !fnt_font_handle) return 0 ; - if ( fnt_font_handle != NULL ) - return int ( pointsize * ( 1.333f * count_lines ( s ) - 0.333f ) ) ; + // The height of a single line is the ascender plus descender, not + // including whitespace above and below. Each additional line + // adds one point size, of course. Remember to round up to avoid + // overlapping artifacts. The bbox string is just a sample of + // "likely to be tall" glyphs. + float ascend; + fnt_font_handle -> getBBox ( "$lfKL", pointsize, slant, NULL, NULL, NULL, &ascend ) ; + float height = ascend + getStringDescender() ; + int lines = count_lines ( s ) ; + if ( lines > 1 ) + height += ( lines - 1 ) * pointsize ; - return 0 ; + return int ( height + 0.999 ) ; + // return int ( pointsize * count_lines ( s ) + 0.999 ) - getStringDescender(); } Index: puInput.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puInput.cxx,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- puInput.cxx 23 Feb 2004 04:16:52 -0000 1.34 +++ puInput.cxx 5 Aug 2004 01:05:48 -0000 1.35 @@ -82,7 +82,8 @@ else { int xx = legendFont.getStringWidth ( " " ) ; - int yy = ( abox.max[1] - abox.min[1] - legendFont.getStringHeight () ) / 2 ; + int yy = ( ( abox.max[1] - abox.min[1] - legendFont.getStringHeight () ) / 2 + + legendFont.getStringDescender () ) ; int ncut ; char *s2 ; @@ -150,20 +151,20 @@ { s2 [ cursor_position-ncut ] = '\0' ; - int cpos = legendFont.getStringWidth ( s2 ) + xx + dx + abox.min[0] ; - int top = yy + legendFont.getStringHeight () ; - int bot = yy - legendFont.getStringDescender() ; + float cpos = 0.5f + legendFont.getStringWidth ( s2 ) + xx + dx + abox.min[0] ; + float top = 0.5f + dy + abox.min[1] + yy + legendFont.getPointSize () ; + float bot = 0.5f + dy + abox.min[1] + yy - legendFont.getStringDescender() ; glColor4fv ( colour [ PUCOL_MISC ] ) ; glBegin ( GL_LINES ) ; - glVertex2i ( cpos , dy + abox.min[1] + bot ) ; - glVertex2i ( cpos , dy + abox.min[1] + top ) ; - glVertex2i ( cpos - 1, dy + abox.min[1] + bot ) ; - glVertex2i ( cpos - 1, dy + abox.min[1] + top ) ; - glVertex2i ( cpos - 4, dy + abox.min[1] + bot ) ; - glVertex2i ( cpos + 3, dy + abox.min[1] + bot ) ; - glVertex2i ( cpos - 4, dy + abox.min[1] + top ) ; - glVertex2i ( cpos + 3, dy + abox.min[1] + top ) ; + glVertex2f ( cpos , bot ) ; + glVertex2f ( cpos , top ) ; + glVertex2f ( cpos - 1, bot ) ; + glVertex2f ( cpos - 1, top ) ; + glVertex2f ( cpos - 3, bot ) ; + glVertex2f ( cpos + 3, bot ) ; + glVertex2f ( cpos - 3, top ) ; + glVertex2f ( cpos + 3, top ) ; glEnd () ; } } Index: puObject.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puObject.cxx,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- puObject.cxx 19 Sep 2002 23:32:58 -0000 1.49 +++ puObject.cxx 5 Aug 2004 01:05:48 -0000 1.50 @@ -337,9 +337,9 @@ case PUPLACE_LOWER_LEFT : /* Backwards compatibility to PUPLACE_LEFT */ case PUPLACE_LOWER_RIGHT : /* Backwards compatibility to PUPLACE_RIGHT */ default : - yy = ( abox.max[1] - abox.min[1] + - legendFont.getStringHeight ( legend ) ) / 2 - - legendFont.getStringHeight () ; + yy = ( abox.max[1] - abox.min[1] + - legendFont.getStringHeight ( legend ) ) / 2 + + legendFont.getStringDescender () ; break ; case PUPLACE_BOTTOM_LEFT : @@ -427,9 +427,9 @@ case PUPLACE_CENTERED_LEFT : case PUPLACE_CENTERED_RIGHT : default : - yy = ( bbox.max[1] - bbox.min[1] + - labelFont.getStringHeight ( label ) ) / 2 - - labelFont.getStringHeight () ; + yy = ( bbox.max[1] - bbox.min[1] - + labelFont.getStringHeight ( label ) ) / 2 + + labelFont.getStringDescender () ; break ; case PUPLACE_LOWER_LEFT : |