Browse Source

Work in snapping some more.

tags/non-daw-v1.1.0
Jonathan Moore Liles 16 years ago
parent
commit
80ec2b6e35
5 changed files with 24 additions and 12 deletions
  1. +8
    -0
      Region.C
  2. +6
    -1
      Timeline.H
  3. +5
    -5
      Track.H
  4. +1
    -0
      Waveform.H
  5. +4
    -6
      main.C

+ 8
- 0
Region.C View File

@@ -277,8 +277,16 @@ void
Region::resize ( void )
{
int X = timeline.ts_to_x( _offset );

assert( _end >= _start );

int W = timeline.ts_to_x( _end - _start );

printf( "%dx%d\n", X, W );

if ( W > 5000 )
W = 5000;

if ( W )
Fl_Widget::resize( X, y(), W, h() );
}


+ 6
- 1
Timeline.H View File

@@ -23,19 +23,24 @@
#include <FL/Fl_Pack.H>

#include "Clip.H"
#include <math.h>

#include <assert.h>

struct Timeline {
Fl_Scroll *scroll;
Fl_Pack *tracks;

float fpp; /* frames per pixel */
// nframes_t fpp;

nframes_t sample_rate;

int
ts_to_x( nframes_t ts )
{
return ts / fpp;
// assert( ts / fpp > 0 );
return ts / fpp;
}

nframes_t


+ 5
- 5
Track.H View File

@@ -101,24 +101,24 @@ public:

if ( abs( rx1 - wx2 ) < snap_pixels )
{
r->offset( w->offset() + ( w->end() - w->start() ) + 1 );
r->offset( w->offset() + w->length() + 1 );

printf( "snap: %lu | %lu\n", w->offset() + (w->end() - w->start()), r->offset() );
printf( "snap: %lu | %lu\n", w->offset() + w->length(), r->offset() );

goto done;
}

if ( abs( rx2 - wx1 ) < snap_pixels )
{
r->offset( (w->offset() - ( r->end() - r->start() )) - 1 );
r->offset( ( w->offset() - r->length() ) - 1 );

printf( "snap: %lu | %lu\n", r->offset() + (r->end() - r->start()), w->offset() );
printf( "snap: %lu | %lu\n", r->offset() + r->length(), w->offset() );

goto done;
}
}

r->offset( timeline.x_to_ts( r->x() ));
r->offset( timeline.x_to_ts( r->x() ) );

done:



+ 1
- 0
Waveform.H View File

@@ -71,6 +71,7 @@ public:
nframes_t start ( void ) const { return _start; }
void end ( nframes_t e ) { _end = e; }
nframes_t end ( void ) const { return _end; }
nframes_t length ( void ) const { return _end - _start; }
void scale ( float s ) { _scale = s; }
float scale ( void ) const { return _scale; }



+ 4
- 6
main.C View File

@@ -88,15 +88,16 @@ main ( int argc, char **argv )

timeline.sample_rate = 44100;

timeline.tracks = new Fl_Pack( 0, 0, 5000, 5000 );
timeline.tracks = new Fl_Pack( 0, 0, 32767, 5000 );
timeline.tracks->type( Fl_Pack::VERTICAL );
timeline.tracks->spacing( 20 );

Fl::get_system_colors();
Fl::scheme( "plastic" );

// Fl_Group *pack = new Fl_Group( 0, 0, 5000, 600 );

Track *track1 = new Track( 40, 0, 5000, 100 );
Track *track1 = new Track( 40, 0, 32768, 100 );

// pack->type( Fl_Pack::VERTICAL );
// pack->box( FL_DOWN_BOX );
@@ -107,10 +108,7 @@ main ( int argc, char **argv )

// wave->resize( 0, 0, 500, 100 );

// wave->peaks( peaks );
wave->start( 0 );
// wave->end( (len / sizeof( float )) / 2 );
wave->end( 50 );
wave->offset( 1024 );

wave->color( FL_CYAN );
wave->selection_color( fl_darker( FL_GRAY ) );


Loading…
Cancel
Save