Browse Source

Add Track_Point class for track widgets with no meaningful length.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
a1dd1192cc
2 changed files with 47 additions and 36 deletions
  1. +47
    -26
      Region.H
  2. +0
    -10
      main.C

+ 47
- 26
Region.H 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;
}

void
draw ( int X, int Y, int W, int H )
{
if ( x() < 0 )
return;

Track_Widget::draw( x(), Y, w(), H );

Track_Widget::draw( x(), Y, w(), H );
draw_label( _label, FL_ALIGN_RIGHT );
}
};

class Tempo_Point : public Track_Point
{
float _tempo;

void
_make_label ( void )
{
if ( ! _label )
_label = new char[40];

char pat[40];
snprintf( _label, 40, "%.1f", _tempo );
}
public:

snprintf( pat, 40, "%.1f", _tempo );
Tempo_Point ( nframes_t when, float bpm )
{
_tempo = bpm;
_offset = when;

draw_label( pat, FL_ALIGN_RIGHT );
_make_label();
}

}
~Tempo_Point ( )
{ if ( _label ) delete[] _label; }

};
};

class Region : public Track_Widget
{


+ 0
- 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) );


Loading…
Cancel
Save