Browse Source

Get vertical scrolling right.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
9f95f2b910
2 changed files with 30 additions and 6 deletions
  1. +29
    -6
      Timeline/Timeline.C
  2. +1
    -0
      Timeline/Timeline.H

+ 29
- 6
Timeline/Timeline.C View File

@@ -43,6 +43,28 @@ const float UPDATE_FREQ = 0.02f;


#include "Transport.H" #include "Transport.H"


/** return the combined height of all visible children of (veritcal)
pack, /p/. This is necessary because pack sizes are adjusted only
when the relevant areas are exposes. */
static int
pack_visible_height ( const Fl_Pack *p )
{
int th = 0;

for ( const Fl_Widget* const *w = p->array(); *w; ++w )
if ( (*w)->visible() )
th += (*w)->h() + p->spacing();

return th;
}

/** recalculate the size of vertical scrolling area and inform scrollbar */
void
Timeline::adjust_vscroll ( void )
{
vscroll->value( _yposition, h() - rulers->h() - hscroll->h(), 0, pack_visible_height( tracks ) );
}

void void
Timeline::cb_scroll ( Fl_Widget *w, void *v ) Timeline::cb_scroll ( Fl_Widget *w, void *v )
{ {
@@ -58,9 +80,7 @@ Timeline::cb_scroll ( Fl_Widget *w )


yposition( vscroll->value() ); yposition( vscroll->value() );


int rh = h() - rulers->h();

vscroll->value( vscroll->value(), 30, 0, max( tracks->h() - rh, rh) );
adjust_vscroll();
} }
else else
{ {
@@ -68,9 +88,8 @@ Timeline::cb_scroll ( Fl_Widget *w )
{ {
_fpp = hscroll->zoom(); _fpp = hscroll->zoom();


// hscroll->range( 0, ts_to_x( _length ) - tracks->w() - Track::width() );
const int tw = tracks->w() - Track::width() - vscroll->w(); const int tw = tracks->w() - Track::width() - vscroll->w();
hscroll->value( ts_to_x( xoffset ), tw, 0, ts_to_x( _length ) - ( tw << 1 ) );
hscroll->value( ts_to_x( xoffset ), tw, 0, ts_to_x( _length ) );


redraw(); redraw();
} }
@@ -435,7 +454,9 @@ Timeline::draw_clip ( void * v, int X, int Y, int W, int H )


tl->draw_child( *tl->rulers ); tl->draw_child( *tl->rulers );


fl_push_clip( tl->tracks->x(), tl->rulers->y() + tl->rulers->h(), tl->tracks->w(), tl->h() - tl->rulers->h() - tl->hscroll->h() );
tl->draw_child( *tl->tracks ); tl->draw_child( *tl->tracks );
fl_pop_clip();


fl_pop_clip(); fl_pop_clip();
} }
@@ -469,6 +490,8 @@ Timeline::draw ( void )
W = tracks->w() - bdw - 1; W = tracks->w() - bdw - 1;
H = tracks->h(); H = tracks->h();


adjust_vscroll();

/* if ( damage() & FL_DAMAGE_USER1 ) */ /* if ( damage() & FL_DAMAGE_USER1 ) */
/* { */ /* { */


@@ -556,7 +579,7 @@ Timeline::draw ( void )
update_child( *rulers ); update_child( *rulers );
fl_pop_clip(); fl_pop_clip();


fl_push_clip( tracks->x(), tracks->y(), tracks->w(), h() - rulers->h() - hscroll->h() );
fl_push_clip( tracks->x(), rulers->y() + rulers->h(), tracks->w(), h() - rulers->h() - hscroll->h() );
update_child( *tracks ); update_child( *tracks );
fl_pop_clip(); fl_pop_clip();




+ 1
- 0
Timeline/Timeline.H View File

@@ -95,6 +95,7 @@ class Timeline : public Fl_Overlay_Window, public RWLock
Fl_Scrollbar *vscroll; Fl_Scrollbar *vscroll;




void adjust_vscroll ( void );
static void cb_scroll ( Fl_Widget *w, void *v ); static void cb_scroll ( Fl_Widget *w, void *v );
void cb_scroll ( Fl_Widget *w ); void cb_scroll ( Fl_Widget *w );




Loading…
Cancel
Save