Skip to content

Commit

Permalink
Editor: Fixed broken scroll and zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
Wohlstand committed Aug 3, 2024
1 parent 27001e9 commit 1135a3c
Showing 1 changed file with 23 additions and 41 deletions.
64 changes: 23 additions & 41 deletions Editor/common_features/graphicsworkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void GraphicsWorkspace::wheelEvent(QWheelEvent *event)
if(rtl)
modS_h *= -1;

if(event->modifiers() & Qt::ShiftModifier)
if((event->modifiers() & Qt::ShiftModifier) != 0)
{
modS *= 2;
modS_h *= 2;
Expand All @@ -307,10 +307,10 @@ void GraphicsWorkspace::wheelEvent(QWheelEvent *event)
int deltaX = delta.x();
int deltaY = delta.y();

if(event->modifiers() & Qt::ControlModifier)
if((event->modifiers() & Qt::ControlModifier) != 0)
{
// Scale the view / do the zoom
if(deltaX > 0)
if(deltaY > 0)
{
if(zoomValue * scaleFactor >= scaleMax) return;
// Zoom in
Expand All @@ -319,7 +319,7 @@ void GraphicsWorkspace::wheelEvent(QWheelEvent *event)
emit zoomValueChanged(qRound(zoomValue * 100));
emit zoomValueChanged(QString::number(qRound(zoomValue * 100)));
}
else if(deltaX < 0)
else if(deltaY < 0)
{
if(zoomValue * scaleFactor <= scaleMin) return;
// Zooming out
Expand All @@ -336,49 +336,31 @@ void GraphicsWorkspace::wheelEvent(QWheelEvent *event)
auto *hBar = horizontalScrollBar();
auto *vBar = verticalScrollBar();

if(event->modifiers() & Qt::AltModifier)
if((event->modifiers() & Qt::AltModifier) != 0)
{
if(deltaX > 0)
vBar->setValue(vBar->value() - modS_h);
else if(deltaX < 0)
vBar->setValue(vBar->value() + modS_h);

if(deltaY > 0)
hBar->setValue(hBar->value() - modS_h);
else if(deltaY < 0)
hBar->setValue(hBar->value() + modS_h);

//event->accept();
replayLastMouseEvent();

if(scene())
scene()->update();

return;
// Ensure values aren't already swapped
if(delta.x() == 0 && delta.y() != 0)
{
deltaY = delta.x();
deltaX = delta.y();
}
}
else
{
if(deltaX > 0)
hBar->setValue(hBar->value() - modS);
else if(deltaX < 0)
hBar->setValue(hBar->value() + modS);

if(deltaY > 0)
vBar->setValue(vBar->value() - modS);
else if(deltaY < 0)
vBar->setValue(vBar->value() + modS);
if(deltaX > 0)
hBar->setValue(hBar->value() - modS);
else if(deltaX < 0)
hBar->setValue(hBar->value() + modS);

//event->accept();
replayLastMouseEvent();
if(deltaY > 0)
vBar->setValue(vBar->value() - modS);
else if(deltaY < 0)
vBar->setValue(vBar->value() + modS);

if(scene())
scene()->update();

return;
}
//event->accept();
replayLastMouseEvent();

//replayLastMouseEvent(); //DEAD CODE
//QGraphicsView::wheelEvent(event);
if(scene())
scene()->update();
}


Expand Down

0 comments on commit 1135a3c

Please sign in to comment.