Clean up region box drawing.
This commit is contained in:
parent
7501a8094b
commit
e94cb69c34
16
Region.C
16
Region.C
|
@ -51,6 +51,10 @@ Region::init ( void )
|
|||
_end = 0;
|
||||
_scale = 1.0f;
|
||||
_clip = NULL;
|
||||
|
||||
|
||||
_box_color = FL_CYAN;
|
||||
_color = FL_BLUE;
|
||||
}
|
||||
|
||||
Region::Region ( const Region & rhs )
|
||||
|
@ -296,14 +300,20 @@ Region::draw ( int X, int Y, int W, int H )
|
|||
int rx = timeline.ts_to_x( _offset ) - X;
|
||||
int rw = min( timeline.ts_to_x( _end - _start ), W );
|
||||
|
||||
fl_draw_box( FL_PLASTIC_UP_BOX, rx, Y, rw, H, FL_CYAN );
|
||||
fl_push_clip( rx, Y, rw, H );
|
||||
|
||||
/* dirty hack to keep the box from flipping to vertical at small sizes */
|
||||
fl_draw_box( FL_PLASTIC_UP_BOX, rx - 10, Y, rw + 50, H, _box_color );
|
||||
|
||||
// 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, FL_GREEN );
|
||||
draw_waveform( rx, Y, rw, H, _clip, _start, _end, _scale, _color );
|
||||
|
||||
// fl_pop_clip();
|
||||
fl_color( FL_BLACK );
|
||||
fl_line( rx, Y, rx, Y + H );
|
||||
fl_line( rx + rw - 1, Y, rx + rw - 1, Y + H );
|
||||
|
||||
fl_pop_clip();
|
||||
|
||||
fl_font( FL_HELVETICA, 14 );
|
||||
fl_color( FL_BLACK );
|
||||
|
|
20
Region.H
20
Region.H
|
@ -27,6 +27,11 @@
|
|||
#include "Track.H"
|
||||
#include "Timeline.H"
|
||||
|
||||
|
||||
/* Regions are "virtual" FLTK widgets; this is necessary because the
|
||||
* dimensions of real FLTK widgets are limited to 16-bits, which is
|
||||
* far too little for our purposes */
|
||||
|
||||
class Region
|
||||
{
|
||||
|
||||
|
@ -40,6 +45,16 @@ class Region
|
|||
|
||||
float _scale; /* amplitude adjustment */
|
||||
|
||||
bool _selected;
|
||||
|
||||
Fl_Color _color; /* color of waveform */
|
||||
Fl_Color _box_color; /* color of background (box) */
|
||||
|
||||
|
||||
static Fl_Color _selection_color;
|
||||
static Fl_Color selection_color ( void ) { return _selection_color; }
|
||||
static void selection_color ( Fl_Color v ) { _selection_color = v; }
|
||||
|
||||
enum trim_e { NO, LEFT, RIGHT };
|
||||
void trim ( enum trim_e t, int X );
|
||||
void init ( void );
|
||||
|
@ -54,6 +69,11 @@ public:
|
|||
int x ( void ) const { return _track->x() + timeline.ts_to_x( _offset - timeline.xoffset ); }
|
||||
int w ( void ) const { return timeline.ts_to_x( _end - _start ); }
|
||||
|
||||
Fl_Group * parent ( void ) const { return _track; }
|
||||
|
||||
Fl_Color color ( void ) { return _color; }
|
||||
Fl_Color box_color ( void ) { return _box_color; }
|
||||
|
||||
int handle ( int m );
|
||||
void draw ( int X, int Y, int W, int H );
|
||||
void resize ( void );
|
||||
|
|
7
Track.C
7
Track.C
|
@ -22,14 +22,21 @@
|
|||
|
||||
#include "Region.H"
|
||||
|
||||
#include <FL/fl_draw.H>
|
||||
|
||||
void
|
||||
Track::draw ( void )
|
||||
{
|
||||
Fl_Group::draw();
|
||||
|
||||
fl_push_clip( x(), y(), w(), h() );
|
||||
|
||||
for ( list <Region *>::iterator r = _regions.begin(); r != _regions.end(); r++ )
|
||||
{
|
||||
(*r)->draw( timeline.xoffset + x(), y(), w(), h() );
|
||||
}
|
||||
|
||||
fl_pop_clip();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue