1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 18:52:55 +08:00

Don't expose DimContainer

This commit is contained in:
Dean Herbert 2019-07-12 11:38:15 +09:00
parent c9599b65eb
commit 0d9f978857
4 changed files with 21 additions and 25 deletions

View File

@ -405,7 +405,7 @@ namespace osu.Game.Tests.Visual.Background
private class TestDimmableStoryboardContainer : DimmableStoryboardContainer private class TestDimmableStoryboardContainer : DimmableStoryboardContainer
{ {
public float CurrentAlpha => DimContainer.Alpha; public float CurrentAlpha => Content.Alpha;
public TestDimmableStoryboardContainer() public TestDimmableStoryboardContainer()
: base(new Storyboard()) : base(new Storyboard())
@ -415,8 +415,8 @@ namespace osu.Game.Tests.Visual.Background
private class TestDimmableBackgroundContainer : DimmableBackgroundContainer private class TestDimmableBackgroundContainer : DimmableBackgroundContainer
{ {
public Color4 CurrentColour => DimContainer.Colour; public Color4 CurrentColour => Content.Colour;
public float CurrentAlpha => DimContainer.Alpha; public float CurrentAlpha => Content.Alpha;
} }
} }
} }

View File

@ -55,14 +55,16 @@ namespace osu.Game.Graphics.Containers
private void load(OsuConfigManager config) private void load(OsuConfigManager config)
{ {
userBlurLevel = config.GetBindable<double>(OsuSetting.BlurLevel); userBlurLevel = config.GetBindable<double>(OsuSetting.BlurLevel);
BlurAmount.ValueChanged += _ => UpdateVisuals();
userBlurLevel.ValueChanged += _ => UpdateVisuals(); userBlurLevel.ValueChanged += _ => UpdateVisuals();
BlurAmount.ValueChanged += _ => UpdateVisuals();
} }
protected override void ApplyFade() protected override bool ShowDimContent => !ShowStoryboard.Value || !StoryboardReplacesBackground.Value; // The background needs to be hidden in the case of it being replaced by the storyboard
protected override void UpdateVisuals()
{ {
// The background needs to be hidden in the case of it being replaced by the storyboard base.UpdateVisuals();
DimContainer.FadeTo(ShowStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint);
Background?.BlurTo(blurTarget, BACKGROUND_FADE_DURATION, Easing.OutQuint); Background?.BlurTo(blurTarget, BACKGROUND_FADE_DURATION, Easing.OutQuint);
} }
} }

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Storyboards; using osu.Game.Storyboards;
using osu.Game.Storyboards.Drawables; using osu.Game.Storyboards.Drawables;
@ -37,10 +36,7 @@ namespace osu.Game.Graphics.Containers
base.LoadComplete(); base.LoadComplete();
} }
protected override void ApplyFade() protected override bool ShowDimContent => ShowStoryboard.Value && UserDimLevel.Value < 1;
{
DimContainer.FadeTo(!ShowStoryboard.Value || UserDimLevel.Value == 1 ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint);
}
private void initializeStoryboard(bool async) private void initializeStoryboard(bool async)
{ {

View File

@ -31,16 +31,16 @@ namespace osu.Game.Graphics.Containers
protected Bindable<bool> ShowStoryboard { get; private set; } protected Bindable<bool> ShowStoryboard { get; private set; }
protected Container DimContainer { get; } protected override Container<Drawable> Content => dimContent;
protected override Container<Drawable> Content => DimContainer; private Container dimContent { get; }
/// <summary> /// <summary>
/// Creates a new <see cref="UserDimContainer"/>. /// Creates a new <see cref="UserDimContainer"/>.
/// </summary> /// </summary>
protected UserDimContainer() protected UserDimContainer()
{ {
AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both }); AddInternal(dimContent = new Container { RelativeSizeAxes = Axes.Both });
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -62,19 +62,17 @@ namespace osu.Game.Graphics.Containers
} }
/// <summary> /// <summary>
/// Apply non-dim related settings to the content, such as hiding and blurring. /// Whether the content of this container should currently be visible.
/// </summary> /// </summary>
/// <remarks> protected virtual bool ShowDimContent => true;
/// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via <see cref="ShowStoryboard"/>
/// and can cause backgrounds to become hidden via <see cref="StoryboardReplacesBackground"/>. Storyboards are also currently unable to be blurred.
/// </remarks>
protected abstract void ApplyFade();
protected void UpdateVisuals() /// <summary>
/// Should be invoked when any dependent dim level or user setting is changed and bring the visual state up-to-date.
/// </summary>
protected virtual void UpdateVisuals()
{ {
ApplyFade(); dimContent.FadeTo(ShowDimContent ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
dimContent.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)UserDimLevel.Value) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint);
DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)UserDimLevel.Value) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint);
} }
} }
} }