Make trimming work.

This commit is contained in:
Jonathan Moore Liles 2008-02-20 01:08:36 -06:00
parent 35d277d67d
commit bcfa0cb029
3 changed files with 53 additions and 58 deletions

View File

@ -71,55 +71,48 @@ Region::Region ( Clip *c )
}
void
Region::trim ( enum trim_e t, int X )
{
switch ( t )
{
case LEFT:
{
int d = X - x();
/* void */
/* Region::trim ( enum trim_e t, int X ) */
/* { */
/* switch ( t ) */
/* { */
/* case LEFT: */
/* { */
/* int d = X - x(); */
long td = timeline.x_to_ts( d );
/* long td = timeline.x_to_ts( d ); */
if ( td < 0 && _start < 0 - td )
td = 0 - _start;
/* if ( td < 0 && _start < 0 - td ) */
/* td = 0 - _start; */
_start += td;
/* _start += td; */
_offset += td;
/* _offset += td; */
// resize();
break;
}
case RIGHT:
{
int d = (x() + w()) - X;
long td = timeline.x_to_ts( d );
/* resize(); */
/* // Fl_Widget::resize( x() + d, y(), w() - d, h() ); */
_end -= td;
/* // _offset = timeline.x_to_ts( x() ); */
// resize();
/* break; */
/* } */
/* case RIGHT: */
/* { */
/* int d = (x() + w()) - X; */
/* long td = timeline.x_to_ts( d ); */
break;
}
default:
return;
/* _end -= td; */
}
/* resize(); */
_track->redraw();
// redraw();
// parent()->redraw();
/* // _end = _start + timeline.x_to_ts( w() - d ); */
/* // Fl_Widget::resize( x(), y(), w() - d, h() ); */
/* break; */
/* } */
/* default: */
/* return; */
/* } */
/* redraw(); */
/* parent()->redraw(); */
/* } */
}
int
Region::handle ( int m )
@ -144,13 +137,12 @@ Region::handle ( int m )
{
switch ( Fl::event_button() )
{
/* case 1: */
/* trim( trimming = LEFT, X ); */
/* break; */
/* case 3: */
/* trim( trimming = RIGHT, X ); */
/* break; */
case 1:
trim( trimming = LEFT, X );
break;
case 3:
trim( trimming = RIGHT, X );
break;
default:
return 0;
@ -202,14 +194,14 @@ Region::handle ( int m )
return 1;
}
/* if ( Fl::event_state() & FL_SHIFT ) */
/* if ( trimming ) */
/* { */
/* trim( trimming, X ); */
/* return 1; */
/* } */
/* else */
/* return 0; */
if ( Fl::event_state() & FL_SHIFT )
if ( trimming )
{
trim( trimming, X );
return 1;
}
else
return 0;
if ( Fl::event_state() & FL_CTRL )
{

View File

@ -51,7 +51,8 @@ public:
int y ( void ) { return _track->y(); }
int h ( void ) { return _track->h(); }
int x ( void ) { return timeline.ts_to_x( _offset ) - timeline.xoffset; }
int x ( void ) { return _track->x() + timeline.ts_to_x( _offset - timeline.xoffset ); }
int w ( void ) { return timeline.ts_to_x( _end - _start ); }
int handle ( int m );
void draw ( int X, int Y, int W, int H );

10
main.C
View File

@ -78,10 +78,12 @@ cb_zoom ( Fl_Widget *w, void *v )
void
cb_scroll ( Fl_Widget *w, void *v )
{
timeline.xoffset = ((Fl_Scrollbar*)w)->value();
timeline.tracks->redraw();
timeline.xoffset = ((Fl_Slider*)w)->value();
// timeline.tracks->redraw();
timeline.scroll->redraw();
printf( "%lu\n", timeline.xoffset );
/* for ( int i = timeline.tracks->children(); i-- ; ) */
/* { */
/* Fl_Group *track = (Fl_Group*)timeline.tracks->child( i ); */
@ -176,7 +178,7 @@ main ( int argc, char **argv )
zoom_slider->value( 256 );
timeline.scrollbar = new Fl_Scrollbar( 0, 600 - 24, 800, 24 );
timeline.scrollbar->range( 0, 293847234 );
timeline.scrollbar->range( 0, 48000 * 2 );
timeline.scrollbar->type( 1 );
timeline.scrollbar->step( 1 );
timeline.scrollbar->callback( cb_scroll, 0 );