1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 20:22:55 +08:00

Merge pull request #525 from huoyaoyuan/controls

DropDown update
This commit is contained in:
Dean Herbert 2017-03-23 09:26:26 +09:00 committed by GitHub
commit e7f32fcbce
19 changed files with 352 additions and 406 deletions

@ -1 +1 @@
Subproject commit 31cf1c4b58c866d047876b15a95a4cf0115d3105 Subproject commit 42ec8a62fb697f1d967a927549dc51336cd66968

View File

@ -1,69 +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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
namespace osu.Game.Graphics.UserInterface
{
public class OsuDropDownHeader : DropDownHeader
{
private SpriteText label;
protected override string Label
{
get { return label.Text; }
set { label.Text = value; }
}
private Color4? accentColour;
public virtual Color4 AccentColour
{
get { return accentColour.GetValueOrDefault(); }
set
{
accentColour = value;
BackgroundColourHover = value;
}
}
public OsuDropDownHeader()
{
Foreground.Padding = new MarginPadding(4);
AutoSizeAxes = Axes.None;
Margin = new MarginPadding { Bottom = 4 };
CornerRadius = 4;
Height = 40;
Foreground.Children = new Drawable[]
{
label = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
new TextAwesome
{
Icon = FontAwesome.fa_chevron_down,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Margin = new MarginPadding { Right = 4 },
TextSize = 20
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = Color4.Black.Opacity(0.5f);
BackgroundColourHover = accentColour ?? colours.PinkDarker;
}
}
}

View File

@ -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 };
}
}

View File

@ -1,85 +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 osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using OpenTK.Graphics;
namespace osu.Game.Graphics.UserInterface
{
public class OsuDropDownMenuItem<U> : DropDownMenuItem<U>
{
public OsuDropDownMenuItem(string text, U value) : base(text, value)
{
Foreground.Padding = new MarginPadding(2);
Masking = true;
CornerRadius = 6;
Children = new[]
{
new FillFlowContainer
{
Direction = FillDirection.Horizontal,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
chevron = new TextAwesome
{
AlwaysPresent = true,
Icon = FontAwesome.fa_chevron_right,
UseFullGlyphHeight = false,
Colour = Color4.Black,
Alpha = 0.5f,
TextSize = 8,
Margin = new MarginPadding { Left = 3, Right = 3 },
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
},
new OsuSpriteText {
Text = text,
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
}
}
}
};
}
private Color4? accentColour;
private TextAwesome chevron;
protected override void FormatForeground(bool hover = false)
{
base.FormatForeground(hover);
chevron.Alpha = hover ? 1 : 0;
}
public Color4 AccentColour
{
get { return accentColour.GetValueOrDefault(); }
set
{
accentColour = value;
BackgroundColourHover = BackgroundColourSelected = value;
FormatBackground();
FormatForeground();
}
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = Color4.Transparent;
BackgroundColourHover = accentColour ?? colours.PinkDarker;
BackgroundColourSelected = Color4.Black.Opacity(0.5f);
}
}
}

View File

