Fix checkboxes with long labels overlapping nub

This commit is contained in:
Dean Herbert 2019-06-09 16:47:48 +09:00
parent 3567bf3863
commit d500f3605e
2 changed files with 12 additions and 11 deletions

View File

@ -6,10 +6,9 @@
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.Containers;
using osuTK.Graphics;
namespace osu.Game.Graphics.UserInterface
@ -33,7 +32,6 @@ public Bindable<bool> Bindable
public string LabelText
{
get => labelSpriteText?.Text;
set
{
if (labelSpriteText != null)
@ -53,7 +51,7 @@ public MarginPadding LabelPadding
protected readonly Nub Nub;
private readonly SpriteText labelSpriteText;
private readonly OsuTextFlowContainer labelSpriteText;
private SampleChannel sampleChecked;
private SampleChannel sampleUnchecked;
@ -62,24 +60,28 @@ public OsuCheckbox()
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
const float nub_padding = 5;
Children = new Drawable[]
{
labelSpriteText = new OsuSpriteText(),
labelSpriteText = new OsuTextFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Padding = new MarginPadding { Right = Nub.EXPANDED_SIZE + nub_padding }
},
Nub = new Nub
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Margin = new MarginPadding { Right = 5 },
Margin = new MarginPadding { Right = nub_padding },
},
new HoverClickSounds()
};
Nub.Current.BindTo(Current);
Current.DisabledChanged += disabled =>
{
labelSpriteText.Alpha = Nub.Alpha = disabled ? 0.3f : 1;
};
Current.DisabledChanged += disabled => { labelSpriteText.Alpha = Nub.Alpha = disabled ? 0.3f : 1; };
}
protected override void LoadComplete()

View File

@ -14,7 +14,6 @@ public class SettingsCheckbox : SettingsItem<bool>
public override string LabelText
{
get => checkbox.LabelText;
set => checkbox.LabelText = value;
}
}