Mixer: Allow creation of mix before creation of project.

Closes #10.
This commit is contained in:
Jonathan Moore Liles 2013-05-13 17:21:57 -07:00
parent 89f2633463
commit d4f96fe762
2 changed files with 33 additions and 38 deletions

View File

@ -172,6 +172,31 @@ Mixer::redraw_windows ( void )
w->redraw(); w->redraw();
} }
void Mixer::command_new ( void )
{
DMESSAGE( "New project" );
char *default_path;
read_line( user_config_dir, "default_path", &default_path );
char *path = new_project_chooser( &default_path );
if ( path )
{
if ( ! Project::create( path, NULL ) )
fl_alert( "Error creating project!" );
free( path );
}
update_menu();
if ( default_path )
{
write_line( user_config_dir, "default_path", default_path );
free( default_path );
}
}
void Mixer::cb_menu(Fl_Widget* o) { void Mixer::cb_menu(Fl_Widget* o) {
Fl_Menu_Bar *menu = (Fl_Menu_Bar*)o; Fl_Menu_Bar *menu = (Fl_Menu_Bar*)o;
@ -185,29 +210,7 @@ void Mixer::cb_menu(Fl_Widget* o) {
if (! strcmp( picked, "&Project/&New") ) if (! strcmp( picked, "&Project/&New") )
{ {
DMESSAGE( "New project" ); command_new();
char *default_path;
read_line( user_config_dir, "default_path", &default_path );
char *path = new_project_chooser( &default_path );
if ( path )
{
if ( ! Project::create( path, NULL ) )
fl_alert( "Error creating project!" );
free( path );
}
update_menu();
if ( default_path )
{
write_line( user_config_dir, "default_path", default_path );
free( default_path );
}
} }
else if (! strcmp( picked, "&Project/&Open" ) ) else if (! strcmp( picked, "&Project/&Open" ) )
{ {
@ -709,21 +712,6 @@ Mixer::save_options ( void )
void void
Mixer::update_menu ( void ) Mixer::update_menu ( void )
{ {
bool b = Project::open();
if ( b )
{
((Fl_Menu_Item*)menubar->find_item( "&Mixer" ))->flags &= ~FL_MENU_INACTIVE;
((Fl_Menu_Item*)menubar->find_item( "&Project/&Save" ))->flags &= ~FL_MENU_INACTIVE;
mixer_strips->activate();
}
else
{
((Fl_Menu_Item*)menubar->find_item( "&Mixer" ))->flags |= FL_MENU_INACTIVE;
((Fl_Menu_Item*)menubar->find_item( "&Project/&Save" ))->flags |= FL_MENU_INACTIVE;
mixer_strips->deactivate();
}
project_name->label( Project::name() ); project_name->label( Project::name() );
} }
@ -736,6 +724,12 @@ Mixer::update_menu ( void )
bool bool
Mixer::command_save ( void ) Mixer::command_save ( void )
{ {
if ( ! Project::open() )
{
command_new();
update_menu();
}
return Project::save(); return Project::save();
} }

View File

@ -110,6 +110,7 @@ public:
public: public:
void command_new ( void );
bool command_save ( void ); bool command_save ( void );
bool command_load ( const char *path, const char *display_name = 0 ); bool command_load ( const char *path, const char *display_name = 0 );
bool command_new ( const char *path, const char *display_name = 0 ); bool command_new ( const char *path, const char *display_name = 0 );