diff --git a/pcbnew/tools/placement_tool.cpp b/pcbnew/tools/placement_tool.cpp index 222da9521f..010afb2ea9 100644 --- a/pcbnew/tools/placement_tool.cpp +++ b/pcbnew/tools/placement_tool.cpp @@ -186,6 +186,21 @@ int ALIGN_DISTRIBUTE_TOOL::AlignBottom( const TOOL_EVENT& aEvent ) int ALIGN_DISTRIBUTE_TOOL::AlignLeft( const TOOL_EVENT& aEvent ) +{ + // Because this tool uses bounding boxes and they aren't mirrored even when + // the view is mirrored, we need to call the other one if mirrored. + if( getView()->IsMirroredX() ) + { + return doAlignRight(); + } + else + { + return doAlignLeft(); + } +} + + +int ALIGN_DISTRIBUTE_TOOL::doAlignLeft() { const SELECTION& selection = m_selectionTool->GetSelection(); @@ -223,6 +238,21 @@ int ALIGN_DISTRIBUTE_TOOL::AlignLeft( const TOOL_EVENT& aEvent ) int ALIGN_DISTRIBUTE_TOOL::AlignRight( const TOOL_EVENT& aEvent ) +{ + // Because this tool uses bounding boxes and they aren't mirrored even when + // the view is mirrored, we need to call the other one if mirrored. + if( getView()->IsMirroredX() ) + { + return doAlignLeft(); + } + else + { + return doAlignRight(); + } +} + + +int ALIGN_DISTRIBUTE_TOOL::doAlignRight() { const SELECTION& selection = m_selectionTool->GetSelection(); diff --git a/pcbnew/tools/placement_tool.h b/pcbnew/tools/placement_tool.h index 3888fe05ba..daf6b8981f 100644 --- a/pcbnew/tools/placement_tool.h +++ b/pcbnew/tools/placement_tool.h @@ -81,6 +81,23 @@ public: void setTransitions() override; private: + + /** + * Sets X coordinate of the selected items to the value of the left-most selected item X coordinate. + * + * NOTE: Uses the bounding box of items, which do not get mirrored even when + * the view is mirrored! + */ + int doAlignLeft(); + + /** + * Aligns selected items using the right edge of their bounding boxes to the right-most item + * + * NOTE: Uses the bounding box of items, which do not get mirrored even when + * the view is mirrored! + */ + int doAlignRight(); + SELECTION_TOOL* m_selectionTool; CONTEXT_MENU* m_placementMenu;