correct label positioning

This commit is contained in:
Gabe Livengood 2022-07-11 17:12:41 -04:00
parent 8617b94c9d
commit d6abdc597d
No known key found for this signature in database
GPG Key ID: 70321B78DAECE683
2 changed files with 12 additions and 10 deletions

View File

@ -26,24 +26,24 @@ public LocalisableString LabelText
{
set
{
if (labelText != null)
labelText.Text = value;
if (LabelTextFlowContainer != null)
LabelTextFlowContainer.Text = value;
}
}
public MarginPadding LabelPadding
{
get => labelText?.Padding ?? new MarginPadding();
get => LabelTextFlowContainer?.Padding ?? new MarginPadding();
set
{
if (labelText != null)
labelText.Padding = value;
if (LabelTextFlowContainer != null)
LabelTextFlowContainer.Padding = value;
}
}
protected readonly Nub Nub;
private readonly OsuTextFlowContainer labelText;
protected readonly OsuTextFlowContainer LabelTextFlowContainer;
private Sample sampleChecked;
private Sample sampleUnchecked;
@ -56,7 +56,7 @@ public OsuCheckbox(bool nubOnRight = true)
Children = new Drawable[]
{
labelText = new OsuTextFlowContainer(ApplyLabelParameters)
LabelTextFlowContainer = new OsuTextFlowContainer(ApplyLabelParameters)
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
@ -70,19 +70,19 @@ public OsuCheckbox(bool nubOnRight = true)
Nub.Anchor = Anchor.CentreRight;
Nub.Origin = Anchor.CentreRight;
Nub.Margin = new MarginPadding { Right = nub_padding };
labelText.Padding = new MarginPadding { Right = Nub.EXPANDED_SIZE + nub_padding * 2 };
LabelTextFlowContainer.Padding = new MarginPadding { Right = Nub.EXPANDED_SIZE + nub_padding * 2 };
}
else
{
Nub.Anchor = Anchor.CentreLeft;
Nub.Origin = Anchor.CentreLeft;
Nub.Margin = new MarginPadding { Left = nub_padding };
labelText.Padding = new MarginPadding { Left = Nub.EXPANDED_SIZE + nub_padding * 2 };
LabelTextFlowContainer.Padding = new MarginPadding { Left = Nub.EXPANDED_SIZE + nub_padding * 2 };
}
Nub.Current.BindTo(Current);
Current.DisabledChanged += disabled => labelText.Alpha = Nub.Alpha = disabled ? 0.3f : 1;
Current.DisabledChanged += disabled => LabelTextFlowContainer.Alpha = Nub.Alpha = disabled ? 0.3f : 1;
}
/// <summary>

View File

@ -19,6 +19,8 @@ public OsuDirectorySelectorHiddenToggle()
Size = new Vector2(100, 50);
Anchor = Anchor.CentreLeft;
Origin = Anchor.CentreLeft;
LabelTextFlowContainer.Anchor = Anchor.CentreLeft;
LabelTextFlowContainer.Origin = Anchor.CentreLeft;
LabelText = @"Show hidden";
}