Add boxy background to track widget labels.
This commit is contained in:
parent
ec2dc52307
commit
c97a15047c
2
Region.C
2
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 );
|
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 ) */
|
/* if ( _selected ) */
|
||||||
|
|
|
@ -45,14 +45,21 @@ Track_Widget::draw_label ( const char *label, Fl_Align align, Fl_Color color )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Fl_Label lab;
|
Fl_Label lab;
|
||||||
|
|
||||||
lab.color = color;
|
lab.color = color;
|
||||||
lab.type = FL_SHADOW_LABEL;
|
// lab.type = FL_SHADOW_LABEL;
|
||||||
|
lab.type = FL_ENGRAVED_LABEL;
|
||||||
lab.value = label;
|
lab.value = label;
|
||||||
lab.font = FL_HELVETICA;
|
lab.font = FL_HELVETICA;
|
||||||
lab.size = 14;
|
lab.size = 14;
|
||||||
|
|
||||||
|
int lw, lh;
|
||||||
|
|
||||||
|
fl_font( lab.font, lab.size );
|
||||||
|
fl_measure( lab.value, lw, lh );
|
||||||
|
|
||||||
int W = w();
|
int W = w();
|
||||||
int H = h();
|
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() )
|
if ( abs_x() < scroll_x() )
|
||||||
dx = min( 32767, scroll_x() - abs_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 );
|
lab.draw( X - dx, Y, W, H, align );
|
||||||
|
|
||||||
if ( align & FL_ALIGN_CLIP ) fl_pop_clip();
|
if ( align & FL_ALIGN_CLIP ) fl_pop_clip();
|
||||||
|
|
Loading…
Reference in New Issue