@@ -198,21 +198,10 @@ Audio_Region::handle ( int m ) | |||
static bool copied = false; | |||
static nframes_t os; | |||
if ( ! active_r() ) | |||
return 0; | |||
// int X = Fl::event_x() - _track->x(); | |||
int X = Fl::event_x(); | |||
int Y = Fl::event_y(); | |||
int ret; | |||
if ( m != FL_RELEASE && Sequence_Region::handle( m ) ) | |||
return 1; | |||
Logger _log( this ); | |||
//log_r->start(); | |||
switch ( m ) | |||
{ | |||
@@ -251,36 +240,26 @@ Audio_Region::handle ( int m ) | |||
case FL_PUSH: | |||
{ | |||
/* splitting */ | |||
if ( Fl::event_shift() && ! Fl::event_ctrl() ) | |||
if ( Fl::test_shortcut( FL_BUTTON2 | FL_SHIFT ) ) | |||
{ | |||
switch ( Fl::event_button() ) | |||
/* split */ | |||
if ( ! copied ) | |||
{ | |||
case 2: | |||
{ | |||
/* split */ | |||
if ( ! copied ) | |||
{ | |||
Loggable::block_start(); | |||
Loggable::block_start(); | |||
Audio_Region *copy = new Audio_Region( *this ); | |||
Audio_Region *copy = new Audio_Region( *this ); | |||
trim( RIGHT, X ); | |||
copy->trim( LEFT, X ); | |||
trim( RIGHT, X ); | |||
copy->trim( LEFT, X ); | |||
sequence()->add( copy ); | |||
sequence()->add( copy ); | |||
log_end(); | |||
log_end(); | |||
Loggable::block_end(); | |||
return 0; | |||
} | |||
} | |||
default: | |||
return 0; | |||
break; | |||
Loggable::block_end(); | |||
} | |||
return 1; | |||
return 0; | |||
} | |||
else | |||
{ | |||
@@ -289,22 +268,9 @@ Audio_Region::handle ( int m ) | |||
/* for panning */ | |||
os = _r->offset; | |||
/* normalization and selection */ | |||
if ( Fl::event_button2() ) | |||
if ( Fl::test_shortcut( FL_BUTTON2 | FL_CTRL ) && ! Fl::event_shift() ) | |||
{ | |||
if ( Fl::event_ctrl() ) | |||
normalize(); | |||
else | |||
{ | |||
if ( Sequence_Widget::current() == this ) | |||
{ | |||
if ( selected() ) | |||
deselect(); | |||
else | |||
select(); | |||
} | |||
} | |||
normalize(); | |||
redraw(); | |||
return 1; | |||
} | |||
@@ -346,11 +312,12 @@ Audio_Region::handle ( int m ) | |||
redraw(); | |||
} | |||
return 0; | |||
return 1; | |||
} | |||
else | |||
return Sequence_Region::handle( m ); | |||
} | |||
break; | |||
} | |||
case FL_RELEASE: | |||
@@ -362,32 +329,29 @@ Audio_Region::handle ( int m ) | |||
return 1; | |||
} | |||
case FL_DRAG: | |||
if ( ! _drag ) | |||
{ | |||
begin_drag( Drag( x() - X, y() - Y, x_to_offset( X ) ) ); | |||
_log.hold(); | |||
} | |||
if ( Fl::event_button1() ) | |||
if ( Fl::test_shortcut( FL_BUTTON1 | FL_SHIFT | FL_CTRL ) ) | |||
{ | |||
if ( Fl::event_state() & ( FL_SHIFT | FL_CTRL ) ) | |||
{ | |||
/* panning */ | |||
int d = (ox + X) - x(); | |||
long td = timeline->x_to_ts( d ); | |||
/* panning */ | |||
int d = (ox + X) - x(); | |||
long td = timeline->x_to_ts( d ); | |||
if ( td > 0 && os < (nframes_t)td ) | |||
_r->offset = 0; | |||
else | |||
_r->offset = os - td; | |||
if ( td > 0 && os < (nframes_t)td ) | |||
_r->offset = 0; | |||
else | |||
_r->offset = os - td; | |||
sequence()->redraw(); | |||
return 1; | |||
} | |||
redraw(); | |||
return 1; | |||
} | |||
ret = Sequence_Region::handle( m ); | |||
return ret | 1; | |||
return Sequence_Region::handle( m ); | |||
default: | |||
return Sequence_Region::handle( m ); | |||
break; | |||
@@ -280,20 +280,21 @@ Sequence::snap ( Sequence_Widget *r ) | |||
int | |||
Sequence::handle ( int m ) | |||
{ | |||
switch ( m ) | |||
{ | |||
case FL_FOCUS: | |||
case FL_UNFOCUS: | |||
return 1; | |||
case FL_LEAVE: | |||
// DMESSAGE( "leave" ); | |||
fl_cursor( FL_CURSOR_DEFAULT ); | |||
return 1; | |||
case FL_DND_DRAG: | |||
return 1; | |||
case FL_ENTER: | |||
// DMESSAGE( "enter" ); | |||
if ( Sequence_Widget::pushed() ) | |||
{ | |||
if ( Sequence_Widget::pushed()->sequence()->class_name() == class_name() ) | |||
{ | |||
/* accept objects dragged from other sequences of this type */ | |||
@@ -306,7 +307,8 @@ Sequence::handle ( int m ) | |||
fl_cursor( (Fl_Cursor)1 ); | |||
} | |||
else | |||
fl_cursor( cursor() ); | |||
if ( ! event_widget() ) | |||
fl_cursor( cursor() ); | |||
return 1; | |||
case FL_DND_ENTER: | |||
@@ -337,16 +339,18 @@ Sequence::handle ( int m ) | |||
{ | |||
int retval = r->dispatch( m ); | |||
if ( retval && m == FL_PUSH ) | |||
if ( retval ) | |||
{ | |||
take_focus(); | |||
if ( m == FL_PUSH ) | |||
{ | |||
take_focus(); | |||
Sequence_Widget::pushed( r ); | |||
Sequence_Widget::pushed( r ); | |||
} | |||
else if ( m == FL_RELEASE ) | |||
Sequence_Widget::pushed( NULL ); | |||
} | |||
if ( retval && m == FL_RELEASE ) | |||
Sequence_Widget::pushed( NULL ); | |||
Loggable::block_start(); | |||
while ( _delete_queue.size() ) | |||
@@ -355,7 +359,6 @@ Sequence::handle ( int m ) | |||
Sequence_Widget *t = _delete_queue.front(); | |||
_delete_queue.pop(); | |||
if ( Sequence_Widget::pushed() == t ) | |||
Sequence_Widget::pushed( NULL ); | |||
if ( Sequence_Widget::belowmouse() == t ) | |||
@@ -136,17 +136,10 @@ Sequence_Region::handle ( int m ) | |||
static bool copied = false; | |||
/* if ( ! active_r() ) */ | |||
/* return 0; */ | |||
// int X = Fl::event_x() - _track->x(); | |||
int X = Fl::event_x(); | |||
int Y = Fl::event_y(); | |||
int ret; | |||
Logger _log( this ); | |||
//log_r->offset(); | |||
switch ( m ) | |||
{ | |||
@@ -188,14 +181,14 @@ Sequence_Region::handle ( int m ) | |||
redraw(); | |||
return 1; | |||
} | |||
else if ( Fl::test_shortcut( FL_CTRL + FL_BUTTON1 ) ) | |||
else if ( Fl::test_shortcut( FL_CTRL + FL_BUTTON1 ) && ! Fl::event_shift() ) | |||
{ | |||
/* duplication */ | |||
fl_cursor( FL_CURSOR_MOVE ); | |||
return 1; | |||
} | |||
else | |||
return Sequence_Widget::handle( m ); | |||
break; | |||
} | |||
case FL_RELEASE: | |||
{ | |||
@@ -216,7 +209,8 @@ Sequence_Region::handle ( int m ) | |||
} | |||
/* trimming */ | |||
if ( Fl::event_state() & FL_SHIFT ) | |||
if ( Fl::event_shift() ) | |||
{ | |||
if ( trimming ) | |||
{ | |||
trim( trimming, X ); | |||
@@ -224,6 +218,7 @@ Sequence_Region::handle ( int m ) | |||
} | |||
else | |||
return 0; | |||
} | |||
else if ( Fl::event_button1() ) | |||
{ | |||
if ( Fl::event_state() & FL_CTRL ) | |||
@@ -238,7 +233,7 @@ Sequence_Region::handle ( int m ) | |||
return 1; | |||
} | |||
} | |||
else if ( ! selected() ) | |||
else if ( Fl::test_shortcut( FL_BUTTON1 ) && ! Fl::event_shift() && ! selected() ) | |||
{ | |||
/* track jumping */ | |||
if ( Y > y() + h() || Y < y() ) | |||
@@ -255,8 +250,7 @@ Sequence_Region::handle ( int m ) | |||
} | |||
} | |||
ret = Sequence_Widget::handle( m ); | |||
return ret | 1; | |||
return Sequence_Widget::handle( m ); | |||
} | |||
default: | |||
return Sequence_Widget::handle( m ); | |||
@@ -252,7 +252,6 @@ Sequence_Widget::dispatch ( int m ) | |||
int r = 0; | |||
for ( list <Sequence_Widget *>::iterator i = _selection.begin(); i != _selection.end(); i++ ) | |||
if ( *i != this ) | |||
r |= (*i)->handle( m ); | |||
@@ -289,27 +288,32 @@ Sequence_Widget::handle ( int m ) | |||
Logger _log( this ); | |||
switch ( m ) | |||
{ | |||
case FL_ENTER: | |||
fl_cursor( FL_CURSOR_HAND ); | |||
return 1; | |||
case FL_LEAVE: | |||
// DMESSAGE( "leave" ); | |||
fl_cursor( sequence()->cursor() ); | |||
return 1; | |||
case FL_PUSH: | |||
{ | |||
/* deletion */ | |||
if ( Fl::event_state() & FL_CTRL && | |||
Fl::event_button3() ) | |||
if ( Fl::test_shortcut( FL_CTRL + FL_BUTTON3 ) && ! Fl::event_shift() ) | |||
{ | |||
redraw(); | |||
sequence()->queue_delete( this ); | |||
return 1; | |||
} | |||
else | |||
if ( Fl::event_button1() ) | |||
return 1; | |||
else if ( Fl::test_shortcut( FL_BUTTON1 ) && ! Fl::event_shift() ) | |||
{ | |||
fl_cursor( FL_CURSOR_MOVE ); | |||
/* movement drag */ | |||
return 1; | |||
} | |||
return 0; | |||
} | |||
@@ -331,11 +335,13 @@ Sequence_Widget::handle ( int m ) | |||
_log.hold(); | |||
} | |||
fl_cursor( FL_CURSOR_MOVE ); | |||
if ( ( Fl::test_shortcut( FL_BUTTON1 + FL_CTRL ) || | |||
Fl::test_shortcut( FL_BUTTON1 ) ) && ! Fl::event_shift() ) | |||
{ | |||
// fl_cursor( FL_CURSOR_MOVE ); | |||
redraw(); | |||
redraw(); | |||
{ | |||
const nframes_t of = timeline->x_to_offset( X ); | |||
if ( of >= _drag->start ) | |||
@@ -346,36 +352,37 @@ Sequence_Widget::handle ( int m ) | |||
if ( Sequence_Widget::_current == this ) | |||
sequence()->snap( this ); | |||
} | |||
if ( X >= sequence()->x() + sequence()->w() || | |||
X <= sequence()->x() ) | |||
{ | |||
/* this drag needs to scroll */ | |||
if ( X >= sequence()->x() + sequence()->w() || | |||
X <= sequence()->x() ) | |||
{ | |||
/* this drag needs to scroll */ | |||
nframes_t pos = timeline->xoffset; | |||
nframes_t pos = timeline->xoffset; | |||
nframes_t d = timeline->x_to_ts( 100 ); | |||
nframes_t d = timeline->x_to_ts( 100 ); | |||
if ( X <= sequence()->x() ) | |||
{ | |||
if ( X <= sequence()->x() ) | |||
{ | |||
if ( pos > d ) | |||
pos -= d; | |||
if ( pos > d ) | |||
pos -= d; | |||
else | |||
pos = 0; | |||
} | |||
else | |||
pos = 0; | |||
} | |||
else | |||
pos += d; | |||
pos += d; | |||
timeline->xposition( timeline->ts_to_x( pos ) ); | |||
timeline->xposition( timeline->ts_to_x( pos ) ); | |||
/* FIXME: why isn't this enough? */ | |||
/* FIXME: why isn't this enough? */ | |||
// sequence()->redraw(); | |||
timeline->redraw(); | |||
} | |||
timeline->redraw(); | |||
} | |||
return 1; | |||
return 1; | |||
} | |||
else | |||
return 0; | |||
} | |||
default: | |||
return 0; | |||
@@ -962,6 +962,10 @@ Timeline::handle ( int m ) | |||
case FL_UNFOCUS: | |||
// redraw(); | |||
return 1; | |||
case FL_ENTER: | |||
return 1; | |||
case FL_LEAVE: | |||
return 1; | |||
case FL_KEYDOWN: | |||
if ( Fl::event_key() == 'r' ) | |||
{ | |||
@@ -998,9 +1002,10 @@ Timeline::handle ( int m ) | |||
} | |||
default: | |||
{ | |||
if ( m == FL_PUSH && this != Fl::focus() ) | |||
take_focus(); | |||
if ( m == FL_PUSH ) | |||
Fl::focus( this ); | |||
//Fl::focus( this ); | |||
int r = Fl_Overlay_Window::handle( m ); | |||
@@ -1014,18 +1019,15 @@ Timeline::handle ( int m ) | |||
{ | |||
case FL_PUSH: | |||
{ | |||
// take_focus(); | |||
if ( Fl::event_state() & ( FL_ALT | FL_CTRL | FL_SHIFT ) ) | |||
return 0; | |||
if ( Fl::event_button1() ) | |||
if ( Fl::test_shortcut( FL_BUTTON1 ) && ! Fl::event_shift() ) | |||
{ | |||
assert( ! drag ); | |||
drag = new Drag( X - x(), Y - y() ); | |||
_selection.x = drag->x; | |||
_selection.y = drag->y; | |||
return 1; | |||
} | |||
else if ( Fl::test_shortcut( FL_BUTTON3 ) && ! Fl::event_shift() ) | |||
{ | |||
@@ -1036,11 +1038,10 @@ Timeline::handle ( int m ) | |||
r->do_callback( static_cast<Fl_Widget*>(menu) ); | |||
} | |||
return 1; | |||
} | |||
else | |||
return 0; | |||
break; | |||
return 0; | |||
} | |||
case FL_DRAG: | |||
{ | |||
@@ -1062,6 +1063,9 @@ Timeline::handle ( int m ) | |||
redraw(); | |||
} | |||
redraw_overlay(); | |||
return 1; | |||
break; | |||
} | |||
case FL_RELEASE: | |||
@@ -1069,7 +1073,6 @@ Timeline::handle ( int m ) | |||
delete drag; | |||
drag = NULL; | |||
if ( range ) | |||
{ | |||
p1 = x_to_offset( _selection.x ); | |||
@@ -1080,18 +1083,19 @@ Timeline::handle ( int m ) | |||
select( _selection ); | |||
_selection.w = _selection.h = 0; | |||
break; | |||
redraw_overlay(); | |||
return 1; | |||
} | |||
default: | |||
return 0; | |||
break; | |||
} | |||
redraw_overlay(); | |||
return 1; | |||
return 0; | |||
} | |||
} | |||
} | |||
@@ -452,7 +452,6 @@ Track::draw ( void ) | |||
int | |||
Track::handle ( int m ) | |||
{ | |||
switch ( m ) | |||
{ | |||
case FL_MOUSEWHEEL: | |||
@@ -478,7 +477,10 @@ Track::handle ( int m ) | |||
int X = Fl::event_x(); | |||
int Y = Fl::event_y(); | |||
if ( Fl::event_button3() && X < Track::width() ) | |||
if ( Fl_Group::handle( m ) ) | |||
return 1; | |||
if ( Fl::test_shortcut( FL_BUTTON3 ) && ! Fl::event_shift() && X < Track::width() ) | |||
{ | |||
int c = output.size(); | |||
@@ -561,14 +563,16 @@ Track::handle ( int m ) | |||
} | |||
} | |||
} | |||
return 1; | |||
} | |||
return 1; | |||
} | |||
return 0; | |||
} | |||
default: | |||
return Fl_Group::handle( m ); | |||
} | |||
return 0; | |||