From c97a15047c90c2ff1f3b91d98cb078ce65782ad5 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Wed, 5 Mar 2008 22:08:06 -0600 Subject: [PATCH] Add boxy background to track widget labels. --- Region.C | 2 +- Track_Widget.C | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Region.C b/Region.C index 70f4da9..c603452 100644 --- a/Region.C +++ b/Region.C @@ -484,7 +484,7 @@ Region::draw ( int X, int Y, int W, int H ) snprintf( pat, sizeof( pat ), "%dm:%.1fs", (int)(length() / timeline->sample_rate) / 60, (double)length() / timeline->sample_rate ); - draw_label( pat, (Fl_Align)(FL_ALIGN_INSIDE | FL_ALIGN_CENTER), FL_GRAY ); + draw_label( pat, (Fl_Align)(FL_ALIGN_INSIDE | FL_ALIGN_CENTER), FL_GREEN ); } /* if ( _selected ) */ diff --git a/Track_Widget.C b/Track_Widget.C index 7891f86..13af790 100644 --- a/Track_Widget.C +++ b/Track_Widget.C @@ -45,14 +45,21 @@ Track_Widget::draw_label ( const char *label, Fl_Align align, Fl_Color color ) } } + Fl_Label lab; lab.color = color; - lab.type = FL_SHADOW_LABEL; +// lab.type = FL_SHADOW_LABEL; + lab.type = FL_ENGRAVED_LABEL; lab.value = label; lab.font = FL_HELVETICA; lab.size = 14; + int lw, lh; + + fl_font( lab.font, lab.size ); + fl_measure( lab.value, lw, lh ); + int W = w(); int H = h(); @@ -71,6 +78,20 @@ Track_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_ROUND_UP_BOX; + const int bx = Fl::box_dx( b ); + const int bw = Fl::box_dw( b ); + + if ( align & FL_ALIGN_BOTTOM ) + fl_draw_box( b, X - dx - bx, Y + H - lh, lw + bw, lh, FL_GRAY ); + else + if ( align & FL_ALIGN_LEFT ) + fl_draw_box( b, X - dx, Y, lw + bw, lh, FL_GRAY ); + else + fl_draw_box( b, X - dx - bx + ((W / 2) - (lw / 2)), Y + ((H / 2) - (lh / 2)), lw + bw, lh, FL_GRAY ); + } + lab.draw( X - dx, Y, W, H, align ); if ( align & FL_ALIGN_CLIP ) fl_pop_clip();