Begin to make Track_Header widget loggable.
This commit is contained in:
parent
bcb8e5205c
commit
d2749e3397
|
@ -161,7 +161,7 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Group( X,
|
|||
// o->end();
|
||||
|
||||
t->track( o );
|
||||
t->color( FL_GREEN );
|
||||
t->color( (Fl_Color)rand() );
|
||||
}
|
||||
|
||||
tracks = o;
|
||||
|
|
|
@ -19,6 +19,25 @@
|
|||
|
||||
#include "Track_Header.H"
|
||||
|
||||
void
|
||||
Track_Header::cb_input_field ( Fl_Widget *w, void *v )
|
||||
{
|
||||
((Track_Header*)v)->cb_input_field();
|
||||
}
|
||||
|
||||
void
|
||||
Track_Header::cb_input_field ( void )
|
||||
{
|
||||
log_start();
|
||||
|
||||
if ( _name )
|
||||
free( _name );
|
||||
|
||||
_name = strdup( name_field->value() );
|
||||
|
||||
log_end();
|
||||
}
|
||||
|
||||
Track_Header::Track_Header ( int X, int Y, int W, int H, const char *L ) :
|
||||
Fl_Group ( X, Y, W, H, L )
|
||||
{
|
||||
|
@ -35,6 +54,8 @@ Track_Header::Track_Header ( int X, int Y, int W, int H, const char *L ) :
|
|||
o->labeltype( FL_NO_LABEL );
|
||||
o->labelcolor( FL_GRAY0 );
|
||||
o->textcolor( 32 );
|
||||
|
||||
o->callback( cb_input_field, (void*)this );
|
||||
}
|
||||
{
|
||||
Fl_Button *o = record_button =
|
||||
|
@ -81,6 +102,18 @@ Track_Header::Track_Header ( int X, int Y, int W, int H, const char *L ) :
|
|||
Fl_Group::current()->resizable( o );
|
||||
}
|
||||
end();
|
||||
|
||||
|
||||
_name = NULL;
|
||||
_track = NULL;
|
||||
_selected = false;
|
||||
|
||||
log_create();
|
||||
}
|
||||
|
||||
Track_Header::~Track_Header ( )
|
||||
{
|
||||
log_destroy();
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -34,11 +34,17 @@ class Track_Header : public Fl_Group, public Loggable
|
|||
|
||||
public:
|
||||
|
||||
Track_Header( int X, int Y, int W, int H, const char *L = 0 );
|
||||
Track_Header ( int X, int Y, int W, int H, const char *L = 0 );
|
||||
~Track_Header ( );
|
||||
|
||||
private:
|
||||
|
||||
Track * _track;
|
||||
|
||||
char *_name;
|
||||
|
||||
bool _selected;
|
||||
|
||||
public:
|
||||
|
||||
Fl_Input * name_field;
|
||||
|
@ -53,14 +59,67 @@ public:
|
|||
|
||||
void set ( char **sa )
|
||||
{
|
||||
return;
|
||||
for ( int i = 0; sa[i]; ++i )
|
||||
{
|
||||
char *s = sa[i];
|
||||
|
||||
strtok( s, " " );
|
||||
|
||||
char *v = s + strlen( s ) + 1;
|
||||
|
||||
if ( *v == '"' )
|
||||
{
|
||||
v++;
|
||||
v[ strlen( v ) - 2 ] = '\0';
|
||||
}
|
||||
|
||||
if ( ! strcmp( s, ":selected" ) )
|
||||
_selected = atoi( v );
|
||||
else
|
||||
if ( ! strcmp( s, ":name" ) )
|
||||
{
|
||||
_name = strdup( v );
|
||||
name_field->value( _name );
|
||||
}
|
||||
else
|
||||
if ( ! strcmp( s, ":track" ) )
|
||||
{
|
||||
int i;
|
||||
sscanf( v, "%X", &i );
|
||||
Track *t = (Track*)Loggable::find( i );
|
||||
|
||||
assert( t );
|
||||
|
||||
_track = t;
|
||||
}
|
||||
|
||||
|
||||
free( s );
|
||||
}
|
||||
|
||||
free( sa );
|
||||
|
||||
}
|
||||
|
||||
char ** get ( void )
|
||||
{
|
||||
return NULL;
|
||||
char **sa = (char**)malloc( sizeof( char* ) * (1 + 3) );
|
||||
|
||||
int i = 0;
|
||||
|
||||
asprintf( &sa[ i++ ], ":name \"%s\"", _name ? _name : "" );
|
||||
asprintf( &sa[ i++ ], ":track 0x%X", _track ? _track->id() : 0 );
|
||||
asprintf( &sa[ i++ ], ":selected %d", _selected );
|
||||
// asprintf( &sa[ i++ ], ":gain %f", _scale );
|
||||
|
||||
sa[ i ] = NULL;
|
||||
|
||||
return sa;
|
||||
}
|
||||
|
||||
static void cb_input_field ( Fl_Widget *w, void *v );
|
||||
void cb_input_field ( void );
|
||||
|
||||
static int width();
|
||||
|
||||
void track( Track * t );
|
||||
|
|
Loading…
Reference in New Issue