示例#1
0
UIMenu::UIMenu() { 
	_options.clear();
	_selected = -1;
    _id = IDManager::instance()->getPickID();
    fillCol(Color4D ( 0.8, 0.8, 1.0, 0.5 ) );
    lineCol(Color4D ( 0,0,0,1.0) ) ;
}
示例#2
0
void
ShredInstance::_setupButtons() { 
    if ( _buttonsready ) return;
    _killButton = new UIButton();
    _killButton->resize(0.8,0.8);
    _killButton->fillCol(Color4D(1.0,0.3, 0.3, 0.9));
    _killButton->lineCol(Color4D(0.2,0.2, 0.2, 0.9));
    _killButton->setLabel( "X" );

    _buttonsready = true;
}
示例#3
0
void
menuItem::reshape()  
{ 
    button.resize(1.0,1.0);
    button.moveto(0.0,0.0);
    button.setCode( code );
    button.setLabel( name );
    button.fitXLabel( 0.75 );
    button.fillCol(Color4D ( 1.0, 1.0, 1.0, 0.8 ) );
    button.lineCol(Color4D ( 0,0,0,1.0) ) ;
}
示例#4
0
AlertBox::AlertBox( std::string s ) :
    _dismissed ( false ),
    _mscale ( 0.045 )
{ 
    setMessage ( s ) ;
    setColor ( Color4D(0.5 , 1.0, 0.5 ) );
}  
示例#5
0
TextContent::TextContent() :
    WindowContent(),
    _leading(0.06),
    _fontScale(0.04),
    _fontAspect(1.0),
    _fontWeight(1),
    _windowLinePos(0),
    _windowLineSpan(0),
    _magicCharPos(0),
    _title("buffer:"),
    _canvasDirty(true),
    _parsed(NULL),
    _parse_tree(NULL),
    _parse_edit_point(0),
    _viewportDirty(true)
{ 
    EM_log( CK_LOG_FINER, "(audicle) TextContent ctor..." );
    _loc.line = 0;
    _loc.chr = 0;
    _markLoc = _loc;
    _wSpace  = bufferFont->length("m");
    _wTab    = _wSpace * 4;
    _viewport.setScale( 1.1, 1.1 );
    _fontColor = Color4D ( 0,0,0,0.95 );
    _buf = new_buffer();
    
    //should be in CodeRevision
}
示例#6
0
void
CodeRevision::_setupButtons() { 
    if ( _buttonsready ) return;
    _sporkButton = new UIButton();
    _sporkButton->resize(0.8,0.8);
    _sporkButton->fillCol(Color4D(0.3,1.0, 0.3, 0.9));
    _sporkButton->lineCol(Color4D(0.2,0.2, 0.2, 0.9));
    _sporkButton->setLabel( "S" );
    _killButton = new UIButton();
    _killButton->resize(0.8,0.8);
    _killButton->fillCol(Color4D(1.0,0.3, 0.3, 0.9));
    _killButton->lineCol(Color4D(0.2,0.2, 0.2, 0.9));
    _killButton->setLabel( "X" );

    _buttonsready = true;
}
示例#7
0
void 
LineRenderer::initColors() { 

	token_colors.resize( NUM_SYNTAX_TYPES, Color4D(0,0,0) );

	token_colors[PAREN]		= Color4D(0,0,1);
	token_colors[CHUCK_OP]	= Color4D(1.0,0.2,0);
	token_colors[KEYWORD]	= Color4D(0.6,0.6,0);
	token_colors[INTEGER]	= Color4D(0.3,0,0);
	token_colors[FLOATING]	= Color4D(0.0,0.3,0);
	token_colors[STRING]	= Color4D(0.0,0.4,0);
	token_colors[COMMENT]	= Color4D(0.8,0.4,0);

}
示例#8
0
t_CKBOOL server_handle_update_info( AudiclePak * pack )
{
    EM_log( CK_LOG_INFO, "server about to handle update info for user %d", pack->user );

    CoCoServer * server = &(CoAudicle::instance()->coco_server); 
    CoCoSession * session = server->get( pack->user );
    if( session != NULL )
    {
        EM_log( CK_LOG_INFO, "server handled update info for user %d", pack->user );
        session->m_update_socket = pack->sender;
        
        // inform user of other users for that server
        AudiclePak packet;
        packet.type = HEY_USER_ADD;
        packet.alloc( 100 );
        packet.length = 100;
        packet.user = session->m_user_id;
        map <t_CKUINT, CoCoSession *>::iterator it;
        for( it = server->m_sessions.begin(); it != server->m_sessions.end(); it++ )
        {
            *(t_CKUINT *)packet.data = (*it).first;
            strcpy( packet.data + 4, (*it).second->m_user_name.c_str() );
            strcpy( packet.data + 36, (*it).second->m_host_name.c_str() );
            session->m_update_socket->send( &packet );
        }

        // set state
        packet.type = UPDATE_DUDE;
        CoCoUserState state;
        state.m_location = Point3D( ( 2.0 * ::rand() / (t_CKFLOAT)RAND_MAX - 1.0 ), 0,
                                    ( 2.0 * ::rand() / (t_CKFLOAT)RAND_MAX - 1.0 ) );
        state.m_orientation = Vec3D( 0, 0, -1 );
        state.m_color = Color4D( (::rand() / (t_CKFLOAT)RAND_MAX), (::rand() / (t_CKFLOAT)RAND_MAX), (::rand() / (t_CKFLOAT)RAND_MAX), 1.0 );
        state.m_home = Point3D( 0, 0, 0 );
        strcpy( state.m_msg, "hey" );
        packet.alloc( sizeof(state) );
        packet.length = sizeof(state);
        memcpy( packet.data, &state, sizeof(state) );
        
        CoAudicle::instance()->coco_server.broadcast( &packet );
        
        // start audio
        CoAudicle::instance()->audio_server.add( session->m_ip.c_str(), CO_AUDIO_PORT );
    }
    else
    {
        EM_log( CK_LOG_INFO, "server not coping well" );
        return FALSE;
    }

    return TRUE;
}
示例#9
0
//-----------------------------------------------------------------------------
// name: AudicleWindow()
// desc: ...
//-----------------------------------------------------------------------------
AudicleWindow::AudicleWindow()
{
    m_windowID = 0;
    memset( m_pick_buffer, 0, sizeof(m_pick_buffer) );
    memset( m_cur_vp, 0, sizeof(m_cur_vp) );
    m_hsize = 800;
    m_vsize = 600;
    m_w = 800;
    m_h = 600;
    m_render_mode = GL_RENDER;
    m_antialiased = false;
//    m_console = NULL;
    m_bg = Color4D( 0.0f, 0.0f, 0.0f, 1.0f );
    m_frame_stamp = 0;
}
示例#10
0
void 
UIRectangle::_defColors( ) { 

    _bg[UI_BASE]      = Color4D( 0.2, 0.2, 0.2, 0.3 );
    _border[UI_BASE]  = Color4D( 0.2, 0.8, 0.2, 0.8 );
    
    _bg[UI_HOVER]     = Color4D( 0.2, 0.2, 0.2, 0.5 );
    _border[UI_HOVER] = Color4D( 0.5, 0.8, 0.5, 0.8 );
    
    _bg[UI_SEL]       = Color4D( 0.5, 0.8, 0.8, 0.9 );
    _border[UI_SEL]   = Color4D( 0.5, 0.9, 0.3, 0.9 );

}
示例#11
0
t_CKUINT
AudicleFaceTnT::render_shred( Shred_Stat * stat) { 

    int j;

    static UIButton nameButton; //plug this into time, potentially

    Shred_Time * time = stat->time;

    check_active_stat( time );

    Color4D scol( 1,1,1,1 );    

    if ( stat->data ) 
        scol = stat->data->color;

    if ( !time->active || !m_drawing_active_set ) 
        scol = scol.interp (Color4D ( 1.0, 1.0, 1.0, 0.2), 0.50);
    else 
        scol = scol.interp ( Color4D ( 1.0, 1.0, 1.0, 1.0 ) , 0.25 );

    static char buf[512];
    sprintf(buf, " (%03d):", stat->xid );

    double sleading = 1.0;
    double ssize = 1.0;
    if ( time->switching ) { 
        double anim_d = ( m_now - time->switch_time ) / time->switch_span ; 
        if (anim_d > 1.0 ) { 
            time->switching = false;
            anim_d = 1.0;
        }
        if ( time->active ) { 

            sleading = anim_d ;
            ssize = anim_d ;
        }
        else { 
            sleading =  1.0 - anim_d ; 
            ssize    =  1.0 - anim_d ; 
        }
    }

    else if ( !time->active ) { 
        ssize = 0.0;
        sleading = 0.0;
        return 0;
    }


    glTranslated ( 0, -m_item_spacing * sleading , 0.0 );

    if ( m_drawing_active_set ) m_active_accum += m_item_spacing * sleading ;
    else m_done_accum += m_item_spacing * sleading;
    
    glPushMatrix();
    
    glTranslated ( -m_aspt + 0.475 , 0, 0 );

    nameButton.resize( ssize * m_item_height, ssize * m_item_height );
    nameButton.setLabel( stat->name + buf );
    nameButton.fitLabel();
    nameButton.setw ( nameButton.w() * 0.65 );

    nameButton.fillCol( scol );
    nameButton.lineCol( Color4D ( 0.3, 0.3, 0.3, 1.0 ) );
    
    glLineWidth( 2.0 );

    glPushMatrix();


    if ( m_drawing_scale > 1.0 ) glScaled (  1.0, 1.0 / m_drawing_scale , 1.0 );
    if ( nameButton.w() > 0.45 ) glScaled ( 0.45 / nameButton.w(), 1.0, 1.0 );
    nameButton.moveto ( -nameButton.w(), nameButton.h() );
    nameButton.drawRounded( 0.80f );

    glPopMatrix();

    glPopMatrix();


    //view for the shred histories...
    glPushMatrix();
    glTranslated ( -m_aspt + 0.5 , 0, 0 );
    glScaled (  ( m_aspt * 2.0 - 0.5 )  / m_window , ssize * m_item_height *  m_mheight , 1.0 );


    glLineWidth ( 1.0 );
    glBegin( GL_LINES);    

    Color4D linebase ( 0.0, 0.8, 0.0 , ( !time->active || !m_drawing_active_set ) ? 0.20 : 1.0 );
    glColor4dv  ( linebase.data() );

    glVertex2d ( 0.0, 0.0 );
    glVertex2d ( m_window, 0.0 );
  
    glEnd();

    linebase = linebase.interp ( scol, 0.5 );

    double x, y, dt, emph;

    t_CKDUR emph_window = min ( 0.5 * m_srate , 0.125 * m_window ) ;
    Color4D emph_col = Color4D ( 1.0, 1.0, 1.0, 1.0);


    glLineWidth(5.0 );
    glBegin(GL_LINES);

    for ( j = time->history.size() -1  ; j > 0 && time->history[j].when > m_now - emph_window ; j-- ) 
    { 
        dt = m_now - time->history[j].when;
        if ( dt < 0 ) fprintf(stderr, "dt < 0 : %f\n", dt );
        x = ( m_wrapmode == 0 ) ?  dt : fmod ( time->history[j].when, m_window ) ;
        y = ( m_log_scale ) ? log ( (double) time->history[j].cycles ) : time->history[j].cycles; 
        emph = ( dt <  emph_window ) ? 1.0 - ( dt / emph_window )  : 0.0 ;
        glColor4dv  ( linebase.interp( emph_col, emph * 0.75).alpha(emph).data() );
        glVertex2d( x , y  );
        glVertex2d( x , 0  );
  
    }
    glEnd();


    glLineWidth (1.0 );
    glColor4dv  ( linebase.data() );
    glBegin(GL_LINES);
    for ( j = time->history.size() -1  ; j > 0 && time->history[j].when > m_earliest ; j-- ) 
    { 

        x = ( m_wrapmode == 0 ) ?  m_now - time->history[j].when : fmod ( time->history[j].when, m_window ) ;
        y = ( m_log_scale ) ? log ( (double) time->history[j].cycles ) : time->history[j].cycles; 

        glVertex2d( x , y  );
        glVertex2d( x , 0  );

        
    }


    glEnd();

/*
    if ( time->history.size() > 0 && stat->wake_time != 0 ) { 
        glPushMatrix();
        glScaled(   1.0, \
                    ( m_log_scale ) ? log ( (double)time->history.back().cycles ) : time->history.back().cycles , \
                    ( m_log_scale ) ? log ( (double)time->history.back().cycles ) : time->history.back().cycles );
        double sleeping = ( stat->wake_time - time->history.back().when );

        //comment this out - old code 
        if ( sleeping > 0 ) { 

            glPushMatrix();
            glTranslated ( (m_wrapmode == 0) ? 0 : fmod ( m_now, m_window )  , 0 , 0  );
            double rev = 90.0 * ( m_now - time->history.back().when ) / sleeping; 
            glRotated( rev, 1.0, 0.0, 0.0 );        
            glColor4d( 1,0.7,0.7,0.8);
            glLineWidth(2);
            glBegin(GL_LINES);
            glVertex3d(0,0.0,0.0 );
            glVertex3d(0,1.0,0.0 );
            glEnd();
            glPopMatrix();
        }
        //end old

        if ( sleeping > 0 ) { 

            double f_to_time =  ( m_now - time->history.back().when ) / sleeping;  
            double xn = (m_wrapmode == 0) ? 0 : fmod ( m_now, m_window );
            double xw = (m_wrapmode == 0) ? stat->wake_time : fmod ( stat->wake_time , m_window );
            glBegin( GL_LINES );
            glColor4d ( 0.25 + 0.75 * f_to_time, 1.0 , f_to_time, 0.4 );
            if ( m_wrapmode != 0 && xw < xn ) { //we're over the page wrap... 
                glVertex3d( xn , -0.1, 0 );
                glVertex3d( m_window, -0.1 , 0 );
                glVertex3d( 0 , -0.1, 0 );
                glVertex3d( xw, -0.1, 0 );
            }
            else { 
                glVertex3d( xn , -0.1, 0  );
                glVertex3d( xw , -0.1, 0 );
            }
            glEnd();
        }

        glPointSize(8);
        glBegin(GL_POINTS);
        glVertex3d( (m_wrapmode == 0 )? stat->wake_time : fmod ( stat->wake_time , m_window )  ,-0.1,0.0 );
        glEnd();
        glPopMatrix();
    }

*/


    glPopMatrix();
 
    return 0;
}
示例#12
0
t_CKUINT
AudicleFaceTnT::render_cycle_shred( Shred_Stat * stat, float w, float h ) { 

    Color4D me;
    if ( stat->state != 3 ) 
        me = stat->data->color.interp( Color4D( 0.7, 1.0, 0.7, 0.7 ), 0.2 );
    else 
        me = stat->data->color.interp( Color4D( 0.5, 0.5, 0.5, 0.2 ), 0.8 );
    
    if ( stat == m_current_shred ) 
        me = me.interp ( Color4D (0.8,1.0,0.8,1.0), 0.5 );

    glPushName(stat->data->name);
    if ( stat->children.size() > 0 ) {  
       glPushMatrix();
       float self = h * (float)stat->cycles / (float)stat->time->group_cycles;
       glColor4dv( stat->data->color.interp( Color4D( 0, 0.8, 0.8, 0.8), 0.2 ).data()  );
       glBegin(GL_QUADS);
       glVertex2f ( 0, 0 );
       glVertex2f ( w, 0 );
       glVertex2f ( w, -self );
       glVertex2f ( 0, -self );
       glEnd();

       glPushMatrix();
        glColor4d ( 0,0,0,0.5 );
        glTranslated( 0.5 * w, -self * 0.5 - 0.025, 0);
        labelFont->scale( 0.05, 1.0 );
        labelFont->draw_centered ( stat->name.c_str() );
//        scaleFont( 0.05, 1.0 );
//        drawString_centered( stat->name.c_str() );
       glPopMatrix();

       glTranslated ( 0, -self, 0 );
       render_cycle_shred_group ( stat->children, 0, stat->children.size(), w, h-self );
       glPopMatrix();
    }

    glColor4dv ( me.data() );
    glBegin(GL_QUADS);
    glVertex2f ( 0, 0 );
    glVertex2f ( w, 0 );
    glVertex2f ( w, -h );
    glVertex2f ( 0, -h );
    glEnd();
    if ( m_current_shred  == stat ) { 
        glPushMatrix();
        int inum = stat->shred_ref->code->num_instr;
        float scale = ( inum == 0 ) ? 1.0 : h / ( 0.05 * (float)inum ); 
        glScaled ( scale , scale, 1.0 );
        for ( int j = 0; j < inum; j++ ) {
            glTranslated ( 0, -0.05, 0 );
            glPushMatrix();
            labelFontMono->scale ( 0.05 );
            labelFontMono->draw ( (char*)( typeid( *(stat->shred_ref->instr[j]) ).name() + 18 ) );
//            scaleFont_mono(0.05, 1.0);
            //plus 18 to skip 'class Chuck_Instr_'
//            drawString_mono( (char*)( typeid( *(stat->shred_ref->instr[j]) ).name() + 18 ) );
            glPopMatrix();
        }
        glPopMatrix();
    }
    if ( stat->state != 3 ) { 
        glColor4dv ( me.interp( Color4D ( 1,1,1,1 ), 0.5 ).data() ) ;
//        fprintf(stderr, "pc : %u of %u ", stat->shred_ref->next_pc, stat->shred_ref->code->num_instr );
        float pc_pos = (float)stat->shred_ref->pc / (float)stat->shred_ref->code->num_instr ; 
        glBegin(GL_LINES);
        glVertex2f ( 0, pc_pos * -h );
        glVertex2f ( w, pc_pos * -h );
        glEnd();
    }

    glColor4d ( 0,0,0,0.5 );
    glBegin(GL_LINE_LOOP);
    glVertex2f ( 0, 0 );
    glVertex2f ( w, 0 );
    glVertex2f ( w, -h );
    glVertex2f ( 0, -h );
    glEnd();

    char buf[256];
    sprintf(buf, "(%d)", stat->xid );
    glLineWidth( (stat==m_current_shred ) ? 3.0 : 2.0);
    glPushMatrix();
        glTranslated( 0.5 * w, -0.5 * h , 0);
        labelFont->scale ( 0.05 );
        labelFont->draw_centered ( buf );
//        scaleFont( 0.05, 1.0 );
//        drawString_centered( buf );
    glPopMatrix();
    glLineWidth(1.0);
    glPushMatrix();
        glTranslated( 0.5 * w, -0.5 * h - 0.045, 0);
        labelFont->scale ( 0.03 );
        labelFont->draw_centered ( stat->name.c_str() );
//        scaleFont( 0.03, 0.8 );
//        drawString_centered( stat->name.c_str() );
    glPopMatrix();

    glPopName();
    return 1;
}
示例#13
0
void
TextContent::draw() {
    
    _fixCanvas();
    _fixView();
    
    glPushMatrix();
    
    glPushMatrix();
    _viewport.setCols( UI_BASE, Color4D( 1.0,1.0,1.0, 0.8 ), Color4D(0.2, 0.5, 0.2, 0.8 ) );
    _viewport.viewTranslate();
    _viewport.filledQuad();
    glPopMatrix();
    
    _viewport.scale();
    _viewport.viewTranslate();
    
    glColor4d( 0,0,0,0.9);
    glLineWidth (2.0);

        
    if (_parse_tree) { 
        glPushMatrix();
        glScaled( _leading * 1.2 , -_leading, 0 ); //scale to match line positions
        glTranslated ( 1.0 , 0.0 ,0.0 );
        glColor4d ( 1,0,0,0.2 );
        _parse_tree->draw_tree();
        glPopMatrix();

        //glPushMatrix();
        //glTranslated( _leading * 5.0, 0, 0 );
        //glPushMatrix();
        //glScaled( _leading * 0.7 , _leading, 0 ); //scale to match line positions
        //_parse_tree->draw_tree_buffer(_buf);
        //glPopMatrix();
        //glPopMatrix();
    }
	
    glLineWidth ( ( _selected ) ? _fontWeight : _fontWeight );

    glTranslated( 0, _windowLinePos * -_leading, 0 ); //for all the lines we are skipping
    
    int n = min ( _windowLinePos + _windowLineSpan , _buf->nlines() );
    for  (int i = _windowLinePos ; i < n ; i++ ) { 
        glTranslated( 0, -_leading, 0 );
        
        glPushMatrix();
        scaleFont(_fontScale , _fontAspect );
        
        //
        if ( RenderMode == GL_RENDER &&  _markSpan.begin.line <= i && i <= _markSpan.end.line ) {  
            
            double x1,x2;
            
            x1 = 0;
            if ( i == _markSpan.begin.line ) 
                x1 = drawString_length(_buf->line(i).str().substr(0, _markSpan.begin.chr).c_str());
            
            
            if ( i == _markSpan.end.line )
                x2 = drawString_length(_buf->line(i).str().substr(0, _markSpan.end.chr).c_str());
            else 
                x2 = drawString_length(_buf->line(i).str().c_str());
            
            glColor4d( 0.0, 0.8, 0.8, 0.6 );
            glBegin(GL_QUADS);
            glVertex2d( x1-10 ,    -10 );
            glVertex2d( x2 + 10 , -10 );
            glVertex2d( x2 + 10 , 110 );
            glVertex2d( x1-10 ,    110 );
            glEnd();
        }
        
        if ( RenderMode == GL_RENDER &&  i == _loc.line ) { 
            
            //highlight span;
                    
            //highlight current line
            glColor4d( 0.8, 0.8, 0.0, 0.2 );
            double x = _canvas.w() * 100 * 200; //drawString_length(_lines[i].cstr());
            glBegin(GL_QUADS); 
            glVertex2d( -10 ,    -10 );
            glVertex2d( x + 10 , -10 );
            glVertex2d( x + 10 , 110 );
            glVertex2d( -10 ,    110 );
            glEnd();
            
            //draw cursor
            x = drawString_length(_buf->line(i).str().substr(0, _loc.chr).c_str());
            double x2 = drawString_length(_buf->line(i).str().substr(0, _loc.chr).c_str());
            glBegin(GL_LINES);
            
            glColor4d( 1.0 , 0.0, 0.0, 0.9 );
            
            glVertex2d ( x, -10 );
            glVertex2d ( x, 110 );
            glVertex2d ( x, -10 );
            glVertex2d ( x2, -10);
            
            glEnd();
            
        }   
        //draw the line
        glColor4d( 0,0,0,0.9);
        _buf->line(i).draw();
        glPopMatrix();
    }
    glPopMatrix();
}
示例#14
0
void 
ShellContent::draw() { 

	if ( _console ) { 
		string s;
		_prompt = _console->prompt();
		while ( _console->has_output() ) { 
			_console->get_output(s);
			output( s );
		}
	}

    _fixCanvas();
    _fixView();

    bool blending = ( WindowManager::getRenderMode() == WINDOW_RENDER_BLEND );
             
    glPushMatrix();
       
    glPushMatrix();
    _viewport.setCols( UI_BASE, Color4D( 1.0,1.0,1.0, 0.8 ), Color4D(0.2, 0.5, 0.2, 0.8 ) );
    _viewport.viewTranslate();
    
    if ( blending ) _viewport.filledQuad();
    glPopMatrix();
    
    _viewport.scale();
    _viewport.viewTranslate();

    glColor4dv( _fontColor.data() );
    glLineWidth (2.0);

    glLineWidth ( _fontWeight );

    //translate to bottom to draw our input line
    glTranslated ( 0, - _viewport.vpH() + _leading * 0.333, 0 );

    //rogue colors!
    if ( blending ) { 
        glColor4d( 1.0,1.0,0.9,1.0);

        glBegin (GL_QUADS);
        glVertex2d (0.0, 0.0  );
        glVertex2d (0.0, _leading  );
        glVertex2d ( _viewport.vpW(), _leading  );
        glVertex2d ( _viewport.vpW(), 0.0  );
        glEnd();
    }
    //draw current entry
    
	drawEntry();

    if ( !_output->empty() ) { 
        int range = min ( _output->nlines(), 8 );
        glColor4dv( _fontColor.data() );
        glTranslated( 0, _leading * ( range ) , 0 );
        for ( t_CKUINT i = _output->nlines()-range ; i < _output->nlines() ; i++ ) { 
            glTranslated ( 0, -_leading, 0 );
            glPushMatrix();
            bufferFont->scale ( _fontScale, _fontAspect );
            bufferFont->draw_sub( _output->line(i).str() );
            glPopMatrix();
        }
    }

    glPopMatrix();

}
示例#15
0
void
ConsoleWindow::drawUILayer() {


    glLineWidth ( 3.0 );

//    _contentWindow.outlineRounded(0.05);
//    _cubeWindow.outlineRounded(0.05);

    Audicle* audi = Audicle::instance();

    double glomod =  fabs( -1.0 + 2.0 * ( m_time * 0.6  - floor(m_time * 0.6 ) ) );

    double xdiv = 0.5 * ( _cubeWindow.right() + _contentWindow.left() ) ;
    glBegin(GL_LINES);
    glColor4d ( 0.2,0.2, 0.2, 1.0 );
    glVertex2d ( xdiv, _cubeWindow.top() - _marginSize );
    glVertex2d ( xdiv, _cubeWindow.bottom() + _marginSize );
    glEnd();


    _sizeBox.outlineRounded();


    glLineWidth(1.5);

    _curLabel.draw( 0.75 );
    _curDisplay.draw( 0.75 );
    
    if ( _active ) { 
        _prevLabel.draw( 0.75 );
        _prevDisplay.draw( 0.75 );
    }

    static char buffer[256];
    double time = the()->shreduler()->now_system;
    int sr = Digitalio::sampling_rate(); //m_sampling_rate;

    int samp = (int) time;
    int sec = samp / sr;
    int min = ( sec / 60 ) ;
    int hr =  ( min / 60 ) ;
    int day = ( hr / 24 );

    samp = samp % sr;
    sec = sec % 60;
    min = min % 60;
    hr = hr % 24;

    if ( day ) sprintf(buffer, "%dd:%02d:%02d:%02d.%05d", day,  hr, min, sec, samp );
    else if ( hr ) sprintf(buffer, "%02d:%02d:%02d.%05d", hr, min, sec, samp );
    else if ( min ) sprintf(buffer, "%02d:%02d.%05d", min, sec, samp );
    else if ( sec ) sprintf(buffer, "%02d.%05d", sec, samp );
    else sprintf(buffer, "%05d", samp );

    _timeDisplay.setLabel( buffer ) ;
    _timeDisplay.fitLabel( 1 );
    _timeDisplay.setw( _timeDisplay.w() * 0.70 );
    _timeDisplay.filledRounded( 0.03f );
    _timeDisplay.drawLabel( 0.75, 1 );
    _timeDisplay.outlineRounded( 0.03f );

    glPushName( _timeLabel.id() );

    Color4D tdark = Color4D( 0.6, 0.9, 0.6, 1.0 );
    Color4D tglow = tdark.interp( _timeLabel.col(), glomod * 1.2  );
    tglow[3] = 1.0;

    _timeLabel.setCol( tglow );

    glBegin( GL_POLYGON );
    _timeLabel.roundVerts( );
    glEnd( );

    _timeLabel.drawLeadedLabel( 0.75f, 0.15f );
    _timeLabel.outlineRounded( ); 

    glPopName();

    if ( _active ) { 

        glLineWidth( 3.0 );
        glPushMatrix();
        
        double cubh = _cubeSides[0].h();
        
        glTranslated ( _cubeWindow.center()[0] - cubh * 3.5 , _cubeWindow.center()[1] + cubh * 1.5, 0 );
        
        if ( _cube_swapping )  { 

            double w = ( m_time - _cube_swap_start ) / _cube_swap_span ;
            if ( w > 1.0 ) { 
                _cube_swapping = false ;
                for ( int i = 0 ; i < 6 ; i++ ) 
                    _swapPos[i] = _cubeSides[i].pos();
            }
            else if ( w > 0 ) 
            {
                for ( int i = 0; i < 6 ; i++ ) { 
                    
                    glPushMatrix();
                    glPushName( _cubeSides[i].id() );
                    Point2D animp = _swapPos[i].interp ( _cubeSides[i].pos() , w );
                    
                    glTranslated( animp[0] - _cubeSides[i].pos()[0], \
                                  animp[1] - _cubeSides[i].pos()[1], 0 );
                    
                    _cubeSides[i].drawQuad( 0.75 );
                    
                    glPopName();
                    glPopMatrix();
                }
            }
        }
        
        if ( !_cube_swapping ) {  
            for ( int i = 0 ; i < 6; i++ ) { 
                glPushName( _cubeSides[i].id() );
                _cubeSides[i].drawQuad( 0.75 );
                glPopName();
            }
        }

        t_CKUINT cur = audi->look_here();
        
        Point2D _cube_spot( cubh * 6.0 , -cubh * 1.5 );
        
        glPushMatrix();
        glTranslated ( _cube_spot[0], _cube_spot[1], 0 );
        glScaled  ( 1.5, 1.5, 1.5 );
        glRotatef ( -30, 1.0, 0.0, 0.0 );
        glRotatef ( 30, 0.0, 1.0 ,0.0 );
        
        glPushMatrix();
        glTranslated( 0, 0, -0.5 * cubh );
        glTranslated(-_cubeSides[cur].center()[0], -_cubeSides[cur].center()[1], 0.0  );
        glPushName( _cubeSides[cur].id() );
        
        
        
        Color4D dark = _cubeSides[cur].col().scale(0.75);
        Color4D glow = dark.interp( _cubeSides[cur].col(), glomod * 1.1  );
        glow[3] = 1.0;
        _cubeSides[cur].setCol( glow );
        
        glBegin( GL_QUADS);
        _cubeSides[cur].quadVerts( );
        glEnd( );
        
        _cubeSides[cur].drawLabel( 0.75 );
        _cubeSides[cur].outlineQuad( );
        
//    _cubeSides[cur].drawQuad( 0.75 );
        
        
        glPopName();
        glPopMatrix();
        
        glPushMatrix();
        glRotatef ( 90, 1.0 , 0, 0 );
        t_CKUINT up = audi->look_from( cur, Audicle::UP ) ;
        glTranslated( 0, 0, -0.5 * cubh );
        glTranslated(-_cubeSides[up].center()[0], -_cubeSides[up].center()[1], 0.0  );
        glPushName( _cubeSides[up].id() );
        _cubeSides[up].drawQuad( 0.75 );
        glPopName();
        glPopMatrix();
        
        glPushMatrix();
        glRotatef ( -90, 0.0 , 1.0 , 0 );
        t_CKUINT rt = audi->look_from( cur, Audicle::RIGHT ); 
        glTranslated( 0, 0, -0.5 * cubh );
        glTranslated(-_cubeSides[rt].center()[0], -_cubeSides[rt].center()[1], 0.0  );
        glPushName( _cubeSides[rt].id() );
        _cubeSides[rt].drawQuad( 0.75 );
        glPopName();
        glPopMatrix();
        
        glPopMatrix();
        
        glPopMatrix();

    }


}
示例#16
0
void
TextContent::draw() {
    
    _fixCanvas();
    _fixView();
    
    glPushMatrix();
    
    glPushMatrix();
    _viewport.setCols( UI_BASE, Color4D( 1.0,1.0,1.0, 0.8 ), Color4D(0.2, 0.5, 0.2, 0.8 ) );
    _viewport.viewTranslate();
    _viewport.filledQuad();
    glPopMatrix();
    
    _viewport.scale();
    _viewport.viewTranslate();

//    glColor4dv ( _fontColor.data() );
    glColor4d( 0,0,0,0.9);
    glLineWidth (2.0);
        
    if (_parse_tree) { 

        glPushMatrix();
        glScaled( _leading * 1.2 , -_leading, 1.0 ); //scale to match line positions
        glTranslated ( 1.0 , 0.0 ,0.0 );
        glColor4d ( 1,0,0,0.2 );
        _parse_tree->draw_tree();
        glPopMatrix();

        //glPushMatrix();
        //glTranslated( _leading * 5.0, 0, 0 );
        //glPushMatrix();
        //glScaled( _leading * 0.7 , _leading, 0 ); //scale to match line positions
        //_parse_tree->draw_tree_buffer(_buf);
        //glPopMatrix();
        //glPopMatrix();

    }


    
    glLineWidth ( ( _selected ) ? _fontWeight : _fontWeight );
    glTranslated( 0, _windowLinePos * -_leading, 0 ); //for all the lines we are skipping

    int n = min ( _windowLinePos + _windowLineSpan , _buf->nlines() );
    bool render_pass = ( AudicleWindow::main()->m_render_mode == GL_RENDER );

    //this is the font's particular idea of a line-height
    // not including descenders..FIX LATER

    double font_text_height = bufferFont->height();

	//bufferFont will be phased out for bufferDraw, which will handle
	//more of the details of line rendering

/*
    double m_time = AudicleWindow::main()->get_current_time();    
    Color4D tdark =  Color4D ( 0.6, 0.8, 0.6, 0.5 );
    Color4D tlight =  Color4D ( 0.6, 0.9, 0.8, 0.4 );
    double blink_per_sec = 1.0;
    double glotime = m_time * blink_per_sec; 
    glotime -= floor ( glotime );
    double glomod =  fabs( -1.0 + 2.0 * ( glotime ) );
    Color4D tglow = tlight.interp( tdark , glomod );
*/

    Color4D tglow = Color4D ( 0.6, 0.8, 0.6, 0.4 );


    for  (int i = _windowLinePos ; i < n ; i++ ) { 
        glTranslated( 0, -_leading, 0 );
        
        if ( render_pass ) { 
            //we put a lot inside the render pass, so we may have broken picking. 
            //we shall see...
            glPushMatrix();

//			bufferDraw->setFontTransform(); // font scale 
			bufferFont->scale( _fontScale, _fontAspect );

            if ( _markSpan.begin.line <= i && i <= _markSpan.end.line ) {  
                //highlight span of selection;
                    
                double x1,x2;
                
                if ( i == _markSpan.begin.line ) 
                    x1 = bufferFont->length( _buf->line(i).substr( 0, _markSpan.begin.chr ) ); 
                else 
                    x1 = 0;

                if ( i == _markSpan.end.line ) { 
                    x2 = bufferFont->length( _buf->line(i).substr( 0, _markSpan.end.chr ) ); 
                }
                else 
                    x2 = bufferFont->length( _buf->line(i).str() ) + 0.5 * font_text_height; 

                if ( x1 != x2  ) { 
                    
                    glColor4dv ( tglow.data() );
//                    glColor4d( 0.3, 0.9, 0.9, 0.4 );
                    
                    glBegin(GL_QUADS);
                    glVertex2d( x1 , -0.4 * font_text_height );
                    glVertex2d( x2 , -0.4 * font_text_height );
                    glVertex2d( x2 ,  1.1 * font_text_height );
                    glVertex2d( x1 ,  1.1 * font_text_height );
                    glEnd();
                }
                
            }
            
            
            if (  i == _loc.line && WindowManager::getRenderMode() == WINDOW_RENDER_BLEND ) { 

                //highlight current line

                double xv = _viewport.vpW() * 100 * 40; 
                double xc = bufferFont->length( _buf->line(i).substr( 0, _loc.chr ) );

                glColor4d( 0.8, 0.8, 0.8, 0.2 );

                glBegin(GL_QUADS); 

                 glVertex2d(   -10 ,  -0.1 * font_text_height );
                 glVertex2d( xv + 10 , -0.1 * font_text_height );
                 glVertex2d( xv + 10 ,  1.1 * font_text_height );
                 glVertex2d(   -10 ,   1.1 * font_text_height );

                glEnd();
 
                glColor4d( 1.0 , 0.0, 0.0, 0.9 );
               
                glBegin(GL_LINES);
                                
                 glVertex2d ( xc, -0.1 * font_text_height );
                 glVertex2d ( xc,  1.1 * font_text_height );
                
                glEnd();
                
            }   

            //draw the line
            glColor4d( 0,0,0,1.0);
//			bufferDraw->draw( _buf->line(i) );
			bufferDraw->draw_tokens( _buf->line(i) );
//            bufferFont->draw( _buf->line(i).str() );
            glPopMatrix();
           
        }

    }
    glColor4d( 0,0,0,1.0);

    glPopMatrix();
}
示例#17
0
void
CodeRevision::draw() { 
    //assume we are a scale of 1
    glPushMatrix();
    glPushName(_id);

        UIButton rev;

        switch ( _status ) { 
            case rev_PARSED     : rev.setCols( UI_BASE, Color4D( 1.0,0.85,0.85,1.0 ), Color4D(0,0,0,1.0)); break;
            case rev_TYPED      : rev.setCols( UI_BASE, Color4D( 1.0,0.92,0.85,1.0 ), Color4D(0,0,0,1.0));  break;
            case rev_COMPILED   : rev.setCols( UI_BASE, Color4D( 1.0,1.0,0.85,1.0 ), Color4D(0,0,0,1.0));  break;
            case rev_READY	    :
            case rev_RUNNING    : rev.setCols( UI_BASE, Color4D( 0.85,1.0,0.85,1.0 ), Color4D(0,0,0,1.0));  break;
            case rev_EDITED     : rev.setCols( UI_BASE, Color4D( 0.9,0.9,1.0,1.0 ), Color4D(0,0,0,1.0));  break;
            default             : rev.setCols( UI_BASE, Color4D( 1.0,1.0,1.0,1.0 ), Color4D(0,0,0,1.0));  break;
        }

        rev.seth( 1.0 );
        rev.setLabel( (char*)_buffer->filename().c_str() );
        rev.fitXLabel( 0.75 );
        rev.draw(0.75);

        if ( _selected ) { 
            _killButton->moveto( rev.left()-_killButton->w(), rev.top() - 0.5* ( rev.h()-_killButton->h() )  );
            _killButton->drawNamed(0.75);
            _sporkButton->moveto( rev.right(), rev.top() - 0.5* ( rev.h()-_sporkButton->h() ) );
            _sporkButton->drawNamed( 0.75 );
        }
        

        glTranslated ( 0, -1.0 , 0 );
        rev.seth ( ( size() - 1 )  );
        glColor4d(0.8, 1.0, 0.9, 0.3);
        glBegin(GL_POLYGON);
        rev.roundVerts();
        glEnd();

        glTranslated ( 1.0, 0 , 0 );
        for ( int i=0; i < _shreds.size() ; i++ ) { 
			ShredInstance * s = _shreds[i];
			if ( s->stat == NULL ) { 
				EM_log( CK_LOG_WARNING, "CodeRevision::draw: (%s) shred stat is NULL (%d)!", (char*)_buffer->filename().c_str(), _shreds[i]->procID); 
				s->stat = Chuck_Stats::instance()->get_shred( s->procID );
				if ( !s->stat ) { 
					EM_log( CK_LOG_WARNING, "CodeRevision::draw: adding as dead(%d)!", (char*)_buffer->filename().c_str(), _shreds[i]->procID); 
					s->stat = new Shred_Stat();
					s->stat->state = shred_KILLED;
				}
				if ( s->stat && !s->stat->data )  {
					AudicleFaceShredder::initialize_stat_data ( s->stat );
				}
			} else {
	            s->draw();
	            glTranslated ( 0, -1.0 , 0 );
			}
        }
        glTranslated ( -1.0, 0, 0);

        glPopName();
        glPopMatrix();
}
示例#18
0
void
ShredInstance::draw() { 

    UIButton shredbutton;
    
    char name[32];

    shredbutton.lineCol(Color4D(0,0,0,1.0) );

    switch ( stat->state ) { 
        case 0:
            shredbutton.fillCol(stat->data->color.interp( Color4D (1.0,0.8,0.8,1.0) , 0.25)  );
            break;
        case 1:
            shredbutton.fillCol(stat->data->color.interp( Color4D (0.8,1.0,0.8,1.0) , 0.25)  );
            break;
        case 2:
            shredbutton.fillCol(stat->data->color.interp( Color4D (1.0,1.0,0.8,1.0) , 0.25)  );
            break;
        case 3:
            shredbutton.fillCol(stat->data->color.interp( Color4D (0.5,0.5,0.5,1.0) , 0.7)  );
            break;
    }

    shredbutton.moveto(0,0);
    shredbutton.seth(1.0);
    if ( stat->children.size() ) 
        sprintf(name, "%d (%ld)", procID, stat->children.size() );
    else
        sprintf(name, "%d", procID, stat->children.size() );
    shredbutton.setLabel( (char*)name );
    shredbutton.fitLabel();
    
    glPushName(pickID);
    
    shredbutton.draw(0.75);

    if ( selected ) { 
        _killButton->moveto( 0.5 * ( shredbutton.w() - _killButton->w() ) , \
                             shredbutton.top()  - 0.5 * ( shredbutton.h() - _killButton->h() ) );
        _killButton->drawNamed();
    }

    if ( selected ) { 
        glPushMatrix();
        glTranslated ( shredbutton.w(), 0, 0);
        shredbutton.resize(1.0,1.0);
        int ndead= 0;
        for ( int i = 0; i < stat->children.size(); i++ ) {         
            if ( stat->children[i]->state == 3 )
                ndead++;
            else { 
                sprintf(name, "%ld", stat->children[i]->xid );
                shredbutton.setLabel(name);
                shredbutton.fitLabel();
                switch ( stat->children[i]->state ) { 
                case 0:
                    shredbutton.fillCol(Color4D (1.0,0.4,0.4,1.0) );
                    break;
                case 1:
                case 2:
                    shredbutton.fillCol(Color4D (0.4,1.0,0.4,1.0) );
                    break;
                }
                shredbutton.draw(0.75);
                glTranslated( shredbutton.w(), 0, 0);
            }
        }
        if ( ndead ) { 
            shredbutton.fillCol( Color4D ( 0.5,0.5,0.5, 0.6 ) );
            sprintf ( name, "%d dead", ndead );
            shredbutton.setLabel(name);
            shredbutton.fitLabel();
            shredbutton.draw(0.75);
        }
        glPopMatrix();
    }
    glPopName();

}
示例#19
0
void
CodeWindow::initShapes() { 

    DisplayWindow::initShapes();

    Color4D border (0.45,0.45,0.45,1.0);

    UIMenu * menu = new UIMenu();
    menu->addOption("open", KEY_CTRL_O );
    menu->addOption("save", KEY_CTRL_S );
    menu->addOption("close", KEY_CTRL_W );
    _closeButton.setMenu( menu );

    _testButton.setLabel("O");
    _testButton.setCode(KEY_CTRL_O);
    _testButton.setCols     (UI_BASE, Color4D(0.9,0.7,0.7,1.0), border );
    _testButton.setCols     (UI_HOVER, Color4D(0.8,0.1,0.1,1.0), border );
    _testButton.setCols     (UI_SEL, Color4D(0.8,0.4,0.4,1.0), border );
    
    _compileButton.setLabel("C");
    _compileButton.setCode(KEY_CTRL_K);
    _compileButton.setCols  (UI_BASE, Color4D(0.9,0.9,0.7,1.0), border );
    _compileButton.setCols  (UI_HOVER, Color4D(0.8,0.8,0.1,1.0), border );
    _compileButton.setCols  (UI_SEL, Color4D(0.8,0.8,0.4,1.0), border );
    
    _sporkButton.setLabel("S");
    _sporkButton.setCode(KEY_CTRL_L);
    _sporkButton.setCols    (UI_BASE, Color4D(0.7,0.9,0.7,1.0), border );
    _sporkButton.setCols    (UI_HOVER, Color4D(0.1,0.8,0.1,1.0), border );
    _sporkButton.setCols    (UI_SEL, Color4D(0.4,0.8,0.4,1.0), border );
    
    _revisionBox.setCols    (UI_BASE, Color4D(0.8,0.8,0.8,1.0), border );
    _revisionBox.setCols    (UI_HOVER, Color4D(0.8,0.8,0.8,1.0), border );
    _revisionBox.setCols    (UI_SEL, Color4D(0.8,0.8,0.8,1.0), border );
}
示例#20
0
void
ConsoleWindow::initShapes() 
{
    DisplayWindow::initShapes();

    Color4D border (0.4, 0.4, 0.4, 1.0  );

    _baseWindow.setCols( UI_BASE, Color4D (1.0,1.0,1.0,0.95), border ); 
    _cubeWindow.setCols( UI_BASE, Color4D (1.0,1.0,1.0,0.9), border ); 
    _contentWindow.setCols( UI_BASE, Color4D (1.0,1.0,1.0,0.9), border ); 

    _sizeBox.setCols ( UI_BASE, Color4D ( 1.0, 0.9,0.9, 1.0 ), border );

    _timeLabel.setLabel("now");
    _timeLabel.fitLabel();
    _timeLabel.setCols( UI_BASE, Color4D (0.8,1.0,0.8,1.0), border ); 
    _timeDisplay.setLabel("1:00:00.10313");
    _timeDisplay.fitLabel();
    _timeDisplay.setCols( UI_BASE, Color4D (1.0,1.0,1.0,1.0), border ); 

    _curLabel.setLabel ("cur");
    _curLabel.fitLabel ();
    _curLabel.setCols( UI_BASE, Color4D (1.0,1.0,0.8,0.9), border ); 
    _curDisplay.setLabel("1");
    _curDisplay.setCols( UI_BASE, Color4D (1.0,1.0,0.8,0.9), border ); 
    
    _prevLabel.setLabel( "prev" );
    _prevLabel.fitLabel();
    _prevLabel.setCols( UI_BASE, Color4D (1.0,1.0,1.0,1.0), border ); 
    _prevDisplay.setLabel("3");
    _prevDisplay.setCols( UI_BASE, Color4D (0.8,0.8,1.0,0.9), border ); 

    char foo[8];
    for ( int i = 0 ; i < 6 ; i++ ) { 
        sprintf(foo, "%d", i+1 );
        _cubeSides[i].setLabel( foo );
    }

    _cubeSides[0].setCols( UI_BASE, Color4D (1.0,1.0,0.8,0.9), border ); 
    _cubeSides[1].setCols( UI_BASE, Color4D (0.8,1.0,0.8,0.9), border ); 
    _cubeSides[2].setCols( UI_BASE, Color4D (0.8,0.8,1.0,0.9), border ); 
    _cubeSides[3].setCols( UI_BASE, Color4D (1.0,0.9,0.8,0.9), border ); 
    _cubeSides[4].setCols( UI_BASE, Color4D (1.0,0.8,0.8,0.9), border ); 
    _cubeSides[5].setCols( UI_BASE, Color4D (1.0,0.8,1.0,0.9), border ); 

}
示例#21
0
void 
ShellContent::draw() { 
    _fixCanvas();
    _fixView();

    glPushMatrix();
       
    glPushMatrix();
    _viewport.setCols( UI_BASE, Color4D( 1.0,1.0,1.0, 0.8 ), Color4D(0.2, 0.5, 0.2, 0.8 ) );
    _viewport.viewTranslate();
    _viewport.filledQuad();
    glPopMatrix();
    
    _viewport.scale();
    _viewport.viewTranslate();

        
    glColor4d( 0,0,0,0.9);
    glLineWidth (2.0);

    glLineWidth ( _fontWeight );

    //translate to bottom to draw our input line
    glTranslated ( 0, - _viewport.vpH() + _leading * 0.333, 0 );

    glColor4d( 1.0,1.0,0.9,1.0);

    glBegin (GL_QUADS);
    glVertex2d (0.0, 0.0  );
    glVertex2d (0.0, _leading  );
    glVertex2d ( _viewport.vpW(), _leading  );
    glVertex2d ( _viewport.vpW(), 0.0  );
    glEnd();

    //draw current entry
    glColor4d( 0.0,0.0,0,1.0);
    glPushMatrix();
      bufferFont->scale ( _fontScale, _fontAspect );
 //     scaleFont_mono ( _fontScale, _fontAspect );
      glPushMatrix();
      drawPromptLine ( _entry );
      glPopMatrix();
      double ds = bufferFont->length( _prompt + "% " + _entry.substr( 0, _loc.chr ) );
      glTranslated ( ds , 0 , 0 );
      glLineWidth(2.0);
      glColor4d( 1.0,0.0,0,1.0);

      glBegin(GL_LINES);
      glVertex2d ( 0 , bufferFont->height() * -0.2 );
      glVertex2d ( 0 , bufferFont->height() *  1.2 );
      glEnd();

    glPopMatrix();


    if ( !_output->empty() ) { 
        int range = min ( _output->nlines(), 8 );
        glColor4d( 0,0.0,0,0.9);
        glTranslated( 0, _leading * ( range + 1 ) , 0 );
        for ( t_CKUINT i = _output->nlines()-range ; i < _output->nlines() ; i++ ) { 
            
            glTranslated ( 0, -_leading, 0 );
            glPushMatrix();
            bufferFont->scale ( _fontScale, _fontAspect );
            drawPromptLine( _output->line(i) );
            glPopMatrix();
            
        }
    }

    glPopMatrix();

}