Timeline: Tweak label drawing of sequence widgets.

This commit is contained in:
Jonathan Moore Liles 2012-06-05 19:00:48 -07:00
parent 275878395f
commit c6f6c57c05
2 changed files with 35 additions and 13 deletions

View File

@ -87,7 +87,19 @@ Control_Point::draw_box ( void )
char val[10];
snprintf( val, sizeof( val ), "%+.2f", 1.0 - _y * 2 );
draw_label( val, (Fl_Align)( FL_ALIGN_TOP | FL_ALIGN_LEFT ), FL_FOREGROUND_COLOR );
Fl_Align a = 0;
if ( x() < _sequence->x() + ( _sequence->w() / 2 ) )
a |= FL_ALIGN_RIGHT;
else
a |= FL_ALIGN_LEFT;
if ( y() < _sequence->y() + ( _sequence->h() / 2 ) )
a |= FL_ALIGN_BOTTOM;
else
a |= FL_ALIGN_TOP;
draw_label( val, a, FL_FOREGROUND_COLOR );
}
}

View File

@ -263,23 +263,29 @@ Sequence_Widget::draw_label ( const char *label, Fl_Align align, Fl_Color color,
if ( abs_x() < scroll_x() )
dx = min( 32767, scroll_x() - abs_x() );
const Fl_Boxtype b = FL_ROUNDED_BOX;
const int bx = Fl::box_dx( b ) + 2;
const int bw = Fl::box_dw( b ) + 4;
const int by = Fl::box_dy( b ) + 2;
const int bh = Fl::box_dh( b ) + 4;
const Fl_Boxtype b = FL_BORDER_BOX;
const int bx = Fl::box_dx( b );
const int bw = Fl::box_dw( b );
const int by = Fl::box_dy( b );
const int bh = Fl::box_dh( b );
/* FIXME: why do we have to do this here? why doesn't Fl_Label::draw take care of this stuff? */
if ( align & FL_ALIGN_INSIDE )
{
if ( align & FL_ALIGN_RIGHT )
X += abs_w() - (lw + bw);
if ( align & FL_ALIGN_BOTTOM )
{
Y += h() - (lh + bh);
X += 2;
}
Y += h() - ( lh + bh );
else if ( align & FL_ALIGN_TOP )
Y += by;
else
Y += ( h() / 2 ) - ( lh + bh );
if ( align & FL_ALIGN_RIGHT )
X += abs_w() - ( lw + bw );
else if ( align & FL_ALIGN_LEFT )
X += bx;
else
X += ( abs_w() / 2 ) - ( ( lw + bw ) / 2 );
}
else
{
@ -287,11 +293,15 @@ Sequence_Widget::draw_label ( const char *label, Fl_Align align, Fl_Color color,
X += abs_w();
else if ( align & FL_ALIGN_LEFT )
X -= lw + bw;
else
X += ( abs_w() / 2 ) - ( ( lw + bw ) / 2 );
if ( align & FL_ALIGN_BOTTOM )
Y += h();
else if ( align & FL_ALIGN_TOP )
Y -= lh + bh;
else
Y += ( h() / 2 ) - ( ( lh + bh ) / 2 );
}
fl_draw_box( b, ( X - dx ), Y - by, lw + bw, lh + bh, fl_color_add_alpha( FL_DARK1, 150 ) );