Improve drawing of unified tempomap.

This commit is contained in:
Jonathan Moore Liles 2008-05-13 21:16:59 -05:00
parent 02db2c1251
commit 62625f35f7
6 changed files with 103 additions and 69 deletions

View File

@ -132,11 +132,11 @@ Sequence::draw ( void )
timeline->draw_measure_lines( X, Y, W, H, color() );
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r )
(*r)->draw_box();
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r )
(*r)->draw();
fl_pop_clip();

View File

@ -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 <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r )
(*r)->draw_box();
for ( list <Sequence_Widget *>::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;
}
}

View File

@ -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

View File

@ -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 <Sequence_Widget *>::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;
}
}
};

View File

@ -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

View File

@ -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)