From 4f399d4304a5b2b3b0fa188e0f7ec71291f95df4 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 18 Jan 2021 14:29:55 +0000 Subject: [PATCH] One more attempt to fix flipping geometry. Fixes https://gitlab.com/kicad/code/kicad/issues/4480 --- pcbnew/pcb_text.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index a3b5ede87e..fba0b82654 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -179,20 +179,22 @@ void PCB_TEXT::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) std::swap( top, bottom ); } - // Now put the text back in it (these look backwards but remember that out text will - // be mirrored when all is said and done) + // Now put the text back in its bounding box switch( GetHorizJustify() ) { - case GR_TEXT_HJUSTIFY_LEFT: SetTextX( right ); break; - case GR_TEXT_HJUSTIFY_CENTER: SetTextX( ( left + right ) / 2 ); break; - case GR_TEXT_HJUSTIFY_RIGHT: SetTextX( left ); break; + case GR_TEXT_HJUSTIFY_LEFT: SetTextX( IsMirrored() ? left : right ); break; + case GR_TEXT_HJUSTIFY_CENTER: SetTextX( ( left + right ) / 2 ); break; + case GR_TEXT_HJUSTIFY_RIGHT: SetTextX( IsMirrored() ? right : left ); break; } - switch( GetVertJustify() ) + if( !aFlipLeftRight ) { - case GR_TEXT_VJUSTIFY_TOP: SetTextY( bottom ); break; - case GR_TEXT_VJUSTIFY_CENTER: SetTextY( ( top + bottom ) / 2 ); break; - case GR_TEXT_VJUSTIFY_BOTTOM: SetTextY( top ); break; + switch( GetVertJustify() ) + { + case GR_TEXT_VJUSTIFY_TOP: SetTextY( bottom ); break; + case GR_TEXT_VJUSTIFY_CENTER: SetTextY( ( top + bottom ) / 2 ); break; + case GR_TEXT_VJUSTIFY_BOTTOM: SetTextY( top ); break; + } } // And restore orientation