Ensure channel traversal shortcut scrolls channel list item into view

This commit is contained in:
Jai Sharma 2022-05-25 12:37:28 +01:00
parent 4a36f3aa4c
commit cd90d29315
2 changed files with 6 additions and 1 deletions

View File

@ -29,6 +29,7 @@ public class ChannelList : Container
private readonly Dictionary<Channel, ChannelListItem> channelMap = new Dictionary<Channel, ChannelListItem>();
private OsuScrollContainer scroll = null!;
private ChannelListItemFlow publicChannelFlow = null!;
private ChannelListItemFlow privateChannelFlow = null!;
private ChannelListItem selector = null!;
@ -43,7 +44,7 @@ private void load(OverlayColourProvider colourProvider)
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background6,
},
new OsuScrollContainer
scroll = new OsuScrollContainer
{
Padding = new MarginPadding { Vertical = 7 },
RelativeSizeAxes = Axes.Both,
@ -104,6 +105,8 @@ public ChannelListItem GetItem(Channel channel)
return channelMap[channel];
}
public void ScrollChannelIntoView(Channel channel) => scroll.ScrollIntoView(this.GetItem(channel));
private ChannelListItemFlow getFlowForChannel(Channel channel)
{
switch (channel.Type)

View File

@ -397,6 +397,8 @@ private void cycleChannel(int direction)
int currentIndex = overlayChannels.IndexOf(currentChannel.Value);
currentChannel.Value = overlayChannels[(currentIndex + direction + overlayChannels.Count) % overlayChannels.Count];
channelList.ScrollChannelIntoView(currentChannel.Value);
}
private IEnumerable<Channel> filterToChatChannels(IEnumerable channels)