Browse Source

Mixer: Allow controller modules to be removed.

tags/non-daw-v1.2.0
Jonathan Moore Liles 13 years ago
parent
commit
363f2f04bc
5 changed files with 71 additions and 8 deletions
  1. +23
    -0
      mixer/src/Chain.C
  2. +1
    -0
      mixer/src/Chain.H
  3. +41
    -5
      mixer/src/Controller_Module.C
  4. +3
    -0
      mixer/src/Controller_Module.H
  5. +3
    -3
      mixer/src/Module.H

+ 23
- 0
mixer/src/Chain.C View File

@@ -293,6 +293,25 @@ void Chain::cb_handle(Fl_Widget* o, void* v) {
((Chain*)(v))->cb_handle(o);
}

void
Chain::remove ( Controller_Module *m )
{
DMESSAGE( "Removing controller module from chain" );

engine()->lock();

m->disconnect();

controls_pack->remove( m );
modules_pack->remove( m );

build_process_queue();

engine()->unlock();

redraw();
}


/* remove a module from the chain. this isn't guaranteed to succeed,
* because removing the module might result in an invalid routing */
@@ -311,11 +330,15 @@ Chain::remove ( Module *m )
fl_alert( "Can't remove module at this point because the resultant chain is invalid" );
}

engine()->lock();

strip()->handle_module_removed( m );

modules_pack->remove( m );

configure_ports();

engine()->unlock();
}

/* determine number of output ports, signal if changed. */


+ 1
- 0
mixer/src/Chain.H View File

@@ -101,6 +101,7 @@ public:

int modules ( void ) const { return modules_pack->children(); }
Module *module ( int n ) const { return (Module*)modules_pack->child( n ); }
void remove ( Controller_Module *m );
void remove ( Module *m );
bool add ( Module *m );
bool add ( Controller_Module *m );


+ 41
- 5
mixer/src/Controller_Module.C View File

@@ -91,6 +91,17 @@ Controller_Module::handle_chain_name_changed()
// change_osc_path( generate_osc_path() );
}

void
Controller_Module::disconnect ( void )
{
for ( std::vector<Module::Port>::iterator i = control_output.begin();
i != control_output.end();
++i )
{
(*i).disconnect();
}
}


void
@@ -99,11 +110,21 @@ Controller_Module::get ( Log_Entry &e ) const
Module::get( e );

Port *p = control_output[0].connected_port();
Module *m = p->module();

e.add( ":module", m );
e.add( ":port", m->control_input_port_index( p ) );
e.add( ":mode", mode() );
if ( !p )
{
e.add( ":module", "" );
e.add( ":port", "" );
e.add( ":mode", "" );
}
else
{
Module *m = p->module();
e.add( ":module", m );
e.add( ":port", m->control_input_port_index( p ) );
e.add( ":mode", mode() );
}
}

void
@@ -485,6 +506,8 @@ Controller_Module::menu_cb ( const Fl_Menu_ *m )
mode( GUI );
else if ( ! strcmp( picked, "Mode/Control Voltage (JACK)" ) )
mode( CV );
else if ( ! strcmp( picked, "/Remove" ) )
command_remove();
}

/** build the context menu for this control */
@@ -498,7 +521,8 @@ Controller_Module::menu ( void )
{ "Mode", 0, 0, 0, FL_SUBMENU },
{ "GUI + OSC", 0, 0, 0, FL_MENU_RADIO | ( mode() == GUI ? FL_MENU_VALUE : 0 ) },
{ "Control Voltage (JACK)", 0, 0, 0, FL_MENU_RADIO | ( mode() == CV ? FL_MENU_VALUE : 0 ) },
{ 0 },
{ 0 },
{ "Remove", 0, 0, 0, 0 },
{ 0 },
};

@@ -569,6 +593,18 @@ Controller_Module::handle_control_changed ( Port *p )
}
}

void
Controller_Module::command_remove ( void )
{
if ( is_default() )
fl_alert( "Default modules may not be deleted." );
else
{
chain()->remove( this );
Fl::delete_widget( this );
}
}

/**********/
/* Engine */
/**********/


+ 3
- 0
mixer/src/Controller_Module.H View File

@@ -78,10 +78,13 @@ public:

void connect_to ( Port *p );
bool connect_spatializer_to ( Module *m );
void disconnect ( void );

void handle_control_changed ( Port *p );
void handle_chain_name_changed ( void );

virtual void command_remove ( void );

LOG_CREATE_FUNC( Controller_Module );

void process ( nframes_t nframes );


+ 3
- 3
mixer/src/Module.H View File

@@ -437,8 +437,8 @@ protected:
public:

void command_open_parameter_editor();
void command_activate ( void );
void command_deactivate ( void );
void command_remove ( void );
virtual void command_activate ( void );
virtual void command_deactivate ( void );
virtual void command_remove ( void );

};

Loading…
Cancel
Save