Improve zooming

This commit is contained in:
Thomas Jentzsch 2019-07-28 19:55:36 +02:00
parent c53fb6ab00
commit 47457664e2
1 changed files with 17 additions and 4 deletions

View File

@ -85,15 +85,15 @@ void TiaZoomWidget::zoom(int level)
if(myZoomLevel == level)
return;
// TODO: zoom to center
//int x = myXOff + myNumCols / 2;
//int y = myYOff + myNumRows / 2;
// zoom to click position
int x = (myXOff << 1) + myClickX / myZoomLevel;
int y = myYOff + myClickY / myZoomLevel;
myZoomLevel = level;
myNumCols = ((_w - 4) >> 1) / myZoomLevel;
myNumRows = (_h - 4) / myZoomLevel;
//setPos(x, y);
setPos(x, y);
recalc();
}
@ -140,6 +140,19 @@ void TiaZoomWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaZoomWidget::handleMouseWheel(int x, int y, int direction)
{
/*
// TODO: zoom towards mouse point
myClickX = (x - getAbsX()) / myZoomLevel + myXOff * 1;
myClickY = (y - getAbsY()) / myZoomLevel + myYOff * 1;
setPos(myClickX, myClickY);
if(direction > 0)
{
}
else
{
}*/
if(direction > 0)
handleEvent(Event::UIDown);
else