Fixup virtual scrolling.
This commit is contained in:
parent
d5dc2a2edf
commit
5e0e95cc0a
36
Region.C
36
Region.C
|
@ -297,8 +297,32 @@ Region::resize ( void )
|
||||||
void
|
void
|
||||||
Region::draw ( int X, int Y, int W, int H )
|
Region::draw ( int X, int Y, int W, int H )
|
||||||
{
|
{
|
||||||
int rx = timeline.ts_to_x( _offset ) - X;
|
if ( ! ( W > 0 && H > 0 ) )
|
||||||
int rw = min( timeline.ts_to_x( _end - _start ), W );
|
return;
|
||||||
|
|
||||||
|
if ( _offset > timeline.xoffset + timeline.x_to_ts( _track->w() ) ||
|
||||||
|
( _offset < timeline.xoffset &&
|
||||||
|
_offset + (_end - _start) < timeline.xoffset ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int rw = timeline.ts_to_x( _end - _start );
|
||||||
|
|
||||||
|
nframes_t end = _offset + ( _end - _start );
|
||||||
|
|
||||||
|
/* calculate waveform offset due to scrolling */
|
||||||
|
nframes_t offset = 0;
|
||||||
|
if ( _offset < timeline.xoffset )
|
||||||
|
{
|
||||||
|
offset = timeline.xoffset - _offset;
|
||||||
|
|
||||||
|
rw = timeline.ts_to_x( (_end - _start) - offset );
|
||||||
|
}
|
||||||
|
|
||||||
|
rw = min( rw, _track->w() );
|
||||||
|
|
||||||
|
int rx = x();
|
||||||
|
|
||||||
|
printf( "rx %d, rw %d\n", rx, rw );
|
||||||
|
|
||||||
fl_push_clip( rx, Y, rw, H );
|
fl_push_clip( rx, Y, rw, H );
|
||||||
|
|
||||||
|
@ -307,7 +331,7 @@ Region::draw ( int X, int Y, int W, int H )
|
||||||
|
|
||||||
// fl_push_clip( x() + Fl::box_dx( box() ), y(), w() - Fl::box_dw( box() ), h() );
|
// fl_push_clip( x() + Fl::box_dx( box() ), y(), w() - Fl::box_dw( box() ), h() );
|
||||||
|
|
||||||
draw_waveform( rx, Y, rw, H, _clip, _start, _end, _scale, _color );
|
draw_waveform( rx, Y, rw, H, _clip, _start + offset, _end - offset, _scale, _color );
|
||||||
|
|
||||||
fl_color( FL_BLACK );
|
fl_color( FL_BLACK );
|
||||||
fl_line( rx, Y, rx, Y + H );
|
fl_line( rx, Y, rx, Y + H );
|
||||||
|
@ -332,4 +356,10 @@ Region::draw ( int X, int Y, int W, int H )
|
||||||
// fl_draw( _clip->name(), X, Y );
|
// fl_draw( _clip->name(), X, Y );
|
||||||
|
|
||||||
//(Fl_Align)FL_ALIGN_LEFT | FL_ALIGN_BOTTOM );
|
//(Fl_Align)FL_ALIGN_LEFT | FL_ALIGN_BOTTOM );
|
||||||
|
|
||||||
|
|
||||||
|
fl_color( FL_RED );
|
||||||
|
fl_line( x(), y(), x(), y() + h() );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
8
Region.H
8
Region.H
|
@ -27,7 +27,8 @@
|
||||||
#include "Track.H"
|
#include "Track.H"
|
||||||
#include "Timeline.H"
|
#include "Timeline.H"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
using namespace std;
|
||||||
/* Regions are "virtual" FLTK widgets; this is necessary because the
|
/* Regions are "virtual" FLTK widgets; this is necessary because the
|
||||||
* dimensions of real FLTK widgets are limited to 16-bits, which is
|
* dimensions of real FLTK widgets are limited to 16-bits, which is
|
||||||
* far too little for our purposes */
|
* far too little for our purposes */
|
||||||
|
@ -56,8 +57,11 @@ public:
|
||||||
|
|
||||||
int y ( void ) const { return _track->y(); }
|
int y ( void ) const { return _track->y(); }
|
||||||
int h ( void ) const { return _track->h(); }
|
int h ( void ) const { return _track->h(); }
|
||||||
int x ( void ) const { return _track->x() + timeline.ts_to_x( _offset - timeline.xoffset ); }
|
int x ( void ) const { return _offset < timeline.xoffset ? -1 : min( 32767, _track->x() + timeline.ts_to_x( _offset - timeline.xoffset ) ); }
|
||||||
|
// int x ( void ) const { return (short)( _track->x() + timeline.ts_to_x( _offset - timeline.xoffset )); }
|
||||||
|
|
||||||
int w ( void ) const { return timeline.ts_to_x( _end - _start ); }
|
int w ( void ) const { return timeline.ts_to_x( _end - _start ); }
|
||||||
|
// int w ( void ) const { return timeline.ts_to_x( (_end - _start) - ( timeline.xoffset - _offset) ); }
|
||||||
|
|
||||||
Fl_Color color ( void ) { return _color; }
|
Fl_Color color ( void ) { return _color; }
|
||||||
Fl_Color box_color ( void ) { return _box_color; }
|
Fl_Color box_color ( void ) { return _box_color; }
|
||||||
|
|
3
Track.C
3
Track.C
|
@ -33,7 +33,8 @@ Track::draw ( void )
|
||||||
|
|
||||||
for ( list <Region *>::iterator r = _regions.begin(); r != _regions.end(); r++ )
|
for ( list <Region *>::iterator r = _regions.begin(); r != _regions.end(); r++ )
|
||||||
{
|
{
|
||||||
(*r)->draw( timeline.xoffset + x(), y(), w(), h() );
|
// (*r)->draw( timeline.xoffset + x(), y(), w(), h() );
|
||||||
|
(*r)->draw( x(), y(), w(), h() );
|
||||||
}
|
}
|
||||||
|
|
||||||
fl_pop_clip();
|
fl_pop_clip();
|
||||||
|
|
Loading…
Reference in New Issue