From 62625f35f71941266cb17a0c8f41c533dcb4ba14 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Tue, 13 May 2008 21:16:59 -0500 Subject: [PATCH] Improve drawing of unified tempomap. --- Timeline/Sequence.C | 4 +- Timeline/Tempo_Map_Sequence.C | 89 +++++++++++++++++++++++++++++++++++ Timeline/Tempo_Point.C | 3 +- Timeline/Tempo_Sequence.H | 63 +------------------------ Timeline/Timeline.C | 4 +- Timeline/makefile.inc | 9 ++-- 6 files changed, 103 insertions(+), 69 deletions(-) create mode 100644 Timeline/Tempo_Map_Sequence.C diff --git a/Timeline/Sequence.C b/Timeline/Sequence.C index 20a5ccc..da6b34d 100644 --- a/Timeline/Sequence.C +++ b/Timeline/Sequence.C @@ -132,11 +132,11 @@ Sequence::draw ( void ) timeline->draw_measure_lines( X, Y, W, H, color() ); - for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ ) + for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r ) (*r)->draw_box(); - for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ ) + for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r ) (*r)->draw(); fl_pop_clip(); diff --git a/Timeline/Tempo_Map_Sequence.C b/Timeline/Tempo_Map_Sequence.C new file mode 100644 index 0000000..4e29f56 --- /dev/null +++ b/Timeline/Tempo_Map_Sequence.C @@ -0,0 +1,89 @@ + +/*******************************************************************************/ +/* Copyright (C) 2008 Jonathan Moore Liles */ +/* */ +/* This program is free software; you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation; either version 2 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ +/* more details. */ +/* */ +/* You should have received a copy of the GNU General Public License along */ +/* with This program; see the file COPYING. If not,write to the Free Software */ +/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/*******************************************************************************/ + +#include "Tempo_Map_Sequence.H" + + +void +Tempo_Map_Sequence::draw ( void ) +{ + if ( ! fl_not_clipped( x(), y(), w(), h() ) ) + return; + + fl_push_clip( x(), y(), w(), h() ); + + /* draw the box with the ends cut off. */ + draw_box( box(), + x() - Fl::box_dx( box() ) - 1, y(), + w() + Fl::box_dw( box() ) + 2, h() >> 1, color() ); + draw_box( box(), + x() - Fl::box_dx( box() ) - 1, y() + (h() >> 1) , + w() + Fl::box_dw( box() ) + 2, h() >> 1, color() ); + + int X, Y, W, H; + + fl_clip_box( x(), y(), w(), h(), X, Y, W, H ); + + if ( Sequence_Widget::pushed() && Sequence_Widget::pushed()->sequence() == this ) + { + /* make sure the Sequence_Widget::pushed widget is above all others */ + remove( Sequence_Widget::pushed() ); + add( Sequence_Widget::pushed() ); + } + + timeline->draw_measure_lines( X, Y, W, H, color() ); + + for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r ) + (*r)->draw_box(); + + for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r ) + (*r)->draw(); + + fl_pop_clip(); +} + +int +Tempo_Map_Sequence::handle ( int m ) +{ + int r = Sequence::handle( m ); + + if ( r ) + return r; + + switch ( m ) + { + case FL_PUSH: + if ( Fl::event_button1() ) + { + static float t = 120.0f; + + if ( Tempo_Point::edit( &t ) ) + { + add( new Tempo_Point( timeline->x_to_offset( Fl::event_x() ), t ) ); + + timeline->redraw(); + } + return 0; + } + default: + return 0; + + } + +} diff --git a/Timeline/Tempo_Point.C b/Timeline/Tempo_Point.C index 751a3ef..bd260fc 100644 --- a/Timeline/Tempo_Point.C +++ b/Timeline/Tempo_Point.C @@ -18,8 +18,9 @@ /*******************************************************************************/ + #include "Tempo_Point.H" -#include "Tempo_Sequence.H" +#include "Tempo_Map_Sequence.H" #include "Timeline.H" // for timeline->tempo_track void diff --git a/Timeline/Tempo_Sequence.H b/Timeline/Tempo_Sequence.H index a2840ee..d936453 100644 --- a/Timeline/Tempo_Sequence.H +++ b/Timeline/Tempo_Sequence.H @@ -42,66 +42,7 @@ public: // box( FL_DOWN_BOX ); } + void draw ( void ); + int handle ( int m ); - /** return a pointer to the closest tempo point *before* /when/ */ - Tempo_Point * - at ( nframes_t when ) - { - for ( std::list ::const_reverse_iterator i = _widgets.rbegin(); - i != _widgets.rend(); i++ ) - if ( (*i)->offset() < when ) - return ((Tempo_Point*)(*i)); - - return NULL; - } - - float - beats_per_minute ( nframes_t when ) - { -// sort(); - - Tempo_Point *p = at( when ); - - if ( p ) - return p->tempo(); - else - return 120.0; - } - - void - beats_per_minute ( nframes_t when, float bpm ) - { - add( new Tempo_Point( when, bpm ) ); - sort(); - } - - int - handle ( int m ) - { - int r = Sequence::handle( m ); - - if ( r ) - return r; - - switch ( m ) - { - case FL_PUSH: - if ( Fl::event_button1() ) - { - static float t = 120.0f; - - if ( Tempo_Point::edit( &t ) ) - { - add( new Tempo_Point( timeline->x_to_offset( Fl::event_x() ), t ) ); - - timeline->redraw(); - } - return 0; - } - default: - return 0; - - } - - } }; diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index 45bfcd9..6bc09b8 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -227,7 +227,9 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi float Timeline::beats_per_minute ( nframes_t when ) const { - return tempo_track->beats_per_minute( when ); + +/* return tempo_track->beats_per_minute( when ); */ + } int diff --git a/Timeline/makefile.inc b/Timeline/makefile.inc index ba2b23d..b88c5d1 100644 --- a/Timeline/makefile.inc +++ b/Timeline/makefile.inc @@ -3,8 +3,10 @@ Timeline_VERSION := 0.5.0 Timeline_SRCS= \ +Timeline/Annotation_Region.C \ Timeline/Audio_File.C \ Timeline/Audio_File_SF.C \ +Timeline/Audio_Region.C \ Timeline/Audio_Sequence.C \ Timeline/Control_Point.C \ Timeline/Control_Sequence.C \ @@ -15,14 +17,14 @@ Timeline/Loggable.C \ Timeline/Peaks.C \ Timeline/Playback_DS.C \ Timeline/Port.C \ +Timeline/Project.C \ Timeline/Record_DS.C \ -Timeline/Audio_Region.C \ Timeline/Sequence.C \ Timeline/Sequence_Point.C \ -Timeline/Sequence_Widget.C \ Timeline/Sequence_Region.C \ -Timeline/Annotation_Region.C \ +Timeline/Sequence_Widget.C \ Timeline/TLE.C \ +Timeline/Tempo_Map_Sequence.C \ Timeline/Tempo_Point.C \ Timeline/Time_Point.C \ Timeline/Timeline.C \ @@ -31,7 +33,6 @@ Timeline/Transport.C \ Timeline/Waveform.C \ Timeline/dsp.C \ Timeline/main.C \ -Timeline/Project.C \ debug.C \ Timeline_OBJS:=$(Timeline_SRCS:.C=.o)