Make region duplication work again.

This commit is contained in:
Jonathan Moore Liles 2008-05-07 19:25:12 -05:00
parent edb9be37ab
commit 9bf7183696
3 changed files with 60 additions and 55 deletions

View File

@ -304,11 +304,6 @@ Audio_Region::handle ( int m )
redraw(); redraw();
return 1; return 1;
} }
else if ( Fl::event_button1() && Fl::event_ctrl() )
{
/* duplication */
return 1;
}
else if ( Fl::test_shortcut( FL_BUTTON3 ) && ! Fl::event_shift() ) else if ( Fl::test_shortcut( FL_BUTTON3 ) && ! Fl::event_shift() )
{ {
/* context menu */ /* context menu */
@ -350,13 +345,13 @@ Audio_Region::handle ( int m )
return 0; return 0;
} }
else else
return Sequence_Widget::handle( m ); return Sequence_Region::handle( m );
} }
break; break;
} }
case FL_RELEASE: case FL_RELEASE:
{ {
Sequence_Widget::handle( m ); Sequence_Region::handle( m );
copied = false; copied = false;
@ -369,11 +364,11 @@ Audio_Region::handle ( int m )
begin_drag( Drag( x() - X, y() - Y, x_to_offset( X ) ) ); begin_drag( Drag( x() - X, y() - Y, x_to_offset( X ) ) );
_log.hold(); _log.hold();
} }
if ( Fl::event_button1() )
/* panning */
if ( Fl::event_state() & FL_SHIFT &&
Fl::event_state() & FL_CTRL )
{ {
if ( Fl::event_state() & ( FL_SHIFT | FL_CTRL ) )
{
/* panning */
int d = (ox + X) - x(); int d = (ox + X) - x();
long td = timeline->x_to_ts( d ); long td = timeline->x_to_ts( d );
@ -385,22 +380,12 @@ Audio_Region::handle ( int m )
sequence()->redraw(); sequence()->redraw();
return 1; return 1;
} }
/* duplication */
if ( Fl::event_state() & FL_CTRL )
{
if ( _drag->state == 0 )
{
sequence()->add( new Audio_Region( *this ) );
_drag->state = 1;
return 1;
}
} }
ret = Sequence_Widget::handle( m ); ret = Sequence_Region::handle( m );
return ret | 1; return ret | 1;
default: default:
return Sequence_Widget::handle( m ); return Sequence_Region::handle( m );
break; break;
} }

View File

@ -135,6 +135,23 @@ private:
static bool snapshot( FILE * fp ); static bool snapshot( FILE * fp );
void init ( bool loggable=true )
{
if ( loggable )
{
_id = ++_log_id;
_old_state = NULL;
_nest = 0;
ensure_size( _id );
_loggables[ _id - 1 ] = this;
}
else
_id = 0;
}
public: public:
static const char *escape ( const char *s ); static const char *escape ( const char *s );
@ -176,19 +193,7 @@ public:
Loggable ( bool loggable=true ) Loggable ( bool loggable=true )
{ {
if ( loggable ) init( loggable );
{
_id = ++_log_id;
_old_state = NULL;
_nest = 0;
ensure_size( _id );
_loggables[ _id - 1 ] = this;
}
else
_id = 0;
} }
void update_id ( int id ); void update_id ( int id );
@ -226,8 +231,9 @@ protected:
/* leaf subclasses *must* call log_create() at the end of their copy contructors */ /* leaf subclasses *must* call log_create() at the end of their copy contructors */
Loggable ( const Loggable &rhs ) Loggable ( const Loggable &rhs )
{ {
init( true );
/* FIXME: get a real id here!!! */ /* FIXME: get a real id here!!! */
_id = 0; // _id = 0;
} }
public: public:

View File

@ -215,10 +215,23 @@ Sequence_Region::handle ( int m )
} }
else else
return 0; return 0;
else if ( Fl::event_button1() )
/* track jumping */
if ( ! selected() )
{ {
if ( Fl::event_state() & FL_CTRL )
{
/* duplication */
if ( _drag->state == 0 )
{
// sequence()->add( new Audio_Region( *this ) );
sequence()->add( this->clone() );
_drag->state = 1;
return 1;
}
}
else if ( ! selected() )
{
/* track jumping */
if ( Y > y() + h() || Y < y() ) if ( Y > y() + h() || Y < y() )
{ {
printf( "wants to jump tracks\n" ); printf( "wants to jump tracks\n" );
@ -233,6 +246,7 @@ Sequence_Region::handle ( int m )
return 0; return 0;
} }
} }
}
ret = Sequence_Widget::handle( m ); ret = Sequence_Widget::handle( m );
return ret | 1; return ret | 1;