@ -0,0 +1,172 @@
// 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.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
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>())
item.AccentColour = value;
}
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
if (accentColour == null)
AccentColour = colours.PinkDarker;
}
protected override DropdownMenuItem<T> CreateMenuItem(string text, T value) => new OsuDropdownMenuItem(text, value) { AccentColour = AccentColour };
private class OsuDropdownMenuItem : DropdownMenuItem<T>
{
public OsuDropdownMenuItem(string text, T value) : base(text, value)
{
Foreground.Padding = new MarginPadding(2);
Masking = true;
CornerRadius = 6;
Children = new[]
{
new FillFlowContainer
{
Direction = FillDirection.Horizontal,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
chevron = new TextAwesome
{
AlwaysPresent = true,
Icon = FontAwesome.fa_chevron_right,
UseFullGlyphHeight = false,
Colour = Color4.Black,
Alpha = 0.5f,
TextSize = 8,
Margin = new MarginPadding { Left = 3, Right = 3 },
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
},
new OsuSpriteText {
Text = text,
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
}
}
}
};
}
private Color4? accentColour;
private TextAwesome chevron;
protected override void FormatForeground(bool hover = false)
{
base.FormatForeground(hover);
chevron.Alpha = hover ? 1 : 0;
}
public Color4 AccentColour
{
get { return accentColour.GetValueOrDefault(); }
set
{
accentColour = value;
BackgroundColourHover = BackgroundColourSelected = value;
FormatBackground();
FormatForeground();
}
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = Color4.Transparent;
BackgroundColourHover = accentColour ?? colours.PinkDarker;
BackgroundColourSelected = Color4.Black.Opacity(0.5f);
}
}
protected class OsuDropdownHeader : DropdownHeader
{
private SpriteText label;
protected override string Label
{
get { return label.Text; }
set { label.Text = value; }
}
private Color4? accentColour;
public virtual Color4 AccentColour
{
get { return accentColour.GetValueOrDefault(); }
set
{
accentColour = value;
BackgroundColourHover = value;
}
}
public OsuDropdownHeader()
{
Foreground.Padding = new MarginPadding(4);
AutoSizeAxes = Axes.None;
Margin = new MarginPadding { Bottom = 4 };
CornerRadius = 4;
Height = 40;
Foreground.Children = new Drawable[]
{
label = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
new TextAwesome
{
Icon = FontAwesome.fa_chevron_down,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Margin = new MarginPadding { Right = 4 },
TextSize = 20
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = Color4.Black.Opacity(0.5f);
BackgroundColourHover = accentColour ?? colours.PinkDarker;
}
}
}
}

View 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;
Background.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);
}
}
}

View File

