mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 11:02:56 +08:00
better resizing
This commit is contained in:
parent
35bc3a42aa
commit
d07d94d606
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
@ -19,7 +20,8 @@ namespace osu.Game.Screens.Play.Options
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract string Title { get; }
|
public abstract string Title { get; }
|
||||||
|
|
||||||
private readonly FillFlowContainer content;
|
private readonly OptionDropdown content;
|
||||||
|
private readonly SimpleButton button;
|
||||||
private bool contentIsVisible;
|
private bool contentIsVisible;
|
||||||
|
|
||||||
protected OptionContainer()
|
protected OptionContainer()
|
||||||
@ -65,7 +67,7 @@ namespace osu.Game.Screens.Play.Options
|
|||||||
Font = @"Exo2.0-Bold",
|
Font = @"Exo2.0-Bold",
|
||||||
Margin = new MarginPadding { Left = 10 },
|
Margin = new MarginPadding { Left = 10 },
|
||||||
},
|
},
|
||||||
new SimpleButton
|
button = new SimpleButton
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.CentreRight,
|
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,
|
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)
|
public new void Add(Drawable drawable)
|
||||||
{
|
{
|
||||||
content.Add(drawable);
|
content.Add(drawable);
|
||||||
@ -98,12 +100,12 @@ namespace osu.Game.Screens.Play.Options
|
|||||||
|
|
||||||
private void triggerContentVisibility()
|
private void triggerContentVisibility()
|
||||||
{
|
{
|
||||||
|
contentIsVisible = !contentIsVisible;
|
||||||
|
|
||||||
if (contentIsVisible)
|
if (contentIsVisible)
|
||||||
content.Show();
|
content.Show();
|
||||||
else
|
else
|
||||||
content.Hide();
|
content.Hide();
|
||||||
|
|
||||||
contentIsVisible = !contentIsVisible;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
50
osu.Game/Screens/Play/Options/OptionDropdown.cs
Normal file
50
osu.Game/Screens/Play/Options/OptionDropdown.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -236,6 +236,7 @@
|
|||||||
<Compile Include="Screens\Play\Options\CollectionOptions.cs" />
|
<Compile Include="Screens\Play\Options\CollectionOptions.cs" />
|
||||||
<Compile Include="Screens\Play\Options\DiscussionOptions.cs" />
|
<Compile Include="Screens\Play\Options\DiscussionOptions.cs" />
|
||||||
<Compile Include="Screens\Play\Options\OptionContainer.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\OptionsDisplay.cs" />
|
||||||
<Compile Include="Screens\Play\Options\PlaybackOptions.cs" />
|
<Compile Include="Screens\Play\Options\PlaybackOptions.cs" />
|
||||||
<Compile Include="Screens\Play\PauseContainer.cs" />
|
<Compile Include="Screens\Play\PauseContainer.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user