From 80fbcd5fbdbd46c9fa26fa0b6528f7679439b58d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 18 Nov 2025 14:41:10 +0100 Subject: [PATCH] Move application of scaling to tablet output area to scaling container It's the safest place for it to be there, really. --- .../Graphics/Containers/ScalingContainer.cs | 15 ++++++++++- .../Settings/Sections/Input/TabletSettings.cs | 25 ------------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/osu.Game/Graphics/Containers/ScalingContainer.cs b/osu.Game/Graphics/Containers/ScalingContainer.cs index 9d2a1c16af..22dabc55ce 100644 --- a/osu.Game/Graphics/Containers/ScalingContainer.cs +++ b/osu.Game/Graphics/Containers/ScalingContainer.cs @@ -1,11 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; +using osu.Framework.Input.Handlers.Tablet; using osu.Framework.Layout; using osu.Framework.Platform; using osu.Framework.Screens; @@ -50,6 +52,8 @@ namespace osu.Game.Graphics.Containers private RectangleF? customRect; private bool customRectIsRelativePosition; + private ITabletHandler? tabletHandler; + /// /// Set a custom position and scale which overrides any user specification. /// @@ -123,7 +127,7 @@ namespace osu.Game.Graphics.Containers } [BackgroundDependencyLoader] - private void load(OsuConfigManager config, ISafeArea safeArea) + private void load(GameHost host, OsuConfigManager config, ISafeArea safeArea) { scalingMode = config.GetBindable(OsuSetting.Scaling); scalingMode.ValueChanged += _ => Scheduler.AddOnce(updateSize); @@ -148,6 +152,8 @@ namespace osu.Game.Graphics.Containers scalingMenuBackgroundDim = config.GetBindable(OsuSetting.ScalingBackgroundDim); scalingMenuBackgroundDim.ValueChanged += _ => Scheduler.AddOnce(updateSize); + + tabletHandler = host.AvailableInputHandlers.OfType().SingleOrDefault(); } protected override void LoadComplete() @@ -222,6 +228,13 @@ namespace osu.Game.Graphics.Containers // An example of how this can occur is when the skin editor is visible and the game screen scaling is set to "Everything". sizableContainer.TransformTo(nameof(CornerRadius), requiresMasking ? corner_radius : 0, TRANSITION_DURATION, requiresMasking ? Easing.OutQuart : Easing.None) .OnComplete(_ => { sizableContainer.Masking = requiresMasking; }); + + // when "everything" scaling mode is active, tablets are expected to constrain output area to the scaled size of the game + if (tabletHandler != null) + { + tabletHandler.OutputAreaSize.Value = scalingMode.Value == ScalingMode.Everything ? new Vector2(sizeX.Value, sizeY.Value) : Vector2.One; + tabletHandler.OutputAreaOffset.Value = scalingMode.Value == ScalingMode.Everything ? new Vector2(posX.Value, posY.Value) : new Vector2(0.5f); + } } private partial class ScalingBackgroundScreen : BackgroundScreenDefault diff --git a/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs index 314e1a1f4c..9ef2fc0933 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs @@ -52,8 +52,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input private Bindable scalingMode = null!; private Bindable scalingSizeX = null!; private Bindable scalingSizeY = null!; - private Bindable scalingPositionX = new Bindable(); - private Bindable scalingPositionY = new Bindable(); [Resolved] private GameHost host { get; set; } @@ -91,8 +89,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input scalingMode = osuConfig.GetBindable(OsuSetting.Scaling); scalingSizeX = osuConfig.GetBindable(OsuSetting.ScalingSizeX); scalingSizeY = osuConfig.GetBindable(OsuSetting.ScalingSizeY); - scalingPositionX = osuConfig.GetBindable(OsuSetting.ScalingPositionX); - scalingPositionY = osuConfig.GetBindable(OsuSetting.ScalingPositionY); Children = new Drawable[] { @@ -299,13 +295,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input aspectRatioApplication = Schedule(() => forceAspectRatio(aspect.NewValue)); }); - updateScaling(); - scalingMode.BindValueChanged(_ => updateScaling()); - scalingSizeX.BindValueChanged(_ => updateScaling()); - scalingSizeY.BindValueChanged(_ => updateScaling()); - scalingPositionX.BindValueChanged(_ => updateScaling()); - scalingPositionY.BindValueChanged(_ => updateScaling()); - pressureThreshold.BindTo(tabletHandler.PressureThreshold); tablet.BindTo(tabletHandler.Tablet); @@ -393,20 +382,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input aspectLock.Value = true; } - private void updateScaling() - { - if (scalingMode.Value == ScalingMode.Everything) - { - outputAreaSize.Value = new Vector2(scalingSizeX.Value, scalingSizeY.Value); - outputAreaOffset.Value = new Vector2(scalingPositionX.Value, scalingPositionY.Value); - } - else - { - outputAreaSize.Value = new Vector2(1, 1); - outputAreaOffset.Value = new Vector2(0.5f, 0.5f); - } - } - private void updateAspectRatio() => aspectRatio.Value = currentAspectRatio; private float currentAspectRatio => sizeX.Value / sizeY.Value;