From a5817e6e75f803b50886b28d348fb33d53363088 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 12 Oct 2017 18:17:23 +0900 Subject: [PATCH] Add a way to change the IconButton icon colour --- osu.Game/Graphics/UserInterface/IconButton.cs | 21 +++++++++++++++++-- osu.Game/Tests/Visual/TestCaseIconButton.cs | 12 +++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index d58f5797a3..afffd930ef 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -27,13 +27,28 @@ namespace osu.Game.Graphics.UserInterface set { flashColour = value; } } + private Color4? iconColour; /// /// The icon colour. This does not affect . /// public Color4 IconColour { - get { return icon.Colour; } - set { icon.Colour = value; } + get { return iconColour ?? Color4.White; } + set + { + iconColour = value; + icon.Colour = value; + } + } + + private Color4? iconHoverColour; + /// + /// The icon colour while the is hovered. + /// + public Color4 IconHoverColour + { + get { return iconHoverColour ?? IconColour; } + set { iconHoverColour = value; } } private Color4? hoverColour; @@ -133,12 +148,14 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnHover(InputState state) { hover.FadeIn(500, Easing.OutQuint); + icon.FadeColour(IconHoverColour, 500, Easing.OutQuint); return base.OnHover(state); } protected override void OnHoverLost(InputState state) { hover.FadeOut(500, Easing.OutQuint); + icon.FadeColour(IconColour, 500, Easing.OutQuint); base.OnHoverLost(state); } diff --git a/osu.Game/Tests/Visual/TestCaseIconButton.cs b/osu.Game/Tests/Visual/TestCaseIconButton.cs index bec8f8314b..acde9df4a9 100644 --- a/osu.Game/Tests/Visual/TestCaseIconButton.cs +++ b/osu.Game/Tests/Visual/TestCaseIconButton.cs @@ -25,14 +25,18 @@ namespace osu.Game.Tests.Visual Children = new[] { new NamedIconButton("No change", new IconButton()), - new NamedIconButton("Green colours", new IconButton + new NamedIconButton("Background colours", new IconButton { - IconColour = Color4.LightGreen, FlashColour = Color4.DarkGreen, - HoverColour = Color4.Green + HoverColour = Color4.Green, }), new NamedIconButton("Full-width", new IconButton { ButtonSize = new Vector2(200, 30) }), - new NamedIconButton("Unchanging size", new IconButton(), false) + new NamedIconButton("Unchanging size", new IconButton(), false), + new NamedIconButton("Icon colours", new IconButton + { + IconColour = Color4.Green, + IconHoverColour = Color4.Red + }) } }; }