mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 00:42:55 +08:00
Fix checkboxes with long labels overlapping nub (#4970)
Fix checkboxes with long labels overlapping nub Co-authored-by: Dan Balasescu <smoogipoo@smgi.me>
This commit is contained in:
commit
c07e1088c6
@ -6,10 +6,9 @@ using osu.Framework.Audio;
|
|||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Containers;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
@ -33,27 +32,26 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
public string LabelText
|
public string LabelText
|
||||||
{
|
{
|
||||||
get => labelSpriteText?.Text;
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (labelSpriteText != null)
|
if (labelText != null)
|
||||||
labelSpriteText.Text = value;
|
labelText.Text = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MarginPadding LabelPadding
|
public MarginPadding LabelPadding
|
||||||
{
|
{
|
||||||
get => labelSpriteText?.Padding ?? new MarginPadding();
|
get => labelText?.Padding ?? new MarginPadding();
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (labelSpriteText != null)
|
if (labelText != null)
|
||||||
labelSpriteText.Padding = value;
|
labelText.Padding = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly Nub Nub;
|
protected readonly Nub Nub;
|
||||||
|
|
||||||
private readonly SpriteText labelSpriteText;
|
private readonly OsuTextFlowContainer labelText;
|
||||||
private SampleChannel sampleChecked;
|
private SampleChannel sampleChecked;
|
||||||
private SampleChannel sampleUnchecked;
|
private SampleChannel sampleUnchecked;
|
||||||
|
|
||||||
@ -62,24 +60,28 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
const float nub_padding = 5;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
labelSpriteText = new OsuSpriteText(),
|
labelText = new OsuTextFlowContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Padding = new MarginPadding { Right = Nub.EXPANDED_SIZE + nub_padding }
|
||||||
|
},
|
||||||
Nub = new Nub
|
Nub = new Nub
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
Margin = new MarginPadding { Right = 5 },
|
Margin = new MarginPadding { Right = nub_padding },
|
||||||
},
|
},
|
||||||
new HoverClickSounds()
|
new HoverClickSounds()
|
||||||
};
|
};
|
||||||
|
|
||||||
Nub.Current.BindTo(Current);
|
Nub.Current.BindTo(Current);
|
||||||
|
|
||||||
Current.DisabledChanged += disabled =>
|
Current.DisabledChanged += disabled => labelText.Alpha = Nub.Alpha = disabled ? 0.3f : 1;
|
||||||
{
|
|
||||||
labelSpriteText.Alpha = Nub.Alpha = disabled ? 0.3f : 1;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -14,7 +14,6 @@ namespace osu.Game.Overlays.Settings
|
|||||||
|
|
||||||
public override string LabelText
|
public override string LabelText
|
||||||
{
|
{
|
||||||
get => checkbox.LabelText;
|
|
||||||
set => checkbox.LabelText = value;
|
set => checkbox.LabelText = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user