From 7f075aecbdf1382bebf1f8ce7d6c085a96db8b12 Mon Sep 17 00:00:00 2001 From: Anthony Berg Date: Thu, 11 Jun 2026 09:42:01 +0200 Subject: [PATCH] Hide already shown tags in overflow popover (#37851) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I found that the overflow in mapper tags was showing the tags that were already shown, so I removed them in the popup. I've also let the popup react to layout updates. https://github.com/user-attachments/assets/f952c23b-990c-4bce-8c44-58ecf7db33f6 --------- Co-authored-by: Bartłomiej Dach --- .../Select/BeatmapMetadataWedge.TagsLine.cs | 56 +++++++++++++++---- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapMetadataWedge.TagsLine.cs b/osu.Game/Screens/Select/BeatmapMetadataWedge.TagsLine.cs index 975dfd6212..4d52018201 100644 --- a/osu.Game/Screens/Select/BeatmapMetadataWedge.TagsLine.cs +++ b/osu.Game/Screens/Select/BeatmapMetadataWedge.TagsLine.cs @@ -5,6 +5,7 @@ using System; using System.Diagnostics; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -33,6 +34,7 @@ namespace osu.Game.Screens.Select private string[] tags = Array.Empty(); private TagsOverflowButton? overflowButton; + private readonly Bindable tagsShownCount = new Bindable(); public string[] Tags { @@ -78,21 +80,28 @@ namespace osu.Game.Screens.Select Debug.Assert(overflowButton != null); float limit = DrawWidth - overflowButton.DrawWidth - 5; - bool showOverflow = false; + int totalTagsShown = 0; - foreach (var text in Children) + foreach (var child in Children) { - if (text.X + text.DrawWidth < limit) - text.Show(); + if (child is TagsOverflowButton) continue; + + if (child.X + child.DrawWidth < limit) + { + child.AlwaysPresent = true; + child.Show(); + totalTagsShown += 1; + } else { - showOverflow = true; - text.AlwaysPresent = false; - text.Hide(); + child.AlwaysPresent = false; + child.Hide(); } } - if (showOverflow) + tagsShownCount.Value = totalTagsShown; + + if (totalTagsShown < tags.Length) overflowButton.Show(); else overflowButton.Hide(); @@ -118,6 +127,7 @@ namespace osu.Game.Screens.Select { Alpha = 0f, PerformSearch = s => PerformSearch?.Invoke(s), + TagsShownCount = { BindTarget = tagsShownCount }, }); drawSizeLayout.Invalidate(); @@ -137,6 +147,8 @@ namespace osu.Game.Screens.Select public Action? PerformSearch { get; init; } + public readonly Bindable TagsShownCount = new Bindable(); + public TagsOverflowButton(string[] tags) { this.tags = tags; @@ -188,14 +200,21 @@ namespace osu.Game.Screens.Select return true; } - public Popover GetPopover() => new TagsOverflowPopover(tags, PerformSearch); + public Popover GetPopover() => new TagsOverflowPopover(tags, PerformSearch) + { + TagsShownCount = { BindTarget = TagsShownCount }, + }; } public partial class TagsOverflowPopover : OsuPopover { + public readonly Bindable TagsShownCount = new Bindable(); + private readonly string[] tags; private readonly Action? performSearch; + private LinkFlowContainer textFlow = null!; + public TagsOverflowPopover(string[] tags, Action? performSearchAction) { this.tags = tags; @@ -205,20 +224,33 @@ namespace osu.Game.Screens.Select [BackgroundDependencyLoader] private void load() { - LinkFlowContainer textFlow; - Child = textFlow = new LinkFlowContainer(t => t.Font = OsuFont.Style.Caption1) { Width = 200, AutoSizeAxes = Axes.Y, }; - foreach (string tag in tags) + updateTags(); + } + + private void updateTags() + { + textFlow.Clear(); + + for (int i = TagsShownCount.Value; i < tags.Length; i++) { + string tag = tags[i]; textFlow.AddLink(tag, () => performSearch?.Invoke(tag)); textFlow.AddText(" "); } } + + protected override void LoadComplete() + { + base.LoadComplete(); + + TagsShownCount.BindValueChanged(_ => updateTags()); + } } } }