From 97063440bbf871a5aa8da9f8c5532199240f366e Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 7 Apr 2019 00:17:12 +0100 Subject: [PATCH] Adjust left- or right-justified text for mirroring. --- pcbnew/class_pcb_text.cpp | 9 +++++++++ pcbnew/class_text_mod.cpp | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index e0bf3e125b..9158b58b3a 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -175,6 +175,15 @@ void TEXTE_PCB::Flip( const wxPoint& aCentre ) SetLayer( FlipLayer( GetLayer(), copperLayerCount ) ); SetMirrored( !IsMirrored() ); + + // adjust justified text for mirroring + if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT || GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) + { + if( ( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) == IsMirrored() ) + SetTextX( GetTextPos().x - GetTextBox().GetWidth() ); + else + SetTextX( GetTextPos().x + GetTextBox().GetWidth() ); + } } diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 09ef1be853..03c025fc8e 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -143,6 +143,16 @@ void TEXTE_MODULE::Flip( const wxPoint& aCentre ) SetLayer( FlipLayer( GetLayer() ) ); SetMirrored( IsBackLayer( GetLayer() ) ); SetLocalCoord(); + + // adjust justified text for mirroring + if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT || GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) + { + if( ( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) == IsMirrored() ) + m_Pos0.x -= GetTextBox().GetWidth(); + else + m_Pos0.x += GetTextBox().GetWidth(); + SetDrawCoord(); + } } bool TEXTE_MODULE::IsParentFlipped() const