1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 15:23:09 +08:00

better resizing

This commit is contained in:
EVAST9919 2017-05-18 07:09:36 +03:00
parent 35bc3a42aa
commit d07d94d606
4 changed files with 85 additions and 32 deletions

View File

@ -3,6 +3,7 @@
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -19,7 +20,8 @@ namespace osu.Game.Screens.Play.Options
/// </summary>
public abstract string Title { get; }
private readonly FillFlowContainer content;
private readonly OptionDropdown content;
private readonly SimpleButton button;
private bool contentIsVisible;
protected OptionContainer()
@ -65,7 +67,7 @@ namespace osu.Game.Screens.Play.Options
Font = @"Exo2.0-Bold",
Margin = new MarginPadding { Left = 10 },
},
new SimpleButton
button = new SimpleButton
{
Origin = Anchor.Centre,
Anchor = Anchor.CentreRight,
@ -76,21 +78,21 @@ namespace osu.Game.Screens.Play.Options
},
}
},
content = new FillFlowContainer
content = new OptionDropdown
{
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Padding = new MarginPadding(15),
Spacing = new Vector2(0, 10),
}
}
},
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
content.StateChanged += (c, s) => button.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, EasingTypes.OutQuint);
}
public new void Add(Drawable drawable)
{
content.Add(drawable);
@ -98,12 +100,12 @@ namespace osu.Game.Screens.Play.Options
private void triggerContentVisibility()
{
contentIsVisible = !contentIsVisible;
if (contentIsVisible)
content.Show();
else
content.Hide();
contentIsVisible = !contentIsVisible;
}
}
}

View File

@ -0,0 +1,50 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Screens.Play.Options
{
public class OptionDropdown : OverlayContainer
{
private const float transition_duration = 600;
private FillFlowContainer content;
public OptionDropdown()
{
Children = new Drawable[]
{
content = new FillFlowContainer
{
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Padding = new MarginPadding(15),
Spacing = new Vector2(0, 10),
}
};
}
public new void Add(Drawable drawable)
{
content.Add(drawable);
}
protected override void PopIn()
{
ResizeTo(new Vector2(1, content.Height), transition_duration, EasingTypes.OutQuint);
FadeIn(transition_duration, EasingTypes.OutQuint);
}
protected override void PopOut()
{
ResizeTo(new Vector2(1, 0), transition_duration, EasingTypes.OutQuint);
FadeOut(transition_duration);
}
}
}

View File

@ -1,24 +1,24 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Game.Configuration;
using osu.Game.Overlays.Settings;
namespace osu.Game.Screens.Play.Options
{
public class PlaybackOptions : OptionContainer
{
public override string Title => @"PLAYBACK";
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
Add(new SettingsSlider<double>
{
LabelText = "Playback speed",
Bindable = config.GetBindable<double>(OsuSetting.PlaybackSpeed),
});
}
}
}
using osu.Framework.Allocation;
using osu.Game.Configuration;
using osu.Game.Overlays.Settings;
namespace osu.Game.Screens.Play.Options
{
public class PlaybackOptions : OptionContainer
{
public override string Title => @"PLAYBACK";
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
Add(new SettingsSlider<double>
{
LabelText = "Playback speed",
Bindable = config.GetBindable<double>(OsuSetting.PlaybackSpeed),
});
}
}
}

View File

@ -236,6 +236,7 @@
<Compile Include="Screens\Play\Options\CollectionOptions.cs" />
<Compile Include="Screens\Play\Options\DiscussionOptions.cs" />
<Compile Include="Screens\Play\Options\OptionContainer.cs" />
<Compile Include="Screens\Play\Options\OptionDropdown.cs" />
<Compile Include="Screens\Play\Options\OptionsDisplay.cs" />
<Compile Include="Screens\Play\Options\PlaybackOptions.cs" />
<Compile Include="Screens\Play\PauseContainer.cs" />