Browse Source

Change the way project length is calculated.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
b17623720e
4 changed files with 46 additions and 52 deletions
  1. +13
    -14
      Timeline/Sequence.C
  2. +1
    -1
      Timeline/Sequence_Widget.C
  3. +28
    -33
      Timeline/Timeline.C
  4. +4
    -4
      Timeline/Timeline.H

+ 13
- 14
Timeline/Sequence.C View File

@@ -181,28 +181,27 @@ Sequence::remove_selected ( void )
void void
Sequence::handle_widget_change ( nframes_t start, nframes_t length ) Sequence::handle_widget_change ( nframes_t start, nframes_t length )
{ {
timeline->update_length( start + length );
// timeline->update_length( start + length );
} }


/** calculate the length of this sequence by looking at the end of the
* least widget it contains */
nframes_t
Sequence::length ( void ) const
{
nframes_t l = 0;


/* /\** calculate the length of this sequence by looking at the end of the */
/* * least widget it contains *\/ */
/* nframes_t */
/* Sequence::length ( void ) const */
/* { */

/* if ( _widgets.size() ) */
/* return _widgets.back().start() + _widgets.back().length(); */
/* else */
/* return 0; */
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r )
l = max( l, (*r)->start() + (*r)->length() );


/* } */
return l;
}


Sequence_Widget * Sequence_Widget *
Sequence::event_widget ( void ) Sequence::event_widget ( void )
{ {
nframes_t ets = timeline->xoffset + timeline->x_to_ts( Fl::event_x() - x() ); nframes_t ets = timeline->xoffset + timeline->x_to_ts( Fl::event_x() - x() );
for ( list <Sequence_Widget *>::const_reverse_iterator r = _widgets.rbegin(); r != _widgets.rend(); r++ )
for ( list <Sequence_Widget *>::const_reverse_iterator r = _widgets.rbegin(); r != _widgets.rend(); ++r )
if ( ets > (*r)->start() && ets < (*r)->start() + (*r)->length() if ( ets > (*r)->start() && ets < (*r)->start() + (*r)->length()
&& Fl::event_y() >= (*r)->y() && Fl::event_y() <= (*r)->y() + (*r)->h() ) && Fl::event_y() >= (*r)->y() && Fl::event_y() <= (*r)->y() + (*r)->h() )
return (*r); return (*r);
@@ -216,7 +215,7 @@ Sequence::select_range ( int X, int W )
nframes_t sts = x_to_offset( X ); nframes_t sts = x_to_offset( X );
nframes_t ets = sts + timeline->x_to_ts( W ); nframes_t ets = sts + timeline->x_to_ts( W );


for ( list <Sequence_Widget *>::const_reverse_iterator r = _widgets.rbegin(); r != _widgets.rend(); r++ )
for ( list <Sequence_Widget *>::const_reverse_iterator r = _widgets.rbegin(); r != _widgets.rend(); ++r )
if ( ! ( (*r)->start() > ets || (*r)->start() + (*r)->length() < sts ) ) if ( ! ( (*r)->start() > ets || (*r)->start() + (*r)->length() < sts ) )
(*r)->select(); (*r)->select();
} }


+ 1
- 1
Timeline/Sequence_Widget.C View File

@@ -413,7 +413,7 @@ Sequence_Widget::handle ( int m )


timeline->xposition( timeline->ts_to_x( pos ) ); timeline->xposition( timeline->ts_to_x( pos ) );


timeline->update_length( start() + length() );
// timeline->update_length( start() + length() );


/* FIXME: why isn't this enough? */ /* FIXME: why isn't this enough? */
// sequence()->redraw(); // sequence()->redraw();


+ 28
- 33
Timeline/Timeline.C View File

@@ -110,7 +110,7 @@ Timeline::adjust_vscroll ( void )
void void
Timeline::adjust_hscroll ( void ) Timeline::adjust_hscroll ( void )
{ {
hscroll->value( ts_to_x( xoffset ), tracks->w() - Track::width(), 0, ts_to_x( _length ) );
hscroll->value( ts_to_x( xoffset ), tracks->w() - Track::width(), 0, ts_to_x( length() ) );
} }


void void
@@ -140,10 +140,10 @@ Timeline::cb_scroll ( Fl_Widget *w )
_fpp = hscroll->zoom(); _fpp = hscroll->zoom();


const int tw = tracks->w() - Track::width(); const int tw = tracks->w() - Track::width();
// hscroll->value( ts_to_x( xoffset ), tw, 0, ts_to_x( _length ) );
// hscroll->value( ts_to_x( xoffset ), tw, 0, ts_to_x( length() ) );


hscroll->value( max( 0, ts_to_x( under_mouse ) - ( Fl::event_x() - tracks->x() - Track::width() ) ), hscroll->value( max( 0, ts_to_x( under_mouse ) - ( Fl::event_x() - tracks->x() - Track::width() ) ),
tw, 0, ts_to_x( _length ) );
tw, 0, ts_to_x( length() ) );


