Refine control sequence drawing code.

pull/3/head
Jonathan Moore Liles 2008-04-23 10:41:35 -05:00
parent 90e263719a
commit 173aeeae82
2 changed files with 83 additions and 53 deletions

View File

@ -47,7 +47,7 @@ Control_Sequence::init ( void )
{
_track = NULL;
color( fl_darker( FL_GREEN ) );
color( fl_darker( FL_YELLOW ) );
}
void
@ -82,6 +82,60 @@ Control_Sequence::set ( Log_Entry &e )
}
}
void
Control_Sequence::draw_curve ( bool flip, bool filled )
{
const int bx = x();
const int by = y() + Fl::box_dy( box() );
const int bw = w();
const int bh = h() - Fl::box_dh( box() );
list <Sequence_Widget *>::const_iterator e = _widgets.end();
e--;
if ( _widgets.size() )
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); ; r++ )
{
const int ry = (*r)->y();
if ( r == _widgets.begin() )
{
if ( flip )
{
if ( filled )
fl_vertex( bx, by );
fl_vertex( bx, ry );
}
else
{
if ( filled )
fl_vertex( bx, bh + by );
fl_vertex( bx, ry );
}
}
fl_vertex( (*r)->x(), ry );
if ( r == e )
{
if ( flip )
{
fl_vertex( bx + bw, ry );
if ( filled )
fl_vertex( bx + bw, by );
}
else
{
fl_vertex( bx + bw, ry );
if ( filled )
fl_vertex( bx + bw, bh + by );
}
break;
}
}
}
void
Control_Sequence::draw ( void )
{
@ -94,7 +148,6 @@ Control_Sequence::draw ( void )
/* draw the box with the ends cut off. */
draw_box( box(), x() - Fl::box_dx( box() ), y(), w() + Fl::box_dw( box() ), h(), color() );
const int bx = x();
const int by = y() + Fl::box_dy( box() );
const int bw = w();
@ -106,11 +159,14 @@ Control_Sequence::draw ( void )
if ( draw_with_gradient )
{
Fl_Color target = fl_color_average( color(), FL_WHITE, 0.50f );
// Fl_Color target = fl_color_average( color(), FL_WHITE, 0.50f );
const Fl_Color c2 = fl_color_average( selection_color(), FL_WHITE, 0.75f );
const Fl_Color c1 = fl_color_average( color(), c2, 0.60f );
for ( int gy = 0; gy < bh; gy++ )
{
fl_color( fl_color_average( target, selection_color(), gy / (float)bh) );
fl_color( fl_color_average( c1, c2, gy / (float)bh) );
fl_line( X, by + gy, X + W, by + gy );
}
}
@ -126,60 +182,30 @@ Control_Sequence::draw ( void )
}
fl_color( fl_color_average( selection_color(), color(), 0.90f ) );
fl_line_style( FL_SOLID, 4 );
if ( draw_with_polygon )
{
fl_begin_complex_polygon();
else
fl_begin_line();
list <Sequence_Widget *>::const_iterator e = _widgets.end();
e--;
if ( _widgets.size() )
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); ; r++ )
{
const int ry = (*r)->y();
if ( r == _widgets.begin() )
{
if ( draw_with_gradient )
{
fl_vertex( bx, by );
fl_vertex( bx, ry );
}
else
{
fl_vertex( bx, bh + by );
fl_vertex( bx, ry );
}
}
fl_vertex( (*r)->x(), ry );
if ( r == e )
{
if ( draw_with_gradient )
{
fl_vertex( bx + bw, ry );
fl_vertex( bx + bw, by );
}
else
{
fl_vertex( bx + bw, ry );
fl_vertex( bx + bw, bh + by );
}
break;
}
}
if ( draw_with_polygon )
draw_curve( draw_with_gradient, true );
fl_end_complex_polygon();
else
fl_color( selection_color() );
fl_line_style( FL_SOLID, 2 );
fl_begin_line();
draw_curve( draw_with_gradient, false );
fl_end_line();
}
else
{
// fl_color( fl_color_average( selection_color(), color(), 0.70f ) );
fl_color( selection_color() );
fl_line_style( FL_SOLID, 2 );
fl_begin_line();
draw_curve( draw_with_gradient, false );
fl_end_line();
}
fl_line_style( FL_SOLID, 0 );

View File

@ -38,6 +38,10 @@ protected:
init();
}
private:
void draw_curve ( bool flip, bool filled );
public:
static bool draw_with_gradient;