Browse Source

Try to make snapping more accurate.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
2d6a93b448
4 changed files with 29 additions and 10 deletions
  1. +3
    -1
      Region.C
  2. +2
    -2
      Region.H
  3. +21
    -6
      Track.H
  4. +3
    -1
      Waveform.H

+ 3
- 1
Region.C View File

@@ -221,6 +221,8 @@ Region::handle ( int m )

// nx = _track->snap( this, nx );

// _offset = timeline.x_to_ts( nx );

position( nx, y() );

_track->snap( this );
@@ -260,7 +262,7 @@ Region::handle ( int m )
timeline.scroll->position( pos, timeline.scroll->yposition() );
}

_offset = timeline.x_to_ts( x() );
// _offset = timeline.x_to_ts( x() );

return 1;
default:


+ 2
- 2
Region.H View File

@@ -48,9 +48,9 @@ public:
void resize ( void );


Track * track ( void ) { return _track; }
Track * track ( void ) const { return _track; }
void track ( Track *t ) { _track = t; }

nframes_t offset ( void ) { return _offset; }
nframes_t offset ( void ) const { return _offset; }
void offset ( nframes_t o ) { _offset = o; }
};

+ 21
- 6
Track.H View File

@@ -25,6 +25,9 @@

#include <stdio.h>


#include <assert.h>

#include <list>
using std::list;

@@ -88,7 +91,7 @@ public:

for ( int i = children(); i-- ; )
{
const Fl_Widget *w = child( i );
const Region *w = (Region*)child( i );

if ( w == r )
continue;
@@ -98,17 +101,29 @@ public:

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

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

goto done;
}

if ( abs( rx2 - wx1 ) < snap_pixels )
{
rx1 = (wx1 - r->w()) + 1;
break;
r->offset( (w->offset() - ( r->end() - r->start() )) - 1 );

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

goto done;
}
}
r->position( rx1, y() );

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

done:

r->resize();
// r->position( rx1, y() );
}

int handle ( int m )


+ 3
- 1
Waveform.H View File

@@ -68,9 +68,11 @@ public:
void draw ( int X, int Y, int W, int H );

void start ( nframes_t s ) { _start = s; }
nframes_t start ( void ) const { return _start; }
void end ( nframes_t e ) { _end = e; }
nframes_t end ( void ) const { return _end; }
void scale ( float s ) { _scale = s; }
float scale ( void ) { return _scale; }
float scale ( void ) const { return _scale; }

// void peaks ( float *p ) { _peaks = p; }
void normalize ( void );


Loading…
Cancel
Save