1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 12:27:26 +08:00

Do not add checkbox padding to the left of menu items if no item actually needs it

RFC. As per
https://discord.com/channels/188630481301012481/188630652340404224/1291346164976980009.

The diff is extremely dumb but I tried a few smarter methods and they're
either not fully correct or don't work. Primary problem is that menu
items are mutable externally and there's no hook provided by the
framework to know that items changed. One could probably be made but I'd
prefer that this change be examined visually first before I engage in
too much ceremony and start changing framework around.
This commit is contained in:
Bartłomiej Dach 2024-10-03 15:32:25 +02:00
parent 4f823a3078
commit 29418226c0
No known key found for this signature in database
2 changed files with 17 additions and 0 deletions

View File

@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -26,6 +27,8 @@ namespace osu.Game.Graphics.UserInterface
public const int TEXT_SIZE = 17;
public const int TRANSITION_LENGTH = 80;
public BindableBool ShowCheckbox { get; } = new BindableBool();
private TextContainer text;
private HotkeyDisplay hotkey;
private HoverClickSounds hoverClickSounds;
@ -72,6 +75,7 @@ namespace osu.Game.Graphics.UserInterface
{
base.LoadComplete();
ShowCheckbox.BindValueChanged(_ => updateState());
Item.Action.BindDisabledChanged(_ => updateState(), true);
FinishTransforms();
}
@ -138,6 +142,8 @@ namespace osu.Game.Graphics.UserInterface
text.BoldText.FadeOut(TRANSITION_LENGTH, Easing.OutQuint);
text.NormalText.FadeIn(TRANSITION_LENGTH, Easing.OutQuint);
}
text.CheckboxContainer.Alpha = ShowCheckbox.Value ? 1 : 0;
}
protected sealed override Drawable CreateContent() => text = CreateTextContainer();

View File

@ -3,6 +3,7 @@
#nullable disable
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
@ -42,6 +43,16 @@ namespace osu.Game.Graphics.UserInterface
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
}
protected override void Update()
{
base.Update();
bool showCheckboxes = Items.Any(i => i is StatefulMenuItem);
foreach (var drawableItem in ItemsContainer.OfType<DrawableOsuMenuItem>())
drawableItem.ShowCheckbox.Value = showCheckboxes;
}
protected override void AnimateOpen()
{
if (!TopLevelMenu && !wasOpened)