Mixer: Refuse to bypass modules whose channel configuration makes bypassing illogical.

This commit is contained in:
Jonathan Moore Liles 2013-03-15 00:05:23 -07:00
parent f29a132dfc
commit b1eb988257
2 changed files with 23 additions and 3 deletions

View File

@ -700,7 +700,14 @@ Module::menu_cb ( const Fl_Menu_ *m )
if ( ! strcmp( picked, "Edit Parameters" ) ) if ( ! strcmp( picked, "Edit Parameters" ) )
command_open_parameter_editor(); command_open_parameter_editor();
else if ( ! strcmp( picked, "Bypass" ) ) else if ( ! strcmp( picked, "Bypass" ) )
if ( ! bypassable() )
{
fl_alert( "Due to its channel configuration, this module cannot be bypassed." );
}
else
{
bypass( ! ( m->mvalue()->flags & FL_MENU_VALUE ) ); bypass( ! ( m->mvalue()->flags & FL_MENU_VALUE ) );
}
else if ( ! strcmp( picked, "Cut" ) ) else if ( ! strcmp( picked, "Cut" ) )
{ {
copy(); copy();
@ -817,9 +824,16 @@ Module::handle ( int m )
return 1; return 1;
} }
else if ( test_press( FL_BUTTON2 ) ) else if ( test_press( FL_BUTTON2 ) )
{
if ( !bypassable() )
{
fl_alert( "Due to its channel configuration, this module cannot be bypassed." );
}
else
{ {
bypass( !bypass() ); bypass( !bypass() );
redraw(); redraw();
}
return 1; return 1;
} }

View File

@ -354,6 +354,12 @@ public:
virtual bool bypass ( void ) const { return _bypass; } virtual bool bypass ( void ) const { return _bypass; }
virtual void bypass ( bool v ) { _bypass = v; redraw(); } virtual void bypass ( bool v ) { _bypass = v; redraw(); }
virtual bool bypassable ( void ) const
{
return ninputs() == noutputs() ||
( ninputs() == 1 && noutputs() == 2 );
}
int control_input_port_index ( Port *p ) int control_input_port_index ( Port *p )
{ {
for ( nframes_t i = control_input.size(); i--; ) for ( nframes_t i = control_input.size(); i--; )