Change the way project length is calculated.
This commit is contained in:
parent
5543edf8ec
commit
b17623720e
|
@ -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 */
|
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r )
|
||||||
/* * least widget it contains *\/ */
|
l = max( l, (*r)->start() + (*r)->length() );
|
||||||
/* nframes_t */
|
|
||||||
/* Sequence::length ( void ) const */
|
|
||||||
/* { */
|
|
||||||
|
|
||||||
/* if ( _widgets.size() ) */
|
return l;
|
||||||
/* return _widgets.back().start() + _widgets.back().length(); */
|
}
|
||||||
/* else */
|
|
||||||
/* return 0; */
|
|
||||||
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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 );
|
||||||
|
|
||||||
|
draw_cursors();
|
||||||
if ( p1 != p2 )
|
|
||||||
{
|
|
||||||
draw_cursor( p1, FL_BLUE, draw_full_arrow_symbol );
|
|
||||||
draw_cursor( p2, FL_GREEN, draw_full_arrow_symbol );
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
nframes_t
|
||||||
Timeline::update_length ( nframes_t l )
|
Timeline::length ( void ) const
|
||||||
{
|
{
|
||||||
_length = max( _length, l );
|
nframes_t l = 0;
|
||||||
|
|
||||||
adjust_hscroll();
|
for ( int i = tracks->children(); i--; )
|
||||||
|
l = max( l, ((Track*)tracks->child( i ))->sequence()->length() );
|
||||||
|
|
||||||
/* nframes_t l = 0; */
|
// adjust_hscroll();
|
||||||
|
|
||||||
/* for ( int i = tracks->children(); i-- ; ) */
|
|
||||||
/* { */
|
|
||||||
/* Track *t = (Track*)tracks->child( i ); */
|
|
||||||
|
|
||||||
/* l = max( l, t->sequence()->length() ); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* _length = l; */
|
|
||||||
|
|
||||||
|
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 *
|
||||||
|
|
|
@ -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…
Reference in New Issue