From eadfff8ac4450b453e0018328459ce3b5904f040 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 10 Jun 2017 10:07:11 +0200 Subject: [PATCH] Better management of the "Zoom to selection" tool in page layout editor. - the useless "arrow tool" is removed. - the "Zoom to selection" tool enable or disable the Zoom to selection (this is a on/off tool) - When enabled, it can be disabled by the popup context menu, like in others applications. --- pagelayout_editor/events_functions.cpp | 15 ++++++++++----- pagelayout_editor/onrightclick.cpp | 10 +++++++++- pagelayout_editor/pl_editor_frame.cpp | 2 +- pagelayout_editor/toolbars_pl_editor.cpp | 4 ---- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/pagelayout_editor/events_functions.cpp b/pagelayout_editor/events_functions.cpp index 44a7df4bac..e34461b1d9 100644 --- a/pagelayout_editor/events_functions.cpp +++ b/pagelayout_editor/events_functions.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN - * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. * @author Jean-Pierre Charras, jp.charras at wanadoo.fr * * This program is free software; you can redistribute it and/or @@ -97,13 +97,15 @@ BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME ) EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner) EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::Process_Special_Functions) - // Vertical toolbar: + // the ID_NO_TOOL_SELECTED id TOOL does not existing currently, but the right click + // popup menu can generate this event. EVT_TOOL( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::Process_Special_Functions ) EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE, PL_EDITOR_FRAME::Process_Special_Functions ) EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::OnUpdateSelectTool ) + EVT_UPDATE_UI( ID_ZOOM_SELECTION, PL_EDITOR_FRAME::OnUpdateSelectTool ) EVT_UPDATE_UI( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode ) EVT_UPDATE_UI( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode ) @@ -130,7 +132,11 @@ void PL_EDITOR_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_SELECT_PAGE_NUMBER: @@ -602,6 +608,5 @@ void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode( wxUpdateUIEvent& eve void PL_EDITOR_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent ) { - if( aEvent.GetEventObject() == m_mainToolBar ) - aEvent.Check( GetToolId() == aEvent.GetId() ); + aEvent.Check( GetToolId() == aEvent.GetId() ); } diff --git a/pagelayout_editor/onrightclick.cpp b/pagelayout_editor/onrightclick.cpp index a95d820f60..5a5a3b315c 100644 --- a/pagelayout_editor/onrightclick.cpp +++ b/pagelayout_editor/onrightclick.cpp @@ -6,7 +6,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 CERN * * This program is free software; you can redistribute it and/or @@ -64,6 +64,14 @@ bool PL_EDITOR_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* aPopMenu ) bool busy = GetScreen()->GetCurItem() != NULL; wxString msg; + // If the tool ID_ZOOM_SELECTION is currently in use, add a + if( GetToolId() == ID_ZOOM_SELECTION && !busy ) + { + AddMenuItem( aPopMenu, ID_NO_TOOL_SELECTED, _( "End Tool" ), + KiBitmap( cursor_xpm ) ); + aPopMenu->AppendSeparator(); + } + if( ! busy ) // No item currently edited { WORKSHEET_DATAITEM* old_item = m_treePagelayout->GetPageLayoutSelectedItem(); diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 4991b8fd7f..35f5afa38e 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN - * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. * @author Jean-Pierre Charras, jp.charras at wanadoo.fr * * This program is free software; you can redistribute it and/or diff --git a/pagelayout_editor/toolbars_pl_editor.cpp b/pagelayout_editor/toolbars_pl_editor.cpp index 2bd84cb5b7..7a0009aa42 100644 --- a/pagelayout_editor/toolbars_pl_editor.cpp +++ b/pagelayout_editor/toolbars_pl_editor.cpp @@ -92,10 +92,6 @@ void PL_EDITOR_FRAME::ReCreateHToolbar( void ) m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiBitmap( zoom_area_xpm ), _( "Zoom to selection" ), wxITEM_CHECK ); - m_mainToolBar->AddSeparator(); - m_mainToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ), - wxEmptyString, wxITEM_CHECK ); - // Display mode switch m_mainToolBar->AddSeparator(); m_mainToolBar->AddTool( ID_SHOW_REAL_MODE, wxEmptyString,