From 1ada4863fc88f0bc83020433ff62783af36d73dd Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 13 Jun 2017 09:23:56 +0200 Subject: [PATCH] Pcbnew: fix incorrect UI behavior of "Zoom to selection" tool in GAL canvas. --- include/draw_frame.h | 3 +++ pcbnew/toolbars_update_user_interface.cpp | 3 +-- pcbnew/tools/zoom_tool.cpp | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/draw_frame.h b/include/draw_frame.h index 1642e2227a..b942a48b8e 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -389,6 +389,9 @@ public: virtual void ReCreateMenuBar() override; virtual void ReCreateAuxiliaryToolbar(); + // Toolbar accessors + wxAuiToolBar* GetMainToolBar() const { return m_mainToolBar; } + /** * Function SetToolID * sets the tool command ID to \a aId and sets the cursor to \a aCursor. The diff --git a/pcbnew/toolbars_update_user_interface.cpp b/pcbnew/toolbars_update_user_interface.cpp index 4ccc68670d..8c840613ab 100644 --- a/pcbnew/toolbars_update_user_interface.cpp +++ b/pcbnew/toolbars_update_user_interface.cpp @@ -211,8 +211,7 @@ void PCB_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent ) void PCB_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent ) { - if( aEvent.GetEventObject() == m_drawToolBar ) - aEvent.Check( GetToolId() == aEvent.GetId() ); + aEvent.Check( GetToolId() == aEvent.GetId() ); } void PCB_EDIT_FRAME::OnUpdateMuWaveToolbar( wxUpdateUIEvent& aEvent ) diff --git a/pcbnew/tools/zoom_tool.cpp b/pcbnew/tools/zoom_tool.cpp index 6a42b1bbfe..4f332c404e 100644 --- a/pcbnew/tools/zoom_tool.cpp +++ b/pcbnew/tools/zoom_tool.cpp @@ -47,6 +47,12 @@ void ZOOM_TOOL::Reset( RESET_REASON aReason ) int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent ) { + // This method is called both when the zoom tool is activated (on) or deactivated (off) + bool zoom_tool_is_on = m_frame->GetMainToolBar()->GetToolToggled( ID_ZOOM_SELECTION ); + + if( !zoom_tool_is_on ) // This is a tool deselection: do nothing + return 0; + m_frame->SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) ); while( auto evt = Wait() ) @@ -64,6 +70,7 @@ int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent ) m_toolMgr->PassEvent(); } + // Exit zoom tool m_frame->SetNoToolSelected(); return 0; }