From 1ec48435809d2ce272f3866a932d75e49e536f30 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Fri, 22 Feb 2008 04:22:22 -0600 Subject: [PATCH] Move log message types into their own class. --- Loggable.H | 32 ++++++++++++++++++++++++++++++++ Region.C | 12 ++++++++++-- Region.H | 23 +++++++++++++++++++++++ Track.C | 4 ++-- Track_Point.H | 18 ++++++++++++++++++ Track_Widget.H | 15 +++++++++++++-- 6 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 Loggable.H diff --git a/Loggable.H b/Loggable.H new file mode 100644 index 0000000..7a6fae6 --- /dev/null +++ b/Loggable.H @@ -0,0 +1,32 @@ + +/*******************************************************************************/ +/* 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. */ +/*******************************************************************************/ + +/* Master class for journaling. */ + +class Loggable +{ + +public: + + /* log messages for journal */ + virtual void log_create ( void ) = 0; + virtual void log_destroy ( void ) = 0; + virtual void log_move ( void ) = 0; + virtual void log_change ( void ) = 0; +}; diff --git a/Region.C b/Region.C index f00e2a0..5edacfb 100644 --- a/Region.C +++ b/Region.C @@ -79,6 +79,8 @@ Region::Region ( const Region & rhs ) _start = rhs._start; _end = rhs._end; _scale = rhs._scale; + + log_create(); } Region::Region ( Audio_File *c ) @@ -86,6 +88,8 @@ Region::Region ( Audio_File *c ) init(); _clip = c; _end = _clip->length(); + + log_create(); } @@ -195,6 +199,7 @@ Region::handle ( int m ) else _selected = ! _selected; + log_change(); redraw(); } @@ -207,8 +212,11 @@ Region::handle ( int m ) case FL_RELEASE: Track_Widget::handle( m ); copied = false; - trimming = NO; - // Fl::release(); + if ( trimming != NO ) + { + trimming = NO; + log_change(); + } return 1; case FL_DRAG: diff --git a/Region.H b/Region.H index 99c63c7..57a276c 100644 --- a/Region.H +++ b/Region.H @@ -51,6 +51,29 @@ class Region : public Track_Widget void trim ( enum trim_e t, int X ); void init ( void ); +protected: + + /* general */ + void log_create ( void ) + { + printf( "region create %p %lu \"%s\" %d %f %lu %lu\n", this, _offset, _clip->name(), _selected, _scale, _start, _end ); + } + + void log_destroy ( void ) + { + printf( "region destroy %p\n", this ); + } + + void log_move ( void ) + { + printf( "region move %p %lu\n", this, _offset ); + } + + void log_change ( void ) + { + printf( "region change %p %d %f %lu %lu\n", this, _selected, _scale, _start, _end ); + } + public: Fl_Boxtype box ( void ) const { return Region::_box; } diff --git a/Track.C b/Track.C index ef751f5..0599721 100644 --- a/Track.C +++ b/Track.C @@ -119,7 +119,7 @@ Track::snap ( Track_Widget *r ) { r->offset( w->offset() + w->length() + 1 ); - printf( "snap: %lu | %lu\n", w->offset() + w->length(), r->offset() ); +// printf( "snap: %lu | %lu\n", w->offset() + w->length(), r->offset() ); goto done; } @@ -128,7 +128,7 @@ Track::snap ( Track_Widget *r ) { r->offset( ( w->offset() - r->length() ) - 1 ); - printf( "snap: %lu | %lu\n", r->offset() + r->length(), w->offset() ); +// printf( "snap: %lu | %lu\n", r->offset() + r->length(), w->offset() ); goto done; } diff --git a/Track_Point.H b/Track_Point.H index aee085c..dfea019 100644 --- a/Track_Point.H +++ b/Track_Point.H @@ -28,6 +28,24 @@ protected: char *_label; + + void log_create ( void ) + { + } + + void log_destroy ( void ) + { + } + + void log_move ( void ) + { + } + + void log_change ( void ) + { + } + + public: Fl_Align align ( void ) const { return FL_ALIGN_RIGHT; } diff --git a/Track_Widget.H b/Track_Widget.H index 30a1090..c952c96 100644 --- a/Track_Widget.H +++ b/Track_Widget.H @@ -20,12 +20,13 @@ #pragma once #include "Track.H" +#include "Loggable.H" #include using namespace std; /* Base class for virtual widget on a track */ -class Track_Widget +class Track_Widget : public Loggable { protected: @@ -200,6 +201,7 @@ public: handle ( int m ) { static int ox, oy; + static bool moved = false; int X = Fl::event_x(); int Y = Fl::event_y(); @@ -214,6 +216,8 @@ public: if ( Fl::event_state() & FL_CTRL && Fl::event_button() == 3 ) { + log_destroy(); + redraw(); _track->queue_delete( this ); return 0; @@ -222,7 +226,12 @@ public: return 1; } case FL_RELEASE: - dump(); + if ( moved ) + { + log_move(); + moved = false; + } +// dump(); fl_cursor( FL_CURSOR_DEFAULT ); return 1; case FL_DRAG: @@ -236,6 +245,8 @@ public: _offset = timeline->x_to_ts( nx ) + timeline->xoffset; _track->snap( this ); + + moved = true; } // _track->redraw();