mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Improve clickability and visuals of MusicController buttons.
This commit is contained in:
@ -30,7 +30,9 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Anchor = Anchor.Centre
|
Anchor = Anchor.Centre
|
||||||
};
|
};
|
||||||
Add(mc);
|
Add(mc);
|
||||||
AddToggleStep(@"Show", state => mc.State = state ? Visibility.Visible : Visibility.Hidden);
|
|
||||||
|
AddToggleStep(@"toggle visibility", state => mc.State = state ? Visibility.Visible : Visibility.Hidden);
|
||||||
|
AddStep(@"show", () => mc.State = Visibility.Visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
private Drawable currentBackground;
|
private Drawable currentBackground;
|
||||||
private DragBar progress;
|
private DragBar progress;
|
||||||
private TextAwesome playButton;
|
private Button playButton;
|
||||||
private SpriteText title, artist;
|
private SpriteText title, artist;
|
||||||
|
|
||||||
private List<BeatmapSetInfo> playList;
|
private List<BeatmapSetInfo> playList;
|
||||||
@ -46,6 +46,8 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private Container dragContainer;
|
private Container dragContainer;
|
||||||
|
|
||||||
|
private const float bottom_black_area_height = 50;
|
||||||
|
|
||||||
public MusicController()
|
public MusicController()
|
||||||
{
|
{
|
||||||
Width = 400;
|
Width = 400;
|
||||||
@ -115,12 +117,23 @@ namespace osu.Game.Overlays
|
|||||||
Text = @"Nothing to play",
|
Text = @"Nothing to play",
|
||||||
Font = @"Exo2.0-BoldItalic"
|
Font = @"Exo2.0-BoldItalic"
|
||||||
},
|
},
|
||||||
new ClickableContainer
|
new FillFlowContainer<Button>
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.X,
|
||||||
Origin = Anchor.Centre,
|
Height = bottom_black_area_height,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
Position = new Vector2(0, -30),
|
Children = new[]
|
||||||
|
{
|
||||||
|
new Button
|
||||||
|
{
|
||||||
|
Action = prev,
|
||||||
|
Icon = FontAwesome.fa_step_backward,
|
||||||
|
},
|
||||||
|
playButton = new Button
|
||||||
|
{
|
||||||
|
Scale = new Vector2(1.4f),
|
||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
if (current?.Track == null) return;
|
if (current?.Track == null) return;
|
||||||
@ -129,69 +142,21 @@ namespace osu.Game.Overlays
|
|||||||
else
|
else
|
||||||
current.Track.Start();
|
current.Track.Start();
|
||||||
},
|
},
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
playButton = new TextAwesome
|
|
||||||
{
|
|
||||||
TextSize = 30,
|
|
||||||
Icon = FontAwesome.fa_play_circle_o,
|
Icon = FontAwesome.fa_play_circle_o,
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Anchor = Anchor.Centre
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
new ClickableContainer
|
new Button
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Position = new Vector2(-30, -30),
|
|
||||||
Action = prev,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new TextAwesome
|
|
||||||
{
|
|
||||||
TextSize = 15,
|
|
||||||
Icon = FontAwesome.fa_step_backward,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Anchor = Anchor.Centre
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new ClickableContainer
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Position = new Vector2(30, -30),
|
|
||||||
Action = next,
|
Action = next,
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new TextAwesome
|
|
||||||
{
|
|
||||||
TextSize = 15,
|
|
||||||
Icon = FontAwesome.fa_step_forward,
|
Icon = FontAwesome.fa_step_forward,
|
||||||
Origin = Anchor.Centre,
|
},
|
||||||
Anchor = Anchor.Centre
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new ClickableContainer
|
new Button
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.BottomRight,
|
Anchor = Anchor.BottomRight,
|
||||||
Position = new Vector2(20, -30),
|
Position = new Vector2(-bottom_black_area_height / 2),
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new TextAwesome
|
|
||||||
{
|
|
||||||
TextSize = 15,
|
|
||||||
Icon = FontAwesome.fa_bars,
|
Icon = FontAwesome.fa_bars,
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Anchor = Anchor.Centre
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
progress = new DragBar
|
progress = new DragBar
|
||||||
{
|
{
|
||||||
@ -416,7 +381,7 @@ namespace osu.Game.Overlays
|
|||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 50,
|
Height = bottom_black_area_height,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
Colour = Color4.Black.Opacity(0.5f)
|
Colour = Color4.Black.Opacity(0.5f)
|
||||||
@ -430,5 +395,91 @@ namespace osu.Game.Overlays
|
|||||||
sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4");
|
sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class Button : ClickableContainer
|
||||||
|
{
|
||||||
|
private readonly TextAwesome icon;
|
||||||
|
private readonly Box hover;
|
||||||
|
private readonly Container content;
|
||||||
|
|
||||||
|
public FontAwesome Icon
|
||||||
|
{
|
||||||
|
get { return icon.Icon; }
|
||||||
|
set { icon.Icon = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private const float button_size = 30;
|
||||||
|
|
||||||
|
public Button()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
Anchor = Anchor.Centre;
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
content = new Container
|
||||||
|
{
|
||||||
|
Size = new Vector2(button_size),
|
||||||
|
CornerRadius = 5,
|
||||||
|
Masking = true,
|
||||||
|
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
EdgeEffect = new EdgeEffect
|
||||||
|
{
|
||||||
|
Colour = Color4.Black.Opacity(0.04f),
|
||||||
|
Type = EdgeEffectType.Shadow,
|
||||||
|
Radius = 5,
|
||||||
|
},
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
hover = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0,
|
||||||
|
},
|
||||||
|
icon = new TextAwesome
|
||||||
|
{
|
||||||
|
TextSize = 18,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Anchor = Anchor.Centre
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
hover.Colour = colours.Yellow.Opacity(0.6f);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(InputState state)
|
||||||
|
{
|
||||||
|
hover.FadeIn(500, EasingTypes.OutQuint);
|
||||||
|
return base.OnHover(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(InputState state)
|
||||||
|
{
|
||||||
|
hover.FadeOut(500, EasingTypes.OutQuint);
|
||||||
|
base.OnHoverLost(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||||
|
{
|
||||||
|
content.ScaleTo(0.7f, 2000, EasingTypes.OutQuint);
|
||||||
|
return base.OnMouseDown(state, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||||
|
{
|
||||||
|
content.ScaleTo(1, 1000, EasingTypes.OutElastic);
|
||||||
|
return base.OnMouseUp(state, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user