Mixer: Add menubar.

This commit is contained in:
Jonathan Moore Liles 2010-01-11 20:31:15 -06:00
parent 4ed6b98297
commit 0e33c199cf
9 changed files with 79 additions and 29 deletions

View File

@ -268,6 +268,17 @@ Controller_Module::connect_to ( Port *p )
} }
} }
void
Controller_Module::resize ( int X, int Y, int W, int H )
{
Module::resize( X, Y, W, H );
if ( ! _pad && children() )
{
child( 0 )->resize( X, Y, W, H );
}
}
int int
Controller_Module::handle ( int m ) Controller_Module::handle ( int m )
{ {

View File

@ -77,6 +77,8 @@ protected:
virtual int handle ( int m ); virtual int handle ( int m );
void resize ( int, int, int, int );
private: private:
std::vector<JACK::Port> jack_input; std::vector<JACK::Port> jack_input;

View File

@ -50,6 +50,7 @@ Gain_Module::Gain_Module ( )
Gain_Module::~Gain_Module ( ) Gain_Module::~Gain_Module ( )
{ {
delete (float*)control_input[0].buffer();
log_destroy(); log_destroy();
} }

View File

@ -26,7 +26,6 @@ class Gain_Module : public Module
public: public:
Gain_Module ( ); Gain_Module ( );
Gain_Module ( int W, int H, const char *L=0 );
virtual ~Gain_Module ( ); virtual ~Gain_Module ( );
const char *name ( void ) const { return "Gain"; } const char *name ( void ) const { return "Gain"; }

View File

@ -25,7 +25,8 @@
#include <FL/Fl_Pack.H> #include <FL/Fl_Pack.H>
#include <FL/Fl_Scroll.H> #include <FL/Fl_Scroll.H>
#include <FL/Fl_Menu_Bar.H> #include <FL/Fl_Menu_Bar.H>
#include <FL/fl_ask.H>
#include "New_Project_Dialog.H"
#include "Engine/Engine.H" #include "Engine/Engine.H"
#include "Project.H" #include "Project.H"
@ -46,6 +47,53 @@ static void update_cb( void *v ) {
((Mixer*)v)->update(); ((Mixer*)v)->update();
} }
void Mixer::cb_menu(Fl_Widget* o) {
Fl_Menu_Bar *menu = (Fl_Menu_Bar*)o;
/* const Fl_Menu_Item *mi = &menu->menu()[menu->value()]; */
char picked[256];
// const char *picked = menu->text();
menu->item_pathname( picked, sizeof( picked ) );
if (! strcmp( picked, "&Project/&New") )
{
DMESSAGE( "New project" );
const char *templates[] = { "Default", NULL };
char *default_path;
char *selected_template;
// read_line( user_config_dir, "default_path", &default_path );
char *path = new_project_chooser( templates, &default_path, &selected_template );
if ( ! Project::create( path, selected_template ) )
fl_alert( "Error creating project!" );
free( path );
free( selected_template );
free( default_path );
// write_line( user_config_dir, "default_path", default_path );
}
else if (! strcmp( picked, "&Project/&Save" ) )
{
Project::save();
}
else if ( !strcmp( picked, "&Mixer/&Add Strip" ) )
{
new_strip();
}
}
void Mixer::cb_menu(Fl_Widget* o, void* v) {
((Mixer*)(v))->cb_menu(o);
}
Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) : Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
Fl_Group( X, Y, W, H, L ) Fl_Group( X, Y, W, H, L )
{ {
@ -54,9 +102,11 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
{ Fl_Menu_Bar *o = new Fl_Menu_Bar( X, Y, W, 24 ); { Fl_Menu_Bar *o = new Fl_Menu_Bar( X, Y, W, 24 );
o->add( "&Project/&New" ); o->add( "&Project/&New" );
o->add( "&Project/&Open" ); o->add( "&Project/&Open" );
o->add( "&Project/&Quit" ); o->add( "&Project/&Save", FL_CTRL + 's', 0, 0 );
o->add( "&Mixer/&Add Strip" ); o->add( "&Project/&Quit", FL_CTRL + 'q', 0, 0 );
o->add( "&Mixer/&Add Strip", 'a', 0, 0 );
o->add( "&Options" ); o->add( "&Options" );
o->callback( cb_menu, this );
} }
{ Fl_Scroll *o = scroll = new Fl_Scroll( X, Y + 24, W, H - 24 ); { Fl_Scroll *o = scroll = new Fl_Scroll( X, Y + 24, W, H - 24 );
o->box( FL_NO_BOX ); o->box( FL_NO_BOX );
@ -211,7 +261,7 @@ Mixer::save ( void )
{ {
MESSAGE( "Saving state" ); MESSAGE( "Saving state" );
Loggable::snapshot_callback( &Mixer::snapshot, this ); Loggable::snapshot_callback( &Mixer::snapshot, this );
Loggable::snapshot( "save.mix" ); Loggable::snapshot( "snapshot" );
return true; return true;
} }
@ -226,23 +276,6 @@ Mixer::handle ( int m )
case FL_ENTER: case FL_ENTER:
case FL_LEAVE: case FL_LEAVE:
return 1; return 1;
case FL_SHORTCUT:
{
if ( Fl::event_key() == 'a' )
{
new_strip();
return 1;
}
else if ( Fl::event_ctrl() && Fl::event_key() == 's' )
{
// save();
Project::save();
return 1;
}
else
return r;
break;
}
default: default:
return r; return r;
break; break;

View File

@ -37,6 +37,9 @@ private:
void snapshot ( void ); void snapshot ( void );
static void snapshot ( void *v ) { ((Mixer*)v)->snapshot(); } static void snapshot ( void *v ) { ((Mixer*)v)->snapshot(); }
void cb_menu(Fl_Widget*);
static void cb_menu(Fl_Widget*, void*);
Fl_Scroll *scroll; Fl_Scroll *scroll;
Fl_Pack *pack; Fl_Pack *pack;

View File

@ -208,16 +208,16 @@ Mixer_Strip::handle_module_added ( Module *m )
DMESSAGE( "Connecting controls to default module \"%s\"", m->name() ); DMESSAGE( "Connecting controls to default module \"%s\"", m->name() );
/* connect default modules to their default controllers/indicators */ /* connect default modules to their default controllers/indicators */
if ( ! strcmp( m->name(), "JACK" ) && m->ninputs() == 0 ) if ( 0 == strcmp( m->name(), "JACK" ) && m->ninputs() == 0 )
{ {
if ( !jack_input_controller->control_output[0].connected() ) if ( !jack_input_controller->control_output[0].connected() )
jack_input_controller->connect_to( &m->control_input[1] ); jack_input_controller->connect_to( &m->control_input[1] );
} }
else if ( ! strcmp( m->name(), "Gain" ) ) else if ( 0 == strcmp( m->name(), "Gain" ) )
{ {
gain_controller->connect_to( &m->control_input[0] ); gain_controller->connect_to( &m->control_input[0] );
} }
else if ( ! strcmp( m->name(), "Meter" ) ) else if ( 0 == strcmp( m->name(), "Meter" ) )
{ {
meter_indicator->connect_to( &m->control_output[0] ); meter_indicator->connect_to( &m->control_output[0] );
} }
@ -327,7 +327,6 @@ Mixer_Strip::init ( )
Fl_Group::current()->resizable(o); Fl_Group::current()->resizable(o);
} }
o->end(); o->end();
Fl_Group::current()->resizable(o); Fl_Group::current()->resizable(o);
} // Fl_Group* o } // Fl_Group* o

View File

@ -46,8 +46,8 @@ class Module : public Fl_Group, public Loggable {
Module_Parameter_Editor *_editor; Module_Parameter_Editor *_editor;
void cb_handle(Fl_Widget*); /* void cb_handle(Fl_Widget*); */
static void cb_handle(Fl_Widget*, void*); /* static void cb_handle(Fl_Widget*, void*); */
void init ( void ); void init ( void );

View File

@ -266,6 +266,8 @@ Project::open ( const char *name )
// timeline->zoom_fit(); // timeline->zoom_fit();
MESSAGE( "Loaded project \"%s\"", name ); MESSAGE( "Loaded project \"%s\"", name );
return 0; return 0;
@ -293,7 +295,7 @@ Project::create ( const char *name, const char *template_name )
if ( chdir( name ) ) if ( chdir( name ) )
FATAL( "WTF? Cannot change to new project directory" ); FATAL( "WTF? Cannot change to new project directory" );
mkdir( "sources", 0777 ); // mkdir( "sources", 0777 );
creat( "snapshot", 0666 ); creat( "snapshot", 0666 );
/* TODO: copy template */ /* TODO: copy template */