Clean up takes menu building. Add 'remove' action.
This commit is contained in:
parent
4731dea3b3
commit
f50c8318ff
|
@ -93,10 +93,6 @@ Project::set_name ( const char *name )
|
||||||
bool
|
bool
|
||||||
Project::write_info ( void )
|
Project::write_info ( void )
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( ! open() )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if ( ! ( fp = fopen( "info", "w" ) ) )
|
if ( ! ( fp = fopen( "info", "w" ) ) )
|
||||||
|
@ -270,16 +266,14 @@ Project::create ( const char *name, const char *template_name )
|
||||||
FATAL( "WTF? Cannot change to new project directory" );
|
FATAL( "WTF? Cannot change to new project directory" );
|
||||||
|
|
||||||
mkdir( "sources", 0777 );
|
mkdir( "sources", 0777 );
|
||||||
|
|
||||||
creat( "info", 0666 );
|
|
||||||
creat( "history", 0666 );
|
creat( "history", 0666 );
|
||||||
|
|
||||||
/* TODO: copy template */
|
/* TODO: copy template */
|
||||||
|
|
||||||
if ( open( name ) == 0 )
|
|
||||||
{
|
|
||||||
write_info();
|
write_info();
|
||||||
|
|
||||||
|
if ( open( name ) == 0 )
|
||||||
|
{
|
||||||
/* add the bare essentials */
|
/* add the bare essentials */
|
||||||
timeline->beats_per_minute( 0, 120 );
|
timeline->beats_per_minute( 0, 120 );
|
||||||
timeline->time( 0, 4, 4 );
|
timeline->time( 0, 4, 4 );
|
||||||
|
|
|
@ -227,8 +227,6 @@ Track::set ( Log_Entry &e )
|
||||||
if ( ! strcmp( s, ":height" ) )
|
if ( ! strcmp( s, ":height" ) )
|
||||||
{
|
{
|
||||||
size( atoi( v ) );
|
size( atoi( v ) );
|
||||||
|
|
||||||
// Fl_Widget::size( w(), height() );
|
|
||||||
resize();
|
resize();
|
||||||
}
|
}
|
||||||
else if ( ! strcmp( s, ":selected" ) )
|
else if ( ! strcmp( s, ":selected" ) )
|
||||||
|
@ -245,6 +243,8 @@ Track::set ( Log_Entry &e )
|
||||||
color( (Fl_Color)atoll( v ) );
|
color( (Fl_Color)atoll( v ) );
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
else if ( ! strcmp( s, ":show-all-takes" ) )
|
||||||
|
show_all_takes( atoi( v ) );
|
||||||
else if ( ! strcmp( s, ":sequence" ) )
|
else if ( ! strcmp( s, ":sequence" ) )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -271,7 +271,6 @@ Track::set ( Log_Entry &e )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::get ( Log_Entry &e ) const
|
Track::get ( Log_Entry &e ) const
|
||||||
{
|
{
|
||||||
|
@ -282,6 +281,7 @@ Track::get ( Log_Entry &e ) const
|
||||||
e.add( ":inputs", input.size() );
|
e.add( ":inputs", input.size() );
|
||||||
e.add( ":outputs", output.size() );
|
e.add( ":outputs", output.size() );
|
||||||
e.add( ":color", (unsigned long)color());
|
e.add( ":color", (unsigned long)color());
|
||||||
|
e.add( ":show-all-takes", _show_all_takes );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -335,24 +335,28 @@ Track::cb_button ( Fl_Widget *w )
|
||||||
{
|
{
|
||||||
case 0: /* show all takes */
|
case 0: /* show all takes */
|
||||||
show_all_takes( take_menu->menu()[ v ].value() );
|
show_all_takes( take_menu->menu()[ v ].value() );
|
||||||
return;
|
break;
|
||||||
case 1: /* new */
|
case 1: /* new */
|
||||||
sequence( (Audio_Sequence*)sequence()->clone_empty() );
|
sequence( (Audio_Sequence*)sequence()->clone_empty() );
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *s = take_menu->menu()[ v ].text;
|
|
||||||
|
|
||||||
for ( int i = takes->children(); i--; )
|
|
||||||
{
|
|
||||||
Audio_Sequence *t = (Audio_Sequence*)takes->child( i );
|
|
||||||
if ( ! strcmp( s, t->name() ) )
|
|
||||||
{
|
|
||||||
sequence( t );
|
|
||||||
redraw();
|
|
||||||
break;
|
break;
|
||||||
|
case 2: /* remove */
|
||||||
|
if ( takes->children() )
|
||||||
|
{
|
||||||
|
Loggable::block_start();
|
||||||
|
|
||||||
|
Sequence *s = sequence();
|
||||||
|
|
||||||
|
sequence( (Audio_Sequence*)takes->child( 0 ) );
|
||||||
|
|
||||||
|
delete s;
|
||||||
|
|
||||||
|
Loggable::block_end();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sequence( (Audio_Sequence*)take_menu->menu()[ v ].user_data() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,6 +427,23 @@ Track::size ( int v )
|
||||||
resize();
|
resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Track::update_take_menu ( void )
|
||||||
|
{
|
||||||
|
take_menu->clear();
|
||||||
|
|
||||||
|
take_menu->add( "Show all takes", 0, 0, 0, FL_MENU_TOGGLE );
|
||||||
|
take_menu->add( "New", 0, 0, 0 );
|
||||||
|
take_menu->add( "Remove", 0, 0, 0, FL_MENU_DIVIDER );
|
||||||
|
|
||||||
|
for ( int i = 0; i < takes->children(); ++i )
|
||||||
|
{
|
||||||
|
Sequence *s = (Sequence *)takes->child( i );
|
||||||
|
|
||||||
|
take_menu->add( s->name(), 0, 0, s );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::add ( Audio_Sequence * t )
|
Track::add ( Audio_Sequence * t )
|
||||||
{
|
{
|
||||||
|
@ -430,13 +451,13 @@ Track::add ( Audio_Sequence * t )
|
||||||
if ( ! t->name() )
|
if ( ! t->name() )
|
||||||
{
|
{
|
||||||
char pat[20];
|
char pat[20];
|
||||||
snprintf( pat, sizeof( pat ), "%d", takes->children() );
|
snprintf( pat, sizeof( pat ), "%d", 1 + takes->children() );
|
||||||
t->name( strdup( pat ) );
|
t->name( strdup( pat ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
take_menu->add( t->name() );
|
|
||||||
|
|
||||||
t->labeltype( FL_ENGRAVED_LABEL );
|
t->labeltype( FL_ENGRAVED_LABEL );
|
||||||
|
|
||||||
|
update_take_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -449,11 +470,13 @@ Track::remove ( Audio_Sequence *t )
|
||||||
|
|
||||||
takes->remove( t );
|
takes->remove( t );
|
||||||
|
|
||||||
|
/* delete t; */
|
||||||
|
|
||||||
timeline->unlock();
|
timeline->unlock();
|
||||||
|
|
||||||
resize();
|
resize();
|
||||||
|
|
||||||
// take_menu->remove( t->name() );
|
update_take_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -96,10 +96,12 @@ private:
|
||||||
|
|
||||||
void update_port_names ( void );
|
void update_port_names ( void );
|
||||||
const char *name_for_port( Port::type_e type, int n );
|
const char *name_for_port( Port::type_e type, int n );
|
||||||
|
void update_take_menu ( void );
|
||||||
|
|
||||||
Track ( );
|
Track ( );
|
||||||
void init ( void );
|
void init ( void );
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void get ( Log_Entry &e ) const;
|
void get ( Log_Entry &e ) const;
|
||||||
|
|
Loading…
Reference in New Issue