Timeline: Improve drag scrolling behavior.
This commit is contained in:
parent
97d149421f
commit
aefc328c2d
|
@ -442,7 +442,7 @@ Sequence_Widget::handle ( int m )
|
||||||
|
|
||||||
if ( ! _drag )
|
if ( ! _drag )
|
||||||
{
|
{
|
||||||
begin_drag ( Drag( Y, x_to_offset( X ) ) );
|
begin_drag ( Drag( X, Y, x_to_offset( X ), start() ) );
|
||||||
_log.hold();
|
_log.hold();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,29 +473,25 @@ Sequence_Widget::handle ( int m )
|
||||||
sequence()->snap( this );
|
sequence()->snap( this );
|
||||||
|
|
||||||
if ( X >= sequence()->x() + sequence()->w() ||
|
if ( X >= sequence()->x() + sequence()->w() ||
|
||||||
X <= sequence()->x() )
|
X <= sequence()->drawable_x() )
|
||||||
{
|
{
|
||||||
/* this drag needs to scroll */
|
/* this drag needs to scroll */
|
||||||
|
|
||||||
nframes_t pos = timeline->xoffset;
|
int64_t pos = s - ( _drag->mouse_offset - _drag->offset );
|
||||||
|
|
||||||
nframes_t d = timeline->x_to_ts( 100 );
|
|
||||||
|
|
||||||
if ( X <= sequence()->x() )
|
if ( X > sequence()->x() + sequence()->w() )
|
||||||
{
|
pos -= timeline->x_to_ts( sequence()->drawable_w() );
|
||||||
|
|
||||||
if ( pos > d )
|
if ( s == 0 )
|
||||||
pos -= d;
|
pos = 0;
|
||||||
else
|
|
||||||
|
if ( pos < 0 )
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
|
||||||
else
|
|
||||||
pos += d;
|
|
||||||
|
|
||||||
timeline->xposition(timeline->ts_to_x(pos));
|
timeline->xposition(timeline->ts_to_x(pos));
|
||||||
|
|
||||||
// timeline->update_length( start() + length() );
|
/* timeline->redraw(); */
|
||||||
|
|
||||||
sequence()->damage( FL_DAMAGE_USER1 );
|
sequence()->damage( FL_DAMAGE_USER1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,9 @@ struct Drag
|
||||||
|
|
||||||
// nframes_t start;
|
// nframes_t start;
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
|
int64_t mouse_offset;
|
||||||
|
|
||||||
Drag( int X, int Y, uint64_t offset=0 ) : x( X ), y( Y ), offset( offset ) { state = 0; }
|
Drag( int X, int Y, uint64_t offset=0, uint64_t mouse_offset = 0 ) : x( X ), y( Y ), offset( offset ), mouse_offset( mouse_offset ) { state = 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* most common position description. /offset/ is only used by Regions,
|
/* most common position description. /offset/ is only used by Regions,
|
||||||
|
|
|
@ -938,7 +938,21 @@ Timeline::prev_line ( nframes_t *frame, bool bar ) const
|
||||||
nframes_t
|
nframes_t
|
||||||
Timeline::x_to_offset ( int x ) const
|
Timeline::x_to_offset ( int x ) const
|
||||||
{
|
{
|
||||||
return x_to_ts( max( 0, x - Track::width() ) ) + xoffset;
|
int d = x - Track::width();
|
||||||
|
|
||||||
|
int64_t r;
|
||||||
|
|
||||||
|
if ( d < 0 )
|
||||||
|
r = (int64_t)xoffset - x_to_ts( 0 - d );
|
||||||
|
else
|
||||||
|
r = (int64_t)xoffset + x_to_ts( d );
|
||||||
|
|
||||||
|
if ( r > JACK_MAX_FRAMES )
|
||||||
|
return JACK_MAX_FRAMES;
|
||||||
|
else if ( r < 0 )
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -1837,7 +1851,7 @@ Timeline::xposition ( int X )
|
||||||
{
|
{
|
||||||
xoffset = x_to_ts( X );
|
xoffset = x_to_ts( X );
|
||||||
|
|
||||||
int dx = ts_to_x( _old_xposition ) - ts_to_x( xoffset );
|
long dx = ts_to_x( _old_xposition ) - ts_to_x( xoffset );
|
||||||
|
|
||||||
if ( dx )
|
if ( dx )
|
||||||
damage( FL_DAMAGE_SCROLL );
|
damage( FL_DAMAGE_SCROLL );
|
||||||
|
|
Loading…
Reference in New Issue