Add new virtual float for username to timestamp padding

This commit is contained in:
Ganendra Afrasya 2019-10-01 20:47:53 +07:00
parent 2f877be0c4
commit 208b9a4eba
3 changed files with 18 additions and 3 deletions

View File

@ -32,6 +32,12 @@ public class TestSceneStandAloneChatDisplay : OsuTestScene
Id = 4,
};
private readonly User longUsernameUser = new User
{
Username = "Very Long Long Username",
Id = 5,
};
[Cached]
private ChannelManager channelManager = new ChannelManager();
@ -99,6 +105,12 @@ protected override void LoadComplete()
Sender = admin,
Content = "Okay okay, calm down guys. Let's do this!"
}));
AddStep("message from long username", () => testChannel.AddNewMessages(new Message(sequence++)
{
Sender = longUsernameUser,
Content = "Hi guys, my new username is lit!"
}));
}
}
}

View File

@ -146,6 +146,7 @@ protected class StandAloneMessage : ChatLine
protected override float HorizontalPadding => 10;
protected override float MessagePadding => 120;
protected override float TimestampPadding => 130;
public StandAloneMessage(Message message)
: base(message)

View File

@ -31,7 +31,9 @@ public class ChatLine : CompositeDrawable
protected virtual float MessagePadding => default_message_padding;
private const float timestamp_padding = 65;
private const float default_timestamp_padding = 65;
protected virtual float TimestampPadding => default_timestamp_padding;
private const float default_horizontal_padding = 15;
@ -94,7 +96,7 @@ private void load(OsuColour colours)
Font = OsuFont.GetFont(size: TextSize, weight: FontWeight.Bold, italics: true),
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
MaxWidth = default_message_padding - timestamp_padding
MaxWidth = default_message_padding - TimestampPadding
};
if (hasBackground)
@ -149,7 +151,7 @@ private void load(OsuColour colours)
new MessageSender(message.Sender)
{
AutoSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = timestamp_padding },
Padding = new MarginPadding { Left = TimestampPadding },
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
Child = effectedUsername,