Add scrollbar for timeline.
This commit is contained in:
parent
76afaa5792
commit
69aee9de79
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <FL/Fl_Scroll.H>
|
||||
#include <FL/Fl_Pack.H>
|
||||
#include <FL/Fl_Scrollbar.H>
|
||||
|
||||
#include "Clip.H"
|
||||
#include <math.h>
|
||||
|
@ -30,12 +31,15 @@
|
|||
struct Timeline {
|
||||
Fl_Scroll *scroll;
|
||||
Fl_Pack *tracks;
|
||||
Fl_Scrollbar *scrollbar;
|
||||
|
||||
float fpp; /* frames per pixel */
|
||||
// nframes_t fpp;
|
||||
|
||||
nframes_t sample_rate;
|
||||
|
||||
nframes_t xoffset;
|
||||
|
||||
int
|
||||
ts_to_x( nframes_t ts )
|
||||
{
|
||||
|
|
3
Track.C
3
Track.C
|
@ -23,9 +23,10 @@
|
|||
void
|
||||
Track::draw ( void )
|
||||
{
|
||||
Fl_Group::draw();
|
||||
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
32
main.C
|
@ -22,6 +22,7 @@
|
|||
#include <FL/Fl_Window.H>
|
||||
#include <FL/Fl_Double_Window.H>
|
||||
#include <FL/Fl_Scroll.H>
|
||||
#include <FL/Fl_Scrollbar.H>
|
||||
#include <FL/Fl_Pack.H>
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Slider.H>
|
||||
|
@ -74,6 +75,29 @@ cb_zoom ( Fl_Widget *w, void *v )
|
|||
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
|
||||
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 );
|
||||
|
||||
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.fpp = 256;
|
||||
|
||||
|
@ -151,6 +175,12 @@ main ( int argc, char **argv )
|
|||
zoom_slider->step( 1 );
|
||||
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->show();
|
||||
|
||||
|
|
Loading…
Reference in New Issue