From 5ac4dbe6414c43149b3ea9ec8593c0e212ff8dd0 Mon Sep 17 00:00:00 2001 From: Andrzej Wolski Date: Sat, 28 Apr 2018 22:32:39 +0200 Subject: [PATCH] Fix window/crossed selection mode recognition in flipped view Fixes: lp:1767233 --- common/preview_items/selection_area.cpp | 8 +++++++- pcbnew/tools/selection_tool.cpp | 16 ++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/common/preview_items/selection_area.cpp b/common/preview_items/selection_area.cpp index 37e6b95d1a..546ffd81ca 100644 --- a/common/preview_items/selection_area.cpp +++ b/common/preview_items/selection_area.cpp @@ -123,7 +123,13 @@ void SELECTION_AREA::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const gal.SetIsFill( true ); gal.SetLineWidth( 1.0 / gal.GetWorldScale() ); + // Set the stroke color to indicate window or crossing selection - gal.SetStrokeColor( ( m_origin.x <= m_end.x ) ? scheme.outline_l2r : scheme.outline_r2l ); + bool windowSelection = ( m_origin.x <= m_end.x ) ? true : false; + + if( aView->IsMirroredX() ) + windowSelection = !windowSelection; + + gal.SetStrokeColor( windowSelection ? scheme.outline_l2r : scheme.outline_r2l ); gal.DrawRectangle( m_origin, m_end ); } diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 71b1176536..7f9a275fef 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -591,6 +591,15 @@ bool SELECTION_TOOL::selectMultiple() int width = area.GetEnd().x - area.GetOrigin().x; int height = area.GetEnd().y - area.GetOrigin().y; + /* Selection mode depends on direction of drag-selection: + * Left > Right : Select objects that are fully enclosed by selection + * Right > Left : Select objects that are crossed by selection + */ + bool windowSelection = width >= 0 ? true : false; + + if( view->IsMirroredX() ) + windowSelection = !windowSelection; + // Construct an EDA_RECT to determine BOARD_ITEM selection EDA_RECT selectionRect( wxPoint( area.GetOrigin().x, area.GetOrigin().y ), wxSize( width, height ) ); @@ -604,12 +613,7 @@ bool SELECTION_TOOL::selectMultiple() if( !item || !selectable( item ) ) continue; - /* Selection mode depends on direction of drag-selection: - * Left > Right : Select objects that are fully enclosed by selection - * Right > Left : Select objects that are crossed by selection - */ - - if( width >= 0 ) + if( windowSelection ) { if( selectionBox.Contains( item->ViewBBox() ) ) {