Browse Source

Mixer: Fix behavior issues of Toggle controls.

tags/non-daw-v1.1.0
Jonathan Moore Liles 13 years ago
parent
commit
100b23d1fb
3 changed files with 47 additions and 10 deletions
  1. +18
    -7
      mixer/src/Controller_Module.C
  2. +28
    -3
      mixer/src/Module_Parameter_Editor.C
  3. +1
    -0
      mixer/src/Module_Parameter_Editor.H

+ 18
- 7
mixer/src/Controller_Module.C 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 )
{ {
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() ) 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 )
{
redraw();
DMESSAGE( "handle_control_changed" );
}
/* if ( control->value() != control_value ) */
/* { */
/* redraw(); */
/* } */


if ( type() == SPATIALIZATION ) if ( type() == SPATIALIZATION )
{ {
@@ -550,7 +558,10 @@ Controller_Module::handle_control_changed ( Port *p )
} }
else else
{ {
control->value(control_value);
if ( type() == TOGGLE )
((Fl_Button*)control)->value(control_value);
else
control->value(control_value);
} }
} }




+ 28
- 3
mixer/src/Module_Parameter_Editor.C View File

@@ -250,7 +250,11 @@ Module_Parameter_Editor::make_controls ( void )


w->align(FL_ALIGN_TOP); w->align(FL_ALIGN_TOP);
w->labelsize( 10 ); 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 ); { 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,11 +388,23 @@ 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 );
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 void


+ 1
- 0
mixer/src/Module_Parameter_Editor.H 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 );


Loading…
Cancel
Save