Mixer: Fix behavior issues of Toggle controls.

This commit is contained in:
Jonathan Moore Liles 2012-02-10 01:06:35 -08:00
parent a11961f9b6
commit 100b23d1fb
3 changed files with 47 additions and 10 deletions

View File

@ -311,6 +311,9 @@ Controller_Module::connect_to ( Port *p )
o->value( p->control_value() ); o->value( p->control_value() );
_type = TOGGLE; _type = TOGGLE;
/* FIXME: hack */
control = (Fl_Valuator*)o;
} }
else if ( p->hints.type == Module::Port::Hints::INTEGER ) else if ( p->hints.type == Module::Port::Hints::INTEGER )
{ {
@ -430,7 +433,13 @@ Controller_Module::cb_handle ( Fl_Widget *w, void *v )
void void
Controller_Module::cb_handle ( Fl_Widget *w ) Controller_Module::cb_handle ( Fl_Widget *w )
{ {
if ( type() == TOGGLE )
{
control_value = ((Fl_Button*)w)->value();
}
else
control_value = ((Fl_Valuator*)w)->value(); control_value = ((Fl_Valuator*)w)->value();
if ( control_output[0].connected() ) if ( control_output[0].connected() )
control_output[0].connected_port()->control_value( control_value ); control_output[0].connected_port()->control_value( control_value );
} }
@ -535,11 +544,10 @@ Controller_Module::handle_control_changed ( Port *p )
if ( p ) if ( p )
control_value = p->control_value(); control_value = p->control_value();
if ( control->value() != control_value ) /* if ( control->value() != control_value ) */
{ /* { */
redraw(); /* redraw(); */
DMESSAGE( "handle_control_changed" ); /* } */
}
if ( type() == SPATIALIZATION ) if ( type() == SPATIALIZATION )
{ {
@ -550,6 +558,9 @@ Controller_Module::handle_control_changed ( Port *p )
} }
else else
{ {
if ( type() == TOGGLE )
((Fl_Button*)control)->value(control_value);
else
control->value(control_value); control->value(control_value);
} }
} }

View File

@ -250,6 +250,10 @@ Module_Parameter_Editor::make_controls ( void )
w->align(FL_ALIGN_TOP); w->align(FL_ALIGN_TOP);
w->labelsize( 10 ); w->labelsize( 10 );
if ( p->hints.type == Module::Port::Hints::BOOLEAN )
w->callback( cb_button_handle, new callback_data( this, i ) );
else
w->callback( cb_value_handle, new callback_data( this, i ) ); w->callback( cb_value_handle, new callback_data( this, i ) );
{ Fl_Group *o = new Fl_Group( 0, 0, 50, 75 ); { Fl_Group *o = new Fl_Group( 0, 0, 50, 75 );
@ -323,6 +327,15 @@ Module_Parameter_Editor::cb_value_handle ( Fl_Widget *w, void *v )
cd->base_widget->set_value( cd->port_number[0], ((Fl_Valuator*)w)->value() ); cd->base_widget->set_value( cd->port_number[0], ((Fl_Valuator*)w)->value() );
} }
void
Module_Parameter_Editor::cb_button_handle ( Fl_Widget *w, void *v )
{
callback_data *cd = (callback_data*)v;
cd->base_widget->set_value( cd->port_number[0], ((Fl_Button*)w)->value() );
}
void void
Module_Parameter_Editor::cb_panner_value_handle ( Fl_Widget *w, void *v ) Module_Parameter_Editor::cb_panner_value_handle ( Fl_Widget *w, void *v )
{ {
@ -375,12 +388,24 @@ Module_Parameter_Editor::handle_control_changed ( Module::Port *p )
{ {
int i = _module->control_input_port_index( p ); int i = _module->control_input_port_index( p );
/* FIXME: very hacky in that it assumes the control is an Fl_Valuator... (which buttons are not) */
Fl_Group *g = (Fl_Group*)control_pack->child( i ); Fl_Group *g = (Fl_Group*)control_pack->child( i );
Fl_Group *g2 = (Fl_Group*)g->child( 0 ); Fl_Group *g2 = (Fl_Group*)g->child( 0 );
if ( p->hints.type == Module::Port::Hints::BOOLEAN )
{
Fl_Button *v = (Fl_Button*)g2->child( 0 );
v->value( p->control_value() );
}
else
{
Fl_Valuator *v = (Fl_Valuator*)g2->child( 0 ); Fl_Valuator *v = (Fl_Valuator*)g2->child( 0 );
v->value( p->control_value() ); v->value( p->control_value() );
} }
}
void void
Module_Parameter_Editor::set_value (int i, float value ) Module_Parameter_Editor::set_value (int i, float value )

View File

@ -52,6 +52,7 @@ class Module_Parameter_Editor : public Fl_Double_Window
}; };
static void cb_button_handle ( Fl_Widget *w, void *v );
static void cb_value_handle ( Fl_Widget *w, void *v ); static void cb_value_handle ( Fl_Widget *w, void *v );
static void cb_panner_value_handle ( Fl_Widget *w, void *v ); static void cb_panner_value_handle ( Fl_Widget *w, void *v );
static void cb_mode_handle ( Fl_Widget *w, void *v ); static void cb_mode_handle ( Fl_Widget *w, void *v );