mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 11: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:
commit
96b6780e0c
@ -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();
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user