From 5ec40ad5ce31eb699cb31a36372faa1b01e6f0c3 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Mon, 18 Feb 2008 01:15:12 -0600 Subject: [PATCH] Permit panning of regions. Try to prevent trimming or panning beyond 0. --- Region.C | 50 ++++++++++++++++++++++++++++++++++++++++++++------ Track.H | 5 +++-- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/Region.C b/Region.C index 006dae7..7d6eb67 100644 --- a/Region.C +++ b/Region.C @@ -75,21 +75,34 @@ Region::trim ( enum trim_e t, int X ) { int d = X - x(); - _start += timeline.x_to_ts( d ); + long td = timeline.x_to_ts( d ); - Fl_Widget::resize( x() + d, y(), w() - d, h() ); + if ( td < 0 && _start < 0 - td ) + td = 0 - _start; - _offset = timeline.x_to_ts( x() ); + _start += td; + + _offset += td; + + resize(); +// Fl_Widget::resize( x() + d, y(), w() - d, h() ); + +// _offset = timeline.x_to_ts( x() ); break; } case RIGHT: { int d = (x() + w()) - X; + long td = timeline.x_to_ts( d ); - _end = _start + timeline.x_to_ts( w() - d ); + _end -= td; - Fl_Widget::resize( x(), y(), w() - d, h() ); + resize(); + +// _end = _start + timeline.x_to_ts( w() - d ); + +// Fl_Widget::resize( x(), y(), w() - d, h() ); break; } default: @@ -113,6 +126,7 @@ Region::handle ( int m ) static enum trim_e trimming; static bool copied = false; + static nframes_t os; int X = Fl::event_x(); int Y = Fl::event_y(); @@ -122,7 +136,8 @@ Region::handle ( int m ) case FL_PUSH: { - if ( Fl::event_state() & FL_SHIFT ) + if ( Fl::event_state() & FL_SHIFT && + ! ( Fl::event_state() & FL_CTRL )) { switch ( Fl::event_button() ) { @@ -143,9 +158,16 @@ Region::handle ( int m ) ox = x() - X; oy = y() - Y; + if ( Fl::event_state() && FL_CTRL ) + { + os = _start; +// Fl::local_grab( this ); + } + if ( Fl::event_button() == 2 ) normalize(); + return 1; } return 0; @@ -155,9 +177,25 @@ Region::handle ( int m ) fl_cursor( FL_CURSOR_DEFAULT ); copied = false; trimming = NO; + // Fl::release(); return 1; case FL_DRAG: + if ( Fl::event_state() & FL_SHIFT && + Fl::event_state() & FL_CTRL ) + { + int d = (ox + X) - x(); + long td = timeline.x_to_ts( d ); + + if ( td > 0 && os < td ) + _start = 0; + else + _start = os - td; + + redraw(); + return 1; + } + if ( Fl::event_state() & FL_SHIFT ) if ( trimming ) { diff --git a/Track.H b/Track.H index d94c357..f1fea32 100644 --- a/Track.H +++ b/Track.H @@ -85,11 +85,12 @@ public: switch ( m ) { case FL_DND_DRAG: - case FL_DND_RELEASE: case FL_DND_ENTER: - case FL_DND_LEAVE: case FL_ENTER: return 1; + case FL_DND_LEAVE: + case FL_DND_RELEASE: + return 1; case FL_PASTE: { const char *text = Fl::event_text();