@ -6,21 +6,25 @@ using System.Linq;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
public class OsuTabControl<T> : TabControl<T> public class OsuTabControl<T> : TabControl<T>
{ {
protected override DropDownMenu<T> CreateDropDownMenu() => new OsuTabDropDownMenu<T>(); protected override Dropdown<T> CreateDropdown() => new OsuTabDropdown();
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem<T> { Value = value }; protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem { Value = value };
protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || DropDown.Contains(screenSpacePos); protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || Dropdown.Contains(screenSpacePos);
public OsuTabControl() public OsuTabControl()
{ {
@ -45,42 +49,146 @@ namespace osu.Game.Graphics.UserInterface
set set
{ {
accentColour = value; accentColour = value;
var dropDown = DropDown as OsuTabDropDownMenu<T>; var dropDown = Dropdown as OsuTabDropdown;
if (dropDown != null) if (dropDown != null)
dropDown.AccentColour = value; dropDown.AccentColour = value;
foreach (var item in TabContainer.Children.OfType<OsuTabItem<T>>()) foreach (var item in TabContainer.Children.OfType<OsuTabItem>())
item.AccentColour = value; item.AccentColour = value;
} }
} }
public class OsuTabDropDownMenu<T1> : OsuDropDownMenu<T1> private class OsuTabItem : TabItem<T>
{ {
protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader private SpriteText text;
private Box box;
private Color4? accentColour;
public Color4 AccentColour
{
get { return accentColour.GetValueOrDefault(); }
set
{
accentColour = value;
if (!Active)
text.Colour = value;
}
}
public new T Value
{
get { return base.Value; }
set
{
base.Value = value;
text.Text = (value as Enum)?.GetDescription();
}
}
public override bool Active
{
get { return base.Active; }
set
{
if (Active == value) return;
if (value)
fadeActive();
else
fadeInactive();
base.Active = value;
}
}
private const float transition_length = 500;
private void fadeActive()
{
box.FadeIn(transition_length, EasingTypes.OutQuint);
text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint);
}
private void fadeInactive()
{
box.FadeOut(transition_length, EasingTypes.OutQuint);
text.FadeColour(AccentColour, transition_length, EasingTypes.OutQuint);
}
protected override bool OnHover(InputState state)
{
if (!Active)
fadeActive();
return true;
}
protected override void OnHoverLost(InputState state)
{
if (!Active)
fadeInactive();
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
if (accentColour == null)
AccentColour = colours.Blue;
}
public OsuTabItem()
{
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
Children = new Drawable[]
{
text = new OsuSpriteText
{
Margin = new MarginPadding(5),
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
TextSize = 14,
Font = @"Exo2.0-Bold", // Font should only turn bold when active?
},
box = new Box
{
RelativeSizeAxes = Axes.X,
Height = 1,
Alpha = 0,
Colour = Color4.White,
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
}
};
}
}
private class OsuTabDropdown : OsuDropdown<T>
{
protected override DropdownHeader CreateHeader() => new OsuTabDropdownHeader
{ {
AccentColour = AccentColour, AccentColour = AccentColour,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
}; };
protected override DropDownMenuItem<T1> CreateDropDownItem(string key, T1 value) protected override DropdownMenuItem<T> CreateMenuItem(string text, T value)
{ {
var item = base.CreateDropDownItem(key, value); var item = base.CreateMenuItem(text, value);
item.ForegroundColourHover = Color4.Black; item.ForegroundColourHover = Color4.Black;
return item; return item;
} }
public OsuTabDropDownMenu() public OsuTabDropdown()
{ {
ContentContainer.Anchor = Anchor.TopRight; DropdownMenu.Anchor = Anchor.TopRight;
ContentContainer.Origin = Anchor.TopRight; DropdownMenu.Origin = Anchor.TopRight;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
ContentBackground.Colour = Color4.Black.Opacity(0.7f); DropdownMenu.Background.Colour = Color4.Black.Opacity(0.7f);
MaxDropDownHeight = 400; DropdownMenu.MaxHeight = 400;
} }
public class OsuTabDropDownHeader : OsuDropDownHeader protected class OsuTabDropdownHeader : OsuDropdownHeader
{ {
public override Color4 AccentColour public override Color4 AccentColour
{ {
@ -104,7 +212,7 @@ namespace osu.Game.Graphics.UserInterface
base.OnHoverLost(state); base.OnHoverLost(state);
} }
public OsuTabDropDownHeader() public OsuTabDropdownHeader()
{ {
RelativeSizeAxes = Axes.None; RelativeSizeAxes = Axes.None;
AutoSizeAxes = Axes.X; AutoSizeAxes = Axes.X;

View File

@ -1,121 +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;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface
{
public class OsuTabItem<T> : TabItem<T>
{
private SpriteText text;
private Box box;
private Color4? accentColour;
public Color4 AccentColour
{
get { return accentColour.GetValueOrDefault(); }
set
{
accentColour = value;
if (!Active)
text.Colour = value;
}
}
public new T Value
{
get { return base.Value; }
set
{
base.Value = value;
text.Text = (value as Enum)?.GetDescription();
}
}
public override bool Active
{
get { return base.Active; }
set
{
if (Active == value) return;
if (value)
fadeActive();
else
fadeInactive();
base.Active = value;
}
}
private const float transition_length = 500;
private void fadeActive()
{
box.FadeIn(transition_length, EasingTypes.OutQuint);
text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint);
}
private void fadeInactive()
{
box.FadeOut(transition_length, EasingTypes.OutQuint);
text.FadeColour(AccentColour, transition_length, EasingTypes.OutQuint);
}
protected override bool OnHover(InputState state)
{
if (!Active)
fadeActive();
return true;
}
protected override void OnHoverLost(InputState state)
{
if (!Active)
fadeInactive();
}
public OsuTabItem()
{
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
Children = new Drawable[]
{
text = new OsuSpriteText
{
Margin = new MarginPadding(5),
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
TextSize = 14,
Font = @"Exo2.0-Bold", // Font should only turn bold when active?
},
box = new Box
{
RelativeSizeAxes = Axes.X,
Height = 1,
Alpha = 0,
Colour = Color4.White,
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
if (accentColour == null)
AccentColour = colours.Blue;
}
}
}

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System.Collections.Generic;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -10,13 +10,12 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using System.Collections.Generic;
namespace osu.Game.Overlays.Options namespace osu.Game.Overlays.Options
{ {
public class OptionDropDown<T> : FillFlowContainer public class OptionDropdown<T> : FillFlowContainer
{ {
private DropDownMenu<T> dropdown; private Dropdown<T> dropdown;
private SpriteText text; private SpriteText text;
public string LabelText public string LabelText
@ -33,12 +32,8 @@ namespace osu.Game.Overlays.Options
get { return bindable; } get { return bindable; }
set set
{ {
if (bindable != null)
bindable.ValueChanged -= bindable_ValueChanged;
bindable = value; bindable = value;
bindable.ValueChanged += bindable_ValueChanged; dropdown.SelectedValue.BindTo(bindable);
bindable_ValueChanged(null, null);
if (bindable.Disabled) if (bindable.Disabled)
Alpha = 0.3f; Alpha = 0.3f;
} }
@ -46,23 +41,6 @@ namespace osu.Game.Overlays.Options
private Bindable<T> bindable; private Bindable<T> bindable;
private void bindable_ValueChanged(object sender, EventArgs e)
{
dropdown.SelectedValue = bindable.Value;
}
private void dropdown_ValueChanged(object sender, EventArgs e)
{
bindable.Value = dropdown.SelectedValue;
}
protected override void Dispose(bool isDisposing)
{
bindable.ValueChanged -= bindable_ValueChanged;
dropdown.ValueChanged -= dropdown_ValueChanged;
base.Dispose(isDisposing);
}
private IEnumerable<KeyValuePair<string, T>> items; private IEnumerable<KeyValuePair<string, T>> items;
public IEnumerable<KeyValuePair<string, T>> Items public IEnumerable<KeyValuePair<string, T>> Items
{ {
@ -73,19 +51,12 @@ namespace osu.Game.Overlays.Options
set set
{ {
items = value; items = value;
if(dropdown != null) if (dropdown != null)
{
dropdown.Items = value; dropdown.Items = value;
// We need to refresh the dropdown because our items changed,
// thus its selected value may be outdated.
if (bindable != null)
dropdown.SelectedValue = bindable.Value;
}
} }
} }
public OptionDropDown() public OptionDropdown()
{ {
Items = new KeyValuePair<string, T>[0]; Items = new KeyValuePair<string, T>[0];
@ -97,14 +68,13 @@ namespace osu.Game.Overlays.Options
text = new OsuSpriteText { text = new OsuSpriteText {
Alpha = 0, Alpha = 0,
}, },
dropdown = new OsuDropDownMenu<T> dropdown = new OsuDropdown<T>
{ {
Margin = new MarginPadding { Top = 5 }, Margin = new MarginPadding { Top = 5 },
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Items = Items, Items = Items,
} }
}; };
dropdown.ValueChanged += dropdown_ValueChanged;
} }
} }
} }

View File

@ -8,9 +8,9 @@ using System.Collections.Generic;
namespace osu.Game.Overlays.Options namespace osu.Game.Overlays.Options
{ {
public class OptionEnumDropDown<T> : OptionDropDown<T> public class OptionEnumDropdown<T> : OptionDropdown<T>
{ {
public OptionEnumDropDown() public OptionEnumDropdown()
{ {
if (!typeof(T).IsEnum) if (!typeof(T).IsEnum)
throw new InvalidOperationException("OptionsDropdown only supports enums as the generic type argument"); throw new InvalidOperationException("OptionsDropdown only supports enums as the generic type argument");

View File

@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Options.Sections.Audio
protected override string Header => "Devices"; protected override string Header => "Devices";
private AudioManager audio; private AudioManager audio;
private OptionDropDown<string> dropdown; private OptionDropdown<string> dropdown;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
@ -50,7 +50,7 @@ namespace osu.Game.Overlays.Options.Sections.Audio
Children = new Drawable[] Children = new Drawable[]
{ {
dropdown = new OptionDropDown<string> dropdown = new OptionDropdown<string>
{ {
Bindable = audio.AudioDevice Bindable = audio.AudioDevice
}, },

View File

@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Options.Sections.Debug
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
new OptionEnumDropDown<GCLatencyMode> new OptionEnumDropdown<GCLatencyMode>
{ {
LabelText = "Active mode", LabelText = "Active mode",
Bindable = config.GetBindable<GCLatencyMode>(FrameworkDebugConfig.ActiveGCMode) Bindable = config.GetBindable<GCLatencyMode>(FrameworkDebugConfig.ActiveGCMode)

View File

@ -23,12 +23,12 @@ namespace osu.Game.Overlays.Options.Sections.Gameplay
LabelText = "Background dim", LabelText = "Background dim",
Bindable = (BindableInt)config.GetBindable<int>(OsuConfig.DimLevel) Bindable = (BindableInt)config.GetBindable<int>(OsuConfig.DimLevel)
}, },
new OptionEnumDropDown<ProgressBarType> new OptionEnumDropdown<ProgressBarType>
{ {
LabelText = "Progress display", LabelText = "Progress display",
Bindable = config.GetBindable<ProgressBarType>(OsuConfig.ProgressBarType) Bindable = config.GetBindable<ProgressBarType>(OsuConfig.ProgressBarType)
}, },
new OptionEnumDropDown<ScoreMeterType> new OptionEnumDropdown<ScoreMeterType>
{ {
LabelText = "Score meter type", LabelText = "Score meter type",
Bindable = config.GetBindable<ScoreMeterType>(OsuConfig.ScoreMeter) Bindable = config.GetBindable<ScoreMeterType>(OsuConfig.ScoreMeter)

View File

@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Options.Sections.General
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
new OptionEnumDropDown<ReleaseStream> new OptionEnumDropdown<ReleaseStream>
{ {
LabelText = "Release stream", LabelText = "Release stream",
Bindable = config.GetBindable<ReleaseStream>(OsuConfig.ReleaseStream), Bindable = config.GetBindable<ReleaseStream>(OsuConfig.ReleaseStream),

View File

@ -57,7 +57,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
LabelText = "Softening filter", LabelText = "Softening filter",
Bindable = config.GetBindable<bool>(OsuConfig.BloomSoftening) Bindable = config.GetBindable<bool>(OsuConfig.BloomSoftening)
}, },
new OptionEnumDropDown<ScreenshotFormat> new OptionEnumDropdown<ScreenshotFormat>
{ {
LabelText = "Screenshot", LabelText = "Screenshot",
Bindable = config.GetBindable<ScreenshotFormat>(OsuConfig.ScreenshotFormat) Bindable = config.GetBindable<ScreenshotFormat>(OsuConfig.ScreenshotFormat)

View File

@ -26,7 +26,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
Children = new Drawable[] Children = new Drawable[]
{ {
new OptionLabel { Text = "Resolution: TODO dropdown" }, new OptionLabel { Text = "Resolution: TODO dropdown" },
new OptionEnumDropDown<WindowMode> new OptionEnumDropdown<WindowMode>
{ {
LabelText = "Screen mode", LabelText = "Screen mode",
Bindable = config.GetBindable<WindowMode>(FrameworkConfig.WindowMode), Bindable = config.GetBindable<WindowMode>(FrameworkConfig.WindowMode),

View File

@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
Children = new Drawable[] Children = new Drawable[]
{ {
// TODO: this needs to be a custom dropdown at some point // TODO: this needs to be a custom dropdown at some point
new OptionEnumDropDown<FrameSync> new OptionEnumDropdown<FrameSync>
{ {
LabelText = "Frame limiter", LabelText = "Frame limiter",
Bindable = config.GetBindable<FrameSync>(FrameworkConfig.FrameSync) Bindable = config.GetBindable<FrameSync>(FrameworkConfig.FrameSync)

View File

@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Options.Sections.Input
LabelText = "Map absolute raw input to the osu! window", LabelText = "Map absolute raw input to the osu! window",
Bindable = config.GetBindable<bool>(OsuConfig.AbsoluteToOsuWindow) Bindable = config.GetBindable<bool>(OsuConfig.AbsoluteToOsuWindow)
}, },
new OptionEnumDropDown<ConfineMouseMode> new OptionEnumDropdown<ConfineMouseMode>
{ {
LabelText = "Confine mouse cursor", LabelText = "Confine mouse cursor",
Bindable = config.GetBindable<ConfineMouseMode>(OsuConfig.ConfineMouse), Bindable = config.GetBindable<ConfineMouseMode>(OsuConfig.ConfineMouse),

View File

@ -86,6 +86,7 @@
<Compile Include="Graphics\UserInterface\BackButton.cs" /> <Compile Include="Graphics\UserInterface\BackButton.cs" />
<Compile Include="Graphics\UserInterface\FocusedTextBox.cs" /> <Compile Include="Graphics\UserInterface\FocusedTextBox.cs" />
<Compile Include="Graphics\UserInterface\Nub.cs" /> <Compile Include="Graphics\UserInterface\Nub.cs" />
<Compile Include="Graphics\UserInterface\OsuMenu.cs" />
<Compile Include="Graphics\UserInterface\OsuPasswordTextBox.cs" /> <Compile Include="Graphics\UserInterface\OsuPasswordTextBox.cs" />
<Compile Include="Graphics\UserInterface\OsuSliderBar.cs" /> <Compile Include="Graphics\UserInterface\OsuSliderBar.cs" />
<Compile Include="Graphics\UserInterface\OsuTextBox.cs" /> <Compile Include="Graphics\UserInterface\OsuTextBox.cs" />
@ -160,9 +161,7 @@
<Compile Include="Overlays\Notifications\SimpleNotification.cs" /> <Compile Include="Overlays\Notifications\SimpleNotification.cs" />
<Compile Include="Overlays\Options\OptionDropDown.cs" /> <Compile Include="Overlays\Options\OptionDropDown.cs" />
<Compile Include="Overlays\Options\OptionLabel.cs" /> <Compile Include="Overlays\Options\OptionLabel.cs" />
<Compile Include="Graphics\UserInterface\OsuDropDownHeader.cs" /> <Compile Include="Graphics\UserInterface\OsuDropdown.cs" />
<Compile Include="Graphics\UserInterface\OsuDropDownMenu.cs" />
<Compile Include="Graphics\UserInterface\OsuDropDownMenuItem.cs" />
<Compile Include="Overlays\Options\OptionsFooter.cs" /> <Compile Include="Overlays\Options\OptionsFooter.cs" />
<Compile Include="Overlays\Options\Sections\DebugSection.cs" /> <Compile Include="Overlays\Options\Sections\DebugSection.cs" />
<Compile Include="Overlays\Options\Sections\Debug\GeneralOptions.cs" /> <Compile Include="Overlays\Options\Sections\Debug\GeneralOptions.cs" />
@ -362,7 +361,6 @@
<Compile Include="Users\Avatar.cs" /> <Compile Include="Users\Avatar.cs" />
<Compile Include="Screens\Select\Leaderboards\DrawableRank.cs" /> <Compile Include="Screens\Select\Leaderboards\DrawableRank.cs" />
<Compile Include="Graphics\UserInterface\OsuTabControl.cs" /> <Compile Include="Graphics\UserInterface\OsuTabControl.cs" />
<Compile Include="Graphics\UserInterface\OsuTabItem.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj"> <ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">