Treat undo as backspace and/or escape when drawing. Ignore redo.
Undo == backspace when drawing a polygon or chained lines. Otherwise it's an escape. Fixes https://gitlab.com/kicad/code/kicad/-/issues/14961
This commit is contained in:
parent
b3235ce667
commit
ef6866757e
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017-2022 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017-2023 Kicad Developers, see AUTHORS.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
|
||||
|
@ -117,6 +117,12 @@ bool POLYGON_GEOM_MANAGER::IsPolygonInProgress() const
|
|||
}
|
||||
|
||||
|
||||
int POLYGON_GEOM_MANAGER::PolygonPointCount() const
|
||||
{
|
||||
return m_lockedPoints.PointCount();
|
||||
}
|
||||
|
||||
|
||||
bool POLYGON_GEOM_MANAGER::NewPointClosesOutline( const VECTOR2I& aPt ) const
|
||||
{
|
||||
return m_lockedPoints.PointCount() > 0 && m_lockedPoints.CPoint( 0 ) == aPt;
|
||||
|
|
|
@ -506,11 +506,20 @@ void SCH_EDIT_FRAME::setupUIConditions()
|
|||
return m_auimgr.GetPane( NetNavigatorPaneName() ).IsShown();
|
||||
};
|
||||
|
||||
auto undoCond =
|
||||
[ this ] (const SELECTION& aSel )
|
||||
{
|
||||
if( SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( aSel ) )
|
||||
return true;
|
||||
|
||||
return GetUndoCommandCount() > 0;
|
||||
};
|
||||
|
||||
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
||||
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
|
||||
|
||||
mgr->SetConditions( ACTIONS::save, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
||||
mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
|
||||
mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
|
||||
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
|
||||
|
||||
mgr->SetConditions( EE_ACTIONS::showSearch, CHECK( searchPaneCond ) );
|
||||
|
|
|
@ -254,7 +254,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
|||
bool isSyntheticClick = symbol && evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->Matches( aEvent );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
m_frame->GetInfoBar()->Dismiss();
|
||||
|
||||
|
@ -451,6 +451,10 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
cleanup();
|
||||
}
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
|
@ -546,7 +550,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
bool isSyntheticClick = image && evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->Matches( aEvent );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
m_frame->GetInfoBar()->Dismiss();
|
||||
|
||||
|
@ -685,6 +689,10 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
cleanup();
|
||||
}
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
|
@ -798,7 +806,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
|||
cursorPos = grid.BestSnapAnchor( cursorPos, LAYER_CONNECTABLE, nullptr );
|
||||
controls->ForceCursorPosition( true, cursorPos );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
|
@ -929,6 +937,10 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
|||
evt->SetPassEvent();
|
||||
}
|
||||
}
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
|
@ -1244,7 +1256,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
};
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
m_frame->GetInfoBar()->Dismiss();
|
||||
|
||||
|
@ -1499,6 +1511,10 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
cleanup();
|
||||
}
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
|
@ -1576,7 +1592,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->Matches( aEvent );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
if( item )
|
||||
{
|
||||
|
@ -1725,6 +1741,10 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
||||
}
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
|
@ -1792,7 +1812,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
|||
bool isSyntheticClick = sheet && evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->Matches( aEvent );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
m_frame->GetInfoBar()->Dismiss();
|
||||
|
||||
|
@ -1916,6 +1936,10 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
||||
}
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
|
|
|
@ -892,7 +892,7 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const TOOL_EVENT& aTool, int aType,
|
|||
m_view->AddToPreview( wire->Clone() );
|
||||
}
|
||||
}
|
||||
else if( evt->IsAction( &EE_ACTIONS::undoLastSegment ) )
|
||||
else if( evt->IsAction( &EE_ACTIONS::undoLastSegment ) || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
if( ( currentMode == LINE_MODE::LINE_MODE_FREE && m_wires.size() > 1 )
|
||||
|| ( LINE_MODE::LINE_MODE_90 && m_wires.size() > 2 ) )
|
||||
|
@ -1005,6 +1005,10 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const TOOL_EVENT& aTool, int aType,
|
|||
{
|
||||
cleanup();
|
||||
}
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017-2022 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017-2023 Kicad Developers, see AUTHORS.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
|
||||
|
@ -141,6 +141,8 @@ public:
|
|||
*/
|
||||
bool IsPolygonInProgress() const;
|
||||
|
||||
int PolygonPointCount() const;
|
||||
|
||||
/**
|
||||
* @return true if locking in the given point would close the current polygon.
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.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
|
||||
|
@ -60,13 +60,10 @@ public:
|
|||
void SetEnd( const VECTOR2I& aEnd )
|
||||
{
|
||||
if( m_angleSnap )
|
||||
{
|
||||
m_end = GetVectorSnapped45( aEnd - m_origin ) + m_origin;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_end = aEnd;
|
||||
}
|
||||
|
||||
setGeometryChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 Ian McInerney <ian.s.mcinerney at ieee.org>
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.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
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
*
|
||||
* @return Functor testing if the undo queue has items.
|
||||
*/
|
||||
SELECTION_CONDITION UndoAvailable();
|
||||
virtual SELECTION_CONDITION UndoAvailable();
|
||||
|
||||
/**
|
||||
* Create a functor that tests if there are any items in the redo queue.
|
||||
|
|
|
@ -681,13 +681,24 @@ void PCB_EDIT_FRAME::setupUIConditions()
|
|||
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
|
||||
PCB_EDITOR_CONDITIONS cond( this );
|
||||
|
||||
auto undoCond =
|
||||
[ this ] (const SELECTION& aSel )
|
||||
{
|
||||
DRAWING_TOOL* drawingTool = m_toolManager->GetTool<DRAWING_TOOL>();
|
||||
|
||||
if( drawingTool && drawingTool->GetDrawingMode() != DRAWING_TOOL::MODE::NONE )
|
||||
return true;
|
||||
|
||||
return GetUndoCommandCount() > 0;
|
||||
};
|
||||
|
||||
wxASSERT( mgr );
|
||||
|
||||
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
||||
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
|
||||
|
||||
mgr->SetConditions( ACTIONS::save, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
||||
mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
|
||||
mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
|
||||
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
|
||||
|
||||
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
|
||||
|
|
|
@ -599,7 +599,7 @@ int DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
COORDS_PADDING );
|
||||
m_controls->ForceCursorPosition( true, cursorPos );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
if( image )
|
||||
{
|
||||
|
@ -740,6 +740,10 @@ int DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
wxBell();
|
||||
}
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
|
@ -831,7 +835,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||
COORDS_PADDING );
|
||||
m_controls->ForceCursorPosition( true, cursorPos );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
if( text )
|
||||
{
|
||||
|
@ -995,6 +999,10 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||
evt->SetPassEvent();
|
||||
}
|
||||
}
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
|
@ -1115,7 +1123,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_controls->ForceCursorPosition( true, cursorPos );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
m_controls->SetAutoPan( false );
|
||||
|
||||
|
@ -1440,6 +1448,10 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
wxBell();
|
||||
}
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
|
@ -1851,7 +1863,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
|||
COORDS_PADDING );
|
||||
m_controls->ForceCursorPosition( true, cursorPos );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
cleanup();
|
||||
|
||||
|
@ -2066,6 +2078,10 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
|||
m_view->Update( &preview );
|
||||
frame()->SetMsgPanel( graphic );
|
||||
}
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else if( graphic && evt->IsAction( &PCB_ACTIONS::decWidth ) )
|
||||
{
|
||||
if( (unsigned) m_stroke.GetWidth() > WIDTH_STEP )
|
||||
|
@ -2225,7 +2241,7 @@ bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
|||
grid.BestSnapAnchor( m_controls->GetMousePosition(), graphic ), COORDS_PADDING );
|
||||
m_controls->ForceCursorPosition( true, cursorPos );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
cleanup();
|
||||
|
||||
|
@ -2386,6 +2402,10 @@ bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
|||
{
|
||||
wxBell();
|
||||
}
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
|
@ -2548,9 +2568,13 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
|||
polyGeomMgr.SetLeaderMode( Is45Limited() ? POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45
|
||||
: POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
if( polyGeomMgr.IsPolygonInProgress() )
|
||||
if( polyGeomMgr.PolygonPointCount() >= 2 && evt->IsAction( &ACTIONS::undo ) )
|
||||
{
|
||||
polyGeomMgr.DeleteLastCorner();
|
||||
}
|
||||
else if( polyGeomMgr.IsPolygonInProgress() )
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
@ -2672,6 +2696,10 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
|||
// m_view->Update( &zoneAsst );
|
||||
evt->SetPassEvent();
|
||||
}*/
|
||||
else if( evt->IsAction( &ACTIONS::redo ) )
|
||||
{
|
||||
wxBell();
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
|
|
Loading…
Reference in New Issue