Add Track_Point class for track widgets with no meaningful length.

pull/3/head
Jonathan Moore Liles 2008-02-20 22:03:48 -06:00
parent 4a266bc86a
commit a1dd1192cc
2 changed files with 47 additions and 36 deletions

View File

@ -75,6 +75,10 @@ public:
virtual int w ( void ) const { return timeline.ts_to_x( _end - _start ); }
// int w ( void ) const { return timeline.ts_to_x( (_end - _start) - ( timeline.xoffset - _offset) ); }
int abs_x ( void ) const { return timeline.ts_to_x( timeline.xoffset ); }
int abs_w ( void ) const { return timeline.ts_to_x( _end - _start ); }
Fl_Color color ( void ) { return _color; }
Fl_Color box_color ( void ) { return _box_color; }
@ -218,44 +222,61 @@ public:
};
class Tempo_Point : public Track_Widget
{
float _tempo;
class Track_Point : public Track_Widget
{
public:
protected:
/* Tempo_Point ( ) */
/* { */
/* _tempo = 120; */
/* } */
char *_label;
Tempo_Point ( nframes_t when, float bpm )
{
_tempo = bpm;
_offset = when;
}
public:
int w ( void ) const { return 10; }
nframes_t length ( void ) const { return timeline.x_to_ts( w() ); }
int w ( void ) const { return 10; }
nframes_t length ( void ) const { return timeline.x_to_ts( w() ); }
void
draw ( int X, int Y, int W, int H )
{
if ( x() < 0 )
return;
Track_Point ( )
{
_label = NULL;
}
Track_Widget::draw( x(), Y, w(), H );
void
draw ( int X, int Y, int W, int H )
{
if ( x() < 0 )
return;
Track_Widget::draw( x(), Y, w(), H );
char pat[40];
draw_label( _label, FL_ALIGN_RIGHT );
}
};
snprintf( pat, 40, "%.1f", _tempo );
class Tempo_Point : public Track_Point
{
float _tempo;
draw_label( pat, FL_ALIGN_RIGHT );
void
_make_label ( void )
{
if ( ! _label )
_label = new char[40];
}
snprintf( _label, 40, "%.1f", _tempo );
}
public:
};
Tempo_Point ( nframes_t when, float bpm )
{
_tempo = bpm;
_offset = when;
_make_label();
}
~Tempo_Point ( )
{ if ( _label ) delete[] _label; }
};
class Region : public Track_Widget
{

10
main.C
View File

@ -36,19 +36,11 @@
#include <stdlib.h>
#include <string.h>
Fl_Color velocity_colors[128];
#include "Track.H"
#include "Timeline.H"
#include "const.h"
void
init_colors ( void )
{
for ( int i = 128; i--; )
velocity_colors[i] = fl_rgb_color( 23, 255 - i * 2, 32 );
}
Timeline timeline;
@ -106,8 +98,6 @@ int
main ( int argc, char **argv )
{
init_colors();
Fl_Double_Window *main_window = new Fl_Double_Window( 0, 0, 800, 600 );
timeline.scroll = new Fl_Scroll( 0, 24, 800, 600 - (24 * 2) );