2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
/* Copyright (C) 2008 Jonathan Moore Liles */
|
|
|
|
/* */
|
|
|
|
/* This program is free software; you can redistribute it and/or modify it */
|
|
|
|
/* under the terms of the GNU General Public License as published by the */
|
|
|
|
/* Free Software Foundation; either version 2 of the License, or (at your */
|
|
|
|
/* option) any later version. */
|
|
|
|
/* */
|
|
|
|
/* This program is distributed in the hope that it will be useful, but WITHOUT */
|
|
|
|
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
|
|
|
|
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
|
|
|
|
/* more details. */
|
|
|
|
/* */
|
|
|
|
/* You should have received a copy of the GNU General Public License along */
|
|
|
|
/* with This program; see the file COPYING. If not,write to the Free Software */
|
|
|
|
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
2010-02-01 03:54:26 +01:00
|
|
|
#include "const.h"
|
|
|
|
|
2010-01-25 03:12:10 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
#include <FL/Fl.H>
|
2010-01-18 06:48:50 +01:00
|
|
|
#include <FL/Fl_Double_Window.H>
|
2009-12-25 01:59:39 +01:00
|
|
|
#include <FL/Fl_Scroll.H>
|
2010-01-25 03:12:10 +01:00
|
|
|
#include <FL/Fl_Tooltip.H>
|
|
|
|
#include <FL/fl_ask.H>
|
2010-01-26 07:49:59 +01:00
|
|
|
#include <FL/Fl_Shared_Image.H>
|
2009-12-25 01:59:39 +01:00
|
|
|
#include <FL/Fl_Pack.H>
|
2010-01-25 03:12:10 +01:00
|
|
|
#include <FL/Boxtypes.H>
|
2009-12-25 01:59:39 +01:00
|
|
|
#include "util/Thread.H"
|
|
|
|
#include "util/debug.h"
|
|
|
|
|
2010-01-25 03:12:10 +01:00
|
|
|
#include "Mixer.H"
|
|
|
|
#include "Project.H"
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
#include "Loggable.H"
|
2009-12-28 06:25:28 +01:00
|
|
|
|
|
|
|
/* for registration */
|
|
|
|
#include "Module.H"
|
|
|
|
#include "Gain_Module.H"
|
|
|
|
#include "Plugin_Module.H"
|
|
|
|
#include "JACK_Module.H"
|
|
|
|
#include "Meter_Module.H"
|
|
|
|
#include "Meter_Indicator_Module.H"
|
|
|
|
#include "Controller_Module.H"
|
2010-01-18 04:16:31 +01:00
|
|
|
#include "Mono_Pan_Module.H"
|
2009-12-28 06:25:28 +01:00
|
|
|
#include "Chain.H"
|
2010-01-25 03:12:10 +01:00
|
|
|
#include "Mixer_Strip.H"
|
2009-12-28 06:25:28 +01:00
|
|
|
|
2010-01-24 03:45:53 +01:00
|
|
|
|
|
|
|
/* TODO: put these in a header */
|
|
|
|
#define USER_CONFIG_DIR ".non-mixer/"
|
|
|
|
|
|
|
|
char *user_config_dir;
|
2010-01-25 03:12:10 +01:00
|
|
|
Mixer *mixer;
|
2010-01-24 03:45:53 +01:00
|
|
|
|
2010-02-01 05:21:05 +01:00
|
|
|
const char *instance_name;
|
|
|
|
|
2010-01-24 03:45:53 +01:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
static int
|
|
|
|
ensure_dirs ( void )
|
|
|
|
{
|
|
|
|
asprintf( &user_config_dir, "%s/%s", getenv( "HOME" ), USER_CONFIG_DIR );
|
|
|
|
|
|
|
|
int r = mkdir( user_config_dir, 0777 );
|
|
|
|
|
|
|
|
return r == 0 || errno == EEXIST;
|
|
|
|
}
|
2009-12-28 06:25:28 +01:00
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
2010-02-01 07:23:01 +01:00
|
|
|
static void cb_main ( Fl_Double_Window *o, void *)
|
2010-01-12 06:31:02 +01:00
|
|
|
{
|
2010-01-27 05:11:30 +01:00
|
|
|
if ( Fl::event_key() != FL_Escape )
|
|
|
|
o->hide();
|
2010-01-12 06:31:02 +01:00
|
|
|
}
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
int
|
|
|
|
main ( int argc, char **argv )
|
|
|
|
{
|
|
|
|
Thread::init();
|
|
|
|
|
|
|
|
Thread thread( "UI" );
|
|
|
|
thread.set();
|
|
|
|
|
2010-01-24 03:45:53 +01:00
|
|
|
ensure_dirs();
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
Fl_Tooltip::color( FL_BLACK );
|
|
|
|
Fl_Tooltip::textcolor( FL_YELLOW );
|
|
|
|
Fl_Tooltip::size( 14 );
|
|
|
|
Fl_Tooltip::hoverdelay( 0.1f );
|
|
|
|
|
2010-01-28 02:58:01 +01:00
|
|
|
Fl::visible_focus( 0 );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
2010-01-26 07:49:59 +01:00
|
|
|
fl_register_images();
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
LOG_REGISTER_CREATE( Mixer_Strip );
|
2009-12-28 06:25:28 +01:00
|
|
|
LOG_REGISTER_CREATE( Chain );
|
|
|
|
LOG_REGISTER_CREATE( Plugin_Module );
|
|
|
|
LOG_REGISTER_CREATE( Gain_Module );
|
|
|
|
LOG_REGISTER_CREATE( Meter_Module );
|
|
|
|
LOG_REGISTER_CREATE( JACK_Module );
|
2010-01-18 04:16:31 +01:00
|
|
|
LOG_REGISTER_CREATE( Mono_Pan_Module );
|
2009-12-28 06:25:28 +01:00
|
|
|
LOG_REGISTER_CREATE( Meter_Indicator_Module );
|
|
|
|
LOG_REGISTER_CREATE( Controller_Module );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
init_boxtypes();
|
|
|
|
|
2009-12-28 06:25:28 +01:00
|
|
|
signal( SIGPIPE, SIG_IGN );
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
Fl::get_system_colors();
|
|
|
|
Fl::scheme( "plastic" );
|
|
|
|
|
2010-01-20 08:43:22 +01:00
|
|
|
Plugin_Module::spawn_discover_thread();
|
|
|
|
|
2010-01-18 06:48:50 +01:00
|
|
|
Fl_Double_Window *main_window;
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
{
|
2010-02-01 07:07:01 +01:00
|
|
|
Fl_Double_Window *o = main_window = new Fl_Double_Window( 800, 600, "Non-DAW : Mixer" );
|
2010-01-12 06:31:02 +01:00
|
|
|
{
|
2010-02-01 03:54:26 +01:00
|
|
|
main_window->xclass( APP_NAME );
|
|
|
|
|
2010-01-12 06:31:02 +01:00
|
|
|
Fl_Widget *o = mixer = new Mixer( 0, 0, main_window->w(), main_window->h(), NULL );
|
|
|
|
Fl_Group::current()->resizable(o);
|
|
|
|
}
|
|
|
|
o->end();
|
2009-12-25 01:59:39 +01:00
|
|
|
|
2010-01-27 05:11:30 +01:00
|
|
|
o->callback( (Fl_Callback*)cb_main, main_window );
|
2010-01-12 06:31:02 +01:00
|
|
|
o->show( argc, argv );
|
|
|
|
}
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
{
|
2010-02-01 05:21:05 +01:00
|
|
|
int r = argc - 1;
|
|
|
|
int i = 1;
|
|
|
|
for ( ; i < argc; ++i, --r )
|
2009-12-25 01:59:39 +01:00
|
|
|
{
|
2010-02-01 05:21:05 +01:00
|
|
|
if ( !strcmp( argv[i], "--instance" ) )
|
2010-01-12 06:31:02 +01:00
|
|
|
{
|
2010-02-01 05:21:05 +01:00
|
|
|
if ( r > 1 )
|
|
|
|
{
|
|
|
|
MESSAGE( "Using instance name \"%s\"", argv[i+1] );
|
|
|
|
instance_name = argv[i+1];
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FATAL( "Missing instance name" );
|
|
|
|
}
|
2010-01-12 06:31:02 +01:00
|
|
|
}
|
2010-02-01 05:21:05 +01:00
|
|
|
else if ( !strncmp( argv[i], "--", 2 ) )
|
|
|
|
{
|
|
|
|
WARNING( "Unrecognized option: %s", argv[i] );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
2009-12-25 01:59:39 +01:00
|
|
|
}
|
2010-02-01 05:21:05 +01:00
|
|
|
|
|
|
|
if ( r >= 1 )
|
2009-12-25 01:59:39 +01:00
|
|
|
{
|
2010-02-01 05:21:05 +01:00
|
|
|
MESSAGE( "Loading \"%s\"", argv[i] );
|
|
|
|
|
|
|
|
if ( ! mixer->command_load( argv[i] ) )
|
|
|
|
{
|
|
|
|
fl_alert( "Error opening project specified on commandline" );
|
|
|
|
}
|
2009-12-25 01:59:39 +01:00
|
|
|
}
|
2010-02-01 05:21:05 +01:00
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Fl::run();
|
|
|
|
|
2010-01-16 09:00:47 +01:00
|
|
|
delete main_window;
|
|
|
|
main_window = NULL;
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
MESSAGE( "Your fun is over" );
|
|
|
|
}
|