Commit 9d8c684a authored by jean-pierre charras's avatar jean-pierre charras

Libedit and Modedit: fix minor, but annoying issues when editing items

parents 5742bfb8 aaabdeae
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2006-2012 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file dialog_lib_edit_draw_item.cpp
*/
#include <dialog_lib_edit_draw_item.h>
......
......@@ -29,13 +29,10 @@
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <eeschema_id.h>
#include <general.h>
#include <protos.h>
#include <libeditframe.h>
#include <class_libentry.h>
......@@ -43,19 +40,17 @@
void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
{
LIB_ITEM* item = m_drawItem;
bool no_item_edited = item == NULL || item->GetFlags() == 0;
if( m_component == NULL ) // No component loaded !
return;
if( item == NULL || item->GetFlags() == 0 )
if( ( GetToolId() == ID_NO_TOOL_SELECTED ) && no_item_edited )
{
item = LocateItemUsingCursor( aPosition );
if( item )
{
item->DisplayInfo( this );
}
else
{
DisplayCmpDoc();
......@@ -84,7 +79,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
break;
case ID_LIBEDIT_PIN_BUTT:
if( m_drawItem == NULL || m_drawItem->GetFlags() == 0 )
if( no_item_edited )
{
CreatePin( DC );
}
......@@ -99,7 +94,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
case ID_LIBEDIT_BODY_RECT_BUTT:
case ID_LIBEDIT_BODY_TEXT_BUTT:
if( m_drawItem == NULL || m_drawItem->GetFlags() == 0 )
if( no_item_edited )
{
m_drawItem = CreateGraphicItem( m_component, DC );
}
......
......@@ -68,19 +68,19 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem )
dialog.SetWidthUnits( ReturnUnitSymbol( g_UserUnit ) );
wxString val = ReturnStringFromValue( g_UserUnit, m_drawLineWidth );
wxString val = ReturnStringFromValue( g_UserUnit, DrawItem->GetWidth() );
dialog.SetWidth( val );
dialog.SetApplyToAllUnits( !m_drawSpecificUnit );
dialog.SetApplyToAllUnits( DrawItem->GetUnit() == 0 );
dialog.EnableApplyToAllUnits( component && component->GetPartCount() > 1 );
dialog.SetApplyToAllConversions( !m_drawSpecificConvert );
dialog.SetApplyToAllConversions( DrawItem->GetConvert() == 0 );
dialog.EnableApplyToAllConversions( component && component->HasConversion() );
// dialog.SetFillStyle( m_drawFillStyle ); // could better to show the current setting
dialog.SetFillStyle( DrawItem->GetFillMode() );
dialog.EnableFillStyle( DrawItem->IsFillable() );
if( dialog.ShowModal() == wxID_CANCEL )
return;
// Init default values (used to create a new draw item)
val = dialog.GetWidth();
m_drawLineWidth = ReturnValueFromString( g_UserUnit, val );
m_drawSpecificConvert = !dialog.GetApplyToAllConversions();
......
......@@ -58,19 +58,20 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
}
}
}
}
item = GetCurItem();
if( !item || (item->GetFlags() == 0) )
{
if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT )
&& !wxGetKeyState( WXK_CONTROL ) )
item = ModeditLocateAndDisplay();
else
{
if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT )
&& !wxGetKeyState( WXK_CONTROL ) )
item = ModeditLocateAndDisplay();
SetCurItem( item );
SetCurItem( item );
}
}
item = GetCurItem();
bool no_item_edited = item == NULL || item->GetFlags() == 0;
switch( GetToolId() )
{
case ID_NO_TOOL_SELECTED:
......@@ -79,7 +80,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_MODEDIT_CIRCLE_TOOL:
case ID_MODEDIT_ARC_TOOL:
case ID_MODEDIT_LINE_TOOL:
if( !item || item->GetFlags() == 0 )
if( no_item_edited )
{
STROKE_T shape = S_SEGMENT;
......@@ -117,9 +118,9 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break;
case ID_MODEDIT_DELETE_TOOL:
if( item == NULL || // No item to delete
(item->GetFlags() != 0) ) // Item in edit, cannot delete it
if( ! no_item_edited ) // Item in edit, cannot delete it
break;
item = ModeditLocateAndDisplay();
if( item->Type() != PCB_MODULE_T ) // Cannot delete the module itself
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment