Overhaul timeline event handling.
This commit is contained in:
parent
0525433a41
commit
0e1ac2563d
|
@ -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,11 +240,7 @@ Audio_Region::handle ( int m )
|
|||
case FL_PUSH:
|
||||
{
|
||||
/* splitting */
|
||||
if ( Fl::event_shift() && ! Fl::event_ctrl() )
|
||||
{
|
||||
switch ( Fl::event_button() )
|
||||
{
|
||||
case 2:
|
||||
if ( Fl::test_shortcut( FL_BUTTON2 | FL_SHIFT ) )
|
||||
{
|
||||
/* split */
|
||||
if ( ! copied )
|
||||
|
@ -272,15 +257,9 @@ Audio_Region::handle ( int m )
|
|||
log_end();
|
||||
|
||||
Loggable::block_end();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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,15 +329,13 @@ 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::event_state() & ( FL_SHIFT | FL_CTRL ) )
|
||||
|
||||
if ( Fl::test_shortcut( FL_BUTTON1 | FL_SHIFT | FL_CTRL ) )
|
||||
{
|
||||
/* panning */
|
||||
int d = (ox + X) - x();
|
||||
|
@ -381,13 +346,12 @@ Audio_Region::handle ( int m )
|
|||
else
|
||||
_r->offset = os - td;
|
||||
|
||||
sequence()->redraw();
|
||||
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,6 +307,7 @@ Sequence::handle ( int m )
|
|||
fl_cursor( (Fl_Cursor)1 );
|
||||
}
|
||||
else
|
||||
if ( ! event_widget() )
|
||||
fl_cursor( cursor() );
|
||||
|
||||
return 1;
|
||||
|
@ -337,15 +339,17 @@ Sequence::handle ( int m )
|
|||
{
|
||||
int retval = r->dispatch( m );
|
||||
|
||||
if ( retval && m == FL_PUSH )
|
||||
if ( retval )
|
||||
{
|
||||
if ( m == FL_PUSH )
|
||||
{
|
||||
take_focus();
|
||||
|
||||
Sequence_Widget::pushed( r );
|
||||
}
|
||||
|
||||
if ( retval && m == FL_RELEASE )
|
||||
else if ( m == FL_RELEASE )
|
||||
Sequence_Widget::pushed( NULL );
|
||||
}
|
||||
|
||||
Loggable::block_start();
|
||||
|
||||
|
@ -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() )
|
||||
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();
|
||||
|
||||
{
|
||||
const nframes_t of = timeline->x_to_offset( X );
|
||||
|
||||
if ( of >= _drag->start )
|
||||
|
@ -346,8 +352,6 @@ Sequence_Widget::handle ( int m )
|
|||
if ( Sequence_Widget::_current == this )
|
||||
sequence()->snap( this );
|
||||
|
||||
}
|
||||
|
||||
if ( X >= sequence()->x() + sequence()->w() ||
|
||||
X <= sequence()->x() )
|
||||
{
|
||||
|
@ -377,6 +381,9 @@ Sequence_Widget::handle ( int m )
|
|||
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue