Fix window/crossed selection mode recognition in flipped view

Fixes: lp:1767233
This commit is contained in:
Andrzej Wolski 2018-04-28 22:32:39 +02:00 committed by Maciej Suminski
parent 7395949ae0
commit 5ac4dbe641
2 changed files with 17 additions and 7 deletions

View File

@ -123,7 +123,13 @@ void SELECTION_AREA::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
gal.SetIsFill( true ); gal.SetIsFill( true );
gal.SetLineWidth( 1.0 / gal.GetWorldScale() ); gal.SetLineWidth( 1.0 / gal.GetWorldScale() );
// Set the stroke color to indicate window or crossing selection // 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 ); gal.DrawRectangle( m_origin, m_end );
} }

View File

@ -591,6 +591,15 @@ bool SELECTION_TOOL::selectMultiple()
int width = area.GetEnd().x - area.GetOrigin().x; int width = area.GetEnd().x - area.GetOrigin().x;
int height = area.GetEnd().y - area.GetOrigin().y; 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 // Construct an EDA_RECT to determine BOARD_ITEM selection
EDA_RECT selectionRect( wxPoint( area.GetOrigin().x, area.GetOrigin().y ), EDA_RECT selectionRect( wxPoint( area.GetOrigin().x, area.GetOrigin().y ),
wxSize( width, height ) ); wxSize( width, height ) );
@ -604,12 +613,7 @@ bool SELECTION_TOOL::selectMultiple()
if( !item || !selectable( item ) ) if( !item || !selectable( item ) )
continue; continue;
/* Selection mode depends on direction of drag-selection: if( windowSelection )
* Left > Right : Select objects that are fully enclosed by selection
* Right > Left : Select objects that are crossed by selection
*/
if( width >= 0 )
{ {
if( selectionBox.Contains( item->ViewBBox() ) ) if( selectionBox.Contains( item->ViewBBox() ) )
{ {