Log changes to track objcets as well.
This commit is contained in:
parent
49628da177
commit
0f9d79b3d8
32
Loggable.C
32
Loggable.C
|
@ -43,22 +43,22 @@ Loggable::open ( const char *filename )
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Loggable::log ( const char *module, const char *action, const char *fmt, ... )
|
||||
{
|
||||
va_list args;
|
||||
/* void */
|
||||
/* Loggable::log ( const char *module, const char *action, const char *fmt, ... ) */
|
||||
/* { */
|
||||
/* va_list args; */
|
||||
|
||||
fprintf( _fp, "%-15s %-8s %p ", module, action, _id );
|
||||
/* fprintf( _fp, "%-15s %-8s %p ", module, action, _id ); */
|
||||
|
||||
if ( fmt )
|
||||
{
|
||||
va_start( args, fmt );
|
||||
vfprintf( _fp, fmt, args );
|
||||
va_end( args );
|
||||
}
|
||||
/* if ( fmt ) */
|
||||
/* { */
|
||||
/* va_start( args, fmt ); */
|
||||
/* vfprintf( _fp, fmt, args ); */
|
||||
/* va_end( args ); */
|
||||
/* } */
|
||||
|
||||
fprintf( _fp, "\n" );
|
||||
}
|
||||
/* fprintf( _fp, "\n" ); */
|
||||
/* } */
|
||||
|
||||
|
||||
static
|
||||
|
@ -167,9 +167,13 @@ Loggable::log_create ( void )
|
|||
|
||||
char **sa = log_dump();
|
||||
|
||||
if ( sa )
|
||||
{
|
||||
log_print( NULL, sa );
|
||||
|
||||
free_sa( sa );
|
||||
}
|
||||
else
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
void
|
||||
|
|
12
Loggable.H
12
Loggable.H
|
@ -105,17 +105,21 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
void log ( const char *module, const char *action, const char *fmt, ... );
|
||||
// void log ( const char *module, const char *action, const char *fmt, ... );
|
||||
void log_start ( void );
|
||||
void log_end ( void );
|
||||
void log_create ( void );
|
||||
void log_destroy ( void );
|
||||
|
||||
public:
|
||||
|
||||
int id ( void ) { return _id; }
|
||||
|
||||
};
|
||||
|
||||
#ifndef _LOGGABLE_C
|
||||
#define log( act, fmt, args... ) log( __CLASS__, act, fmt, ## args )
|
||||
#endif
|
||||
/* #ifndef _LOGGABLE_C */
|
||||
/* #define log( act, fmt, args... ) log( __CLASS__, act, fmt, ## args ) */
|
||||
/* #endif */
|
||||
|
||||
/* #define LOG_START Logger _logger( this ) */
|
||||
/* #define LOG_END _logger.print( this ) */
|
||||
|
|
5
Region.C
5
Region.C
|
@ -54,11 +54,6 @@ void
|
|||
Region::init ( void )
|
||||
{
|
||||
|
||||
/* align( FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_BOTTOM | FL_ALIGN_CLIP ); */
|
||||
/* labeltype( FL_SHADOW_LABEL ); */
|
||||
/* labelcolor( FL_WHITE ); */
|
||||
/* box( FL_PLASTIC_UP_BOX ); */
|
||||
|
||||
_track = NULL;
|
||||
_offset = 0;
|
||||
_start = 0;
|
||||
|
|
14
Region.H
14
Region.H
|
@ -72,6 +72,7 @@ protected:
|
|||
asprintf( &sa[2], ":r %lu", _end );
|
||||
asprintf( &sa[3], ":selected %d", _selected );
|
||||
asprintf( &sa[4], ":gain %f", _scale );
|
||||
// asprintf( &sa[4], ":track 0x%X", _track->id() );
|
||||
|
||||
// asprintf( &r, ":x %lu\n:l %lu\n:r %lu\n:selected %d\n:gain %f", _offset, _start, _end, _selected, _scale );
|
||||
|
||||
|
@ -104,6 +105,19 @@ protected:
|
|||
if ( ! strcmp( s, ":gain" ) )
|
||||
_scale = atof( v );
|
||||
|
||||
/* else */
|
||||
/* if ( ! strcmp( s, ":track" ) ) */
|
||||
/* { */
|
||||
/* int i; */
|
||||
/* sscanf( v, "%X", &i ); */
|
||||
/* Track *t = (Track*)Loggable::find( i ); */
|
||||
|
||||
/* assert( t ); */
|
||||
|
||||
/* t->add( this ); */
|
||||
/* } */
|
||||
|
||||
|
||||
free( s );
|
||||
}
|
||||
|
||||
|
|
|
@ -40,9 +40,9 @@ protected:
|
|||
|
||||
const char *class_name ( void ) { return "Tempo_Point"; }
|
||||
|
||||
void log_create ( void ) { log( "create", "%lu %f", _offset, _tempo ); }
|
||||
void log_destroy ( void ) { log( "destroy", NULL ); }
|
||||
void log_move ( void ) { log( "move", "%lu", _offset ); }
|
||||
/* void log_create ( void ) { log( "create", "%lu %f", _offset, _tempo ); } */
|
||||
/* void log_destroy ( void ) { log( "destroy", NULL ); } */
|
||||
/* void log_move ( void ) { log( "move", "%lu", _offset ); } */
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -54,9 +54,9 @@ protected:
|
|||
|
||||
const char *class_name ( void ) { return "Time_Point"; }
|
||||
|
||||
void log_create ( void ) { log( "create", "%lu %d %d", _offset, _time.beats_per_bar, _time.note_type ); }
|
||||
void log_destroy ( void ) { log( "destroy", NULL ); }
|
||||
void log_move ( void ) { log( "move", "%lu", _offset ); }
|
||||
/* void log_create ( void ) { log( "create", "%lu %d %d", _offset, _time.beats_per_bar, _time.note_type ); } */
|
||||
/* void log_destroy ( void ) { log( "destroy", NULL ); } */
|
||||
/* void log_move ( void ) { log( "move", "%lu", _offset ); } */
|
||||
|
||||
public:
|
||||
|
||||
|
|
8
Track.C
8
Track.C
|
@ -27,6 +27,10 @@
|
|||
|
||||
Track_Widget * Track::_queued_widget = NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static bool
|
||||
sort_func ( Track_Widget *lhs, Track_Widget *rhs )
|
||||
{
|
||||
|
@ -84,6 +88,8 @@ Track::event_widget ( void )
|
|||
void
|
||||
Track::add ( Track_Widget *r )
|
||||
{
|
||||
log_start();
|
||||
|
||||
if ( r->track() )
|
||||
{
|
||||
r->track()->remove( r );
|
||||
|
@ -93,6 +99,8 @@ Track::add ( Track_Widget *r )
|
|||
_widgets.push_back( r );
|
||||
|
||||
r->track( this );
|
||||
|
||||
log_end();
|
||||
}
|
||||
|
||||
/* snap /r/ to nearest edge */
|
||||
|
|
40
Track.H
40
Track.H
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Loggable.H"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -34,7 +35,7 @@ using std::list;
|
|||
class Region;
|
||||
class Track_Widget;
|
||||
|
||||
class Track : public Fl_Group
|
||||
class Track : public Fl_Group, public Loggable
|
||||
{
|
||||
Track *_next;
|
||||
Track *_prev;
|
||||
|
@ -47,8 +48,38 @@ protected:
|
|||
list <Track_Widget *> _widgets;
|
||||
Track_Widget *event_widget ( void );
|
||||
|
||||
const char *class_name ( void ) { return "Track"; }
|
||||
|
||||
|
||||
void set ( char ** ) { return; }
|
||||
|
||||
char ** log_dump ( void )
|
||||
{
|
||||
// char *r;
|
||||
|
||||
char **sa = (char**)malloc( sizeof( char* ) * 2);
|
||||
sa[0] = (char*)malloc( (_widgets.size() * ((sizeof( int ) * 2) + 3)) + 1 );
|
||||
sa[1] = NULL;
|
||||
|
||||
char *s = sa[0];
|
||||
|
||||
s += sprintf( s, ":items " );
|
||||
for ( list <Track_Widget *>::const_iterator i = _widgets.begin(); i != _widgets.end(); i++ )
|
||||
{
|
||||
s += sprintf( s, "0x%X", ((Loggable*)(*i))->id() );
|
||||
|
||||
list <Track_Widget *>::const_iterator e = i;
|
||||
if ( ++e != _widgets.end() )
|
||||
s += sprintf( s, "," );
|
||||
}
|
||||
|
||||
return sa;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Track ( int X, int Y, int W, int H ) : Fl_Group( X, Y, W, H )
|
||||
{
|
||||
_next = _prev = NULL;
|
||||
|
@ -56,6 +87,13 @@ public:
|
|||
|
||||
box( FL_DOWN_BOX );
|
||||
color( fl_darker( FL_GRAY ) );
|
||||
|
||||
log_create();
|
||||
}
|
||||
|
||||
~Track ( )
|
||||
{
|
||||
log_destroy();
|
||||
}
|
||||
|
||||
Track *next ( void ) const { return _next; }
|
||||
|
|
Loading…
Reference in New Issue