@@ -126,6 +126,8 @@ deurlify ( char *url ) | |||||
void | void | ||||
Audio_Sequence::handle_widget_change ( nframes_t start, nframes_t length ) | Audio_Sequence::handle_widget_change ( nframes_t start, nframes_t length ) | ||||
{ | { | ||||
Sequence::handle_widget_change( start, length ); | |||||
/* a region has changed. we may need to rebuffer... */ | /* a region has changed. we may need to rebuffer... */ | ||||
/* trigger rebuffer */ | /* trigger rebuffer */ | ||||
@@ -176,6 +176,26 @@ Sequence::remove_selected ( void ) | |||||
} | } | ||||
void | |||||
Sequence::handle_widget_change ( nframes_t start, nframes_t 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 */ | |||||
/* { */ | |||||
/* if ( _widgets.size() ) */ | |||||
/* return _widgets.back().start() + _widgets.back().length(); */ | |||||
/* else */ | |||||
/* return 0; */ | |||||
/* } */ | |||||
Sequence_Widget * | Sequence_Widget * | ||||
Sequence::event_widget ( void ) | Sequence::event_widget ( void ) | ||||
{ | { | ||||
@@ -67,7 +67,7 @@ public: | |||||
/* child classes should implement this if they need to take | /* child classes should implement this if they need to take | ||||
special action when a widget is changed/moved/resized. /start/ | special action when a widget is changed/moved/resized. /start/ | ||||
and /length/ define the affected region */ | and /length/ define the affected region */ | ||||
virtual void handle_widget_change ( nframes_t start, nframes_t length ) { (void)(start + length); } | |||||
virtual void handle_widget_change ( nframes_t start, nframes_t length ); | |||||
/* welcome to C++ */ | /* welcome to C++ */ | ||||
LOG_NAME_FUNC( Sequence ); | LOG_NAME_FUNC( Sequence ); | ||||
@@ -115,6 +115,8 @@ public: | |||||
Sequence_Widget * overlaps ( Sequence_Widget *r ); | Sequence_Widget * overlaps ( Sequence_Widget *r ); | ||||
nframes_t length ( void ) const; | |||||
virtual Sequence * clone ( void ) | virtual Sequence * clone ( void ) | ||||
{ | { | ||||
assert( 0 ); | assert( 0 ); | ||||
@@ -384,6 +384,8 @@ Sequence_Widget::handle ( int m ) | |||||
timeline->xposition( timeline->ts_to_x( pos ) ); | timeline->xposition( timeline->ts_to_x( pos ) ); | ||||
timeline->update_length( start() + length() ); | |||||
/* FIXME: why isn't this enough? */ | /* FIXME: why isn't this enough? */ | ||||
// sequence()->redraw(); | // sequence()->redraw(); | ||||
timeline->redraw(); | timeline->redraw(); | ||||
@@ -20,8 +20,10 @@ | |||||
#include "Tempo_Sequence.H" | #include "Tempo_Sequence.H" | ||||
void | void | ||||
Tempo_Sequence::handle_widget_change ( nframes_t, nframes_t ) | |||||
Tempo_Sequence::handle_widget_change ( nframes_t start, nframes_t length ) | |||||
{ | { | ||||
Sequence::handle_widget_change( start, length ); | |||||
sort(); | sort(); | ||||
timeline->update_tempomap(); | timeline->update_tempomap(); | ||||
timeline->redraw(); | timeline->redraw(); | ||||
@@ -20,8 +20,10 @@ | |||||
#include "Time_Sequence.H" | #include "Time_Sequence.H" | ||||
void | void | ||||
Time_Sequence::handle_widget_change ( nframes_t, nframes_t ) | |||||
Time_Sequence::handle_widget_change ( nframes_t start, nframes_t length ) | |||||
{ | { | ||||
Sequence::handle_widget_change( start, length ); | |||||
sort(); | sort(); | ||||
timeline->update_tempomap(); | timeline->update_tempomap(); | ||||
timeline->redraw(); | timeline->redraw(); | ||||
@@ -107,6 +107,12 @@ Timeline::adjust_vscroll ( void ) | |||||
vscroll->value( _yposition, h() - rulers->h() - hscroll->h(), 0, pack_visible_height( tracks ) ); | vscroll->value( _yposition, h() - rulers->h() - hscroll->h(), 0, pack_visible_height( tracks ) ); | ||||
} | } | ||||
void | |||||
Timeline::adjust_hscroll ( void ) | |||||
{ | |||||
hscroll->value( ts_to_x( xoffset ), tracks->w() - Track::width(), 0, ts_to_x( _length ) ); | |||||
} | |||||
void | void | ||||
Timeline::cb_scroll ( Fl_Widget *w, void *v ) | Timeline::cb_scroll ( Fl_Widget *w, void *v ) | ||||
{ | { | ||||
@@ -135,6 +141,7 @@ Timeline::cb_scroll ( Fl_Widget *w ) | |||||
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 ) ); | ||||
@@ -333,8 +340,9 @@ 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 = -1; | |||||
_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 ); | ||||
@@ -643,8 +651,8 @@ Timeline::xposition ( int X ) | |||||
{ | { | ||||
// _old_xposition = xoffset; | // _old_xposition = xoffset; | ||||
/* FIXME: shouldn't have to do this... */ | |||||
X = min( X, ts_to_x( _length ) - tracks->w() - Track::width() ); | |||||
/* /\* FIXME: shouldn't have to do this... *\/ */ | |||||
/* X = min( X, ts_to_x( _length ) - tracks->w() - Track::width() ); */ | |||||
xoffset = x_to_ts( X ); | xoffset = x_to_ts( X ); | ||||
@@ -960,6 +968,26 @@ Timeline::handle_scroll ( int m ) | |||||
return 0; | return 0; | ||||
} | } | ||||
void | |||||
Timeline::update_length ( nframes_t l ) | |||||
{ | |||||
_length = max( _length, l ); | |||||
adjust_hscroll(); | |||||
/* nframes_t l = 0; */ | |||||
/* for ( int i = tracks->children(); i-- ; ) */ | |||||
/* { */ | |||||
/* Track *t = (Track*)tracks->child( i ); */ | |||||
/* l = max( l, t->sequence()->length() ); */ | |||||
/* } */ | |||||
/* _length = l; */ | |||||
} | |||||
int | int | ||||
Timeline::handle ( int m ) | Timeline::handle ( int m ) | ||||
{ | { | ||||
@@ -95,6 +95,7 @@ class Timeline : public Fl_Overlay_Window, public RWLock | |||||
Fl_Scrollbar *vscroll; | Fl_Scrollbar *vscroll; | ||||
void adjust_vscroll ( void ); | void adjust_vscroll ( void ); | ||||
void adjust_hscroll ( void ); | |||||
static void cb_scroll ( Fl_Widget *w, void *v ); | static void cb_scroll ( Fl_Widget *w, void *v ); | ||||
void cb_scroll ( Fl_Widget *w ); | void cb_scroll ( Fl_Widget *w ); | ||||
static void menu_cb ( Fl_Widget *w, void *v ); | static void menu_cb ( Fl_Widget *w, void *v ); | ||||
@@ -103,7 +104,6 @@ class Timeline : public Fl_Overlay_Window, public RWLock | |||||
int _fpp; /* frames per pixel, power of two */ | int _fpp; /* frames per pixel, power of two */ | ||||
nframes_t _length; | nframes_t _length; | ||||
nframes_t p1, p2; /* cursors */ | nframes_t p1, p2; /* cursors */ | ||||
/* not permitted */ | /* not permitted */ | ||||
@@ -144,6 +144,7 @@ public: | |||||
nframes_t fpp ( void ) const { return 1 << _fpp; } | nframes_t fpp ( void ) const { return 1 << _fpp; } | ||||
nframes_t length ( void ) const { return _length; } | nframes_t length ( void ) const { return _length; } | ||||
void update_length ( nframes_t l ); | |||||
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; } | ||||