diff --git a/Region.C b/Region.C index d325a10..66814de 100644 --- a/Region.C +++ b/Region.C @@ -19,6 +19,7 @@ #include "Track.H" #include "Region.H" +#include "Timeline.H" #include #include @@ -27,6 +28,8 @@ #include +extern Timeline timeline; + Region::Region ( int X, int Y, int W, int H, const char *L=0 ) : Waveform( X, Y, W, H, L ) { align( FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_BOTTOM | FL_ALIGN_CLIP ); @@ -147,6 +150,19 @@ Region::handle ( int m ) parent()->redraw(); fl_cursor( FL_CURSOR_MOVE ); + + if ( Fl::event_x() >= timeline.scroll->x() + timeline.scroll->w() || + Fl::event_x() <= timeline.scroll->x() ) + { + int d; + if ( Fl::event_x() <= timeline.scroll->x() ) + d = -100; + else + d = 100; + /* this drag needs to scroll */ + timeline.scroll->position( timeline.scroll->xposition() + d, timeline.scroll->yposition() ); + } + return 1; default: return 0; diff --git a/Timeline.H b/Timeline.H new file mode 100644 index 0000000..24df797 --- /dev/null +++ b/Timeline.H @@ -0,0 +1,26 @@ + +/*******************************************************************************/ +/* Copyright (C) 2008 Jonathan Moore Liles */ +/* */ +/* This program is free software; you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation; either version 2 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ +/* more details. */ +/* */ +/* You should have received a copy of the GNU General Public License along */ +/* with This program; see the file COPYING. If not,write to the Free Software */ +/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/*******************************************************************************/ + +#pragma once + +#include + +struct Timeline { + Fl_Scroll *scroll; +}; diff --git a/main.C b/main.C index b9b2cfc..7ae291d 100644 --- a/main.C +++ b/main.C @@ -37,6 +37,7 @@ Fl_Color velocity_colors[128]; #include "Track.H" +#include "Timeline.H" void init_colors ( void ) @@ -45,6 +46,8 @@ init_colors ( void ) velocity_colors[i] = fl_rgb_color( 23, 255 - i * 2, 32 ); } +Timeline timeline; + int main ( int argc, char **argv ) { @@ -53,7 +56,7 @@ main ( int argc, char **argv ) Fl_Double_Window *main_window = new Fl_Double_Window( 0, 0, 800, 600 ); - Fl_Scroll *scroll = new Fl_Scroll( 0, 0, 800, 600 ); + timeline.scroll = new Fl_Scroll( 0, 0, 800, 600 ); Fl_Pack *tracks = new Fl_Pack( 0, 0, 5000, 5000 ); tracks->type( Fl_Pack::VERTICAL ); @@ -117,7 +120,7 @@ main ( int argc, char **argv ) track2->prev( track1 ); tracks->end(); - scroll->end(); + timeline.scroll->end(); main_window->end(); main_window->show();