mirror of
https://github.com/ppy/osu.git
synced 2026-05-23 09:40:16 +08:00
Center window within usable bounds
This commit is contained in:
@@ -255,8 +255,17 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||
window.WindowState = Framework.Platform.WindowState.Normal;
|
||||
}
|
||||
|
||||
windowedPositionX.Value = 0.5;
|
||||
windowedPositionY.Value = 0.5;
|
||||
var dBounds = currentDisplay.Value.Bounds;
|
||||
var dUsable = currentDisplay.Value.UsableBounds;
|
||||
int w = size.NewValue.Width;
|
||||
int h = size.NewValue.Height;
|
||||
|
||||
float adjustedY = Math.Max(
|
||||
dUsable.Y + (dUsable.Height - h) / 2f,
|
||||
dUsable.Y + (host.Window?.BorderSize.Value.Top ?? 0) // titlebar adjustment
|
||||
);
|
||||
windowedPositionY.Value = dBounds.Height - h != 0 ? (adjustedY - dBounds.Y) / (dBounds.Height - h) : 0;
|
||||
windowedPositionX.Value = dBounds.Width - w != 0 ? (dUsable.X - dBounds.X + (dUsable.Width - w) / 2f) / (dBounds.Width - w) : 0;
|
||||
});
|
||||
|
||||
sizeWindowed.BindValueChanged(size =>
|
||||
|
||||
Reference in New Issue
Block a user