From c8bb330e8e1478e39821f43281e33520282ae399 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Fri, 2 May 2008 00:52:50 -0500 Subject: [PATCH] Try to clean up region dragging. --- Timeline/Region.C | 2 +- Timeline/Sequence_Widget.C | 20 ++++++++++---------- Timeline/Sequence_Widget.H | 4 ++-- Timeline/Timeline.C | 3 +++ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Timeline/Region.C b/Timeline/Region.C index 616addd..8f9df1a 100644 --- a/Timeline/Region.C +++ b/Timeline/Region.C @@ -420,7 +420,7 @@ Region::handle ( int m ) if ( ! _drag ) { - begin_drag( Drag( x() - X, y() - Y ) ); + begin_drag( Drag( x() - X, y() - Y, x_to_offset( X ) ) ); _log.hold(); } diff --git a/Timeline/Sequence_Widget.C b/Timeline/Sequence_Widget.C index 28011bd..15e41d7 100644 --- a/Timeline/Sequence_Widget.C +++ b/Timeline/Sequence_Widget.C @@ -180,29 +180,29 @@ Sequence_Widget::handle ( int m ) return 1; case FL_DRAG: - case FL_DND_DRAG: { if ( ! _drag ) { - begin_drag ( Drag( x() - X, y() - Y ) ); + begin_drag ( Drag( x() - X, y() - Y, x_to_offset( X ) ) ); _log.hold(); } fl_cursor( FL_CURSOR_MOVE ); - const int ox = _drag->x; - redraw(); - if ( timeline->ts_to_x( timeline->xoffset ) + ox + X > _track->x() ) { - int nx = (ox + X) - _track->x(); + const nframes_t of = timeline->x_to_offset( X ); - // _r->offset = timeline->x_to_ts( nx ) + timeline->xoffset; - offset( timeline->x_to_ts( nx ) + timeline->xoffset ); + if ( of >= _drag->offset ) + { + _r->offset = of - _drag->offset; - if ( Sequence_Widget::_current == this ) - _track->snap( this ); + if ( Sequence_Widget::_current == this ) + _track->snap( this ); + } + else + _r->offset = 0; } if ( X >= _track->x() + _track->w() || diff --git a/Timeline/Sequence_Widget.H b/Timeline/Sequence_Widget.H index d574a88..7df0da7 100644 --- a/Timeline/Sequence_Widget.H +++ b/Timeline/Sequence_Widget.H @@ -35,9 +35,9 @@ struct Drag int y; int state; - Sequence_Widget *original; + nframes_t offset; - Drag( int X, int Y ) : x( X ), y( Y ) { state = 0; } + Drag( int X, int Y, nframes_t offset=0 ) : x( X ), y( Y ), offset( offset ) { state = 0; } }; struct Range diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index ac0ab31..e60e9d1 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -562,6 +562,9 @@ Timeline::resize ( int X, int Y, int W, int H ) void Timeline::draw ( void ) { + if ( ! visible_r() ) + return; + int X, Y, W, H; int bdx = 0;