From b424dc11e18d8481c3cc35a0b300368d022555ca Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 17 Jun 2023 23:47:26 -0400 Subject: [PATCH] Hotkey feedback for inactive layer display mode --- common/dialogs/hotkey_cycle_popup.cpp | 2 +- common/tool/actions.cpp | 3 +++ include/tool/actions.h | 1 + pcbnew/tools/pcb_control.cpp | 29 +++++++++++++++++++++++++++ pcbnew/tools/pcb_control.h | 2 ++ 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/common/dialogs/hotkey_cycle_popup.cpp b/common/dialogs/hotkey_cycle_popup.cpp index 8af6d628f1..0c90e47316 100644 --- a/common/dialogs/hotkey_cycle_popup.cpp +++ b/common/dialogs/hotkey_cycle_popup.cpp @@ -77,7 +77,7 @@ void HOTKEY_CYCLE_POPUP::Popup( const wxString& aTitle, const wxArrayString& aIt m_listBox->SetSelection( std::min( aSelection, static_cast( m_listBox->GetCount() ) - 1 ) ); - int width = 0; + int width = m_stTitle->GetTextExtent( aTitle ).x; int height = 0; for( const wxString& item : aItems ) diff --git a/common/tool/actions.cpp b/common/tool/actions.cpp index 9213184e8e..dd707d6744 100644 --- a/common/tool/actions.cpp +++ b/common/tool/actions.cpp @@ -708,3 +708,6 @@ const TOOL_EVENT EVENTS::DisambiguatePoint( TC_MESSAGE, TA_ACTION, "common.Inter const TOOL_EVENT EVENTS::GridChangedByKeyEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.gridChangedByKey" ); + +const TOOL_EVENT EVENTS::ContrastModeChangedByKeyEvent( TC_MESSAGE, TA_ACTION, + "common.Interactive.contrastModeChangedByKeyEvent" ); diff --git a/include/tool/actions.h b/include/tool/actions.h index 647a2df025..a4b7c027c4 100644 --- a/include/tool/actions.h +++ b/include/tool/actions.h @@ -225,6 +225,7 @@ public: ///< Used for hotkey feedback const static TOOL_EVENT GridChangedByKeyEvent; + const static TOOL_EVENT ContrastModeChangedByKeyEvent; }; #endif // __ACTIONS_H diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index ee8d7f1e68..25e79b8a93 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -318,6 +319,33 @@ int PCB_CONTROL::HighContrastModeCycle( const TOOL_EVENT& aEvent ) m_frame->SetDisplayOptions( opts ); + m_toolMgr->PostEvent( EVENTS::ContrastModeChangedByKeyEvent ); + + return 0; +} + + +int PCB_CONTROL::ContrastModeFeedback( const TOOL_EVENT& aEvent ) +{ + if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback ) + return 0; + + PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions(); + + wxArrayString labels; + labels.Add( _( "Normal" ) ); + labels.Add( _( "Dimmed" ) ); + labels.Add( _( "Hidden" ) ); + + if( !m_frame->GetHotkeyPopup() ) + m_frame->CreateHotkeyPopup(); + + HOTKEY_CYCLE_POPUP* popup = m_frame->GetHotkeyPopup(); + + if( popup ) + popup->Popup( _( "Inactive Layer Display" ), labels, + static_cast( opts.m_ContrastModeDisplay ) ); + return 0; } @@ -1553,6 +1581,7 @@ void PCB_CONTROL::setTransitions() Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayToggle.MakeEvent() ); Go( &PCB_CONTROL::HighContrastMode, ACTIONS::highContrastMode.MakeEvent() ); Go( &PCB_CONTROL::HighContrastModeCycle, ACTIONS::highContrastModeCycle.MakeEvent() ); + Go( &PCB_CONTROL::ContrastModeFeedback, EVENTS::ContrastModeChangedByKeyEvent ); Go( &PCB_CONTROL::NetColorModeCycle, PCB_ACTIONS::netColorModeCycle.MakeEvent() ); Go( &PCB_CONTROL::RatsnestModeCycle, PCB_ACTIONS::ratsnestModeCycle.MakeEvent() ); Go( &PCB_CONTROL::FlipPcbView, PCB_ACTIONS::flipBoard.MakeEvent() ); diff --git a/pcbnew/tools/pcb_control.h b/pcbnew/tools/pcb_control.h index f1065352c3..fb8d7b8d64 100644 --- a/pcbnew/tools/pcb_control.h +++ b/pcbnew/tools/pcb_control.h @@ -65,6 +65,8 @@ public: // Update the view with the new high-contrast mode from the display settings int HighContrastMode( const TOOL_EVENT& aEvent ); + int ContrastModeFeedback( const TOOL_EVENT& aEvent ); + // Rotate through the available high-contrast, net color and ratsnest color modes int HighContrastModeCycle( const TOOL_EVENT& aEvent ); int NetColorModeCycle( const TOOL_EVENT& aEvent );