Fix AlignLeft / AlignRight when using Flip Board view

Fixes: lp:1734377
* https://bugs.launchpad.net/kicad/+bug/1734377
This commit is contained in:
Jon Evans 2017-12-09 14:16:27 -05:00 committed by Maciej Suminski
parent 6ee26fdd8c
commit b6ac603f0a
2 changed files with 47 additions and 0 deletions

View File

@ -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();

View File

@ -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;