Fix rotate bug in symbol library editor.

The rotate hotkey was rotating individual items when a block was selected
which is invalid behavior.  Add check for block mode and disable rotating
items when block mode is active.

Fixes: lp:1660875

https://bugs.launchpad.net/kicad/+bug/1660875
This commit is contained in:
Wayne Stambaugh 2017-02-01 10:45:21 -05:00
parent 77af6547c1
commit 9319ef034d
1 changed files with 23 additions and 12 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2008-2017 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -225,10 +225,12 @@ static EDA_HOTKEY HkLoadSchematic( _HKI( "Load Schematic" ), HK_LOAD_SCH, 'L' +
static EDA_HOTKEY HkAutoplaceFields( _HKI( "Autoplace Fields" ), HK_AUTOPLACE_FIELDS, 'O',
ID_AUTOPLACE_FIELDS );
static EDA_HOTKEY HkUpdatePcbFromSch( _HKI( "Update PCB from Schematics" ), HK_UPDATE_PCB_FROM_SCH, WXK_F8 );
static EDA_HOTKEY HkUpdatePcbFromSch( _HKI( "Update PCB from Schematics" ), HK_UPDATE_PCB_FROM_SCH,
WXK_F8 );
// Higtlight connection
static EDA_HOTKEY HkHighlightConnection( _HKI( "Highlight Connection" ), ID_HOTKEY_HIGHLIGHT, 'X' + GR_KB_CTRL );
static EDA_HOTKEY HkHighlightConnection( _HKI( "Highlight Connection" ), ID_HOTKEY_HIGHLIGHT,
'X' + GR_KB_CTRL );
// List of common hotkey descriptors
static EDA_HOTKEY* common_Hotkey_List[] =
@ -645,8 +647,6 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
cmd.SetEventObject( this );
bool itemInEdit = m_drawItem && m_drawItem->InEditMode();
/* Convert lower to upper case (the usual toupper function has problem
* with non ascii codes like function keys */
if( (aHotKey >= 'a') && (aHotKey <= 'z') )
@ -660,6 +660,10 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
if( hotKey == NULL )
return false;
bool itemInEdit = GetScreen()->GetCurItem() && GetScreen()->GetCurItem()->GetFlags();
bool blocInProgress = GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK;
switch( hotKey->m_Idcommand )
{
default:
@ -744,13 +748,20 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break;
case HK_ROTATE:
if( ! itemInEdit )
if( blocInProgress )
{
GetScreen()->m_BlockLocate.SetCommand( BLOCK_ROTATE );
HandleBlockPlace( aDC );
}
else
{
m_drawItem = LocateItemUsingCursor( aPosition );
if( m_drawItem )
{
cmd.SetId( ID_LIBEDIT_ROTATE_ITEM );
GetEventHandler()->ProcessEvent( cmd );
if( m_drawItem )
{
cmd.SetId( ID_LIBEDIT_ROTATE_ITEM );
GetEventHandler()->ProcessEvent( cmd );
}
}
break;
@ -802,6 +813,7 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
}
}
break;
case HK_MIRROR_Y: // Mirror Y
m_drawItem = LocateItemUsingCursor( aPosition );
cmd.SetId( ID_LIBEDIT_MIRROR_Y );
@ -831,8 +843,7 @@ EDA_HOTKEY* LIB_VIEW_FRAME::GetHotKeyDescription( int aCommand ) const
}
bool LIB_VIEW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
EDA_ITEM* aItem )
bool LIB_VIEW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
{
if( aHotKey == 0 )
return false;