Smarten up double-click handing in PCBNew drawing tool.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/15700
This commit is contained in:
parent
c2c71facb1
commit
aef0f44b8e
|
@ -46,7 +46,6 @@ public:
|
|||
{
|
||||
m_origin = aOrigin;
|
||||
m_originSet = true;
|
||||
setGeometryChanged();
|
||||
}
|
||||
|
||||
VECTOR2I GetOrigin() const
|
||||
|
@ -63,8 +62,6 @@ public:
|
|||
m_end = GetVectorSnapped45( aEnd - m_origin ) + m_origin;
|
||||
else
|
||||
m_end = aEnd;
|
||||
|
||||
setGeometryChanged();
|
||||
}
|
||||
|
||||
VECTOR2I GetEnd() const
|
||||
|
@ -96,40 +93,18 @@ public:
|
|||
void Reset()
|
||||
{
|
||||
m_originSet = false;
|
||||
setGeometryChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the geometry has changed, eg such that a client should redraw.
|
||||
*/
|
||||
bool HasGeometryChanged() const
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return m_changed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the geometry changed flag, call after the client code has updated everything as
|
||||
* needed.
|
||||
*/
|
||||
void ClearGeometryChanged()
|
||||
{
|
||||
m_changed = false;
|
||||
}
|
||||
|
||||
protected:
|
||||
///< Mark the geometry as changed for clients to notice
|
||||
void setGeometryChanged()
|
||||
{
|
||||
m_changed = true;
|
||||
return !m_originSet || m_origin == m_end;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
VECTOR2I m_origin, m_end;
|
||||
VECTOR2I m_origin;
|
||||
VECTOR2I m_end;
|
||||
bool m_angleSnap = false;
|
||||
|
||||
///< Has the geometry changed such that a client should redraw?
|
||||
bool m_changed = false;
|
||||
bool m_originSet = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -1985,29 +1985,23 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
|||
{
|
||||
PCB_SHAPE* snapItem = dynamic_cast<PCB_SHAPE*>( grid.GetSnapped() );
|
||||
|
||||
if( shape == SHAPE_T::SEGMENT && ( twoPointMgr.GetOrigin() == twoPointMgr.GetEnd()
|
||||
|| evt->IsDblClick( BUT_LEFT )
|
||||
|| snapItem ) )
|
||||
if( shape == SHAPE_T::SEGMENT && snapItem && graphic->GetLength() > 0 )
|
||||
{
|
||||
// User has clicked twice in the same spot
|
||||
// or clicked on the end of an existing segment (closing a path)
|
||||
// User has clicked on the end of an existing segment, closing a path
|
||||
BOARD_COMMIT commit( m_frame );
|
||||
|
||||
// If the user clicks on an existing snap point from a drawsegment
|
||||
// we finish the segment as they are likely closing a path
|
||||
if( snapItem && graphic->GetLength() > 0.0 )
|
||||
{
|
||||
commit.Add( graphic );
|
||||
commit.Push( _( "Draw Line" ) );
|
||||
m_toolMgr->RunAction<EDA_ITEM*>( PCB_ACTIONS::selectItem, graphic );
|
||||
}
|
||||
else
|
||||
{
|
||||
delete graphic;
|
||||
}
|
||||
|
||||
graphic = nullptr;
|
||||
}
|
||||
else if( twoPointMgr.IsEmpty() || evt->IsDblClick( BUT_LEFT ) )
|
||||
{
|
||||
// User has clicked twice in the same spot, meaning we're finished
|
||||
delete graphic;
|
||||
graphic = nullptr;
|
||||
}
|
||||
|
||||
preview.Clear();
|
||||
twoPointMgr.Reset();
|
||||
|
|
Loading…
Reference in New Issue