1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Fix zooming with keyboard shortcuts

This commit is contained in:
Ivan Savenko
2024-05-19 09:58:55 +00:00
parent 11c00711f9
commit 16f963bed5
8 changed files with 21 additions and 18 deletions

View File

@ -88,7 +88,7 @@ void MapViewController::setTileSize(const Point & tileSize)
setViewCenter(newViewCenter, model->getLevel());
}
void MapViewController::modifyTileSize(int stepsChange)
void MapViewController::modifyTileSize(int stepsChange, bool useDeadZone)
{
// we want to zoom in/out in fixed 10% steps, to allow player to return back to exactly 100% zoom just by scrolling
// so, zooming in for 5 steps will put game at 1.1^5 = 1.61 scale
@ -117,10 +117,13 @@ void MapViewController::modifyTileSize(int stepsChange)
if (actualZoom != currentZoom)
{
targetTileSize = actualZoom;
if(actualZoom.x >= defaultTileSize - zoomTileDeadArea && actualZoom.x <= defaultTileSize + zoomTileDeadArea)
actualZoom.x = defaultTileSize;
if(actualZoom.y >= defaultTileSize - zoomTileDeadArea && actualZoom.y <= defaultTileSize + zoomTileDeadArea)
actualZoom.y = defaultTileSize;
if (useDeadZone)
{
if(actualZoom.x >= defaultTileSize - zoomTileDeadArea && actualZoom.x <= defaultTileSize + zoomTileDeadArea)
actualZoom.x = defaultTileSize;
if(actualZoom.y >= defaultTileSize - zoomTileDeadArea && actualZoom.y <= defaultTileSize + zoomTileDeadArea)
actualZoom.y = defaultTileSize;
}
bool isInDeadZone = targetTileSize != actualZoom || actualZoom == Point(defaultTileSize, defaultTileSize);