Browse Source

Timeline: Fix region/fade drawing at tight zoom levels.

Closes #164
tags/non-daw-v1.2.0
Jonathan Moore Liles 8 years ago
parent
commit
319a393cd6
5 changed files with 24 additions and 16 deletions
  1. +5
    -6
      timeline/src/Audio_Region.C
  2. +1
    -1
      timeline/src/Control_Point.H
  3. +1
    -1
      timeline/src/Sequence_Point.H
  4. +1
    -1
      timeline/src/Sequence_Region.C
  5. +16
    -7
      timeline/src/Sequence_Widget.H

+ 5
- 6
timeline/src/Audio_Region.C View File

@@ -405,7 +405,7 @@ Audio_Region::draw_fade ( const Fade &fade, Fade::fade_dir_e dir, bool line, int
if ( dir == Fade::In )
{
fx = line_x();
fx = curve_x();
if ( fx + width < X ||
fx > X + W )
@@ -414,7 +414,7 @@ Audio_Region::draw_fade ( const Fade &fade, Fade::fade_dir_e dir, bool line, int
}
else
{
fx = line_x() + abs_w();
fx = curve_x() + abs_w();

if ( fx - width > X + W ||
fx < X )
@@ -431,8 +431,8 @@ Audio_Region::draw_fade ( const Fade &fade, Fade::fade_dir_e dir, bool line, int
fl_vertex( fx, dy + height );

{
const float ti = 1.0f / (float)width;
float ts = 0.0f;
const double ti = 1.0 / (double)width;
double ts = 0.0;
const int xi = dir == Fade::In ? 1 : -1;

@@ -487,8 +487,7 @@ Audio_Region::draw_box( void )
b = FL_DOWN_FRAME;
}

fl_draw_box( b, line_x(), y(), abs_w(), h(), c );
fl_draw_box( b, x(), y(), w(), h(), c );

// fl_pop_clip();
}


+ 1
- 1
timeline/src/Control_Point.H View File

@@ -57,7 +57,7 @@ public:
/* only for playback thread */
nframes_t when ( void ) const { return _range.start; }

int abs_w ( void ) const { return 8; }
long abs_w ( void ) const { return 8; }

int y ( void ) const { return parent()->y() + ((float)parent()->h() * _y); }
int h ( void ) const { return 8; }


+ 1
- 1
timeline/src/Sequence_Point.H View File

@@ -41,7 +41,7 @@ protected:
public:

Fl_Align align ( void ) const { return FL_ALIGN_RIGHT; }
virtual int abs_w ( void ) const { return 8; }
virtual long abs_w ( void ) const { return 8; }

// virtual int abs_x ( void ) const { return Sequence_Widget::abs_x() - ( abs_w() >> 1 ); }
// virtual int x ( void ) const { return Sequence_Widget::line_x() - ( abs_w() >> 1 ); }


+ 1
- 1
timeline/src/Sequence_Region.C View File

@@ -239,7 +239,7 @@ Sequence_Region::draw_box ( void )
{
Fl_Color c = selected() ? selection_color() : box_color();

fl_draw_box( box(), line_x(), y(), abs_w(), h(), fl_color_add_alpha( c, 127 ) );
fl_draw_box( box(), x(), y(), w(), h(), fl_color_add_alpha( c, 127 ) );
}

void


+ 16
- 7
timeline/src/Sequence_Widget.H View File

@@ -189,8 +189,9 @@ public:
int get_x( nframes_t frame ) const
{
return frame < timeline->xoffset ?
_sequence->drawable_x() :
min( _sequence->drawable_x() + _sequence->drawable_w(), _sequence->drawable_x() + timeline->ts_to_x( frame - timeline->xoffset ) );
_sequence->drawable_x() - 10 :
min( _sequence->drawable_x() + _sequence->drawable_w(),
_sequence->drawable_x() + timeline->ts_to_x( frame - timeline->xoffset ) );
}

virtual int x ( void ) const
@@ -198,19 +199,27 @@ public:
return get_x( _r->start );
}

/* use this as x() when you need to draw lines between widgets */
/* use this as x() when you need to draw lines between widgets. Clamped to -32767-32767 to match max canvas size of FLTK/NTK */
int line_x ( void ) const
{
return _r->start < timeline->xoffset ?
max( -32767, _sequence->drawable_x() - timeline->ts_to_x( timeline->xoffset - _r->start )) :
min( 32767, _sequence->drawable_x() + timeline->ts_to_x( _r->start - timeline->xoffset ) );
min( 32767, _sequence->drawable_x() + timeline->ts_to_x( _r->start - timeline->xoffset ));
}

/* same as above but un-clamped for cairo */
long curve_x ( void ) const
{
return _r->start < timeline->xoffset ?
_sequence->drawable_x() - timeline->ts_to_x( timeline->xoffset - _r->start ) :
_sequence->drawable_x() + timeline->ts_to_x( _r->start - timeline->xoffset );
}

virtual int w ( void ) const
{
// int tx = timeline->ts_to_x( _r->start );

int rw;
long rw;

if ( _r->start < timeline->xoffset )
{
@@ -222,11 +231,11 @@ public:
else
rw = abs_w();

return min( rw, _sequence->drawable_w() );
return (int)min( rw, (long)(_sequence->drawable_w() + 20) );
}

int abs_x ( void ) const { return timeline->ts_to_x( _r->start ); }
virtual int abs_w ( void ) const { return timeline->ts_to_x( _r->length ); }
virtual long abs_w ( void ) const { return timeline->ts_to_x( _r->length ); }

Fl_Color color ( void ) const { return _color; }
void color ( Fl_Color v ) { _color = v; }


Loading…
Cancel
Save