Pcbnew: Don't flip tool text when view is flipped

CHANGED: When using tools like the ruler, circle, arc, etc, they
display info text.  If the view is flipped, the text is also flipped.
This MR fixes the flipped text and also corrects text X offset and
justification to match normal view.
This commit is contained in:
PJM 2020-10-09 23:46:38 -07:00 committed by Jeff Young
parent 22cde88ba9
commit 6de5cf827a
1 changed files with 13 additions and 2 deletions

View File

@ -129,6 +129,8 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
// offset (enough to keep clear of a system cursor if present)
VECTOR2D textPos = aCursorPos;
bool ViewFlipped = gal->IsFlippedX();
// if the text goes above the cursor, shift it up
if( aTextQuadrant.y > 0 )
{
@ -137,7 +139,11 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
if( aTextQuadrant.x < 0 )
{
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
if( ViewFlipped )
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
else
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
textPos.x += 15.0 / gal->GetWorldScale();
if( aDrawingDropShadows )
@ -145,7 +151,11 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
}
else
{
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
if( ViewFlipped )
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
else
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
textPos.x -= 15.0 / gal->GetWorldScale();
if( aDrawingDropShadows )
@ -155,6 +165,7 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
gal->SetIsFill( false );
gal->SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ) );
gal->SetLineWidth( textDims.StrokeWidth );
gal->SetTextMirrored( ViewFlipped ); // Prevent text flipping when view is flipped
if( aDrawingDropShadows )
{