void GLUI_Control::draw_bkgd_box( int x_min, int x_max, int y_min, int y_max ) { set_to_bkgd_color(); glBegin( GL_QUADS ); glVertex2i( x_min, y_min ); glVertex2i( x_max, y_min ); glVertex2i( x_max, y_max ); glVertex2i( x_min, y_max ); glEnd(); }
void GLUI_StaticText::erase_text( void ) { if ( NOT can_draw() ) return; set_to_bkgd_color(); glDisable( GL_CULL_FACE ); glBegin( GL_TRIANGLES ); glVertex2i( 0,0 ); glVertex2i( w, 0 ); glVertex2i( w, h ); glVertex2i( 0, 0 ); glVertex2i( w, h ); glVertex2i( 0, h ); glEnd(); }
void GLUI_Translation::draw_2d_arrow( int radius, int filled, int orientation ) { float x1 = .2, x2 = .4, y1 = .54, y2 = .94, y0; float x1a, x1b; vec3 col1( 0.0, 0.0, 0.0 ), col2( .45, .45, .45 ), col3( .7, .7, .7 ), col4( 1.0, 1.0, 1.0 ); vec3 c1, c2, c3, c4, c5, c6; vec3 white(1.0,1.0,1.0), black(0.0,0.0,0.0), gray(.45,.45,.45), bkgd(.7,.7,.7); int c_off; /* color index offset */ if ( glui ) bkgd.set(glui->bkgd_color_f[0], glui->bkgd_color_f[1], glui->bkgd_color_f[2]); /* bkgd[0] = 255.0; bkgd[1] = 0; */ /** The following 8 colors define the shading of an octagon, in clockwise order, starting from the upstroke on the left **/ /** This is for an outside and inside octagons **/ vec3 colors_out[]={white, white, white, gray, black, black, black, gray}; vec3 colors_in[] ={bkgd,white,bkgd,gray,gray,gray,gray,gray}; #define SET_COL_OUT(i) glColor3fv((float*) &colors_out[(i)%8][0]); #define SET_COL_IN(i) glColor3fv((float*) &colors_in[(i)%8][0]); x1 = (float)radius * .2; x2 = x1 * 2; y1 = (float)radius * .54; y2 = y1 + x2; x1a = x1; x1b = x1; glMatrixMode(GL_MODELVIEW); glPushMatrix(); #define DRAW_SEG( xa,ya,xb,yb ) glVertex2f(xa,ya); glVertex2f(xb,yb); glScalef( -1.0, 1.0, 1.0 ); if ( orientation == 2 ) { c_off = 4; } else if ( orientation == 0 ) { c_off = 0; glRotatef( 180.0, 0.0, 0.0, 1.0 ); } else if ( orientation == 1 ) { c_off = 2; glRotatef( 90.0, 0.0, 0.0, 1.0 ); } else if ( orientation == 3 ) { c_off = 6; glRotatef( -90.0, 0.0, 0.0, 1.0 ); } if ( trans_type == GLUI_TRANSLATION_Z ) y0 = 0.0; else if ( trans_type == GLUI_TRANSLATION_XY ) y0 = x1; else y0 = 0.0; if ( trans_type == GLUI_TRANSLATION_Z ) { if ( orientation == 0 ) { y1 += 2.0; y2 += 0.0; x1b -= 2.0; x2 -= 2.0; x1a += 2.0; } else if ( orientation == 2 ) { y1 -= 6.0; x1a += 2.0; x1b += 4.0; x2 += 6.0; } } /*** Fill in inside of arrow ***/ if ( NOT filled ) { /*** Means button is up - control is not clicked ***/ /*glColor3f( .8, .8, .8 ); */ set_to_bkgd_color(); glColor3f( bkgd[0]+.07, bkgd[1]+.07, bkgd[2]+.07 ); } else { /*** Button is down on control ***/ glColor3f( .6, .6, .6 ); c_off += 4; /* Indents the shadows - goes from a raised look to embossed */ } /*** Check if control is enabled or not ***/ if ( NOT enabled ) { set_to_bkgd_color(); /*c_off += 4; -- Indents the shadows - goes from a raised look to embossed */ colors_out[0] = colors_out[1] = colors_out[2] = colors_out[7] = gray; colors_out[3] = colors_out[4] = colors_out[5] = colors_out[6] = white; colors_in[0] = colors_in[1] = colors_in[2] = colors_in[7] = white; colors_in[3] = colors_in[4] = colors_in[5] = colors_in[6] = gray; } glBegin( GL_POLYGON ); glVertex2f( 0.0, 0.0 ); glVertex2f( -x1a, 0.0 ); glVertex2f( -x1a, 0.0 ); glVertex2f( -x1b, y1 ); glVertex2f( x1b, y1); glVertex2f( x1a, 0.0 ); glVertex2f( x1a, 0.0 ); glVertex2f( 0.0, 0.0 ); glEnd(); glBegin( GL_TRIANGLES ); glVertex2f( -x2, y1 ); glVertex2f( 0.0, y2 ); glVertex2f( x2, y1 ); glEnd(); glLineWidth( 1.0 ); /*** Draw arrow outline ***/ glBegin( GL_LINES ); SET_COL_IN(1+c_off); DRAW_SEG( 0.0, y2-1.0, -x2, y1-1.0 ); SET_COL_IN(6+c_off); DRAW_SEG( -x2+2.0, y1+1.0, -x1b+1.0, y1+1.0 ); SET_COL_IN(0+c_off); DRAW_SEG( -x1b+1.0, y1+1.0, -x1a+1.0, y0 ); SET_COL_IN(3+c_off); DRAW_SEG( 0.0, y2-1.0, x2, y1-1.0 ); SET_COL_IN(6+c_off); DRAW_SEG( x2-1.0, y1+1.0, x1b-1.0, y1+1.0 ); SET_COL_IN(4+c_off); DRAW_SEG( x1b-1.0, y1+1.0, x1a-1.0, y0 ); SET_COL_OUT(0+c_off); DRAW_SEG( -x1a, y0, -x1b, y1 ); SET_COL_OUT(6+c_off); DRAW_SEG( -x1b, y1, -x2, y1 ); SET_COL_OUT(1+c_off); DRAW_SEG( -x2, y1, 0.0, y2 ); SET_COL_OUT(3+c_off); DRAW_SEG( 0.0, y2, x2, y1 ); SET_COL_OUT(6+c_off); DRAW_SEG( x2, y1, x1b, y1 ); SET_COL_OUT(4+c_off); DRAW_SEG( x1b, y1, x1a, y0 ); glEnd(); #undef DRAW_SEG glPopMatrix(); }
void GLUI_EditText::draw_text( int x, int y ) { GLUI_DRAWINGSENTINAL_IDIOM int text_x, i, sel_lo, sel_hi; if ( debug ) dump( stdout, "-> DRAW_TEXT" ); if ( NOT draw_text_only ) { if ( enabled ) glColor3f( 1., 1., 1. ); else set_to_bkgd_color(); glDisable( GL_CULL_FACE ); glBegin( GL_QUADS ); glVertex2i( text_x_offset+2, 2 ); glVertex2i( w-2, 2 ); glVertex2i( w-2, h-2 ); glVertex2i( text_x_offset+2, h-2 ); glEnd(); } /** Find where to draw the text **/ text_x = text_x_offset + 2 + GLUI_EDITTEXT_BOXINNERMARGINX; /*printf( "text_x: %d substr_width: %d start/end: %d/%d\n", text_x, substring_width( substring_start, substring_end ), substring_start, substring_end ); */ /** Find lower and upper selection bounds **/ sel_lo = MIN(sel_start, sel_end ); sel_hi = MAX(sel_start, sel_end ); int sel_x_start, sel_x_end, delta; /** Draw selection area dark **/ if ( sel_start != sel_end ) { sel_x_start = text_x; sel_x_end = text_x; for( i=substring_start; i<=substring_end; i++ ) { delta = char_width( text[i] ); if ( i < sel_lo ) { sel_x_start += delta; sel_x_end += delta; } else if ( i < sel_hi ) { sel_x_end += delta; } } glColor3f( 0.0f, 0.0f, .6f ); glBegin( GL_QUADS ); glVertex2i( sel_x_start, 2 ); glVertex2i( sel_x_end, 2 ); glVertex2i( sel_x_end, h-2 ); glVertex2i( sel_x_start, h-2 ); glEnd(); } if ( sel_start == sel_end ) { /* No current selection */ if ( enabled ) glColor3b( 0, 0, 0 ); else glColor3b( 32, 32, 32 ); glRasterPos2i( text_x, 13); for( i=substring_start; i<=substring_end; i++ ) { glutBitmapCharacter( get_font(), this->text[i] ); } } else { /* There is a selection */ int x = text_x; for( i=substring_start; i<=substring_end; i++ ) { if ( IN_BOUNDS( i, sel_lo, sel_hi-1)) { /* This character is selected */ glColor3f( 1., 1., 1. ); glRasterPos2i( x, 13); glutBitmapCharacter( get_font(), this->text[i] ); } else { glColor3f( 0., 0., 0. ); glRasterPos2i( x, 13); glutBitmapCharacter( get_font(), this->text[i] ); } x += char_width( text[i] ); } } if ( debug ) dump( stdout, "<- DRAW_TEXT" ); }