From 1d13924e0a9051d8f5582b9922c0e8bcd27d2a54 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 21 Mar 2017 01:05:48 +0800 Subject: [PATCH 1/9] Remove redundant type parameter. Nested type has implicit type parameter from base type. --- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index d5699eddaf..de81757fdf 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface { public class OsuTabControl : TabControl { - protected override DropDownMenu CreateDropDownMenu() => new OsuTabDropDownMenu(); + protected override DropDownMenu CreateDropDownMenu() => new OsuTabDropDownMenu(); protected override TabItem CreateTabItem(T value) => new OsuTabItem { Value = value }; @@ -45,7 +45,7 @@ namespace osu.Game.Graphics.UserInterface set { accentColour = value; - var dropDown = DropDown as OsuTabDropDownMenu; + var dropDown = DropDown as OsuTabDropDownMenu; if (dropDown != null) dropDown.AccentColour = value; foreach (var item in TabContainer.Children.OfType>()) @@ -53,7 +53,7 @@ namespace osu.Game.Graphics.UserInterface } } - public class OsuTabDropDownMenu : OsuDropDownMenu + public class OsuTabDropDownMenu : OsuDropDownMenu { protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader { @@ -62,7 +62,7 @@ namespace osu.Game.Graphics.UserInterface Origin = Anchor.TopRight, }; - protected override DropDownMenuItem CreateDropDownItem(string key, T1 value) + protected override DropDownMenuItem CreateDropDownItem(string key, T value) { var item = base.CreateDropDownItem(key, value); item.ForegroundColourHover = Color4.Black; From f0edf5d3d3ec772961c51cce18e45af51c199b61 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 22 Mar 2017 06:51:26 +0800 Subject: [PATCH 2/9] Update to DropDown and Menu. --- .../Graphics/UserInterface/OsuDropDown.cs | 40 ++++++++++++ .../Graphics/UserInterface/OsuDropDownMenu.cs | 61 ------------------- osu.Game/Graphics/UserInterface/OsuMenu.cs | 34 +++++++++++ .../Graphics/UserInterface/OsuTabControl.cs | 20 +++--- osu.Game/Overlays/Options/OptionDropDown.cs | 4 +- osu.Game/osu.Game.csproj | 3 +- 6 files changed, 88 insertions(+), 74 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/OsuDropDown.cs delete mode 100644 osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs create mode 100644 osu.Game/Graphics/UserInterface/OsuMenu.cs diff --git a/osu.Game/Graphics/UserInterface/OsuDropDown.cs b/osu.Game/Graphics/UserInterface/OsuDropDown.cs new file mode 100644 index 0000000000..51fb335698 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/OsuDropDown.cs @@ -0,0 +1,40 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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 : DropDown + { + 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>()) + item.AccentColour = value; + } + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + if (accentColour == null) + AccentColour = colours.PinkDarker; + } + + protected override DropDownMenuItem CreateMenuItem(string key, T value) => new OsuDropDownMenuItem(key, value) { AccentColour = AccentColour }; + } +} \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs deleted file mode 100644 index 5d9e30db8d..0000000000 --- a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// 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 : DropDownMenu - { - 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>()) - 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 CreateDropDownItem(string key, T value) => new OsuDropDownMenuItem(key, value) { AccentColour = AccentColour }; - } -} \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs new file mode 100644 index 0000000000..4e80e1502a --- /dev/null +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -0,0 +1,34 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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); + } + } +} diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index de81757fdf..947b39f621 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface { public class OsuTabControl : TabControl { - protected override DropDownMenu CreateDropDownMenu() => new OsuTabDropDownMenu(); + protected override DropDown CreateDropDownMenu() => new OsuTabDropDown(); protected override TabItem CreateTabItem(T value) => new OsuTabItem { 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>()) @@ -53,7 +53,7 @@ namespace osu.Game.Graphics.UserInterface } } - public class OsuTabDropDownMenu : OsuDropDownMenu + public class OsuTabDropDown : OsuDropDown { protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader { @@ -62,22 +62,22 @@ namespace osu.Game.Graphics.UserInterface Origin = Anchor.TopRight, }; - protected override DropDownMenuItem CreateDropDownItem(string key, T value) + protected override DropDownMenuItem 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 diff --git a/osu.Game/Overlays/Options/OptionDropDown.cs b/osu.Game/Overlays/Options/OptionDropDown.cs index 4387e90b5a..690d3d21a5 100644 --- a/osu.Game/Overlays/Options/OptionDropDown.cs +++ b/osu.Game/Overlays/Options/OptionDropDown.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Options { public class OptionDropDown : FillFlowContainer { - private DropDownMenu dropdown; + private DropDown dropdown; private SpriteText text; public string LabelText @@ -97,7 +97,7 @@ namespace osu.Game.Overlays.Options text = new OsuSpriteText { Alpha = 0, }, - dropdown = new OsuDropDownMenu + dropdown = new OsuDropDown { Margin = new MarginPadding { Top = 5 }, RelativeSizeAxes = Axes.X, diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 188d929888..3f97e196db 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -85,6 +85,7 @@ + @@ -159,7 +160,7 @@ - + From b46ded77945cfb9484cb2f797e070b10d8728ca9 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 22 Mar 2017 07:49:21 +0800 Subject: [PATCH 3/9] Use Bindable for DropDown. --- osu.Game/Overlays/Options/OptionDropDown.cs | 36 ++------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/osu.Game/Overlays/Options/OptionDropDown.cs b/osu.Game/Overlays/Options/OptionDropDown.cs index 690d3d21a5..9c9cd17b12 100644 --- a/osu.Game/Overlays/Options/OptionDropDown.cs +++ b/osu.Game/Overlays/Options/OptionDropDown.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // 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.Graphics; using osu.Framework.Graphics.Containers; @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using System.Collections.Generic; namespace osu.Game.Overlays.Options { @@ -33,12 +32,8 @@ namespace osu.Game.Overlays.Options get { return bindable; } set { - if (bindable != null) - bindable.ValueChanged -= bindable_ValueChanged; bindable = value; - bindable.ValueChanged += bindable_ValueChanged; - bindable_ValueChanged(null, null); - + dropdown.SelectedValue.BindTo(bindable); if (bindable.Disabled) Alpha = 0.3f; } @@ -46,23 +41,6 @@ namespace osu.Game.Overlays.Options private Bindable 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> items; public IEnumerable> Items { @@ -73,15 +51,8 @@ namespace osu.Game.Overlays.Options set { items = value; - if(dropdown != null) - { + if (dropdown != null) 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; - } } } @@ -104,7 +75,6 @@ namespace osu.Game.Overlays.Options Items = Items, } }; - dropdown.ValueChanged += dropdown_ValueChanged; } } } From b06eb0122c8860fa480081cde2849d162a3e3272 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 22 Mar 2017 07:55:47 +0800 Subject: [PATCH 4/9] Fix for colours and members rename. --- osu.Game/Graphics/UserInterface/OsuDropDown.cs | 2 +- osu.Game/Graphics/UserInterface/OsuMenu.cs | 2 +- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuDropDown.cs b/osu.Game/Graphics/UserInterface/OsuDropDown.cs index 51fb335698..a921be1a1d 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropDown.cs @@ -35,6 +35,6 @@ namespace osu.Game.Graphics.UserInterface AccentColour = colours.PinkDarker; } - protected override DropDownMenuItem CreateMenuItem(string key, T value) => new OsuDropDownMenuItem(key, value) { AccentColour = AccentColour }; + protected override DropDownMenuItem CreateMenuItem(string text, T value) => new OsuDropDownMenuItem(text, value) { AccentColour = AccentColour }; } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index 4e80e1502a..95df3be9bf 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface public OsuMenu() { CornerRadius = 4; - ContentBackground.Colour = Color4.Black.Opacity(0.5f); + Background.Colour = Color4.Black.Opacity(0.5f); ItemsContainer.Padding = new MarginPadding(5); } diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 947b39f621..84f3125ca4 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface { public class OsuTabControl : TabControl { - protected override DropDown CreateDropDownMenu() => new OsuTabDropDown(); + protected override DropDown CreateDropDown() => new OsuTabDropDown(); protected override TabItem CreateTabItem(T value) => new OsuTabItem { Value = value }; @@ -62,9 +62,9 @@ namespace osu.Game.Graphics.UserInterface Origin = Anchor.TopRight, }; - protected override DropDownMenuItem CreateMenuItem(string key, T value) + protected override DropDownMenuItem CreateMenuItem(string text, T value) { - var item = base.CreateMenuItem(key, value); + var item = base.CreateMenuItem(text, value); item.ForegroundColourHover = Color4.Black; return item; } @@ -76,7 +76,7 @@ namespace osu.Game.Graphics.UserInterface RelativeSizeAxes = Axes.X; - DropDownMenu.Colour = Color4.Black.Opacity(0.7f); + DropDownMenu.Background.Colour = Color4.Black.Opacity(0.7f); DropDownMenu.MaxHeight = 400; } From 0dbc232ebf96c8f425b90d4c445909a04df9b758 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 22 Mar 2017 22:32:32 +0800 Subject: [PATCH 5/9] Rename all DropDown -> Dropdown. --- .../{OsuDropDown.cs => OsuDropdown.cs} | 10 +++---- ...DropDownHeader.cs => OsuDropdownHeader.cs} | 4 +-- ...DownMenuItem.cs => OsuDropdownMenuItem.cs} | 4 +-- .../Graphics/UserInterface/OsuTabControl.cs | 26 +++++++++---------- .../{OptionDropDown.cs => OptionDropdown.cs} | 8 +++--- ...nEnumDropDown.cs => OptionEnumDropdown.cs} | 4 +-- .../Sections/Audio/AudioDevicesOptions.cs | 4 +-- .../Options/Sections/Debug/GCOptions.cs | 2 +- .../Sections/Gameplay/GeneralOptions.cs | 4 +-- .../Options/Sections/General/UpdateOptions.cs | 2 +- .../Sections/Graphics/DetailOptions.cs | 2 +- .../Sections/Graphics/LayoutOptions.cs | 2 +- .../Sections/Graphics/RendererOptions.cs | 2 +- .../Options/Sections/Input/MouseOptions.cs | 2 +- osu.Game/osu.Game.csproj | 6 ++--- 15 files changed, 41 insertions(+), 41 deletions(-) rename osu.Game/Graphics/UserInterface/{OsuDropDown.cs => OsuDropdown.cs} (67%) rename osu.Game/Graphics/UserInterface/{OsuDropDownHeader.cs => OsuDropdownHeader.cs} (92%) rename osu.Game/Graphics/UserInterface/{OsuDropDownMenuItem.cs => OsuDropdownMenuItem.cs} (92%) rename osu.Game/Overlays/Options/{OptionDropDown.cs => OptionDropdown.cs} (88%) rename osu.Game/Overlays/Options/{OptionEnumDropDown.cs => OptionEnumDropdown.cs} (89%) diff --git a/osu.Game/Graphics/UserInterface/OsuDropDown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs similarity index 67% rename from osu.Game/Graphics/UserInterface/OsuDropDown.cs rename to osu.Game/Graphics/UserInterface/OsuDropdown.cs index a921be1a1d..d8d4a93091 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -8,9 +8,9 @@ using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface { - public class OsuDropDown : DropDown + public class OsuDropdown : Dropdown { - protected override DropDownHeader CreateHeader() => new OsuDropDownHeader { AccentColour = AccentColour }; + protected override DropdownHeader CreateHeader() => new OsuDropdownHeader { AccentColour = AccentColour }; protected override Menu CreateMenu() => new OsuMenu(); @@ -22,8 +22,8 @@ namespace osu.Game.Graphics.UserInterface { accentColour = value; if (Header != null) - ((OsuDropDownHeader)Header).AccentColour = value; - foreach (var item in MenuItems.OfType>()) + ((OsuDropdownHeader)Header).AccentColour = value; + foreach (var item in MenuItems.OfType>()) item.AccentColour = value; } } @@ -35,6 +35,6 @@ namespace osu.Game.Graphics.UserInterface AccentColour = colours.PinkDarker; } - protected override DropDownMenuItem CreateMenuItem(string text, T value) => new OsuDropDownMenuItem(text, value) { AccentColour = AccentColour }; + protected override DropdownMenuItem CreateMenuItem(string text, T value) => new OsuDropdownMenuItem(text, value) { AccentColour = AccentColour }; } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs b/osu.Game/Graphics/UserInterface/OsuDropdownHeader.cs similarity index 92% rename from osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs rename to osu.Game/Graphics/UserInterface/OsuDropdownHeader.cs index 559ffca283..8bef24a6f8 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdownHeader.cs @@ -12,7 +12,7 @@ using osu.Framework.Extensions.Color4Extensions; namespace osu.Game.Graphics.UserInterface { - public class OsuDropDownHeader : DropDownHeader + public class OsuDropdownHeader : DropdownHeader { private SpriteText label; protected override string Label @@ -32,7 +32,7 @@ namespace osu.Game.Graphics.UserInterface } } - public OsuDropDownHeader() + public OsuDropdownHeader() { Foreground.Padding = new MarginPadding(4); diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuDropdownMenuItem.cs similarity index 92% rename from osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs rename to osu.Game/Graphics/UserInterface/OsuDropdownMenuItem.cs index 71650dee52..bcd53a8dbd 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdownMenuItem.cs @@ -12,9 +12,9 @@ using OpenTK.Graphics; namespace osu.Game.Graphics.UserInterface { - public class OsuDropDownMenuItem : DropDownMenuItem + public class OsuDropdownMenuItem : DropdownMenuItem { - public OsuDropDownMenuItem(string text, U value) : base(text, value) + public OsuDropdownMenuItem(string text, T value) : base(text, value) { Foreground.Padding = new MarginPadding(2); diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 84f3125ca4..8a22347c76 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -16,11 +16,11 @@ namespace osu.Game.Graphics.UserInterface { public class OsuTabControl : TabControl { - protected override DropDown CreateDropDown() => new OsuTabDropDown(); + protected override Dropdown CreateDropdown() => new OsuTabDropdown(); protected override TabItem 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() { @@ -45,7 +45,7 @@ namespace osu.Game.Graphics.UserInterface set { accentColour = value; - var dropDown = DropDown as OsuTabDropDown; + var dropDown = Dropdown as OsuTabDropdown; if (dropDown != null) dropDown.AccentColour = value; foreach (var item in TabContainer.Children.OfType>()) @@ -53,34 +53,34 @@ namespace osu.Game.Graphics.UserInterface } } - public class OsuTabDropDown : OsuDropDown + public class OsuTabDropdown : OsuDropdown { - protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader + protected override DropdownHeader CreateHeader() => new OsuTabDropdownHeader { AccentColour = AccentColour, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, }; - protected override DropDownMenuItem CreateMenuItem(string text, T value) + protected override DropdownMenuItem CreateMenuItem(string text, T value) { var item = base.CreateMenuItem(text, value); item.ForegroundColourHover = Color4.Black; return item; } - public OsuTabDropDown() + public OsuTabDropdown() { - DropDownMenu.Anchor = Anchor.TopRight; - DropDownMenu.Origin = Anchor.TopRight; + DropdownMenu.Anchor = Anchor.TopRight; + DropdownMenu.Origin = Anchor.TopRight; RelativeSizeAxes = Axes.X; - DropDownMenu.Background.Colour = Color4.Black.Opacity(0.7f); - DropDownMenu.MaxHeight = 400; + DropdownMenu.Background.Colour = Color4.Black.Opacity(0.7f); + DropdownMenu.MaxHeight = 400; } - public class OsuTabDropDownHeader : OsuDropDownHeader + public class OsuTabDropdownHeader : OsuDropdownHeader { public override Color4 AccentColour { @@ -104,7 +104,7 @@ namespace osu.Game.Graphics.UserInterface base.OnHoverLost(state); } - public OsuTabDropDownHeader() + public OsuTabDropdownHeader() { RelativeSizeAxes = Axes.None; AutoSizeAxes = Axes.X; diff --git a/osu.Game/Overlays/Options/OptionDropDown.cs b/osu.Game/Overlays/Options/OptionDropdown.cs similarity index 88% rename from osu.Game/Overlays/Options/OptionDropDown.cs rename to osu.Game/Overlays/Options/OptionDropdown.cs index 9c9cd17b12..d46e786bca 100644 --- a/osu.Game/Overlays/Options/OptionDropDown.cs +++ b/osu.Game/Overlays/Options/OptionDropdown.cs @@ -13,9 +13,9 @@ using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options { - public class OptionDropDown : FillFlowContainer + public class OptionDropdown : FillFlowContainer { - private DropDown dropdown; + private Dropdown dropdown; private SpriteText text; public string LabelText @@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Options } } - public OptionDropDown() + public OptionDropdown() { Items = new KeyValuePair[0]; @@ -68,7 +68,7 @@ namespace osu.Game.Overlays.Options text = new OsuSpriteText { Alpha = 0, }, - dropdown = new OsuDropDown + dropdown = new OsuDropdown { Margin = new MarginPadding { Top = 5 }, RelativeSizeAxes = Axes.X, diff --git a/osu.Game/Overlays/Options/OptionEnumDropDown.cs b/osu.Game/Overlays/Options/OptionEnumDropdown.cs similarity index 89% rename from osu.Game/Overlays/Options/OptionEnumDropDown.cs rename to osu.Game/Overlays/Options/OptionEnumDropdown.cs index 50d1d36b4c..1a4f4635e2 100644 --- a/osu.Game/Overlays/Options/OptionEnumDropDown.cs +++ b/osu.Game/Overlays/Options/OptionEnumDropdown.cs @@ -8,9 +8,9 @@ using System.Collections.Generic; namespace osu.Game.Overlays.Options { - public class OptionEnumDropDown : OptionDropDown + public class OptionEnumDropdown : OptionDropdown { - public OptionEnumDropDown() + public OptionEnumDropdown() { if (!typeof(T).IsEnum) throw new InvalidOperationException("OptionsDropdown only supports enums as the generic type argument"); diff --git a/osu.Game/Overlays/Options/Sections/Audio/AudioDevicesOptions.cs b/osu.Game/Overlays/Options/Sections/Audio/AudioDevicesOptions.cs index 25585845b0..2818f5fbd7 100644 --- a/osu.Game/Overlays/Options/Sections/Audio/AudioDevicesOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Audio/AudioDevicesOptions.cs @@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Options.Sections.Audio protected override string Header => "Devices"; private AudioManager audio; - private OptionDropDown dropdown; + private OptionDropdown dropdown; [BackgroundDependencyLoader] private void load(AudioManager audio) @@ -50,7 +50,7 @@ namespace osu.Game.Overlays.Options.Sections.Audio Children = new Drawable[] { - dropdown = new OptionDropDown + dropdown = new OptionDropdown { Bindable = audio.AudioDevice }, diff --git a/osu.Game/Overlays/Options/Sections/Debug/GCOptions.cs b/osu.Game/Overlays/Options/Sections/Debug/GCOptions.cs index ada57e8dd0..4350625d51 100644 --- a/osu.Game/Overlays/Options/Sections/Debug/GCOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Debug/GCOptions.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Options.Sections.Debug { Children = new Drawable[] { - new OptionEnumDropDown + new OptionEnumDropdown { LabelText = "Active mode", Bindable = config.GetBindable(FrameworkDebugConfig.ActiveGCMode) diff --git a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs b/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs index 1c28f6247d..70a2c52322 100644 --- a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs @@ -23,12 +23,12 @@ namespace osu.Game.Overlays.Options.Sections.Gameplay LabelText = "Background dim", Bindable = (BindableInt)config.GetBindable(OsuConfig.DimLevel) }, - new OptionEnumDropDown + new OptionEnumDropdown { LabelText = "Progress display", Bindable = config.GetBindable(OsuConfig.ProgressBarType) }, - new OptionEnumDropDown + new OptionEnumDropdown { LabelText = "Score meter type", Bindable = config.GetBindable(OsuConfig.ScoreMeter) diff --git a/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs b/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs index c45dc9cbd4..2b2939e432 100644 --- a/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs +++ b/osu.Game/Overlays/Options/Sections/General/UpdateOptions.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Options.Sections.General { Children = new Drawable[] { - new OptionEnumDropDown + new OptionEnumDropdown { LabelText = "Release stream", Bindable = config.GetBindable(OsuConfig.ReleaseStream), diff --git a/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs index e66d097094..0af8a4c580 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/DetailOptions.cs @@ -57,7 +57,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics LabelText = "Softening filter", Bindable = config.GetBindable(OsuConfig.BloomSoftening) }, - new OptionEnumDropDown + new OptionEnumDropdown { LabelText = "Screenshot", Bindable = config.GetBindable(OsuConfig.ScreenshotFormat) diff --git a/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs index 0a2e8f91a4..8c4930d99d 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/LayoutOptions.cs @@ -26,7 +26,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics Children = new Drawable[] { new OptionLabel { Text = "Resolution: TODO dropdown" }, - new OptionEnumDropDown + new OptionEnumDropdown { LabelText = "Screen mode", Bindable = config.GetBindable(FrameworkConfig.WindowMode), diff --git a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs index b98337f1e6..c898879167 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/RendererOptions.cs @@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics Children = new Drawable[] { // TODO: this needs to be a custom dropdown at some point - new OptionEnumDropDown + new OptionEnumDropdown { LabelText = "Frame limiter", Bindable = config.GetBindable(FrameworkConfig.FrameSync) diff --git a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs b/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs index ef1dd755b7..92be00bdb0 100644 --- a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Options.Sections.Input LabelText = "Map absolute raw input to the osu! window", Bindable = config.GetBindable(OsuConfig.AbsoluteToOsuWindow) }, - new OptionEnumDropDown + new OptionEnumDropdown { LabelText = "Confine mouse cursor", Bindable = config.GetBindable(OsuConfig.ConfineMouse), diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 39b9d8d9e5..879ca9ddbe 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -161,9 +161,9 @@ - - - + + + From 5043032b480f95ac4fbd4ead05873f050f1c8e69 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 22 Mar 2017 22:56:45 +0800 Subject: [PATCH 6/9] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 31cf1c4b58..42ec8a62fb 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 31cf1c4b58c866d047876b15a95a4cf0115d3105 +Subproject commit 42ec8a62fb697f1d967a927549dc51336cd66968 From ba32d50456e2299023b48c34209e53255aaecef1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Mar 2017 08:44:52 +0900 Subject: [PATCH 7/9] Consolidate nested classes. --- .../Graphics/UserInterface/OsuDropdown.cs | 132 ++++++++++++++++++ .../UserInterface/OsuDropdownHeader.cs | 69 --------- .../UserInterface/OsuDropdownMenuItem.cs | 85 ----------- .../Graphics/UserInterface/OsuTabControl.cs | 112 ++++++++++++++- osu.Game/Graphics/UserInterface/OsuTabItem.cs | 121 ---------------- osu.Game/osu.Game.csproj | 3 - 6 files changed, 242 insertions(+), 280 deletions(-) delete mode 100644 osu.Game/Graphics/UserInterface/OsuDropdownHeader.cs delete mode 100644 osu.Game/Graphics/UserInterface/OsuDropdownMenuItem.cs delete mode 100644 osu.Game/Graphics/UserInterface/OsuTabItem.cs diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index d8d4a93091..04b7d18de7 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -4,7 +4,13 @@ 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 { @@ -36,5 +42,131 @@ namespace osu.Game.Graphics.UserInterface } protected override DropdownMenuItem CreateMenuItem(string text, T value) => new OsuDropdownMenuItem(text, value) { AccentColour = AccentColour }; + + private class OsuDropdownMenuItem : DropdownMenuItem + { + 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); + } + } + + 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; + } + } } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuDropdownHeader.cs b/osu.Game/Graphics/UserInterface/OsuDropdownHeader.cs deleted file mode 100644 index 8bef24a6f8..0000000000 --- a/osu.Game/Graphics/UserInterface/OsuDropdownHeader.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// 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; - } - } -} \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuDropdownMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuDropdownMenuItem.cs deleted file mode 100644 index bcd53a8dbd..0000000000 --- a/osu.Game/Graphics/UserInterface/OsuDropdownMenuItem.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// 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 : DropdownMenuItem - { - 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); - } - } -} \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 8a22347c76..20f75cf932 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -6,11 +6,15 @@ using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; 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 { @@ -53,7 +57,111 @@ namespace osu.Game.Graphics.UserInterface } } - public class OsuTabDropdown : OsuDropdown + private class OsuTabItem : TabItem + { + 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 U 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 { protected override DropdownHeader CreateHeader() => new OsuTabDropdownHeader { @@ -80,7 +188,7 @@ namespace osu.Game.Graphics.UserInterface DropdownMenu.MaxHeight = 400; } - public class OsuTabDropdownHeader : OsuDropdownHeader + protected class OsuTabDropdownHeader : OsuDropdownHeader { public override Color4 AccentColour { diff --git a/osu.Game/Graphics/UserInterface/OsuTabItem.cs b/osu.Game/Graphics/UserInterface/OsuTabItem.cs deleted file mode 100644 index acfca1b67b..0000000000 --- a/osu.Game/Graphics/UserInterface/OsuTabItem.cs +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// 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 : TabItem - { - 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; - } - } -} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 879ca9ddbe..c2bb88d2f8 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -161,9 +161,7 @@ - - @@ -363,7 +361,6 @@ - From 3dee39346fe61364a5e95910008c5afb0d4ff5e3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Mar 2017 08:49:29 +0900 Subject: [PATCH 8/9] U -> T1. --- osu.Game/Graphics/UserInterface/OsuDropdown.cs | 4 ++-- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 04b7d18de7..20b96a4045 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -43,9 +43,9 @@ namespace osu.Game.Graphics.UserInterface protected override DropdownMenuItem CreateMenuItem(string text, T value) => new OsuDropdownMenuItem(text, value) { AccentColour = AccentColour }; - private class OsuDropdownMenuItem : DropdownMenuItem + private class OsuDropdownMenuItem : DropdownMenuItem { - public OsuDropdownMenuItem(string text, U value) : base(text, value) + public OsuDropdownMenuItem(string text, T1 value) : base(text, value) { Foreground.Padding = new MarginPadding(2); diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 20f75cf932..2f26a1ca30 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -57,7 +57,7 @@ namespace osu.Game.Graphics.UserInterface } } - private class OsuTabItem : TabItem + private class OsuTabItem : TabItem { private SpriteText text; private Box box; @@ -74,7 +74,7 @@ namespace osu.Game.Graphics.UserInterface } } - public new U Value + public new T1 Value { get { return base.Value; } set From b0340f77d829850af2aff0aef48085cef3b49197 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Mar 2017 08:57:14 +0900 Subject: [PATCH 9/9] Remove nested types completely. --- osu.Game/Graphics/UserInterface/OsuDropdown.cs | 8 ++++---- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 20b96a4045..7a31337660 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -29,7 +29,7 @@ namespace osu.Game.Graphics.UserInterface accentColour = value; if (Header != null) ((OsuDropdownHeader)Header).AccentColour = value; - foreach (var item in MenuItems.OfType>()) + foreach (var item in MenuItems.OfType()) item.AccentColour = value; } } @@ -41,11 +41,11 @@ namespace osu.Game.Graphics.UserInterface AccentColour = colours.PinkDarker; } - protected override DropdownMenuItem CreateMenuItem(string text, T value) => new OsuDropdownMenuItem(text, value) { AccentColour = AccentColour }; + protected override DropdownMenuItem CreateMenuItem(string text, T value) => new OsuDropdownMenuItem(text, value) { AccentColour = AccentColour }; - private class OsuDropdownMenuItem : DropdownMenuItem + private class OsuDropdownMenuItem : DropdownMenuItem { - public OsuDropdownMenuItem(string text, T1 value) : base(text, value) + public OsuDropdownMenuItem(string text, T value) : base(text, value) { Foreground.Padding = new MarginPadding(2); diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 2f26a1ca30..8283c1baa0 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -22,7 +22,7 @@ namespace osu.Game.Graphics.UserInterface { protected override Dropdown CreateDropdown() => new OsuTabDropdown(); - protected override TabItem CreateTabItem(T value) => new OsuTabItem { Value = value }; + protected override TabItem CreateTabItem(T value) => new OsuTabItem { Value = value }; protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || Dropdown.Contains(screenSpacePos); @@ -52,12 +52,12 @@ namespace osu.Game.Graphics.UserInterface var dropDown = Dropdown as OsuTabDropdown; if (dropDown != null) dropDown.AccentColour = value; - foreach (var item in TabContainer.Children.OfType>()) + foreach (var item in TabContainer.Children.OfType()) item.AccentColour = value; } } - private class OsuTabItem : TabItem + private class OsuTabItem : TabItem { private SpriteText text; private Box box; @@ -74,7 +74,7 @@ namespace osu.Game.Graphics.UserInterface } } - public new T1 Value + public new T Value { get { return base.Value; } set