Make the gerbview ruler tool more like the pcb ruler tool

* Allow the ruler to persist after clicking once on the canvas
This commit is contained in:
Ian McInerney 2020-10-08 00:45:47 +01:00
parent 7e17b39755
commit 50405b558e
2 changed files with 13 additions and 22 deletions

View File

@ -585,7 +585,9 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
const VECTOR2I cursorPos = controls.GetCursorPosition();
auto clearRuler = [&] () {
auto clearRuler =
[&] ()
{
view.SetVisible( &ruler, false );
controls.SetAutoPan( false );
controls.CaptureCursor( false );
@ -595,7 +597,9 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
if( evt->IsCancelInteractive() )
{
if( originSet )
{
clearRuler();
}
else
{
m_frame->PopTool( tool );
@ -622,12 +626,9 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
// click or drag starts
else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
{
if( !evt->IsDrag( BUT_LEFT ) )
{
twoPtMgr.SetOrigin( cursorPos );
twoPtMgr.SetEnd( cursorPos );
}
controls.CaptureCursor( true );
controls.SetAutoPan( true );
@ -635,14 +636,6 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
originSet = true;
}
else if( !originSet && evt->IsMotion() )
{
// make sure the origin is set before a drag starts
// otherwise you can miss a step
twoPtMgr.SetOrigin( cursorPos );
twoPtMgr.SetEnd( cursorPos );
}
// second click or mouse up after drag ends
else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
{
@ -650,8 +643,6 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
controls.SetAutoPan( false );
controls.CaptureCursor( false );
view.SetVisible( &ruler, false );
}
// move or drag when origin set updates rules

View File

@ -220,7 +220,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
controls.SetAutoPan( false );
controls.CaptureCursor( false );
while( auto evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );