From 08182d2c5ffabeda3b01c9938221e3b7e026facf Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Wed, 20 Feb 2008 18:14:44 -0600 Subject: [PATCH] Make track use track_widget base class instead of regions. --- Region.C | 6 ++---- Region.H | 31 +++++++++++++++++++++++++++++-- Track.C | 20 ++++++++++---------- Track.H | 11 ++++++----- 4 files changed, 47 insertions(+), 21 deletions(-) diff --git a/Region.C b/Region.C index b1ca138..99be3f2 100644 --- a/Region.C +++ b/Region.C @@ -300,15 +300,13 @@ Region::resize ( void ) int measure = 40; -/* X is the timeline offset, W is the width of the track */ +/* Draw (part of) region. Start is */ void -Region::draw ( int X, int Y, int W, int H ) +Region::draw ( int X, int Y, int W, int H ) { if ( ! ( W > 0 && H > 0 ) ) return; - - if ( _offset > timeline.xoffset + timeline.x_to_ts( _track->w() ) || ( _offset < timeline.xoffset && _offset + (_end - _start) < timeline.xoffset ) ) diff --git a/Region.H b/Region.H index 880139b..25c01bb 100644 --- a/Region.H +++ b/Region.H @@ -35,7 +35,7 @@ using namespace std; /* Base class for virtual widget on a track */ -class TrackWidget +class Track_Widget { protected: @@ -78,9 +78,36 @@ public: nframes_t start ( void ) const { return _start; } nframes_t length ( void ) const { return _end - _start; } + + virtual void + draw ( int X, int Y, int W, int H ) + { + fl_draw_box( FL_FLAT_BOX, X, Y, W, H, _box_color ); + } + + virtual int + handle ( int m ) { return 0; } + + }; -class Region : public TrackWidget + +class Tempo : public Track_Widget +{ + float _tempo; + + void + draw ( int X, int Y, int W, int H ) + { + + + + + } + +}; + +class Region : public Track_Widget { Clip *_clip; /* clip this region represents */ diff --git a/Track.C b/Track.C index cf0356c..957feb7 100644 --- a/Track.C +++ b/Track.C @@ -33,7 +33,7 @@ Track::draw ( void ) fl_push_clip( x(), y(), w(), h() ); - for ( list ::iterator r = _regions.begin(); r != _regions.end(); r++ ) + for ( list ::iterator r = _regions.begin(); r != _regions.end(); r++ ) { // (*r)->draw( timeline.xoffset + x(), y(), w(), h() ); (*r)->draw( x(), y(), w(), h() ); @@ -43,18 +43,18 @@ Track::draw ( void ) } void -Track::remove_region ( Region *r ) +Track::remove_region ( Track_Widget *r ) { _regions.remove( r ); } -Region * +Track_Widget * Track::event_region ( void ) { // FIXME: doesn't handle overlap! int ets = timeline.xoffset + timeline.x_to_ts( Fl::event_x() ); - for ( list ::iterator r = _regions.begin(); r != _regions.end(); r++ ) + for ( list ::iterator r = _regions.begin(); r != _regions.end(); r++ ) if ( ets > (*r)->offset() && ets < (*r)->offset() + (*r)->length() ) return (*r); @@ -62,7 +62,7 @@ Track::event_region ( void ) } void -Track::add ( Region *r ) +Track::add ( Track_Widget *r ) { if ( r->track() ) { @@ -83,16 +83,16 @@ Track::add ( Region *r ) /* snap /r/ to nearest edge */ void -Track::snap ( Region *r ) +Track::snap ( Track_Widget *r ) { const int snap_pixels = 10; int rx1 = r->x(); int rx2 = r->x() + r->w(); - for ( list ::iterator i = _regions.begin(); i != _regions.end(); i++ ) + for ( list ::iterator i = _regions.begin(); i != _regions.end(); i++ ) { - const Region *w = (*i); + const Track_Widget *w = (*i); if ( w == r ) continue; @@ -131,7 +131,7 @@ done: int Track::handle ( int m ) { - static Region *current_region; + static Track_Widget *current_region; switch ( m ) { @@ -180,7 +180,7 @@ Track::handle ( int m ) return 1; default: { - Region *r = event_region(); + Track_Widget *r = event_region(); if ( current_region ) r = current_region; diff --git a/Track.H b/Track.H index 636d508..8d28aea 100644 --- a/Track.H +++ b/Track.H @@ -32,17 +32,18 @@ using std::list; class Region; +class Track_Widget; class Track : public Fl_Group { Track *_next; Track *_prev; - list _regions; + list _regions; char *_name; - Region *event_region ( void ); + Track_Widget *event_region ( void ); public: @@ -62,9 +63,9 @@ public: void draw ( void ); - void remove_region ( Region *r ); - void add ( Region *r ); - void snap ( Region *r ); + void remove_region ( Track_Widget *r ); + void add ( Track_Widget *r ); + void snap ( Track_Widget *r ); int handle ( int m ); };