GRID_HELPER: enable/disable grid in editor with ALT

Apply optional grid while editing
This commit is contained in:
Seth Hillbrand 2018-10-04 21:08:15 -07:00
parent 28c19cb613
commit 4c6b84bfdb
4 changed files with 8 additions and 9 deletions

View File

@ -1022,7 +1022,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
while( OPT_TOOL_EVENT evt = Wait() ) while( OPT_TOOL_EVENT evt = Wait() )
{ {
grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), aGraphic ); cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), aGraphic );
// 45 degree angle constraint enabled with an option and toggled with Ctrl // 45 degree angle constraint enabled with an option and toggled with Ctrl
@ -1220,6 +1220,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
aGraphic->SetLayer( layer ); aGraphic->SetLayer( layer );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), aGraphic ); VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), aGraphic );
if( evt->IsClick( BUT_LEFT ) ) if( evt->IsClick( BUT_LEFT ) )
@ -1360,7 +1361,7 @@ void DRAWING_TOOL::runPolygonEventLoop( POLYGON_GEOM_MANAGER& polyGeomMgr )
{ {
LSET layers( m_frame->GetActiveLayer() ); LSET layers( m_frame->GetActiveLayer() );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), layers ); VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), layers );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )

View File

@ -377,6 +377,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
do do
{ {
grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
if( evt->IsAction( &PCB_ACTIONS::editActivate ) || if( evt->IsAction( &PCB_ACTIONS::editActivate ) ||
evt->IsAction( &PCB_ACTIONS::move ) || evt->IsAction( &PCB_ACTIONS::move ) ||

View File

@ -48,13 +48,9 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
while( OPT_TOOL_EVENT evt = Wait() ) while( OPT_TOOL_EVENT evt = Wait() )
{ {
VECTOR2I cursorPos = controls->GetCursorPosition(); grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( m_cursorSnapping );
if( m_cursorSnapping ) VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetCursorPosition(), m_layerMask );
{
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
cursorPos = grid.BestSnapAnchor( cursorPos, m_layerMask );
}
if( evt->IsClick( BUT_LEFT ) ) if( evt->IsClick( BUT_LEFT ) )
{ {

View File

@ -332,6 +332,7 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
break; break;
grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
if( !m_editPoints || if( !m_editPoints ||
evt->Matches( m_selectionTool->ClearedEvent ) || evt->Matches( m_selectionTool->ClearedEvent ) ||