mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:03:08 +08:00
Update to DropDown and Menu.
This commit is contained in:
parent
1d13924e0a
commit
f0edf5d3d3
40
osu.Game/Graphics/UserInterface/OsuDropDown.cs
Normal file
40
osu.Game/Graphics/UserInterface/OsuDropDown.cs
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuDropDown<T> : DropDown<T>
|
||||
{
|
||||
protected override DropDownHeader CreateHeader() => new OsuDropDownHeader { AccentColour = AccentColour };
|
||||
|
||||
protected override Menu CreateMenu() => new OsuMenu();
|
||||
|
||||
private Color4? accentColour;
|
||||
public virtual Color4 AccentColour
|
||||
{
|
||||
get { return accentColour.GetValueOrDefault(); }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
if (Header != null)
|
||||
((OsuDropDownHeader)Header).AccentColour = value;
|
||||
foreach (var item in MenuItems.OfType<OsuDropDownMenuItem<T>>())
|
||||
item.AccentColour = value;
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
if (accentColour == null)
|
||||
AccentColour = colours.PinkDarker;
|
||||
}
|
||||
|
||||
protected override DropDownMenuItem<T> CreateMenuItem(string key, T value) => new OsuDropDownMenuItem<T>(key, value) { AccentColour = AccentColour };
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuDropDownMenu<T> : DropDownMenu<T>
|
||||
{
|
||||
protected override DropDownHeader CreateHeader() => new OsuDropDownHeader { AccentColour = AccentColour };
|
||||
|
||||
private Color4? accentColour;
|
||||
public virtual Color4 AccentColour
|
||||
{
|
||||
get { return accentColour.GetValueOrDefault(); }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
if (Header != null)
|
||||
((OsuDropDownHeader)Header).AccentColour = value;
|
||||
foreach (var item in ItemList.OfType<OsuDropDownMenuItem<T>>())
|
||||
item.AccentColour = value;
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
if (accentColour == null)
|
||||
AccentColour = colours.PinkDarker;
|
||||
}
|
||||
|
||||
public OsuDropDownMenu()
|
||||
{
|
||||
ContentContainer.CornerRadius = 4;
|
||||
ContentBackground.Colour = Color4.Black.Opacity(0.5f);
|
||||
|
||||
DropDownItemsContainer.Padding = new MarginPadding(5);
|
||||
}
|
||||
|
||||
protected override void AnimateOpen() => ContentContainer.FadeIn(300, EasingTypes.OutQuint);
|
||||
|
||||
protected override void AnimateClose() => ContentContainer.FadeOut(300, EasingTypes.OutQuint);
|
||||
|
||||
protected override void UpdateContentHeight()
|
||||
{
|
||||
var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight;
|
||||
ContentContainer.ResizeTo(new Vector2(1, State == DropDownMenuState.Opened ? actualHeight : 0), 300, EasingTypes.OutQuint);
|
||||
}
|
||||
|
||||
protected override DropDownMenuItem<T> CreateDropDownItem(string key, T value) => new OsuDropDownMenuItem<T>(key, value) { AccentColour = AccentColour };
|
||||
}
|
||||
}
|
34
osu.Game/Graphics/UserInterface/OsuMenu.cs
Normal file
34
osu.Game/Graphics/UserInterface/OsuMenu.cs
Normal file
@ -0,0 +1,34 @@
|
||||
// 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 OpenTK.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuMenu : Menu
|
||||
{
|
||||
public OsuMenu()
|
||||
{
|
||||
CornerRadius = 4;
|
||||
ContentBackground.Colour = Color4.Black.Opacity(0.5f);
|
||||
|
||||
ItemsContainer.Padding = new MarginPadding(5);
|
||||
}
|
||||
|
||||
protected override void AnimateOpen() => FadeIn(300, EasingTypes.OutQuint);
|
||||
|
||||
protected override void AnimateClose() => FadeOut(300, EasingTypes.OutQuint);
|
||||
|
||||
protected override void UpdateContentHeight()
|
||||
{
|
||||
var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight;
|
||||
ResizeTo(new Vector2(1, State == MenuState.Opened ? actualHeight : 0), 300, EasingTypes.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuTabControl<T> : TabControl<T>
|
||||
{
|
||||
protected override DropDownMenu<T> CreateDropDownMenu() => new OsuTabDropDownMenu();
|
||||
protected override DropDown<T> CreateDropDownMenu() => new OsuTabDropDown();
|
||||
|
||||
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem<T> { Value = value };
|
||||
|
||||
@ -45,7 +45,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
var dropDown = DropDown as OsuTabDropDownMenu;
|
||||
var dropDown = DropDown as OsuTabDropDown;
|
||||
if (dropDown != null)
|
||||
dropDown.AccentColour = value;
|
||||
foreach (var item in TabContainer.Children.OfType<OsuTabItem<T>>())
|
||||
@ -53,7 +53,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
public class OsuTabDropDownMenu : OsuDropDownMenu<T>
|
||||
public class OsuTabDropDown : OsuDropDown<T>
|
||||
{
|
||||
protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader
|
||||
{
|
||||
@ -62,22 +62,22 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Origin = Anchor.TopRight,
|
||||
};
|
||||
|
||||
protected override DropDownMenuItem<T> CreateDropDownItem(string key, T value)
|
||||
protected override DropDownMenuItem<T> CreateMenuItem(string key, T value)
|
||||
{
|
||||
var item = base.CreateDropDownItem(key, value);
|
||||
var item = base.CreateMenuItem(key, value);
|
||||
item.ForegroundColourHover = Color4.Black;
|
||||
return item;
|
||||
}
|
||||
|
||||
public OsuTabDropDownMenu()
|
||||
public OsuTabDropDown()
|
||||
{
|
||||
ContentContainer.Anchor = Anchor.TopRight;
|
||||
ContentContainer.Origin = Anchor.TopRight;
|
||||
DropDownMenu.Anchor = Anchor.TopRight;
|
||||
DropDownMenu.Origin = Anchor.TopRight;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
ContentBackground.Colour = Color4.Black.Opacity(0.7f);
|
||||
MaxDropDownHeight = 400;
|
||||
DropDownMenu.Colour = Color4.Black.Opacity(0.7f);
|
||||
DropDownMenu.MaxHeight = 400;
|
||||
}
|
||||
|
||||
public class OsuTabDropDownHeader : OsuDropDownHeader
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Options
|
||||
{
|
||||
public class OptionDropDown<T> : FillFlowContainer
|
||||
{
|
||||
private DropDownMenu<T> dropdown;
|
||||
private DropDown<T> dropdown;
|
||||
private SpriteText text;
|
||||
|
||||
public string LabelText
|
||||
@ -97,7 +97,7 @@ namespace osu.Game.Overlays.Options
|
||||
text = new OsuSpriteText {
|
||||
Alpha = 0,
|
||||
},
|
||||
dropdown = new OsuDropDownMenu<T>
|
||||
dropdown = new OsuDropDown<T>
|
||||
{
|
||||
Margin = new MarginPadding { Top = 5 },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
|
@ -85,6 +85,7 @@
|
||||
<Compile Include="Graphics\UserInterface\BackButton.cs" />
|
||||
<Compile Include="Graphics\UserInterface\FocusedTextBox.cs" />
|
||||
<Compile Include="Graphics\UserInterface\Nub.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuMenu.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuPasswordTextBox.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuSliderBar.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuTextBox.cs" />
|
||||
@ -159,7 +160,7 @@
|
||||
<Compile Include="Overlays\Options\OptionDropDown.cs" />
|
||||
<Compile Include="Overlays\Options\OptionLabel.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuDropDownHeader.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuDropDownMenu.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuDropDown.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuDropDownMenuItem.cs" />
|
||||
<Compile Include="Overlays\Options\OptionsFooter.cs" />
|
||||
<Compile Include="Overlays\Options\Sections\DebugSection.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user