void GLUI_Separator::draw( int x, int y ) { int width, indent, orig; int cont_x, cont_y, cont_w, cont_h, cont_x_off, cont_y_off; if ( NOT can_draw() ) return; orig = set_to_glut_window(); if ( parent() != NULL ) { get_this_column_dims(&cont_x, &cont_y, &cont_w, &cont_h, &cont_x_off, &cont_y_off); width = cont_w - cont_x_off*2; } else { width = this->w; } indent = width * .05; glLineWidth( 1.0 ); glBegin( GL_LINES ); glColor3f( .5, .5, .5 ); glVertex2i( indent, GLUI_SEPARATOR_HEIGHT/2-1 ); glVertex2i( width-indent, GLUI_SEPARATOR_HEIGHT/2-1 ); glColor3f( 1., 1., 1. ); glVertex2i( indent, GLUI_SEPARATOR_HEIGHT/2 ); glVertex2i( width-indent, GLUI_SEPARATOR_HEIGHT/2 ); glEnd(); restore_window(orig); }
void GLUI_StaticText::set_text( char *text ) { int orig, state; orig = set_to_glut_window(); state = glui->set_front_draw_buffer(); /**** Erase old text first *****/ glMatrixMode( GL_MODELVIEW ); glPushMatrix(); translate_to_origin(); erase_text(); glPopMatrix(); set_name( text ); if ( NOT can_draw() ) return; /**** Redraw the text in the window ****/ glMatrixMode( GL_MODELVIEW ); glPushMatrix(); translate_to_origin(); draw_text(); glPopMatrix(); glui->restore_draw_buffer(state); restore_window( orig ); }
void GLUI_RadioButton::draw_active_area( void ) { int text_width, left, right, orig; if ( NOT can_draw() ) return; orig = set_to_glut_window(); text_width = _glutBitmapWidthString( glui->font, name ); left = text_x_offset-3; right = left + 7 + text_width; if ( active ) { glEnable( GL_LINE_STIPPLE ); glLineStipple( 1, 0x5555 ); glColor3f( 0., 0., 0. ); } else { glColor3ub( glui->bkgd_color.r, glui->bkgd_color.g, glui->bkgd_color.b ); } glBegin( GL_LINE_LOOP ); glVertex2i(left,0); glVertex2i( right,0); glVertex2i(right,h+1); glVertex2i( left,h+1); glEnd(); glDisable( GL_LINE_STIPPLE ); restore_window(orig); }
void GLUI_Rotation::iaction_draw_active_area_persp( void ) { if ( NOT can_draw() ) return; copy_float_array_to_ball(); setup_texture(); setup_lights(); glEnable(GL_CULL_FACE ); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); mat4 tmp_rot = *ball->rot_ptr; glMultMatrixf( (float*) &tmp_rot[0][0] ); /*** Draw the checkered box ***/ /*glDisable( GL_TEXTURE_2D ); */ draw_ball( 1.96 ); glPopMatrix(); glDisable( GL_TEXTURE_2D ); glDisable( GL_LIGHTING ); glDisable( GL_CULL_FACE ); }
void GLUI_RadioGroup::draw( int x, int y ) { if ( NOT can_draw() ) return; draw_group(false); }
void GLUI_StaticText::set_text( const char *text ) { int orig; /**** Erase old text first *****/ glMatrixMode( GL_MODELVIEW ); glPushMatrix(); translate_to_origin(); erase_text(); glPopMatrix(); set_name( (char *) text ); if ( NOT can_draw() ) return; orig = set_to_glut_window(); /**** Redraw the text in the window ****/ glMatrixMode( GL_MODELVIEW ); glPushMatrix(); translate_to_origin(); draw_text(); glPopMatrix(); restore_window( orig ); }
void GLUI_RadioButton::draw( int x, int y ) { int orig; orig = set_to_glut_window(); if ( NOT group OR NOT can_draw() ) return; /*** See if we're the currently-selected button. If so, draw ***/ if ( group->int_val == this->user_id ) { if ( enabled ) glui->std_bitmaps.draw( GLUI_STDBITMAP_RADIOBUTTON_ON, 0, 0 ); else glui->std_bitmaps.draw( GLUI_STDBITMAP_RADIOBUTTON_ON_DIS, 0, 0 ); } else { if ( enabled ) glui->std_bitmaps.draw( GLUI_STDBITMAP_RADIOBUTTON_OFF, 0, 0 ); else glui->std_bitmaps.draw( GLUI_STDBITMAP_RADIOBUTTON_OFF_DIS, 0, 0 ); } draw_active_area(); draw_name( text_x_offset, 10 ); restore_window(orig); }
int GLUI_Spinner::mouse_down_handler( int local_x, int local_y ) { this->state = find_arrow( local_x, local_y ); /* printf( "spinner: mouse down : %d/%d arrow:%d\n", local_x, local_y, find_arrow( local_x, local_y )); */ if ( state != GLUI_SPINNER_STATE_UP AND state != GLUI_SPINNER_STATE_DOWN ) return true; reset_growth(); if ( can_draw() ) draw_arrows(); /*** ints and floats behave a bit differently. When you click on an int spinner, you expect the value to immediately go up by 1, whereas for a float it'll go up only by a fractional amount. Therefore, we go ahead and increment by one for int spinners ***/ if ( data_type == GLUI_SPINNER_INT ) { if ( state == GLUI_SPINNER_STATE_UP ) edittext->set_float_val( edittext->float_val + 1.0 ); else if ( state == GLUI_SPINNER_STATE_DOWN ) edittext->set_float_val( edittext->float_val - .9 ); } do_click(); return false; }
void GLUI_Spinner::draw_arrows( void ) { if ( NOT can_draw() ) return; translate_and_draw_front(); }
void GLUI_Translation::iaction_draw_active_area_ortho( void ) { if ( NOT can_draw() ) return; /********* Draw emboss circles around arcball control *********/ float radius; radius = (float)(h-22)/2.0; /* MIN((float)w/2.0, (float)h/2.0); */ glLineWidth( 1.0 ); draw_emboss_box( (int) -radius-2, (int)radius+2, (int)-radius-2, (int)radius+2 ); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); glTranslatef( .5, .5, .5 ); /* glScalef( radius-1.0, radius-1.0, radius-1.0 ); */ if ( trans_type == GLUI_TRANSLATION_Z ) draw_2d_z_arrows((int)radius-1); else if ( trans_type == GLUI_TRANSLATION_XY ) draw_2d_xy_arrows((int)radius-1); else if ( trans_type == GLUI_TRANSLATION_X ) draw_2d_x_arrows((int)radius-1); else if ( trans_type == GLUI_TRANSLATION_Y ) draw_2d_y_arrows((int)radius-1); glPopMatrix(); }
/** * \brief Draws a new glyph on this sheet. * \param c The character to draw. * \param face The font face from which we take the glyph. */ void bear::visual::true_type_font::glyph_sheet::draw_character ( charset::char_type c, const freetype_face& face ) { CLAW_PRECOND( can_draw( c, face ) ); const size_box_type glyph_size( face.get_glyph_size(c) ); if ( m_next_position.x + glyph_size.x + 2 * s_margin.x >= m_image.width() ) { m_next_position.x = 0; m_next_position.y += m_current_line_height; m_current_line_height = 0; } m_image.draw( face.get_glyph( c ), m_next_position + s_margin ); character_placement placement; placement.clip = clip_rectangle( m_next_position, glyph_size + 2 * s_margin ); placement.metrics = face.get_glyph_metrics( c ); placement.metrics = glyph_metrics ( placement.metrics.get_advance() - s_margin, placement.metrics.get_bearing() - s_margin ); m_placement[ c ] = placement; m_next_position.x += glyph_size.x + 2 * s_margin.x; m_current_line_height = std::max ( m_current_line_height, (unsigned int)( glyph_size.y + 2 * s_margin.y ) ); } // true_type_font::glyph_sheet::draw_character()
int GLUI_TextBox::mouse_down_handler( int local_x, int local_y ) { int tmp_insertion_pt; if ( debug ) dump( stdout, "-> MOUSE DOWN" ); tmp_insertion_pt = find_insertion_pt( local_x, local_y ); if ( tmp_insertion_pt == -1 ) { if ( glui ) glui->deactivate_current_control( ); return false; } insertion_pt = tmp_insertion_pt; sel_start = sel_end = insertion_pt; keygoal_x = insert_x; if ( can_draw()) update_and_draw_text(); if ( debug ) dump( stdout, "<- MOUSE UP" ); return true; }
// virtual void GLUI_Slider::set_int_val( int new_int ) { CLAMP(new_int, int_low, int_high); int_val = new_int; output_live(true); if (can_draw()) draw_translated_active_area(); }
void GLUI_StaticText::draw_text( void ) { if ( NOT can_draw() ) return; erase_text(); draw_name( 0, 9 ); }
// virtual void GLUI_Slider::set_float_val( float new_float ) { CLAMP(new_float, float_low, float_high); float_val = new_float; output_live(true); if (can_draw()) draw_translated_active_area(); }
int GLUI_Spinner::mouse_held_down_handler( int local_x, int local_y, int new_inside) { int new_state; if ( state == GLUI_SPINNER_STATE_NONE ) return false; /* printf("spinner: mouse held: %d/%d inside: %d\n",local_x,local_y, new_inside); */ if ( state == GLUI_SPINNER_STATE_BOTH ) { /* dragging? */ do_drag( local_x, local_y ); } else { /* not dragging */ new_state = find_arrow( local_x, local_y ); if ( new_state == state ) { /** Still in same arrow **/ do_click(); } else { if ( new_inside OR 1) { /** The state changed, but we're still inside - that means we moved off the arrow: begin dragging **/ state = GLUI_SPINNER_STATE_BOTH; } else { /*** Here check y of mouse position to determine whether to drag ***/ /* ... */ } } /*** We switched to up/down dragging ***/ if ( state == GLUI_SPINNER_STATE_BOTH ) { glutSetCursor( GLUT_CURSOR_UP_DOWN ); last_x = local_x; last_y = local_y; /** If the spinner has limits, we reset the growth value, since reset_growth() will compute a new growth value for dragging vs. clicking. If the spinner has no limits, then we just let the growth remain at whatever the user has incremented it up to **/ if ( edittext->has_limits != GLUI_LIMIT_NONE ) reset_growth(); } if ( can_draw() ) draw_arrows(); } return false; }
void GLUI_EditText::update_and_draw_text( void ) { if ( NOT can_draw() ) return; update_substring_bounds(); /* printf( "ss: %d/%d\n", substring_start, substring_end ); */ redraw(); }
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(); }
int GLUI_EditText::special_handler( int key,int modifiers ) { if ( NOT glui ) return false; if ( debug ) printf( "SPECIAL:%d - mod:%d subs:%d/%d ins:%d sel:%d/%d\n", key, modifiers, substring_start, substring_end,insertion_pt, sel_start, sel_end ); if ( key == GLUT_KEY_LEFT ) { if ( (modifiers & GLUT_ACTIVE_CTRL) != 0 ) { insertion_pt = find_word_break( insertion_pt, -1 ); } else { insertion_pt--; } } else if ( key == GLUT_KEY_RIGHT ) { if ( (modifiers & GLUT_ACTIVE_CTRL) != 0 ) { insertion_pt = find_word_break( insertion_pt, +1 ); } else { insertion_pt++; } } else if ( key == GLUT_KEY_HOME ) { insertion_pt = 0; } else if ( key == GLUT_KEY_END ) { insertion_pt = (int) text.length(); } /*** Update selection if shift key is down ***/ if ( (modifiers & GLUT_ACTIVE_SHIFT ) != 0 ) sel_end = insertion_pt; else sel_start = sel_end = insertion_pt; CLAMP( insertion_pt, 0, (int) text.length()); /* Make sure insertion_pt is in bounds */ CLAMP( sel_start, 0, (int) text.length()); /* Make sure insertion_pt is in bounds */ CLAMP( sel_end, 0, (int) text.length()); /* Make sure insertion_pt is in bounds */ /******** Now redraw text ***********/ if ( can_draw()) update_and_draw_text(); return true; }
void GLUI_Column::draw( int x, int y ) { int orig; int panel_x, panel_y, panel_w, panel_h, panel_x_off, panel_y_off; int y_diff; if ( NOT can_draw() ) return; if ( int_val == 1 ) { /* Draw a vertical bar */ orig = set_to_glut_window(); if ( parent() != NULL ) { get_this_column_dims(&panel_x, &panel_y, &panel_w, &panel_h, &panel_x_off, &panel_y_off); y_diff = y_abs - panel_y; if ( 0 ) { glLineWidth(1.0); glBegin( GL_LINES ); glColor3f( .5, .5, .5 ); glVertex2i( -GLUI_XOFF+1, -y_diff + GLUI_SEPARATOR_HEIGHT/2 ); glVertex2i( -GLUI_XOFF+1, -y_diff + panel_h - GLUI_SEPARATOR_HEIGHT/2); glColor3f( 1.0, 1.0, 1.0 ); glVertex2i( -GLUI_XOFF+2, -y_diff + GLUI_SEPARATOR_HEIGHT/2 ); glVertex2i( -GLUI_XOFF+2, -y_diff + panel_h - GLUI_SEPARATOR_HEIGHT/2); glEnd(); } else { glLineWidth(1.0); glBegin( GL_LINES ); glColor3f( .5, .5, .5 ); glVertex2i( -2, 0 ); glVertex2i( -2, h ); /*glVertex2i( 0, -y_diff + GLUI_SEPARATOR_HEIGHT/2 ); */ /*glVertex2i( 0, -y_diff + panel_h - GLUI_SEPARATOR_HEIGHT/2); */ glColor3f( 1.0, 1.0, 1.0 ); glVertex2i( -1, 0 ); glVertex2i( -1, h ); /*glVertex2i( 1, -y_diff + GLUI_SEPARATOR_HEIGHT/2 ); */ /*glVertex2i( 1, -y_diff + panel_h - GLUI_SEPARATOR_HEIGHT/2); */ glEnd(); } } restore_window(orig); } }
void GLUI_Rotation::draw_ball( float radius ) { if ( NOT can_draw() ) return; if (quadObj == NULL) quadObj = gluNewQuadric(); if (quadObj) { gluQuadricDrawStyle(quadObj, GLU_FILL); gluQuadricNormals(quadObj, GLU_SMOOTH); gluQuadricTexture(quadObj, true ); gluSphere(quadObj, radius, 16, 16); } }
void GLUI_StaticText::draw( int x, int y ) { int orig; if ( NOT can_draw() ) return; orig = set_to_glut_window(); draw_text(); restore_window( orig ); }
static void key_action(int key) { int i, size; if(signal_sent) { print_help(); signal_sent = 0; } /* * First, try to process the key by object (subwindow, menu) that * could be on top. */ size = sizeof key_funct/sizeof(int (*)(int)); for(i = 0; i < size; i++) if(key_funct[i](key)) goto SKIP; if(current->keys(key)) goto SKIP; /* cursor movement */ size = sizeof key_handlers/sizeof(struct key_handler); for(i = 0; i < size; i++) if(key_handlers[i].c == key) { key_handlers[i].handler(current); if(can_draw()) pad_draw(); goto SKIP; } switch(key) { case 'c': full_cmd ^= 1; current->redraw(); break; case '/': m_search(); break; case KBD_F1: help(); break; case KBD_ESC: case 'q': curses_end(); exit(0); default: return; } SKIP: dolog("%s: doing refresh\n", __FUNCTION__); wnoutrefresh(main_win); wnoutrefresh(info_win.wd); pad_refresh(); menu_refresh(); box_refresh(); info_refresh(); doupdate(); }
void GLUI_StaticText::draw( int x, int y ) { int orig, state; if ( NOT can_draw() ) return; orig = set_to_glut_window(); state = glui->set_front_draw_buffer(); draw_text(); glui->restore_draw_buffer(state); restore_window( orig ); }
void GLUI_RadioButton::draw_checked( void ) { int orig; if ( NOT can_draw() ) return; orig = set_to_glut_window(); if ( enabled ) glui->std_bitmaps.draw( GLUI_STDBITMAP_RADIOBUTTON_ON, 0, 0 ); else glui->std_bitmaps.draw( GLUI_STDBITMAP_RADIOBUTTON_ON_DIS, 0, 0 ); draw_active_area(); restore_window(orig); }
void GLUI_RadioButton::draw_O( void ) { int i, j, orig; if ( NOT can_draw() ) return; orig = set_to_glut_window(); glBegin( GL_POINTS ); for(i=3; i<=GLUI_RADIOBUTTON_SIZE-3; i++ ) for(j=3; j<=GLUI_RADIOBUTTON_SIZE-3; j++ ) glVertex2i(i,j); glEnd(); restore_window(orig); }
void GLUI_EditText::draw_insertion_pt( void ) { int curr_x, i; if ( NOT can_draw() ) return; /*** Don't draw insertion pt if control is disabled ***/ if ( NOT enabled ) return; if ( debug ) dump( stdout, "-> DRAW_INS_PT" ); if ( sel_start != sel_end OR insertion_pt < 0 ) { return; /* Don't draw insertion point if there is a current selection */ } /* printf( "insertion pt: %d\n", insertion_pt ); */ curr_x = this->x_abs + text_x_offset + substring_width( substring_start, substring_end ) + 2 /* The edittext box has a 2-pixel margin */ + GLUI_EDITTEXT_BOXINNERMARGINX; /** plus this many pixels blank space between the text and the box **/ for( i=substring_end; i>=insertion_pt; i-- ) { curr_x -= char_width( text[i] ); } glColor3f( 0.0, 0.0, 0.0 ); glBegin( GL_LINE_LOOP ); /*** glVertex2i( curr_x, y_abs + 4 ); glVertex2i( curr_x, y_abs + 4 ); glVertex2i( curr_x, y_abs + h - 3 ); glVertex2i( curr_x, y_abs + h - 3 ); ***/ curr_x -= x_abs; glVertex2i( curr_x, 0 + 4 ); glVertex2i( curr_x, 0 + 4 ); glVertex2i( curr_x, 0 + h - 3 ); glVertex2i( curr_x, 0 + h - 3 ); glEnd(); if ( debug ) dump( stdout, "-> DRAW_INS_PT" ); }
void GLUI_Rotation::draw_ball( float radius ) { if ( NOT can_draw() ) return; if (quadObj == NULL) quadObj = gluNewQuadric(); if (quadObj) { gluQuadricDrawStyle(quadObj, GLU_FILL); gluQuadricNormals(quadObj, GLU_SMOOTH); gluQuadricTexture(quadObj, true ); glMatrixMode(GL_TEXTURE); glLoadIdentity(); double checkerTiles=2.0; /* black-white checker tiles across whole sphere */ glScalef(checkerTiles,checkerTiles,1.0); gluSphere(quadObj, radius, 32, 16); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); } }
void GLUI_EditText::draw( int x, int y ) { int orig; int name_x; if ( NOT can_draw() ) return; orig = set_to_glut_window(); name_x = MAX(text_x_offset - string_width(this->name) - 3,0); draw_name( name_x , 13); glBegin( GL_LINES ); glColor3f( .5, .5, .5 ); glVertex2i( text_x_offset, 0 ); glVertex2i( w, 0 ); glVertex2i( text_x_offset, 0 ); glVertex2i( text_x_offset, h ); glColor3f( 1., 1., 1. ); glVertex2i( text_x_offset, h ); glVertex2i( w, h ); glVertex2i( w, h ); glVertex2i( w, 0 ); if ( enabled ) glColor3f( 0., 0., 0. ); else glColor3f( .25, .25, .25 ); glVertex2i( text_x_offset+1, 1 ); glVertex2i( w-1, 1 ); glVertex2i( text_x_offset+1, 1 ); glVertex2i( text_x_offset+1, h-1 ); glColor3f( .75, .75, .75 ); glVertex2i( text_x_offset+1, h-1 ); glVertex2i( w-1, h-1 ); glVertex2i( w-1, h-1 ); glVertex2i( w-1, 1 ); glEnd(); /** Find where to draw the text **/ update_substring_bounds(); draw_text(0,0); draw_insertion_pt(); restore_window(orig); }
void GLUI_TextBox::set_text( const char *new_text ) { text = new_text; substring_start = 0; substring_end = text.length() - 1; insertion_pt = -1; sel_start = 0; sel_end = 0; visible_lines = 0; start_line = 0; curr_line = 0; num_lines = 0; if ( can_draw() ) update_and_draw_text(); /*** Now update the live variable ***/ output_live(true); }