1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Fix [#12262]: Windows can appear off screen in some cases (#14881)

Fix: [#12262] Windows can appear off screen with small screens or high scaling.
This commit is contained in:
Daniel Karandikar
2021-07-03 13:38:39 +01:00
committed by GitHub
parent 77781874f2
commit b017ea4159
3 changed files with 16 additions and 7 deletions

View File

@@ -170,6 +170,7 @@ The following people are not part of the development team, but have been contrib
* Ryan D. (rctdude2)
* (zrowny)
* Emre Aydin (aemreaydin)
* Daniel Karandikar (DKarandikar)
## Toolchain
* (Balletie) - macOS

View File

@@ -13,6 +13,7 @@
- Change: [#14751] “No construction above tree height” limitation now allows placing high trees.
- Change: [#14841] Redesign the About window, including new button to copy the current version info.
- Fix: [#11829] Visual glitches and crashes when using RCT1 assets from mismatched or corrupt CSG1.DAT and CSG1i.DAT files.
- Fix: [#12262] Windows can appear off screen with small screens or high scaling.
- Fix: [#13581] Opening the Options menu causes a noticeable drop in FPS.
- Fix: [#13894] Block brakes do not animate.
- Fix: [#13986] OpenGL: Track preview window, flip/rotate button do not update the thumbnail.

View File

@@ -86,14 +86,21 @@ static bool WindowFitsOnScreen(const ScreenCoordsXY& loc, int32_t width, int32_t
return WindowFitsBetweenOthers(loc, width, height);
}
static ScreenCoordsXY ClampWindowToScreen(const ScreenCoordsXY& pos, const int32_t screenWidth, const int32_t width)
static ScreenCoordsXY ClampWindowToScreen(
const ScreenCoordsXY& pos, const int32_t screenWidth, const int32_t screenHeight, const int32_t width, const int32_t height)
{
auto screenPos = pos;
if (screenPos.x < 0)
if (width > screenWidth || screenPos.x < 0)
screenPos.x = 0;
if (screenPos.x + width > screenWidth)
else if (screenPos.x + width > screenWidth)
screenPos.x = screenWidth - width;
auto toolbarAllowance = (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) ? 0 : (TOP_TOOLBAR_HEIGHT + 1);
if (height - toolbarAllowance > screenHeight || screenPos.y < toolbarAllowance)
screenPos.y = toolbarAllowance;
else if (screenPos.y + height - toolbarAllowance > screenHeight)
screenPos.y = screenHeight + toolbarAllowance - height;
return screenPos;
}
@@ -115,7 +122,7 @@ static ScreenCoordsXY GetAutoPositionForNewWindow(int32_t width, int32_t height)
{
if (WindowFitsWithinSpace(cornerPos, width, height))
{
return ClampWindowToScreen(cornerPos, screenWidth, width);
return ClampWindowToScreen(cornerPos, screenWidth, screenHeight, width, height);
}
}
@@ -139,7 +146,7 @@ static ScreenCoordsXY GetAutoPositionForNewWindow(int32_t width, int32_t height)
auto screenPos = w->windowPos + offset;
if (WindowFitsWithinSpace(screenPos, width, height))
{
return ClampWindowToScreen(screenPos, screenWidth, width);
return ClampWindowToScreen(screenPos, screenWidth, screenHeight, width, height);
}
}
}
@@ -164,7 +171,7 @@ static ScreenCoordsXY GetAutoPositionForNewWindow(int32_t width, int32_t height)
auto screenPos = w->windowPos + offset;
if (WindowFitsOnScreen(screenPos, width, height))
{
return ClampWindowToScreen(screenPos, screenWidth, width);
return ClampWindowToScreen(screenPos, screenWidth, screenHeight, width, height);
}
}
}
@@ -180,7 +187,7 @@ static ScreenCoordsXY GetAutoPositionForNewWindow(int32_t width, int32_t height)
}
}
return ClampWindowToScreen(screenPos, screenWidth, width);
return ClampWindowToScreen(screenPos, screenWidth, screenHeight, width, height);
}
static ScreenCoordsXY GetCentrePositionForNewWindow(int32_t width, int32_t height)