Permit panning of regions. Try to prevent trimming or panning beyond 0.

This commit is contained in:
Jonathan Moore Liles 2008-02-18 01:15:12 -06:00
parent 6b48c0d629
commit 5ec40ad5ce
2 changed files with 47 additions and 8 deletions

View File

@ -75,21 +75,34 @@ Region::trim ( enum trim_e t, int X )
{ {
int d = X - 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; break;
} }
case RIGHT: case RIGHT:
{ {
int d = (x() + w()) - X; 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; break;
} }
default: default:
@ -113,6 +126,7 @@ Region::handle ( int m )
static enum trim_e trimming; static enum trim_e trimming;
static bool copied = false; static bool copied = false;
static nframes_t os;
int X = Fl::event_x(); int X = Fl::event_x();
int Y = Fl::event_y(); int Y = Fl::event_y();
@ -122,7 +136,8 @@ Region::handle ( int m )
case FL_PUSH: case FL_PUSH:
{ {
if ( Fl::event_state() & FL_SHIFT ) if ( Fl::event_state() & FL_SHIFT &&
! ( Fl::event_state() & FL_CTRL ))
{ {
switch ( Fl::event_button() ) switch ( Fl::event_button() )
{ {
@ -143,9 +158,16 @@ Region::handle ( int m )
ox = x() - X; ox = x() - X;
oy = y() - Y; oy = y() - Y;
if ( Fl::event_state() && FL_CTRL )
{
os = _start;
// Fl::local_grab( this );
}
if ( Fl::event_button() == 2 ) if ( Fl::event_button() == 2 )
normalize(); normalize();
return 1; return 1;
} }
return 0; return 0;
@ -155,9 +177,25 @@ Region::handle ( int m )
fl_cursor( FL_CURSOR_DEFAULT ); fl_cursor( FL_CURSOR_DEFAULT );
copied = false; copied = false;
trimming = NO; trimming = NO;
// Fl::release();
return 1; return 1;
case FL_DRAG: 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 ( Fl::event_state() & FL_SHIFT )
if ( trimming ) if ( trimming )
{ {

View File

@ -85,11 +85,12 @@ public:
switch ( m ) switch ( m )
{ {
case FL_DND_DRAG: case FL_DND_DRAG:
case FL_DND_RELEASE:
case FL_DND_ENTER: case FL_DND_ENTER:
case FL_DND_LEAVE:
case FL_ENTER: case FL_ENTER:
return 1; return 1;
case FL_DND_LEAVE:
case FL_DND_RELEASE:
return 1;
case FL_PASTE: case FL_PASTE:
{ {
const char *text = Fl::event_text(); const char *text = Fl::event_text();