Make region deletion undoable.
This commit is contained in:
parent
9e47efc585
commit
143035f0e8
|
@ -87,11 +87,7 @@ Audio_Track::handle ( int m )
|
|||
return 0;
|
||||
}
|
||||
|
||||
Region *r = new Region( c );
|
||||
|
||||
r->offset( timeline->x_to_ts( Fl::event_x() ) );
|
||||
|
||||
this->add( r );
|
||||
Region *r = new Region( c, this, timeline->xoffset + timeline->x_to_ts( Fl::event_x() ) );
|
||||
|
||||
redraw();
|
||||
return 1;
|
||||
|
|
16
Region.C
16
Region.C
|
@ -91,6 +91,7 @@ Region::init ( void )
|
|||
_color = FL_BLUE;
|
||||
}
|
||||
|
||||
/* copy constructor */
|
||||
Region::Region ( const Region & rhs )
|
||||
{
|
||||
_offset = rhs._offset;
|
||||
|
@ -103,6 +104,7 @@ Region::Region ( const Region & rhs )
|
|||
log_create();
|
||||
}
|
||||
|
||||
/* */
|
||||
Region::Region ( Audio_File *c )
|
||||
{
|
||||
init();
|
||||
|
@ -113,6 +115,20 @@ Region::Region ( Audio_File *c )
|
|||
}
|
||||
|
||||
|
||||
/* used when DND importing */
|
||||
Region::Region ( Audio_File *c, Track *t, nframes_t o )
|
||||
{
|
||||
init();
|
||||
_clip = c;
|
||||
_end = _clip->length();
|
||||
_track = t;
|
||||
_offset = o;
|
||||
|
||||
_track->add( this );
|
||||
|
||||
log_create();
|
||||
}
|
||||
|
||||
void
|
||||
Region::trim ( enum trim_e t, int X )
|
||||
{
|
||||
|
|
36
Region.H
36
Region.H
|
@ -63,11 +63,12 @@ protected:
|
|||
char ** log_dump ( void )
|
||||
{
|
||||
// char *r;
|
||||
char **sa = (char**)malloc( sizeof( char* ) * 7 );
|
||||
char **sa = (char**)malloc( sizeof( char* ) * 8 );
|
||||
|
||||
int i = 0;
|
||||
|
||||
asprintf( &sa[ i++ ], ":source \"%s\"", _clip->name() );
|
||||
asprintf( &sa[ i++ ], ":source \"%s\"", _clip ? _clip->name() : "" );
|
||||
asprintf( &sa[ i++ ], ":track 0x%X", _track ? _track->id() : 0 );
|
||||
asprintf( &sa[ i++ ], ":x %lu", _offset );
|
||||
asprintf( &sa[ i++ ], ":l %lu", _start );
|
||||
asprintf( &sa[ i++ ], ":r %lu", _end );
|
||||
|
@ -75,9 +76,6 @@ protected:
|
|||
asprintf( &sa[ i++ ], ":gain %f", _scale );
|
||||
|
||||
sa[ i ] = NULL;
|
||||
// asprintf( &sa[4], ":track 0x%X", _track->id() );
|
||||
|
||||
// asprintf( &r, ":x %lu\n:l %lu\n:r %lu\n:selected %d\n:gain %f", _offset, _start, _end, _selected, _scale );
|
||||
|
||||
return sa;
|
||||
}
|
||||
|
@ -115,18 +113,23 @@ protected:
|
|||
_scale = atof( v );
|
||||
else
|
||||
if ( ! strcmp( s, ":source" ) )
|
||||
_clip = Audio_File::from_file( v );
|
||||
/* else */
|
||||
/* if ( ! strcmp( s, ":track" ) ) */
|
||||
/* { */
|
||||
/* int i; */
|
||||
/* sscanf( v, "%X", &i ); */
|
||||
/* Track *t = (Track*)Loggable::find( i ); */
|
||||
{
|
||||
if ( ! ( _clip = Audio_File::from_file( v ) ) )
|
||||
{
|
||||
printf( "Grave error: could not open source \"%s\"\n", v );
|
||||
}
|
||||
}
|
||||
else
|
||||
if ( ! strcmp( s, ":track" ) )
|
||||
{
|
||||
int i;
|
||||
sscanf( v, "%X", &i );
|
||||
Track *t = (Track*)Loggable::find( i );
|
||||
|
||||
/* assert( t ); */
|
||||
assert( t );
|
||||
|
||||
/* t->add( this ); */
|
||||
/* } */
|
||||
t->add( this );
|
||||
}
|
||||
|
||||
|
||||
free( s );
|
||||
|
@ -153,6 +156,8 @@ public:
|
|||
|
||||
r->set( sa );
|
||||
|
||||
r->log_create();
|
||||
|
||||
return (Loggable *)r;
|
||||
}
|
||||
|
||||
|
@ -167,6 +172,7 @@ public:
|
|||
|
||||
Region ( const Region & rhs );
|
||||
Region ( Audio_File *c );
|
||||
Region ( Audio_File *c, Track *t, nframes_t o );
|
||||
|
||||
int handle ( int m );
|
||||
void draw_box( int X, int Y, int W, int H );
|
||||
|
|
4
Track.C
4
Track.C
|
@ -76,7 +76,7 @@ Track::draw ( void )
|
|||
void
|
||||
Track::remove ( Track_Widget *r )
|
||||
{
|
||||
Logger _log( this );
|
||||
// Logger _log( this );
|
||||
|
||||
_widgets.remove( r );
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ Track::event_widget ( void )
|
|||
void
|
||||
Track::add ( Track_Widget *r )
|
||||
{
|
||||
Logger _log( this );
|
||||
// Logger _log( this );
|
||||
|
||||
if ( r->track() )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue