From 100b23d1fb69d1447f028e60d0d8992027b08e21 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Fri, 10 Feb 2012 01:06:35 -0800 Subject: [PATCH] Mixer: Fix behavior issues of Toggle controls. --- mixer/src/Controller_Module.C | 25 ++++++++++++++++------- mixer/src/Module_Parameter_Editor.C | 31 ++++++++++++++++++++++++++--- mixer/src/Module_Parameter_Editor.H | 1 + 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/mixer/src/Controller_Module.C b/mixer/src/Controller_Module.C index b9ce74f..9b1235e 100644 --- a/mixer/src/Controller_Module.C +++ b/mixer/src/Controller_Module.C @@ -311,6 +311,9 @@ Controller_Module::connect_to ( Port *p ) o->value( p->control_value() ); _type = TOGGLE; + + /* FIXME: hack */ + control = (Fl_Valuator*)o; } else if ( p->hints.type == Module::Port::Hints::INTEGER ) { @@ -430,7 +433,13 @@ Controller_Module::cb_handle ( Fl_Widget *w, void *v ) void Controller_Module::cb_handle ( Fl_Widget *w ) { - control_value = ((Fl_Valuator*)w)->value(); + if ( type() == TOGGLE ) + { + control_value = ((Fl_Button*)w)->value(); + } + else + control_value = ((Fl_Valuator*)w)->value(); + if ( control_output[0].connected() ) control_output[0].connected_port()->control_value( control_value ); } @@ -535,11 +544,10 @@ Controller_Module::handle_control_changed ( Port *p ) if ( p ) control_value = p->control_value(); - if ( control->value() != control_value ) - { - redraw(); - DMESSAGE( "handle_control_changed" ); - } + /* if ( control->value() != control_value ) */ + /* { */ + /* redraw(); */ + /* } */ if ( type() == SPATIALIZATION ) { @@ -550,7 +558,10 @@ Controller_Module::handle_control_changed ( Port *p ) } else { - control->value(control_value); + if ( type() == TOGGLE ) + ((Fl_Button*)control)->value(control_value); + else + control->value(control_value); } } diff --git a/mixer/src/Module_Parameter_Editor.C b/mixer/src/Module_Parameter_Editor.C index 1338b4c..f521b90 100644 --- a/mixer/src/Module_Parameter_Editor.C +++ b/mixer/src/Module_Parameter_Editor.C @@ -250,7 +250,11 @@ Module_Parameter_Editor::make_controls ( void ) w->align(FL_ALIGN_TOP); w->labelsize( 10 ); - w->callback( cb_value_handle, new callback_data( this, i ) ); + + 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 ) ); { 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() ); } +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 Module_Parameter_Editor::cb_panner_value_handle ( Fl_Widget *w, void *v ) { @@ -375,11 +388,23 @@ Module_Parameter_Editor::handle_control_changed ( Module::Port *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 *g2 = (Fl_Group*)g->child( 0 ); - Fl_Valuator *v = (Fl_Valuator*)g2->child( 0 ); - v->value( p->control_value() ); + + 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 ); + + v->value( p->control_value() ); + } } void diff --git a/mixer/src/Module_Parameter_Editor.H b/mixer/src/Module_Parameter_Editor.H index b2fe550..193f17f 100644 --- a/mixer/src/Module_Parameter_Editor.H +++ b/mixer/src/Module_Parameter_Editor.H @@ -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_panner_value_handle ( Fl_Widget *w, void *v ); static void cb_mode_handle ( Fl_Widget *w, void *v );