Fix broken behavior of the "Zoom to selection" tool in Gerbview and Eeschema.

This commit is contained in:
jean-pierre charras 2017-06-10 09:06:25 +02:00
parent d37a33723a
commit 526b5e2cd3
6 changed files with 37 additions and 13 deletions

View File

@ -93,7 +93,7 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
break; break;
case BLOCK_ZOOM: // Window Zoom case BLOCK_ZOOM: // Window Zoom
msg = _( "Win Zoom" ); msg = _( "Zoom to selection" );
break; break;
case BLOCK_ROTATE: // Rotate 90 deg case BLOCK_ROTATE: // Rotate 90 deg

View File

@ -71,6 +71,9 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
switch( GetToolId() ) switch( GetToolId() )
{ {
case ID_ZOOM_SELECTION:
break;
case ID_NO_TOOL_SELECTED: case ID_NO_TOOL_SELECTED:
// If an item is currently in edit, finish edit // If an item is currently in edit, finish edit
if( item_in_edit ) if( item_in_edit )

View File

@ -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_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_NORMAL_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganNormal )
EVT_UPDATE_UI( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganConvert ) 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_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI( ID_ZOOM_SELECTION, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_ZOOM_SELECTION, LIB_EDIT_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT, EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
LIB_EDIT_FRAME::OnUpdateEditingPart ) LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_SHOW_ELECTRICAL_TYPE, LIB_EDIT_FRAME::OnUpdateElectricalType ) 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 ) void LIB_EDIT_FRAME::OnUpdateElectricalType( wxUpdateUIEvent& aEvent )
{ {
aEvent.Check( GetShowElectricalType() ); aEvent.Check( GetShowElectricalType() );
@ -1123,12 +1129,13 @@ void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event )
void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
{ {
int id = aEvent.GetId(); 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_lastDrawItem = NULL;
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), // Stop the current command and deselect the current tool.
wxEmptyString ); m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
LIB_PART* part = GetCurPart(); LIB_PART* part = GetCurPart();
@ -1139,7 +1146,11 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
break; break;
case ID_ZOOM_SELECTION: 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; break;
case ID_LIBEDIT_PIN_BUTT: case ID_LIBEDIT_PIN_BUTT:

View File

@ -108,6 +108,9 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_NO_TOOL_SELECTED: case ID_NO_TOOL_SELECTED:
break; break;
case ID_ZOOM_SELECTION:
break;
case ID_HIGHLIGHT: case ID_HIGHLIGHT:
HighlightConnectionAtPosition( aPosition ); HighlightConnectionAtPosition( aPosition );
break; break;

View File

@ -519,6 +519,7 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
{ {
int id = aEvent.GetId(); int id = aEvent.GetId();
int lastToolID = GetToolId();
// Stop the current command and deselect the current tool. // Stop the current command and deselect the current tool.
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
@ -534,7 +535,11 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
break; break;
case ID_ZOOM_SELECTION: 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; break;
case ID_HIERARCHY_PUSH_POP_BUTT: case ID_HIERARCHY_PUSH_POP_BUTT:
@ -644,8 +649,7 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent ) void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
{ {
if( aEvent.GetEventObject() == m_drawToolBar ) aEvent.Check( GetToolId() == aEvent.GetId() );
aEvent.Check( GetToolId() == aEvent.GetId() );
} }

View File

@ -212,7 +212,11 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_ZOOM_SELECTION: 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; break;
case ID_POPUP_CLOSE_CURRENT_TOOL: case ID_POPUP_CLOSE_CURRENT_TOOL:
@ -462,6 +466,5 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
void GERBVIEW_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent ) void GERBVIEW_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
{ {
if( aEvent.GetEventObject() == m_optionsToolBar ) aEvent.Check( GetToolId() == aEvent.GetId() );
aEvent.Check( GetToolId() == aEvent.GetId() );
} }