Make trimming work.
This commit is contained in:
parent
35d277d67d
commit
bcfa0cb029
98
Region.C
98
Region.C
|
@ -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 */
|
long td = timeline.x_to_ts( d );
|
||||||
/* Region::trim ( enum trim_e t, int X ) */
|
|
||||||
/* { */
|
|
||||||
/* switch ( t ) */
|
|
||||||
/* { */
|
|
||||||
/* case LEFT: */
|
|
||||||
/* { */
|
|
||||||
/* int d = X - x(); */
|
|
||||||
|
|
||||||
/* long td = timeline.x_to_ts( d ); */
|
if ( td < 0 && _start < 0 - td )
|
||||||
|
td = 0 - _start;
|
||||||
|
|
||||||
/* if ( td < 0 && _start < 0 - td ) */
|
_start += td;
|
||||||
/* td = 0 - _start; */
|
|
||||||
|
|
||||||
/* _start += td; */
|
_offset += td;
|
||||||
|
|
||||||
/* _offset += td; */
|
// resize();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RIGHT:
|
||||||
|
{
|
||||||
|
int d = (x() + w()) - X;
|
||||||
|
long td = timeline.x_to_ts( d );
|
||||||
|
|
||||||
/* resize(); */
|
_end -= td;
|
||||||
/* // Fl_Widget::resize( x() + d, y(), w() - d, h() ); */
|
|
||||||
|
|
||||||
/* // _offset = timeline.x_to_ts( x() ); */
|
// resize();
|
||||||
|
|
||||||
/* break; */
|
break;
|
||||||
/* } */
|
}
|
||||||
/* case RIGHT: */
|
default:
|
||||||
/* { */
|
return;
|
||||||
/* int d = (x() + w()) - X; */
|
|
||||||
/* long td = timeline.x_to_ts( d ); */
|
|
||||||
|
|
||||||
/* _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
|
int
|
||||||
Region::handle ( int m )
|
Region::handle ( int m )
|
||||||
|
@ -144,13 +137,12 @@ Region::handle ( int m )
|
||||||
{
|
{
|
||||||
switch ( Fl::event_button() )
|
switch ( Fl::event_button() )
|
||||||
{
|
{
|
||||||
|
case 1:
|
||||||
/* case 1: */
|
trim( trimming = LEFT, X );
|
||||||
/* trim( trimming = LEFT, X ); */
|
break;
|
||||||
/* break; */
|
case 3:
|
||||||
/* case 3: */
|
trim( trimming = RIGHT, X );
|
||||||
/* trim( trimming = RIGHT, X ); */
|
break;
|
||||||
/* break; */
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -202,14 +194,14 @@ Region::handle ( int m )
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if ( Fl::event_state() & FL_SHIFT ) */
|
if ( Fl::event_state() & FL_SHIFT )
|
||||||
/* if ( trimming ) */
|
if ( trimming )
|
||||||
/* { */
|
{
|
||||||
/* trim( trimming, X ); */
|
trim( trimming, X );
|
||||||
/* return 1; */
|
return 1;
|
||||||
/* } */
|
}
|
||||||
/* else */
|
else
|
||||||
/* return 0; */
|
return 0;
|
||||||
|
|
||||||
if ( Fl::event_state() & FL_CTRL )
|
if ( Fl::event_state() & FL_CTRL )
|
||||||
{
|
{
|
||||||
|
|
3
Region.H
3
Region.H
|
@ -51,7 +51,8 @@ public:
|
||||||
|
|
||||||
int y ( void ) { return _track->y(); }
|
int y ( void ) { return _track->y(); }
|
||||||
int h ( void ) { return _track->h(); }
|
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 );
|
int handle ( int m );
|
||||||
void draw ( int X, int Y, int W, int H );
|
void draw ( int X, int Y, int W, int H );
|
||||||
|
|
10
main.C
10
main.C
|
@ -78,10 +78,12 @@ cb_zoom ( Fl_Widget *w, void *v )
|
||||||
void
|
void
|
||||||
cb_scroll ( Fl_Widget *w, void *v )
|
cb_scroll ( Fl_Widget *w, void *v )
|
||||||
{
|
{
|
||||||
timeline.xoffset = ((Fl_Scrollbar*)w)->value();
|
timeline.xoffset = ((Fl_Slider*)w)->value();
|
||||||
timeline.tracks->redraw();
|
// timeline.tracks->redraw();
|
||||||
|
|
||||||
timeline.scroll->redraw();
|
timeline.scroll->redraw();
|
||||||
|
|
||||||
|
printf( "%lu\n", timeline.xoffset );
|
||||||
|
|
||||||
/* for ( int i = timeline.tracks->children(); i-- ; ) */
|
/* for ( int i = timeline.tracks->children(); i-- ; ) */
|
||||||
/* { */
|
/* { */
|
||||||
/* Fl_Group *track = (Fl_Group*)timeline.tracks->child( i ); */
|
/* Fl_Group *track = (Fl_Group*)timeline.tracks->child( i ); */
|
||||||
|
@ -176,7 +178,7 @@ main ( int argc, char **argv )
|
||||||
zoom_slider->value( 256 );
|
zoom_slider->value( 256 );
|
||||||
|
|
||||||
timeline.scrollbar = new Fl_Scrollbar( 0, 600 - 24, 800, 24 );
|
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->type( 1 );
|
||||||
timeline.scrollbar->step( 1 );
|
timeline.scrollbar->step( 1 );
|
||||||
timeline.scrollbar->callback( cb_scroll, 0 );
|
timeline.scrollbar->callback( cb_scroll, 0 );
|
||||||
|
|
Loading…
Reference in New Issue