From 6c07927b408d56ba78b77b4f0b20036708f90daa Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 28 Feb 2008 10:37:02 -0600 Subject: [PATCH] Show measure lines in a different color from beat lines. --- Tempo_Point.H | 1 + Timeline.C | 16 +++++++++++++++- Timeline.H | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Tempo_Point.H b/Tempo_Point.H index 2cc3018..3ffb174 100644 --- a/Tempo_Point.H +++ b/Tempo_Point.H @@ -82,6 +82,7 @@ public: if ( m == FL_RELEASE ) { _track->sort(); + timeline->rulers->redraw(); timeline->tracks->redraw(); } return r; diff --git a/Timeline.C b/Timeline.C index 0f12f96..dba2eb1 100644 --- a/Timeline.C +++ b/Timeline.C @@ -176,6 +176,14 @@ Timeline::beats_per_minute ( nframes_t when ) const return tempo_track->beats_per_minute( when ); } +int +Timeline::beats_per_bar ( nframes_t when ) const +{ + time_sig t = time_track->time( when ); + + return t.beats_per_bar; +} + void Timeline::beats_per_minute ( nframes_t when, float bpm ) { @@ -187,7 +195,9 @@ void Timeline::draw_measure_lines ( int X, int Y, int W, int H, Fl_Color color ) { fl_line_style( FL_DASH, 2 ); - fl_color( fl_color_average( FL_BLACK, color, 0.65f ) ); + + Fl_Color beat = fl_color_average( FL_BLACK, color, 0.65f ); + Fl_Color bar = fl_color_average( FL_RED, color, 0.65f ); // int measure = ts_to_x( sample_rate * 60 / beats_per_minute() ); @@ -200,6 +210,10 @@ Timeline::draw_measure_lines ( int X, int Y, int W, int H, Fl_Color color ) /* don't bother with lines this close together */ if ( measure < 4 ) break; + if ( 0 == (x / measure) % beats_per_bar( x_to_ts( x ) + xoffset ) ) + fl_color( bar ); + else + fl_color( beat ); if ( 0 == (ts_to_x( xoffset ) + x) % measure ) fl_line( x, Y, x, Y + H ); diff --git a/Timeline.H b/Timeline.H index c944791..34aa665 100644 --- a/Timeline.H +++ b/Timeline.H @@ -100,6 +100,8 @@ struct Timeline : public Fl_Group float beats_per_minute ( nframes_t when ) const; void beats_per_minute ( nframes_t when, float bpm ); + int beats_per_bar ( nframes_t when ) const; + void draw_measure_lines ( int X, int Y, int W, int H, Fl_Color color ); /** set scroll position */