diff --git a/common/block_commande.cpp b/common/block_commande.cpp index 00a77af7e9..1ae3fa3a92 100644 --- a/common/block_commande.cpp +++ b/common/block_commande.cpp @@ -93,7 +93,7 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame ) break; case BLOCK_ZOOM: // Window Zoom - msg = _( "Win Zoom" ); + msg = _( "Zoom to selection" ); break; case BLOCK_ROTATE: // Rotate 90 deg diff --git a/eeschema/libedit_onleftclick.cpp b/eeschema/libedit_onleftclick.cpp index da6c97ad83..85febe8563 100644 --- a/eeschema/libedit_onleftclick.cpp +++ b/eeschema/libedit_onleftclick.cpp @@ -71,6 +71,9 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) switch( GetToolId() ) { + case ID_ZOOM_SELECTION: + break; + case ID_NO_TOOL_SELECTED: // If an item is currently in edit, finish edit if( item_in_edit ) diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index a4fc18f61f..65165b21bf 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -174,8 +174,8 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_UPDATE_UI( ID_LIBEDIT_SELECT_ALIAS, LIB_EDIT_FRAME::OnUpdateSelectAlias ) EVT_UPDATE_UI( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganNormal ) EVT_UPDATE_UI( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganConvert ) - EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnUpdateEditingPart ) - EVT_UPDATE_UI( ID_ZOOM_SELECTION, LIB_EDIT_FRAME::OnUpdateEditingPart ) + EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnUpdateSelectTool ) + EVT_UPDATE_UI( ID_ZOOM_SELECTION, LIB_EDIT_FRAME::OnUpdateSelectTool ) EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_SHOW_ELECTRICAL_TYPE, LIB_EDIT_FRAME::OnUpdateElectricalType ) @@ -474,6 +474,12 @@ void LIB_EDIT_FRAME::OnShowElectricalType( wxCommandEvent& event ) } +void LIB_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent ) +{ + aEvent.Check( GetToolId() == aEvent.GetId() ); +} + + void LIB_EDIT_FRAME::OnUpdateElectricalType( wxUpdateUIEvent& aEvent ) { aEvent.Check( GetShowElectricalType() ); @@ -1123,12 +1129,13 @@ void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event ) void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) { int id = aEvent.GetId(); + int lastToolID = GetToolId(); - if( GetToolId() == ID_NO_TOOL_SELECTED ) + if( GetToolId() == ID_NO_TOOL_SELECTED || GetToolId() == ID_ZOOM_SELECTION ) m_lastDrawItem = NULL; - m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), - wxEmptyString ); + // Stop the current command and deselect the current tool. + m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); LIB_PART* part = GetCurPart(); @@ -1139,7 +1146,11 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) break; case ID_ZOOM_SELECTION: - SetToolID( id, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) ); + // This tool is located on the main toolbar: switch it on or off on click on it + if( lastToolID != ID_ZOOM_SELECTION ) + SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) ); + else + SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); break; case ID_LIBEDIT_PIN_BUTT: diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index 5721d6c4d1..3334664cdb 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -108,6 +108,9 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case ID_NO_TOOL_SELECTED: break; + case ID_ZOOM_SELECTION: + break; + case ID_HIGHLIGHT: HighlightConnectionAtPosition( aPosition ); break; diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index cf043b1bfb..a6baccb100 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -519,6 +519,7 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent ) void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) { int id = aEvent.GetId(); + int lastToolID = GetToolId(); // Stop the current command and deselect the current tool. m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); @@ -534,7 +535,11 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) break; case ID_ZOOM_SELECTION: - SetToolID( id, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) ); + // This tool is located on the main toolbar: switch it on or off on click + if( lastToolID != ID_ZOOM_SELECTION ) + SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) ); + else + SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); break; case ID_HIERARCHY_PUSH_POP_BUTT: @@ -644,8 +649,7 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent ) { - if( aEvent.GetEventObject() == m_drawToolBar ) - aEvent.Check( GetToolId() == aEvent.GetId() ); + aEvent.Check( GetToolId() == aEvent.GetId() ); } diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index df964f751b..f4086ccc73 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -212,7 +212,11 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_ZOOM_SELECTION: - SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) ); + // This tool is located on the main toolbar: switch it on or off on click + if( GetToolId() != ID_ZOOM_SELECTION ) + SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) ); + else + SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); break; case ID_POPUP_CLOSE_CURRENT_TOOL: @@ -462,6 +466,5 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) void GERBVIEW_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent ) { - if( aEvent.GetEventObject() == m_optionsToolBar ) - aEvent.Check( GetToolId() == aEvent.GetId() ); + aEvent.Check( GetToolId() == aEvent.GetId() ); }