Use autosize instead of max width on fixed width timestamps

This commit is contained in:
Joseph Madamba 2022-11-06 18:24:54 -08:00
parent 93f84ece0d
commit b977fc8181
2 changed files with 17 additions and 27 deletions

View File

@ -191,7 +191,6 @@ namespace osu.Game.Online.Chat
{ {
protected override float TextSize => 15; protected override float TextSize => 15;
protected override float Spacing => 5; protected override float Spacing => 5;
protected override float TimestampWidth => 45;
protected override float UsernameWidth => 75; protected override float UsernameWidth => 75;
public StandAloneMessage(Message message) public StandAloneMessage(Message message)

View File

@ -48,8 +48,6 @@ namespace osu.Game.Overlays.Chat
protected virtual float Spacing => 15; protected virtual float Spacing => 15;
protected virtual float TimestampWidth => 60;
protected virtual float UsernameWidth => 130; protected virtual float UsernameWidth => 130;
private Color4 usernameColour; private Color4 usernameColour;
@ -93,38 +91,31 @@ namespace osu.Game.Overlays.Chat
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
ColumnDimensions = new[] ColumnDimensions = new[]
{ {
new Dimension(GridSizeMode.Absolute, TimestampWidth + Spacing + UsernameWidth + Spacing), new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.Absolute, Spacing + UsernameWidth + Spacing),
new Dimension(), new Dimension(),
}, },
Content = new[] Content = new[]
{ {
new Drawable[] new Drawable[]
{ {
new Container timestamp = new OsuSpriteText
{ {
RelativeSizeAxes = Axes.X, Shadow = false,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: TextSize * 0.75f, weight: FontWeight.SemiBold, fixedWidth: true),
Colour = colourProvider?.Background1 ?? Colour4.White,
AlwaysPresent = true,
},
new MessageSender(message.Sender)
{
Width = UsernameWidth,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Children = new Drawable[] Origin = Anchor.TopRight,
{ Anchor = Anchor.TopRight,
timestamp = new OsuSpriteText Child = createUsername(),
{ Margin = new MarginPadding { Horizontal = Spacing },
Shadow = false,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: TextSize * 0.75f, weight: FontWeight.SemiBold, fixedWidth: true),
MaxWidth = TimestampWidth,
Colour = colourProvider?.Background1 ?? Colour4.White,
},
new MessageSender(message.Sender)
{
Width = UsernameWidth,
AutoSizeAxes = Axes.Y,
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
Child = createUsername(),
Margin = new MarginPadding { Horizontal = Spacing },
},
},
}, },
ContentFlow = new LinkFlowContainer(t => ContentFlow = new LinkFlowContainer(t =>
{ {