@@ -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; | |||||
}; |
@@ -79,6 +79,8 @@ Region::Region ( const Region & rhs ) | |||||
_start = rhs._start; | _start = rhs._start; | ||||
_end = rhs._end; | _end = rhs._end; | ||||
_scale = rhs._scale; | _scale = rhs._scale; | ||||
log_create(); | |||||
} | } | ||||
Region::Region ( Audio_File *c ) | Region::Region ( Audio_File *c ) | ||||
@@ -86,6 +88,8 @@ Region::Region ( Audio_File *c ) | |||||
init(); | init(); | ||||
_clip = c; | _clip = c; | ||||
_end = _clip->length(); | _end = _clip->length(); | ||||
log_create(); | |||||
} | } | ||||
@@ -195,6 +199,7 @@ Region::handle ( int m ) | |||||
else | else | ||||
_selected = ! _selected; | _selected = ! _selected; | ||||
log_change(); | |||||
redraw(); | redraw(); | ||||
} | } | ||||
@@ -207,8 +212,11 @@ Region::handle ( int m ) | |||||
case FL_RELEASE: | case FL_RELEASE: | ||||
Track_Widget::handle( m ); | Track_Widget::handle( m ); | ||||
copied = false; | copied = false; | ||||
trimming = NO; | |||||
// Fl::release(); | |||||
if ( trimming != NO ) | |||||
{ | |||||
trimming = NO; | |||||
log_change(); | |||||
} | |||||
return 1; | return 1; | ||||
case FL_DRAG: | case FL_DRAG: | ||||
@@ -51,6 +51,29 @@ class Region : public Track_Widget | |||||
void trim ( enum trim_e t, int X ); | void trim ( enum trim_e t, int X ); | ||||
void init ( void ); | 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: | public: | ||||
Fl_Boxtype box ( void ) const { return Region::_box; } | Fl_Boxtype box ( void ) const { return Region::_box; } | ||||
@@ -119,7 +119,7 @@ Track::snap ( Track_Widget *r ) | |||||
{ | { | ||||
r->offset( w->offset() + w->length() + 1 ); | 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; | goto done; | ||||
} | } | ||||
@@ -128,7 +128,7 @@ Track::snap ( Track_Widget *r ) | |||||
{ | { | ||||
r->offset( ( w->offset() - r->length() ) - 1 ); | 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; | goto done; | ||||
} | } | ||||
@@ -28,6 +28,24 @@ protected: | |||||
char *_label; | char *_label; | ||||
void log_create ( void ) | |||||
{ | |||||
} | |||||
void log_destroy ( void ) | |||||
{ | |||||
} | |||||
void log_move ( void ) | |||||
{ | |||||
} | |||||
void log_change ( void ) | |||||
{ | |||||
} | |||||
public: | public: | ||||
Fl_Align align ( void ) const { return FL_ALIGN_RIGHT; } | Fl_Align align ( void ) const { return FL_ALIGN_RIGHT; } | ||||
@@ -20,12 +20,13 @@ | |||||
#pragma once | #pragma once | ||||
#include "Track.H" | #include "Track.H" | ||||
#include "Loggable.H" | |||||
#include <algorithm> | #include <algorithm> | ||||
using namespace std; | using namespace std; | ||||
/* Base class for virtual widget on a track */ | /* Base class for virtual widget on a track */ | ||||
class Track_Widget | |||||
class Track_Widget : public Loggable | |||||
{ | { | ||||
protected: | protected: | ||||
@@ -200,6 +201,7 @@ public: | |||||
handle ( int m ) | handle ( int m ) | ||||
{ | { | ||||
static int ox, oy; | static int ox, oy; | ||||
static bool moved = false; | |||||
int X = Fl::event_x(); | int X = Fl::event_x(); | ||||
int Y = Fl::event_y(); | int Y = Fl::event_y(); | ||||
@@ -214,6 +216,8 @@ public: | |||||
if ( Fl::event_state() & FL_CTRL && | if ( Fl::event_state() & FL_CTRL && | ||||
Fl::event_button() == 3 ) | Fl::event_button() == 3 ) | ||||
{ | { | ||||
log_destroy(); | |||||
redraw(); | redraw(); | ||||
_track->queue_delete( this ); | _track->queue_delete( this ); | ||||
return 0; | return 0; | ||||
@@ -222,7 +226,12 @@ public: | |||||
return 1; | return 1; | ||||
} | } | ||||
case FL_RELEASE: | case FL_RELEASE: | ||||
dump(); | |||||
if ( moved ) | |||||
{ | |||||
log_move(); | |||||
moved = false; | |||||
} | |||||
// dump(); | |||||
fl_cursor( FL_CURSOR_DEFAULT ); | fl_cursor( FL_CURSOR_DEFAULT ); | ||||
return 1; | return 1; | ||||
case FL_DRAG: | case FL_DRAG: | ||||
@@ -236,6 +245,8 @@ public: | |||||
_offset = timeline->x_to_ts( nx ) + timeline->xoffset; | _offset = timeline->x_to_ts( nx ) + timeline->xoffset; | ||||
_track->snap( this ); | _track->snap( this ); | ||||
moved = true; | |||||
} | } | ||||
// _track->redraw(); | // _track->redraw(); | ||||