From 3b04b602d9d59bd52f1645b4b4f24490b750dec5 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 22 Sep 2021 09:23:00 -0700 Subject: [PATCH] Don't walk text/labels when mirroring We have a fixed bottom-align for the text and labels in eeschema. Therefore, mirroring vertically needs to account for the text's offset from the bounding box center. Fixes https://gitlab.com/kicad/code/kicad/issues/9208 --- eeschema/tools/sch_edit_tool.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 7d0759b571..65ef81531d 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -792,6 +792,21 @@ int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) pin->MirrorHorizontally( sheet->GetBoundingBox().GetCenter().x ); } } + else if( item->Type() == SCH_TEXT_T || item->Type() == SCH_LABEL_T ) + { + /// Text and Labels are aligned to their bottom right corners and we don't flip the + /// alignment corner, so we need to offset this in the vertical direction + + wxPoint textMirrorPoint = mirrorPoint; + + textMirrorPoint.y += item->GetBoundingBox().GetHeight() / 2; + textMirrorPoint = m_frame->GetNearestHalfGridPosition( textMirrorPoint ); + + if( vertical ) + item->MirrorVertically( textMirrorPoint.y ); + else + item->MirrorHorizontally( textMirrorPoint.x ); + } else { if( vertical )