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 <mars@montik.net>
This commit is contained in:
Martin Sivak 2018-01-12 11:40:55 +01:00 committed by Wayne Stambaugh
parent 7a28f3d4cf
commit d5cdd78062
10 changed files with 31 additions and 20 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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 );

View File

@ -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;

View File

@ -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;

View File

@ -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:

View File

@ -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;