Puzzle app. Piece rotation with step 15 degrees by holding Ctrl key.

This commit is contained in:
Roman Telezhynskyi 2024-07-29 18:52:38 +03:00
parent d3d550ce70
commit dc7f0fc74f
3 changed files with 13 additions and 0 deletions

View file

@ -8,6 +8,7 @@
- Fix parsing SVG fonts.
- Add "Twin Sans" single stroke font.
- Fixed generation of mirror side of piece based on fold line.
- Puzzle app. Piece rotation with step 15 degrees by holding Ctrl key.
# Valentina 0.7.53 June 25, 2024
- Fix layout sheet export with empty name.

View file

@ -409,6 +409,7 @@ void VPGraphicsPieceControls::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
m_rotationStartPoint = event->scenePos();
m_rotationSum = 0;
m_controlsVisible = false;
m_handleCorner = SelectedHandleCorner(event->pos());
m_ignorePieceTransformation = true;
@ -453,6 +454,16 @@ void VPGraphicsPieceControls::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
rotateOn = rotateOn - 360.;
}
m_rotationSum += rotateOn;
if (event->modifiers() & Qt::ControlModifier)
{
const qreal sign = std::copysign(1.0, m_rotationSum);
const int steps = qFloor(qAbs(m_rotationSum / 15));
rotateOn = 15 * steps * sign;
m_rotationSum -= rotateOn;
}
if (not qFuzzyIsNull(rotateOn))
{
if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())

View file

@ -151,6 +151,7 @@ private:
bool allowChangeMerge{false};
QList<VPPiecePtr> m_selectedPieces{};
bool m_ignorePieceTransformation{false};
qreal m_rotationSum{0};
QMap<VPHandleCornerType, QPixmap> m_handlePixmaps{};
QMap<VPHandleCornerType, QPixmap> m_handleHoverPixmaps{};