1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 09:07:25 +08:00

Merge pull request #30101 from bdach/menu-padding-left

Do not add checkbox padding to the left of menu items if no item actually needs it
This commit is contained in:
Bartłomiej Dach 2024-10-04 12:22:35 +02:00 committed by GitHub
commit 96b6780e0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 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

@ -42,6 +42,25 @@ namespace osu.Game.Graphics.UserInterface
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
}
protected override void Update()
{
base.Update();
bool showCheckboxes = false;
foreach (var drawableItem in ItemsContainer)
{
if (drawableItem.Item is StatefulMenuItem)
showCheckboxes = true;
}
foreach (var drawableItem in ItemsContainer)
{
if (drawableItem is DrawableOsuMenuItem osuItem)
osuItem.ShowCheckbox.Value = showCheckboxes;
}
}
protected override void AnimateOpen()
{
if (!TopLevelMenu && !wasOpened)