From ea7facb2fb94510d72dacad71c42432caa98a1e0 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 28 Feb 2008 20:02:40 -0600 Subject: [PATCH] Add track header widget and adjust tracks to compensate. --- Makefile | 8 +++++-- Region.C | 2 +- Timeline.C | 19 +++++++++++------ Track.C | 2 +- Track.H | 2 ++ Track_Header.fl | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ Track_Widget.H | 15 +++++++------- 7 files changed, 85 insertions(+), 18 deletions(-) create mode 100644 Track_Header.fl diff --git a/Makefile b/Makefile index 96a9b1d..aafbe97 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ -CXXFLAGS=-ggdb -Wall -O0 +CXXFLAGS=-ggdb -Wall -O0 #LIBS=-L/usr/lib/sox -I/usr/include/sox -lsox -lsfx LIBS=-lsndfile `fltk-config --ldflags` # CXXFLAGS=`fltk-config -cxxflags` -SRCS= Waveform.C Region.C Peaks.C main.C Track.C Audio_Track.C Timeline.C Audio_File.C Audio_File_SF.C Loggable.C +SRCS= Waveform.C Region.C Peaks.C main.C Track.C Audio_Track.C Timeline.C Audio_File.C Audio_File_SF.C Loggable.C Track_Header.C OBJS=$(SRCS:.C=.o) @@ -16,6 +16,10 @@ all: test makedepend @ echo -n "Compiling: "; tput bold; tput setaf 3; echo $<; tput sgr0; true @ $(CXX) $(CXXFLAGS) -c $< -o $@ + +%.C : %.fl + @ fluid -c $< + $(OBJS): Makefile diff --git a/Region.C b/Region.C index bc059ed..6b5e06e 100644 --- a/Region.C +++ b/Region.C @@ -193,7 +193,7 @@ Region::handle ( int m ) static bool copied = false; static nframes_t os; - int X = Fl::event_x(); + int X = Fl::event_x() - _track->x(); int Y = Fl::event_y(); int ret; diff --git a/Timeline.C b/Timeline.C index 044353e..58f6b3d 100644 --- a/Timeline.C +++ b/Timeline.C @@ -25,6 +25,8 @@ #include +#include "Track_Header.H" + void cb_hscroll ( Fl_Widget *w, void *v ) { @@ -90,7 +92,7 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Group( X, } { - Fl_Pack *o = new Fl_Pack( X, Y, W - vscroll->w(), H - hscroll->h(), "rulers" ); + Fl_Pack *o = new Fl_Pack( X + Track_Header::width(), Y, W - Track_Header::width() - vscroll->w(), H - hscroll->h(), "rulers" ); o->type( Fl_Pack::VERTICAL ); { @@ -144,13 +146,15 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Group( X, Track *l = NULL; for ( int i = 16; i--; ) { - - Track *o = new Audio_Track( 0, 0, 800, 100 ); + Track_Header *t = new Track_Header( 0, 0, 800, 100 ); + Track *o = new Audio_Track( 0, 0, 1, 100 ); o->prev( l ); if ( l ) l->next( o ); l = o; - o->end(); +// o->end(); + + t->track( o ); } tracks = o; @@ -345,12 +349,15 @@ Timeline::draw ( void ) int dy = _old_yposition - yposition; if ( ! dy ) - fl_scroll( X, rulers->y(), W, rulers->h(), dx, 0, draw_clip, this ); + fl_scroll( X + Track_Header::width(), rulers->y(), rulers->w(), rulers->h(), dx, 0, draw_clip, this ); Y = rulers->y() + rulers->h(); H = h() - rulers->h() - hscroll->h(); - fl_scroll( X, Y, W, H, dx, dy, draw_clip, this ); + if ( dy == 0 ) + fl_scroll( X + Track_Header::width(), Y, W - Track_Header::width(), H, dx, dy, draw_clip, this ); + else + fl_scroll( X, Y, W, H, dx, dy, draw_clip, this ); _old_xposition = xoffset; _old_yposition = yposition; diff --git a/Track.C b/Track.C index 35087b7..ec0ad1c 100644 --- a/Track.C +++ b/Track.C @@ -85,7 +85,7 @@ Track::remove ( Track_Widget *r ) Track_Widget * Track::event_widget ( void ) { - int ets = timeline->xoffset + timeline->x_to_ts( Fl::event_x() ); + int ets = timeline->xoffset + timeline->x_to_ts( Fl::event_x() - x() ); for ( list ::const_reverse_iterator r = _widgets.rbegin(); r != _widgets.rend(); r++ ) if ( ets > (*r)->offset() && ets < (*r)->offset() + (*r)->length() ) return (*r); diff --git a/Track.H b/Track.H index 6c502a4..85db483 100644 --- a/Track.H +++ b/Track.H @@ -88,6 +88,8 @@ public: box( FL_DOWN_BOX ); color( fl_darker( FL_GRAY ) ); + end(); + log_create(); } diff --git a/Track_Header.fl b/Track_Header.fl new file mode 100644 index 0000000..ac254a7 --- /dev/null +++ b/Track_Header.fl @@ -0,0 +1,55 @@ +# data file for the Fltk User Interface Designer (fluid) +version 1.0107 +header_name {.H} +code_name {.C} +decl {\#include "Track.H"} {public +} + +widget_class Track_Header {open + xywh {30 535 1156 116} type Double resizable visible +} { + Function {width()} {open return_type {static int} + } { + code {return 150;} {} + } + decl {Track *_track;} {} + Fl_Group {} {open selected + xywh {2 2 149 113} box THIN_UP_FRAME + code0 {o->size( Track_Header::width(), o->h() );} + } { + Fl_Group {} {open + xywh {4 4 144 66} + } { + Fl_Input name_field { + xywh {4 9 144 25} color 33 labeltype NO_LABEL labelcolor 32 textcolor 32 + } + Fl_Button record_button { + label {@circle} + xywh {6 38 26 27} type Toggle box THIN_UP_FRAME color 32 labelsize 8 + } + Fl_Button mute_button { + label m + xywh {35 38 26 27} type Toggle box PLASTIC_UP_FRAME color 48 labelsize 11 + } + Fl_Button solo_button { + label s + xywh {66 38 26 27} type Toggle box PLASTIC_UP_FRAME color 48 labelsize 11 + } + Fl_Menu_Button take_menu { + label T open + xywh {97 38 47 27} box THIN_UP_BOX + } {} + } + } + Fl_Pack takes {open + xywh {150 1 1006 114} resizable + code0 {o->resize( x() + width(), y(), w() - width(), h() );} + } {} + Function {track( Track *t )} {open return_type void + } { + code {_track = t; + +t->size( 1, takes->h() ); +takes->add( t );} {} + } +} diff --git a/Track_Widget.H b/Track_Widget.H index 8d648d9..6e0f492 100644 --- a/Track_Widget.H +++ b/Track_Widget.H @@ -84,7 +84,6 @@ public: int abs_x ( void ) const { return timeline->ts_to_x( _offset ); } virtual int abs_w ( void ) const { return timeline->ts_to_x( _end - _start ); } - Fl_Color color ( void ) { return _color; } Fl_Color box_color ( void ) { return _box_color; } @@ -130,11 +129,11 @@ public: } - virtual void - dump ( void ) - { - printf( "Unknown %p %lu %lu %lu\n", this, _offset, _start, _end ); - } +/* virtual void */ +/* dump ( void ) */ +/* { */ +/* printf( "Unknown %p %lu %lu %lu\n", this, _offset, _start, _end ); */ +/* } */ virtual void draw_label ( const char *label, Fl_Align align ) @@ -253,9 +252,9 @@ public: redraw(); - if ( timeline->ts_to_x( timeline->xoffset ) + ox + X > 0 ) + if ( timeline->ts_to_x( timeline->xoffset ) + ox + X > _track->x() ) { - int nx = ox + X; + int nx = (ox + X) - _track->x(); _offset = timeline->x_to_ts( nx ) + timeline->xoffset;