From 423a8428e158a518af0749acd354c00a22f95b56 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 19 Sep 2013 21:28:02 -0700 Subject: [PATCH] Mixer: Fix focus issues with new sliders. --- FL/Fl_Value_SliderX.C | 17 ++++++++++++++--- mixer/src/Controller_Module.C | 18 +++++++++++++++++- mixer/src/Controller_Module.H | 1 + mixer/src/Mixer_Strip.C | 14 ++++++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/FL/Fl_Value_SliderX.C b/FL/Fl_Value_SliderX.C index 98ca6bc..e084516 100644 --- a/FL/Fl_Value_SliderX.C +++ b/FL/Fl_Value_SliderX.C @@ -42,6 +42,17 @@ void Fl_Value_SliderX::input_cb(Fl_Widget*, void* v) { { t.value_damage(); t.do_callback(); + +// Fl::focus(NULL); + for ( Fl_Widget *p = t.parent(); p; p = p->parent() ) + { + if ( p->visible_focus() ) + { + p->take_focus(); + break; + } + } + } } } @@ -75,9 +86,9 @@ Fl_Value_SliderX::Fl_Value_SliderX(int X, int Y, int W, int H, const char*l) input.parent((Fl_Group *)this); // kludge! input.callback(input_cb, this); input.when(FL_WHEN_ENTER_KEY); - box(input.box()); - color(input.color()); - selection_color(input.selection_color()); + /* box(input.box()); */ + /* color(input.color()); */ + /* selection_color(input.selection_color()); */ align(FL_ALIGN_LEFT); value_damage(); textsize(9); diff --git a/mixer/src/Controller_Module.C b/mixer/src/Controller_Module.C index 6d98c47..e1ca791 100644 --- a/mixer/src/Controller_Module.C +++ b/mixer/src/Controller_Module.C @@ -52,6 +52,20 @@ bool Controller_Module::learn_by_number = false; bool Controller_Module::_learn_mode = false; +void +Controller_Module::take_focus ( void ) +{ + bool v = visible_focus(); + + if ( ! v ) + set_visible_focus(); + + Fl_Widget::take_focus(); + + if ( ! v ) + clear_visible_focus(); +} + Controller_Module::Controller_Module ( bool is_default ) : Module( is_default, 50, 100, name() ) { // label( "" ); @@ -72,6 +86,7 @@ Controller_Module::Controller_Module ( bool is_default ) : Module( is_default, 5 end(); +// clear_visible_focus(); log_create(); } @@ -310,6 +325,7 @@ Controller_Module::maybe_create_panner ( void ) } else { +// o->clear_visible_focus(); o->resize( x(), y(), w(), h() ); add( o ); resizable( o ); @@ -496,7 +512,7 @@ Controller_Module::connect_to ( Port *p ) control_value = p->control_value(); - w->set_visible_focus(); + w->clear_visible_focus(); w->align(FL_ALIGN_TOP); w->labelsize( 10 ); w->callback( cb_handle, this ); diff --git a/mixer/src/Controller_Module.H b/mixer/src/Controller_Module.H index 58edbcf..83973ba 100644 --- a/mixer/src/Controller_Module.H +++ b/mixer/src/Controller_Module.H @@ -105,6 +105,7 @@ public: int handle ( int m ); + void take_focus ( void ); // void set_control_value ( float f ) { control_value = f; } protected: diff --git a/mixer/src/Mixer_Strip.C b/mixer/src/Mixer_Strip.C index ce57b62..679e1f7 100644 --- a/mixer/src/Mixer_Strip.C +++ b/mixer/src/Mixer_Strip.C @@ -650,6 +650,7 @@ Mixer_Strip::init ( ) o->type( Fl_Scalepack::HORIZONTAL ); { Controller_Module *o = gain_controller = new Controller_Module( true ); o->horizontal(false); + o->clear_visible_focus(); o->pad( false ); o->size( 33, 100 ); } @@ -872,6 +873,16 @@ Mixer_Strip::menu_cb ( const Fl_Menu_ *m ) if ( Fl::event_shift() || 1 == fl_choice( "Are you sure you want to remove this strip?\n\n(this action cannot be undone)", "Cancel", "Remove", NULL ) ) command_close(); } + else if ( ! strcmp( picked, "/Gain" ) ) + { + gain_controller->take_focus(); + } + else if ( ! strcmp( picked, "/Mute" ) ) + { + ((Fl_Button*)mute_controller->child(0))->value( ! + ((Fl_Button*)mute_controller->child(0))->value()); + + } else if ( ! strcmp( picked, "Auto Output/On" ) ) { manual_connection( false ); @@ -1079,6 +1090,9 @@ Mixer_Strip::menu ( void ) const m.add( "Width/Wide", 'w', 0, 0, FL_MENU_RADIO | ( width_button->value() ? FL_MENU_VALUE : 0 ) ); m.add( "View/Fader", 'f', 0, 0, FL_MENU_RADIO | ( 0 == tab_button->value() ? FL_MENU_VALUE : 0 ) ); m.add( "View/Signal", 's', 0, 0, FL_MENU_RADIO | ( 1 == tab_button->value() ? FL_MENU_VALUE : 0 ) ); + m.add( "Mute", 'm', 0, 0, 0 ); +// ( 1 == mute_controller->control_output[0].connected_port()->control_value() ? FL_MENU_VALUE : 0 ) ); + m.add( "Gain", 'g', 0, 0 ); m.add( "Move Left", '[', 0, 0 ); m.add( "Move Right", ']', 0, 0 ); m.add( "Color", 0, 0, 0 );