Fix positioning a transformation origin for a background image.

This commit is contained in:
Roman Telezhynskyi 2022-11-22 09:57:47 +02:00
parent 3e64af6443
commit 6e924ba0fa
2 changed files with 10 additions and 1 deletions

View File

@ -178,8 +178,11 @@ void VBackgroundImageControls::UpdateControls()
prepareGeometryChange(); prepareGeometryChange();
m_image = m_doc->GetBackgroundImage(m_id); m_image = m_doc->GetBackgroundImage(m_id);
if(not m_customOrigin)
{
m_originPos = m_image.BoundingRect().center(); m_originPos = m_image.BoundingRect().center();
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VBackgroundImageControls::boundingRect() const -> QRectF auto VBackgroundImageControls::boundingRect() const -> QRectF
@ -394,6 +397,8 @@ void VBackgroundImageControls::mousePressEvent(QGraphicsSceneMouseEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VBackgroundImageControls::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void VBackgroundImageControls::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
m_customOrigin = true;
if (m_tranformationType == BITransformationType::Scale) if (m_tranformationType == BITransformationType::Scale)
{ {
ScaleImage(event); ScaleImage(event);
@ -426,8 +431,10 @@ void VBackgroundImageControls::mouseReleaseEvent(QGraphicsSceneMouseEvent *event
setCursor(VAbstractValApplication::VApp()->getSceneView()->viewport()->cursor()); setCursor(VAbstractValApplication::VApp()->getSceneView()->viewport()->cursor());
} }
m_customOrigin = false;
m_controlsVisible = true; m_controlsVisible = true;
m_allowChangeMerge = false; m_allowChangeMerge = false;
m_originSaved = false;
if (m_tranformationType == BITransformationType::Scale) if (m_tranformationType == BITransformationType::Scale)
{ {

View File

@ -131,6 +131,8 @@ private:
bool m_showOrigin{false}; bool m_showOrigin{false};
QPointF m_originPos{}; QPointF m_originPos{};
bool m_originSaved{false};
bool m_customOrigin{false};
void InitPixmaps(); void InitPixmaps();