From 825d16c5b77f6e40945cf37b4c14b94c723613e6 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 21 Feb 2008 00:12:21 -0600 Subject: [PATCH] Reinstitute drag scrolling. --- Region.C | 30 ++-------------------- Region.H | 77 ++++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 54 insertions(+), 53 deletions(-) diff --git a/Region.C b/Region.C index 142b163..c802147 100644 --- a/Region.C +++ b/Region.C @@ -240,23 +240,6 @@ Region::handle ( int m ) ret = Track_Widget::handle( m ); return ret | 1; -/* if ( X >= timeline.scroll->x() + timeline.scroll->w() || */ -/* X <= timeline.scroll->x() ) */ -/* { */ -/* /\* this drag needs to scroll *\/ */ - -/* long pos = timeline.scroll->xposition(); */ - -/* if ( X <= timeline.scroll->x() ) */ -/* pos -= 100; */ -/* else */ -/* pos += 100; */ - -/* if ( pos < 0 ) */ -/* pos = 0; */ - -/* timeline.scroll->position( pos, timeline.scroll->yposition() ); */ -/* } */ // _offset = timeline.x_to_ts( x() ); @@ -309,8 +292,6 @@ Region::draw ( int X, int Y, int W, int H ) int rx = x(); -// printf( "rx %d, rw %d\n", rx, rw ); - fl_push_clip( rx, Y, rw, H ); /* dirty hack to keep the box from flipping to vertical at small sizes */ @@ -327,16 +308,9 @@ Region::draw ( int X, int Y, int W, int H ) fl_line( rx, Y, rx, Y + H ); fl_line( rx + rw - 1, Y, rx + rw - 1, Y + H ); - fl_pop_clip(); - - fl_font( FL_HELVETICA, 14 ); - fl_color( FL_BLACK ); - - draw_label( _clip->name(), (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_BOTTOM | FL_ALIGN_CLIP | FL_ALIGN_INSIDE) ); - -/* fl_color( FL_RED ); */ -/* fl_line( x(), y(), x(), y() + h() ); */ + draw_label( _clip->name(), (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_BOTTOM /*| FL_ALIGN_CLIP*/ | FL_ALIGN_INSIDE) ); + fl_pop_clip(); } diff --git a/Region.H b/Region.H index 72aa21c..3888183 100644 --- a/Region.H +++ b/Region.H @@ -168,10 +168,10 @@ public: if ( align & FL_ALIGN_INSIDE ) { - X += Fl::box_dx( box() ); - Y += Fl::box_dy( box() ); - W -= Fl::box_dw( box() ); - H -= Fl::box_dh( box() ); + X += Fl::box_dx( box() ); + Y += Fl::box_dy( box() ); + W -= Fl::box_dw( box() ); + H -= Fl::box_dh( box() ); } if ( align & FL_ALIGN_CLIP ) fl_push_clip( X, Y, W, H ); @@ -223,6 +223,33 @@ public: _track->redraw(); fl_cursor( FL_CURSOR_MOVE ); + + if ( X >= _track->x() + _track->w() || + X <= _track->x() ) + { + /* this drag needs to scroll */ + + nframes_t pos = timeline.xoffset; + + nframes_t d = timeline.x_to_ts( 100 ); + + if ( X <= _track->x() ) + { + + if ( pos > d ) + pos -= d; + else + pos = 0; + } + else + pos += d; + + timeline.xoffset = pos; + + timeline.tracks->redraw(); + } + + return 1; } default: @@ -291,33 +318,33 @@ public: }; - class Region : public Track_Widget - { +class Region : public Track_Widget +{ - Clip *_clip; /* clip this region represents */ + Clip *_clip; /* clip this region represents */ - float _scale; /* amplitude adjustment */ + float _scale; /* amplitude adjustment */ - static Fl_Boxtype _box; - static Fl_Color _selection_color; - static Fl_Color selection_color ( void ) { return _selection_color; } - static void selection_color ( Fl_Color v ) { _selection_color = v; } + static Fl_Boxtype _box; + static Fl_Color _selection_color; + static Fl_Color selection_color ( void ) { return _selection_color; } + static void selection_color ( Fl_Color v ) { _selection_color = v; } - enum trim_e { NO, LEFT, RIGHT }; - void trim ( enum trim_e t, int X ); - void init ( void ); + enum trim_e { NO, LEFT, RIGHT }; + void trim ( enum trim_e t, int X ); + void init ( void ); - public: +public: - Fl_Boxtype box ( void ) const { return Region::_box; } + Fl_Boxtype box ( void ) const { return Region::_box; } - Region ( const Region & rhs ); - Region ( Clip *c ); + Region ( const Region & rhs ); + Region ( Clip *c ); - int handle ( int m ); - void draw_box( int X, int Y, int W, int H ); - void draw ( int X, int Y, int W, int H ); - void resize ( void ); + int handle ( int m ); + void draw_box( int X, int Y, int W, int H ); + void draw ( int X, int Y, int W, int H ); + void resize ( void ); - void normalize ( void ); - }; + void normalize ( void ); +};