Add scrollbar for timeline.

This commit is contained in:
Jonathan Moore Liles 2008-02-20 00:11:33 -06:00
parent 76afaa5792
commit 69aee9de79
3 changed files with 37 additions and 2 deletions

View File

@ -21,6 +21,7 @@
#include <FL/Fl_Scroll.H> #include <FL/Fl_Scroll.H>
#include <FL/Fl_Pack.H> #include <FL/Fl_Pack.H>
#include <FL/Fl_Scrollbar.H>
#include "Clip.H" #include "Clip.H"
#include <math.h> #include <math.h>
@ -30,12 +31,15 @@
struct Timeline { struct Timeline {
Fl_Scroll *scroll; Fl_Scroll *scroll;
Fl_Pack *tracks; Fl_Pack *tracks;
Fl_Scrollbar *scrollbar;
float fpp; /* frames per pixel */ float fpp; /* frames per pixel */
// nframes_t fpp; // nframes_t fpp;
nframes_t sample_rate; nframes_t sample_rate;
nframes_t xoffset;
int int
ts_to_x( nframes_t ts ) ts_to_x( nframes_t ts )
{ {

View File

@ -23,9 +23,10 @@
void void
Track::draw ( void ) Track::draw ( void )
{ {
Fl_Group::draw();
for ( list <Region *>::iterator r = _regions.begin(); r != _regions.end(); r++ ) for ( list <Region *>::iterator r = _regions.begin(); r != _regions.end(); r++ )
{ {
(*r)->draw( x(), y(), w(), h() ); (*r)->draw( timeline.xoffset + x(), y(), w(), h() );
} }
} }

32
main.C
View File

@ -22,6 +22,7 @@
#include <FL/Fl_Window.H> #include <FL/Fl_Window.H>
#include <FL/Fl_Double_Window.H> #include <FL/Fl_Double_Window.H>
#include <FL/Fl_Scroll.H> #include <FL/Fl_Scroll.H>
#include <FL/Fl_Scrollbar.H>
#include <FL/Fl_Pack.H> #include <FL/Fl_Pack.H>
#include <FL/Fl_Group.H> #include <FL/Fl_Group.H>
#include <FL/Fl_Slider.H> #include <FL/Fl_Slider.H>
@ -74,6 +75,29 @@ cb_zoom ( Fl_Widget *w, void *v )
printf( "%f\n", timeline.fpp ); printf( "%f\n", timeline.fpp );
} }
void
cb_scroll ( Fl_Widget *w, void *v )
{
timeline.xoffset = ((Fl_Scrollbar*)w)->value();
timeline.tracks->redraw();
timeline.scroll->redraw();
/* for ( int i = timeline.tracks->children(); i-- ; ) */
/* { */
/* Fl_Group *track = (Fl_Group*)timeline.tracks->child( i ); */
/* track-> */
/* } */
/* /\* for ( int j = track->children(); j-- ; ) *\/ */
/* /\* ((Region*)(track->child( j )))->resize(); *\/ */
/* /\* } *\/ */
}
int int
main ( int argc, char **argv ) main ( int argc, char **argv )
{ {
@ -82,7 +106,7 @@ main ( int argc, char **argv )
Fl_Double_Window *main_window = new Fl_Double_Window( 0, 0, 800, 600 ); Fl_Double_Window *main_window = new Fl_Double_Window( 0, 0, 800, 600 );
timeline.scroll = new Fl_Scroll( 0, 24, 800, 600 - 24 ); timeline.scroll = new Fl_Scroll( 0, 24, 800, 600 - (24 * 2) );
timeline.scroll->type( Fl_Scroll::VERTICAL ); timeline.scroll->type( Fl_Scroll::VERTICAL );
timeline.fpp = 256; timeline.fpp = 256;
@ -151,6 +175,12 @@ main ( int argc, char **argv )
zoom_slider->step( 1 ); zoom_slider->step( 1 );
zoom_slider->value( 256 ); zoom_slider->value( 256 );
timeline.scrollbar = new Fl_Scrollbar( 0, 600 - 24, 800, 24 );
timeline.scrollbar->range( 0, 293847234 );
timeline.scrollbar->type( 1 );
timeline.scrollbar->step( 1 );
timeline.scrollbar->callback( cb_scroll, 0 );
main_window->end(); main_window->end();
main_window->show(); main_window->show();