Channel list item hover effect

This commit is contained in:
DrabWeb 2017-05-29 22:04:53 -03:00
parent d8e86da78c
commit 2ba86cffa6
1 changed files with 20 additions and 1 deletions

View File

@ -7,6 +7,7 @@
using osu.Framework.Allocation; 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.Input;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
@ -22,11 +23,13 @@ public class ChannelListItem : ClickableContainer, IFilterable
private readonly Channel channel; private readonly Channel channel;
private readonly OsuSpriteText name;
private readonly OsuSpriteText topic; private readonly OsuSpriteText topic;
private readonly TextAwesome joinedCheckmark; private readonly TextAwesome joinedCheckmark;
private Color4? joinedColour; private Color4? joinedColour;
private Color4? topicColour; private Color4? topicColour;
private Color4 hoverColour;
public string[] FilterTerms => new[] { channel.Name }; public string[] FilterTerms => new[] { channel.Name };
public bool MatchingCurrentFilter public bool MatchingCurrentFilter
@ -80,7 +83,7 @@ public ChannelListItem(Channel channel)
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Children = new[] Children = new[]
{ {
new OsuSpriteText name = new OsuSpriteText
{ {
Text = channel.ToString(), Text = channel.ToString(),
TextSize = text_size, TextSize = text_size,
@ -143,10 +146,25 @@ private void load(OsuColour colours)
{ {
topicColour = colours.Gray9; topicColour = colours.Gray9;
joinedColour = colours.Blue; joinedColour = colours.Blue;
hoverColour = colours.Yellow;
updateColour(channel.Joined); updateColour(channel.Joined);
} }
protected override bool OnHover(InputState state)
{
if (!channel.Joined.Value)
name.FadeColour(hoverColour, transition_duration);
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
if (!channel.Joined.Value)
name.FadeColour(Color4.White, transition_duration);
}
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
if(channel != null) channel.Joined.ValueChanged -= updateColour; if(channel != null) channel.Joined.ValueChanged -= updateColour;
@ -157,6 +175,7 @@ private void updateColour(bool joined)
{ {
if (joined) if (joined)
{ {
name.FadeColour(Color4.White, transition_duration);
joinedCheckmark.FadeTo(1f, transition_duration); joinedCheckmark.FadeTo(1f, transition_duration);
topic.FadeTo(0.8f, transition_duration); topic.FadeTo(0.8f, transition_duration);
topic.FadeColour(Color4.White, transition_duration); topic.FadeColour(Color4.White, transition_duration);