Simplify some straight paths logic

This commit is contained in:
BigBahss
2020-08-23 09:25:03 -04:00
committed by garak
parent 5f5087df05
commit de2246e2fd
2 changed files with 6 additions and 13 deletions

View File

@@ -17,16 +17,12 @@ void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
// Set straight paths on/off and snap to the dominant axis when on
bool straightPathsEnabled = event->modifiers() & Qt::ControlModifier;
if (this->settings->straightPathsEnabled || straightPathsEnabled) {
this->straightPathMode = true;
} else {
this->straightPathMode = false;
this->prevStraightPathState = false;
this->lockedAxis = MapPixmapItem::Axis::None;
}
if (this->straightPathMode) {
this->lockNondominantAxis(event);
x = this->adjustCoord(x, MapPixmapItem::Axis::X);
y = this->adjustCoord(y, MapPixmapItem::Axis::Y);
} else {
this->prevStraightPathState = false;
this->lockedAxis = MapPixmapItem::Axis::None;
}
// Paint onto the map.
@@ -61,14 +57,12 @@ void MapPixmapItem::shift(QGraphicsSceneMouseEvent *event) {
// Set straight paths on/off and snap to the dominant axis when on
bool straightPathsEnabled = event->modifiers() & Qt::ControlModifier;
if (this->settings->straightPathsEnabled || straightPathsEnabled) {
this->straightPathMode = true;
} else {
this->straightPathMode = false;
}
if (this->straightPathMode) {
this->lockNondominantAxis(event);
x = this->adjustCoord(x, MapPixmapItem::Axis::X);
y = this->adjustCoord(y, MapPixmapItem::Axis::Y);
} else {
this->prevStraightPathState = false;
this->lockedAxis = MapPixmapItem::Axis::None;
}
if (event->type() == QEvent::GraphicsSceneMousePress) {