mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 00:13:19 +08:00
Merge pull request #21192 from Samaoo/fix-tablet-area-dimensions
Fix inaccurate tablet area dimensions when applying aspect ratio
This commit is contained in:
commit
4c6ab27ae4
@ -3,6 +3,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -308,9 +309,9 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
|
||||
// if lock is applied (or the specified values were out of range) aim to adjust the axis the user was not adjusting to conform.
|
||||
if (sizeChanged == sizeX)
|
||||
sizeY.Value = (int)(areaSize.Value.X / aspectRatio.Value);
|
||||
sizeY.Value = getHeight(areaSize.Value.X, aspectRatio.Value);
|
||||
else
|
||||
sizeX.Value = (int)(areaSize.Value.Y * aspectRatio.Value);
|
||||
sizeX.Value = getWidth(areaSize.Value.Y, aspectRatio.Value);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -324,12 +325,12 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
aspectLock.Value = false;
|
||||
|
||||
int proposedHeight = (int)(sizeX.Value / aspectRatio);
|
||||
int proposedHeight = getHeight(sizeX.Value, aspectRatio);
|
||||
|
||||
if (proposedHeight < sizeY.MaxValue)
|
||||
sizeY.Value = proposedHeight;
|
||||
else
|
||||
sizeX.Value = (int)(sizeY.Value * aspectRatio);
|
||||
sizeX.Value = getWidth(sizeY.Value, aspectRatio);
|
||||
|
||||
updateAspectRatio();
|
||||
|
||||
@ -340,5 +341,9 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
private void updateAspectRatio() => aspectRatio.Value = currentAspectRatio;
|
||||
|
||||
private float currentAspectRatio => sizeX.Value / sizeY.Value;
|
||||
|
||||
private static int getHeight(float width, float aspectRatio) => (int)Math.Round(width / aspectRatio);
|
||||
|
||||
private static int getWidth(float height, float aspectRatio) => (int)Math.Round(height * aspectRatio);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user