From 8b95806b2fd050435c0101d8a3208c7a25e477e2 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 31 Jan 2010 18:25:14 -0600 Subject: [PATCH] Mixer: Improve keyboard focus. --- FL/Fl_Packscroller.H | 1 + Mixer/Controller_Module.C | 2 ++ Mixer/Meter_Indicator_Module.C | 2 ++ Mixer/Mixer_Strip.C | 14 +++++++------- Mixer/Mixer_Strip.H | 2 -- Mixer/Module.C | 14 ++++++++++++++ Mixer/Module_Parameter_Editor.C | 3 +++ 7 files changed, 29 insertions(+), 9 deletions(-) diff --git a/FL/Fl_Packscroller.H b/FL/Fl_Packscroller.H index 9d4fd4e..5877fe0 100644 --- a/FL/Fl_Packscroller.H +++ b/FL/Fl_Packscroller.H @@ -170,6 +170,7 @@ public: case FL_LEAVE: return 1; case FL_FOCUS: + case FL_UNFOCUS: return 1; case FL_KEYBOARD: { diff --git a/Mixer/Controller_Module.C b/Mixer/Controller_Module.C index badf5a6..2a96d5e 100644 --- a/Mixer/Controller_Module.C +++ b/Mixer/Controller_Module.C @@ -262,6 +262,7 @@ Controller_Module::connect_to ( Port *p ) control_value = p->control_value(); + w->set_visible_focus(); w->align(FL_ALIGN_TOP); w->labelsize( 10 ); w->callback( cb_handle, this ); @@ -269,6 +270,7 @@ Controller_Module::connect_to ( Port *p ) if ( _pad ) { Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( w ); + flg->set_visible_focus(); size( flg->w(), flg->h() ); add( flg ); } diff --git a/Mixer/Meter_Indicator_Module.C b/Mixer/Meter_Indicator_Module.C index 004c35a..979d88f 100644 --- a/Mixer/Meter_Indicator_Module.C +++ b/Mixer/Meter_Indicator_Module.C @@ -64,6 +64,8 @@ Meter_Indicator_Module::Meter_Indicator_Module ( bool is_default ) end(); + clear_visible_focus(); + Fl::add_timeout( CONTROL_UPDATE_FREQ, update_cb, this ); } diff --git a/Mixer/Mixer_Strip.C b/Mixer/Mixer_Strip.C index e1903f5..5cf2c3d 100644 --- a/Mixer/Mixer_Strip.C +++ b/Mixer/Mixer_Strip.C @@ -304,7 +304,7 @@ Mixer_Strip::update ( void ) void Mixer_Strip::init ( ) { - selection_color( FL_FOREGROUND_COLOR ); + selection_color( FL_RED ); _chain = 0; @@ -313,6 +313,7 @@ Mixer_Strip::init ( ) Fl_Group::color( FL_BACKGROUND_COLOR ); + set_visible_focus(); clip_children( 1 ); Fl_Pack *gain_pack; @@ -469,7 +470,7 @@ Mixer_Strip::draw ( void ) if ( damage() != FL_DAMAGE_USER1 ) Fl_Group::draw(); - Fl_Group::draw_box( FL_ROUNDED_FRAME, x(), y(), w(), h(), _focused ? Fl_Group::selection_color() : FL_BLACK ); + Fl_Group::draw_box( FL_UP_FRAME, x(), y(), w(), h(), Fl::focus() == this ? Fl_Group::selection_color() : FL_BLACK ); } @@ -588,7 +589,8 @@ Mixer_Strip::handle ( int m ) if ( Fl_Group::handle( m ) ) return 1; - else if ( test_press( FL_BUTTON3 ) ) + + if ( test_press( FL_BUTTON3 ) ) { menu_popup( &menu() ); return 1; @@ -597,13 +599,11 @@ Mixer_Strip::handle ( int m ) return 0; } case FL_FOCUS: - _focused = true; damage( FL_DAMAGE_USER1 ); - return 1; + return Fl_Group::handle( m ) || 1; case FL_UNFOCUS: - _focused = false; damage( FL_DAMAGE_USER1 ); - return 1; + return Fl_Group::handle( m ) || 1; } return Fl_Group::handle( m ); diff --git a/Mixer/Mixer_Strip.H b/Mixer/Mixer_Strip.H index 56347e2..08727f3 100644 --- a/Mixer/Mixer_Strip.H +++ b/Mixer/Mixer_Strip.H @@ -109,8 +109,6 @@ private: void cb_handle(Fl_Widget*); static void cb_handle(Fl_Widget*, void*); - bool _focused; - void set_tab ( void ); void update_port_names ( void ); diff --git a/Mixer/Module.C b/Mixer/Module.C index 27d6b15..e29cb1d 100644 --- a/Mixer/Module.C +++ b/Mixer/Module.C @@ -95,9 +95,12 @@ Module::init ( void ) _chain = 0; _instances = 1; _bypass = 0; + box( FL_UP_BOX ); labeltype( FL_NO_LABEL ); clip_children( 1 ); + set_visible_focus(); + selection_color( FL_RED ); } @@ -325,6 +328,11 @@ Module::draw_box ( void ) fl_draw_box( box(), tx + (spacing * i), ty, tw / instances(), th, Fl::belowmouse() == this ? fl_lighter( c ) : c ); } + if ( this == Fl::focus() ) + { + fl_draw_box( FL_UP_FRAME, x(), y(), w(), h(), selection_color() ); + } + if ( audio_input.size() && audio_output.size() ) { /* maybe draw control indicators */ @@ -556,6 +564,8 @@ Module::handle ( int m ) } case FL_PUSH: { + take_focus(); + if ( Fl_Group::handle( m ) ) return 1; else if ( test_press( FL_BUTTON3 ) ) @@ -582,6 +592,10 @@ Module::handle ( int m ) return 0; } + case FL_FOCUS: + case FL_UNFOCUS: + redraw(); + return 1; } return Fl_Group::handle( m ); diff --git a/Mixer/Module_Parameter_Editor.C b/Mixer/Module_Parameter_Editor.C index 102d187..95f01a6 100644 --- a/Mixer/Module_Parameter_Editor.C +++ b/Mixer/Module_Parameter_Editor.C @@ -239,6 +239,9 @@ Module_Parameter_Editor::make_controls ( void ) o->resizable( 0 ); o->end(); + o->set_visible_focus(); + flg->set_visible_focus(); + flg->position( o->x(), o->y() ); bound->position( o->x(), flg->y() + flg->h() ); o->size( flg->w(), flg->h() + bound->h() );