From d5cdd780627085d9ad42acb9489612784b513c67 Mon Sep 17 00:00:00 2001 From: Martin Sivak Date: Fri, 12 Jan 2018 11:40:55 +0100 Subject: [PATCH] eeschema: keystroke zoom should obey disabled centering Keystroke zoom (F1/F2) always centered the screen, because it was handled as ID_POPUP_ZOOM_IN event. Mousewheel scrolling was ok, because it is handled using different event based on the configuration. This patch introduces special event ids for keystroke zooming that are then properly translated to either ID_POPUP_ZOOM_IN or ID_OFFCENTER_ZOOM_IN depending on the configuration. The same issue is fixed for legacy canvas pcbnew. Fixes: lp:1742567 * https://bugs.launchpad.net/kicad/+bug/1742567 Signed-off-by: Martin Sivak --- common/zoom.cpp | 8 ++++++++ cvpcb/class_DisplayFootprintsFrame.cpp | 4 ++-- eeschema/hotkeys.cpp | 12 ++++++------ gerbview/hotkeys.cpp | 4 ++-- include/id.h | 3 +++ pagelayout_editor/hotkeys.cpp | 4 ++-- pcbnew/footprint_wizard_frame.cpp | 4 ++-- pcbnew/hotkeys.cpp | 4 ++-- pcbnew/hotkeys_board_editor.cpp | 4 ++-- pcbnew/hotkeys_module_editor.cpp | 4 ++-- 10 files changed, 31 insertions(+), 20 deletions(-) diff --git a/common/zoom.cpp b/common/zoom.cpp index 216a4ad926..bb17df0199 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -132,6 +132,14 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) BASE_SCREEN* screen = GetScreen(); wxPoint center = GetScrollCenterPosition(); + if ( id == ID_KEY_ZOOM_IN ) { + id = GetCanvas()->GetEnableZoomNoCenter() ? + ID_OFFCENTER_ZOOM_IN : ID_POPUP_ZOOM_IN; + } else if ( id == ID_KEY_ZOOM_OUT ) { + id = GetCanvas()->GetEnableZoomNoCenter() ? + ID_OFFCENTER_ZOOM_OUT : ID_POPUP_ZOOM_OUT; + } + switch( id ) { case ID_OFFCENTER_ZOOM_IN: diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 352d43912b..57c072c210 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -339,12 +339,12 @@ bool DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi switch( aHotKey ) { case WXK_F1: - cmd.SetId( ID_POPUP_ZOOM_IN ); + cmd.SetId( ID_KEY_ZOOM_IN ); GetEventHandler()->ProcessEvent( cmd ); break; case WXK_F2: - cmd.SetId( ID_POPUP_ZOOM_OUT ); + cmd.SetId( ID_KEY_ZOOM_OUT ); GetEventHandler()->ProcessEvent( cmd ); break; diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index 7a60d70e23..e13187b7e7 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -103,16 +103,16 @@ static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, GR_KB_CTR // Zoom In #if !defined( __WXMAC__ ) -static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1, ID_POPUP_ZOOM_IN ); +static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1, ID_KEY_ZOOM_IN ); #else -static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, GR_KB_CTRL + '+', ID_POPUP_ZOOM_IN ); +static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, GR_KB_CTRL + '+', ID_KEY_ZOOM_IN ); #endif // Zoom Out #if !defined( __WXMAC__ ) -static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2, ID_POPUP_ZOOM_OUT ); +static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2, ID_KEY_ZOOM_OUT ); #else -static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-', ID_POPUP_ZOOM_OUT ); +static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-', ID_KEY_ZOOM_OUT ); #endif static EDA_HOTKEY HkHelp( _HKI( "Help (this window)" ), HK_HELP, '?' ); @@ -907,12 +907,12 @@ bool LIB_VIEW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, break; case HK_ZOOM_IN: - cmd.SetId( ID_POPUP_ZOOM_IN ); + cmd.SetId( ID_KEY_ZOOM_IN ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_OUT: - cmd.SetId( ID_POPUP_ZOOM_OUT ); + cmd.SetId( ID_KEY_ZOOM_OUT ); GetEventHandler()->ProcessEvent( cmd ); break; diff --git a/gerbview/hotkeys.cpp b/gerbview/hotkeys.cpp index 19ed1315a9..a3f17d58fb 100644 --- a/gerbview/hotkeys.cpp +++ b/gerbview/hotkeys.cpp @@ -169,12 +169,12 @@ bool GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit break; case HK_ZOOM_IN: - cmd.SetId( ID_POPUP_ZOOM_IN ); + cmd.SetId( ID_KEY_ZOOM_IN ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_OUT: - cmd.SetId( ID_POPUP_ZOOM_OUT ); + cmd.SetId( ID_KEY_ZOOM_OUT ); GetEventHandler()->ProcessEvent( cmd ); break; diff --git a/include/id.h b/include/id.h index 1ca5b4dacc..bfb6e14416 100644 --- a/include/id.h +++ b/include/id.h @@ -191,6 +191,9 @@ enum main_id ID_POPUP_ZOOM_PAGE, ID_POPUP_ZOOM_REDRAW, + ID_KEY_ZOOM_IN, + ID_KEY_ZOOM_OUT, + /* Reserve IDs for popup menu zoom levels. If you need more * levels of zoom, change ID_POPUP_ZOOM_LEVEL_END. Note that more * than 15 entries in a context submenu may get too large to display diff --git a/pagelayout_editor/hotkeys.cpp b/pagelayout_editor/hotkeys.cpp index 4648f98f1a..b2fcea142f 100644 --- a/pagelayout_editor/hotkeys.cpp +++ b/pagelayout_editor/hotkeys.cpp @@ -75,8 +75,8 @@ static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME, ID static EDA_HOTKEY HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4, ID_POPUP_ZOOM_CENTER ); static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3, ID_ZOOM_REDRAW ); -static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2, ID_POPUP_ZOOM_OUT ); -static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1, ID_POPUP_ZOOM_IN ); +static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2, ID_KEY_ZOOM_OUT ); +static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1, ID_KEY_ZOOM_IN ); static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ), HK_ZOOM_SELECTION, '@', ID_ZOOM_SELECTION ); static EDA_HOTKEY HkHelp( _HKI( "Help (this window)" ), HK_HELP, '?' ); static EDA_HOTKEY HkMoveItem( _HKI( "Move Item" ), HK_MOVE_ITEM, 'M', ID_POPUP_ITEM_MOVE ); diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 6ec4b61064..dd5453dd2a 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -550,13 +550,13 @@ bool FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition switch( aHotKey ) { case WXK_F1: - cmd.SetId( ID_POPUP_ZOOM_IN ); + cmd.SetId( ID_KEY_ZOOM_IN ); GetEventHandler()->ProcessEvent( cmd ); keyHandled = true; break; case WXK_F2: - cmd.SetId( ID_POPUP_ZOOM_OUT ); + cmd.SetId( ID_KEY_ZOOM_OUT ); GetEventHandler()->ProcessEvent( cmd ); keyHandled = true; break; diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 1a8b740fdc..b80089976e 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -430,12 +430,12 @@ bool FOOTPRINT_VIEWER_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aP break; case HK_ZOOM_IN: - cmd.SetId( ID_POPUP_ZOOM_IN ); + cmd.SetId( ID_KEY_ZOOM_IN ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_OUT: - cmd.SetId( ID_POPUP_ZOOM_OUT ); + cmd.SetId( ID_KEY_ZOOM_OUT ); GetEventHandler()->ProcessEvent( cmd ); break; diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index b3af034f4d..ea41f05d03 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -222,11 +222,11 @@ bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit break; case HK_ZOOM_IN: - evt_type = ID_POPUP_ZOOM_IN; + evt_type = ID_KEY_ZOOM_IN; break; case HK_ZOOM_OUT: - evt_type = ID_POPUP_ZOOM_OUT; + evt_type = ID_KEY_ZOOM_OUT; break; case HK_ZOOM_REDRAW: diff --git a/pcbnew/hotkeys_module_editor.cpp b/pcbnew/hotkeys_module_editor.cpp index ef8ffca1af..1713e1bccf 100644 --- a/pcbnew/hotkeys_module_editor.cpp +++ b/pcbnew/hotkeys_module_editor.cpp @@ -123,12 +123,12 @@ bool FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPos break; case HK_ZOOM_IN: - cmd.SetId( ID_POPUP_ZOOM_IN ); + cmd.SetId( ID_KEY_ZOOM_IN ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_OUT: - cmd.SetId( ID_POPUP_ZOOM_OUT ); + cmd.SetId( ID_KEY_ZOOM_OUT ); GetEventHandler()->ProcessEvent( cmd ); break;