redraw(); redraw();
} }
@@ -358,10 +358,10 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi
{ {
// sample_rate() = engine->sample_rate(); // sample_rate() = engine->sample_rate();
_fpp = 8; _fpp = 8;
// _length = sample_rate() * 60 * 2;
// length() = sample_rate() * 60 * 2;


/* FIXME: hack */ /* FIXME: hack */
_length = x_to_ts( W );
// length() = x_to_ts( W );


{ {
Fl_Pack *o = new Fl_Pack( X, rulers->y() + rulers->h(), W - vscroll->w(), 1 ); Fl_Pack *o = new Fl_Pack( X, rulers->y() + rulers->h(), W - vscroll->w(), 1 );
@@ -678,7 +678,7 @@ Timeline::xposition ( int X )
// _old_xposition = xoffset; // _old_xposition = xoffset;


/* /\* FIXME: shouldn't have to do this... *\/ */ /* /\* FIXME: shouldn't have to do this... *\/ */
/* X = min( X, ts_to_x( _length ) - tracks->w() - Track::width() ); */
/* X = min( X, ts_to_x( length() ) - tracks->w() - Track::width() ); */


xoffset = x_to_ts( X ); xoffset = x_to_ts( X );


@@ -729,6 +729,16 @@ Timeline::resize ( int X, int Y, int W, int H )
vscroll->size( vscroll->w(), H - 18 ); vscroll->size( vscroll->w(), H - 18 );
} }


void
Timeline::draw_cursors ( void ) const
{
if ( p1 != p2 )
{
draw_cursor( p1, FL_BLUE, draw_full_arrow_symbol );
draw_cursor( p2, FL_GREEN, draw_full_arrow_symbol );
}
}

void void
Timeline::draw ( void ) Timeline::draw ( void )
{ {
@@ -761,12 +771,7 @@ Timeline::draw ( void )
draw_child( *hscroll ); draw_child( *hscroll );
draw_child( *vscroll ); draw_child( *vscroll );



if ( p1 != p2 )
{
draw_cursor( p1, FL_BLUE, draw_full_arrow_symbol );
draw_cursor( p2, FL_GREEN, draw_full_arrow_symbol );
}
draw_cursors();


redraw_overlay(); redraw_overlay();


@@ -805,12 +810,8 @@ Timeline::draw ( void )
update_child( *hscroll ); update_child( *hscroll );
update_child( *vscroll ); update_child( *vscroll );


draw_cursors();


if ( p1 != p2 )
{
draw_cursor( p1, FL_BLUE, draw_full_arrow_symbol );
draw_cursor( p2, FL_GREEN, draw_full_arrow_symbol );
}
} }


done: done:
@@ -823,7 +824,7 @@ done:




void void
Timeline::draw_cursor ( nframes_t frame, Fl_Color color, void (*symbol)(Fl_Color) )
Timeline::draw_cursor ( nframes_t frame, Fl_Color color, void (*symbol)(Fl_Color) ) const
{ {
// int x = ( ts_to_x( frame ) - ts_to_x( xoffset ) ) + tracks->x() + Track::width(); // int x = ( ts_to_x( frame ) - ts_to_x( xoffset ) ) + tracks->x() + Track::width();


@@ -869,6 +870,7 @@ void
Timeline::draw_playhead ( void ) Timeline::draw_playhead ( void )
{ {
draw_cursor( transport->frame, FL_RED, draw_full_arrow_symbol ); draw_cursor( transport->frame, FL_RED, draw_full_arrow_symbol );
draw_cursor( length(), FL_BLACK, draw_full_arrow_symbol );
} }


void void
@@ -994,24 +996,17 @@ Timeline::handle_scroll ( int m )
return 0; return 0;
} }


void
Timeline::update_length ( nframes_t l )
nframes_t
Timeline::length ( void ) const
{ {
_length = max( _length, l );

adjust_hscroll();

/* nframes_t l = 0; */

/* for ( int i = tracks->children(); i-- ; ) */
/* { */
/* Track *t = (Track*)tracks->child( i ); */
nframes_t l = 0;


/* l = max( l, t->sequence()->length() ); */
/* } */
for ( int i = tracks->children(); i--; )
l = max( l, ((Track*)tracks->child( i ))->sequence()->length() );


/* _length = l; */
// adjust_hscroll();


return l;
} }


int int
@@ -1200,7 +1195,7 @@ Timeline::zoom ( float secs )
void void
Timeline::zoom_fit ( void ) Timeline::zoom_fit ( void )
{ {
zoom( _length / (float)sample_rate() );
zoom( length() / (float)sample_rate() );
} }


Track * Track *


+ 4
- 4
Timeline/Timeline.H View File

@@ -103,7 +103,6 @@ class Timeline : public Fl_Overlay_Window, public RWLock
void menu_cb ( Fl_Menu_ *m ); void menu_cb ( Fl_Menu_ *m );


int _fpp; /* frames per pixel, power of two */ int _fpp; /* frames per pixel, power of two */
nframes_t _length;


nframes_t p1, p2; /* cursors */ nframes_t p1, p2; /* cursors */


@@ -144,8 +143,8 @@ public:
void update_tempomap ( void ); void update_tempomap ( void );


nframes_t fpp ( void ) const { return 1 << _fpp; } nframes_t fpp ( void ) const { return 1 << _fpp; }
nframes_t length ( void ) const { return _length; }
void update_length ( nframes_t l );
nframes_t length ( void ) const;
nframes_t sample_rate ( void ) const { return _sample_rate; } nframes_t sample_rate ( void ) const { return _sample_rate; }
int ts_to_x( nframes_t ts ) const { return ts >> _fpp; } int ts_to_x( nframes_t ts ) const { return ts >> _fpp; }
nframes_t x_to_ts ( int x ) const { return x << _fpp; } nframes_t x_to_ts ( int x ) const { return x << _fpp; }
@@ -166,7 +165,8 @@ public:


void xposition ( int X ); void xposition ( int X );
void yposition ( int Y ); void yposition ( int Y );
void draw_cursor ( nframes_t frame, Fl_Color color, void (*symbol)(Fl_Color) );
void draw_cursor ( nframes_t frame, Fl_Color color, void (*symbol)(Fl_Color) ) const;
void draw_cursors ( void ) const;
void draw_playhead ( void ); void draw_playhead ( void );
void redraw_playhead ( void ); void redraw_playhead ( void );
void resize ( int X, int Y, int W, int H ); void resize ( int X, int Y, int W, int H );


Loading…
Cancel
Save