From c9d858eaf5bb86b37184dff55a806e64c6239c17 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 24 Oct 2021 13:15:53 +0100 Subject: [PATCH] Add status bar message for constraint mode. Fixes https://gitlab.com/kicad/code/kicad/issues/9282 --- common/eda_draw_frame.cpp | 26 ++++++++++++++++++-------- gerbview/gerbview_frame.cpp | 6 ++++-- include/eda_draw_frame.h | 2 ++ pcbnew/pcb_base_frame.cpp | 5 +++-- pcbnew/tools/drawing_tool.cpp | 23 ++++++++++++++++++++++- pcbnew/tools/drawing_tool.h | 2 ++ 6 files changed, 51 insertions(+), 13 deletions(-) diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index b26f3ceb52..796c3162ee 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -111,11 +111,12 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame m_auimgr.SetFlags( wxAUI_MGR_DEFAULT ); - CreateStatusBar( 7 ); + CreateStatusBar( 8 ); // set the size of the status bar subwindows: wxWindow* stsbar = GetStatusBar(); + int spacer = KIUI::GetTextSize( wxT( "M" ), stsbar ).x * 2; int dims[] = { @@ -126,22 +127,25 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame // as the width of '0' unless the font is fixed width, and it usually won't be. // zoom: - KIUI::GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10, + KIUI::GetTextSize( wxT( "Z 762000" ), stsbar ).x + spacer, // cursor coords - KIUI::GetTextSize( wxT( "X 0234.567890 Y 0234.567890" ), stsbar ).x + 10, + KIUI::GetTextSize( wxT( "X 1234.1234 Y 1234.1234" ), stsbar ).x + spacer, // delta distances - KIUI::GetTextSize( wxT( "dx 0234.567890 dx 0234.567890 d 0234.567890" ), stsbar ).x + 10, + KIUI::GetTextSize( wxT( "dx 1234.1234 dy 1234.1234 dist 1234.1234" ), stsbar ).x + spacer, // grid size - KIUI::GetTextSize( wxT( "grid X 0234.567890 Y 0234.567890" ), stsbar ).x + 10, + KIUI::GetTextSize( wxT( "grid X 1234.1234 Y 1234.1234" ), stsbar ).x + spacer, // units display, Inches is bigger than mm - KIUI::GetTextSize( _( "Inches" ), stsbar ).x + 10, + KIUI::GetTextSize( _( "Inches" ), stsbar ).x + spacer, - // Size for the "Current Tool" panel; longest string from SetTool() - KIUI::GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10, + // Size for the "Current Tool" panel; longest string from SetTool() + KIUI::GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + spacer, + + // constraint mode + KIUI::GetTextSize( _( "Constrain to H, V, 45" ), stsbar ).x + spacer }; SetStatusWidths( arrayDim( dims ), dims ); @@ -517,6 +521,12 @@ void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg ) } +void EDA_DRAW_FRAME::DisplayConstraintsMsg( const wxString& msg ) +{ + SetStatusText( msg, 7 ); +} + + void EDA_DRAW_FRAME::DisplayGridMsg() { wxString line; diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index edb05ae6fd..5eb27bd2df 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -942,13 +942,15 @@ void GERBVIEW_FRAME::SetGridColor( const COLOR4D& aColor ) void GERBVIEW_FRAME::DisplayGridMsg() { + VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize(); wxString line; line.Printf( "grid X %s Y %s", - MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ), - MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y ) ); + MessageTextFromValue( m_userUnits, gridSize.x, false ), + MessageTextFromValue( m_userUnits, gridSize.y, false ) ); SetStatusText( line, 4 ); + SetStatusText( line, 4 ); } diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index c0450e8a36..79ab0cfe56 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -324,6 +324,8 @@ public: void DisplayToolMsg( const wxString& msg ) override; + void DisplayConstraintsMsg( const wxString& msg ); + /** * Called when modifying the page settings. * In derived classes it can be used to modify parameters like draw area size, diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index f322b40678..91270abec7 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -611,11 +611,12 @@ GENERAL_COLLECTORS_GUIDE PCB_BASE_FRAME::GetCollectorsGuide() void PCB_BASE_FRAME::DisplayGridMsg() { + VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize(); wxString line; line.Printf( "grid X %s Y %s", - MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ), - MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y ) ); + MessageTextFromValue( m_userUnits, gridSize.x, false ), + MessageTextFromValue( m_userUnits, gridSize.y, false ) ); SetStatusText( line, 4 ); } diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index b5a9e75af5..55c8a6e72d 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -25,7 +25,8 @@ #include "drawing_tool.h" - +#include +#include #include #include #include @@ -239,6 +240,8 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason ) m_controls = getViewControls(); m_board = getModel(); m_frame = getEditFrame(); + + updateStatusBar(); } @@ -248,6 +251,22 @@ DRAWING_TOOL::MODE DRAWING_TOOL::GetDrawingMode() const } +void DRAWING_TOOL::updateStatusBar() const +{ + if( m_frame ) + { + bool constrained; + + if( m_frame->IsType( FRAME_PCB_EDITOR ) ) + constrained = m_frame->Settings().m_PcbUse45DegreeLimit; + else + constrained = m_frame->Settings().m_FpeditUse45DegreeLimit; + + m_frame->DisplayConstraintsMsg( constrained ? _( "Constrain to H, V, 45" ) : _( "" ) ); + } +} + + int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent ) { if( m_isFootprintEditor && !m_frame->GetModel() ) @@ -1381,6 +1400,8 @@ int DRAWING_TOOL::ToggleLine45degMode( const TOOL_EVENT& toolEvent ) else m_frame->Settings().m_FpeditUse45DegreeLimit = !m_frame->Settings().m_FpeditUse45DegreeLimit; + updateStatusBar(); + return 0; } diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index 0a320722a7..c520ee8b38 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -261,6 +261,8 @@ private: ///< Return the appropriate width for a segment depending on the settings. int getSegmentWidth( PCB_LAYER_ID aLayer ) const; + void updateStatusBar() const; + KIGFX::VIEW* m_view; KIGFX::VIEW_CONTROLS* m_controls; BOARD* m_board;