Implement VotePill component

This commit is contained in:
Andrei Zavatski 2019-10-08 19:56:43 +03:00
parent 4230b00110
commit 35cfb16c8d
1 changed files with 51 additions and 4 deletions

View File

@ -13,6 +13,8 @@
using osu.Framework.Input.Events;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
namespace osu.Game.Overlays.Comments
{
@ -60,12 +62,28 @@ public DrawableComment(Comment comment)
{
new Drawable[]
{
new UpdateableAvatar(comment.User)
new FillFlowContainer
{
Size = new Vector2(avatar_size),
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Horizontal = margin },
Masking = true,
CornerRadius = avatar_size / 2,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Children = new Drawable[]
{
new VotePill(comment.VotesCount)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
new UpdateableAvatar(comment.User)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(avatar_size),
Masking = true,
CornerRadius = avatar_size / 2,
},
}
},
new FillFlowContainer
{
@ -239,5 +257,34 @@ public ParentUsername(Comment comment)
};
}
}
private class VotePill : CircularContainer
{
private const int height = 20;
private const int margin = 10;
public VotePill(int count)
{
AutoSizeAxes = Axes.X;
Height = height;
Masking = true;
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black
},
new SpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Margin = new MarginPadding { Horizontal = margin },
Font = OsuFont.GetFont(size: 14),
Text = $"+{count}"
}
};
}
}
}
}