1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Merge pull request #19048 from ggliv/directoryselector-hidden-toggle

Add hidden item toggle to directory/file selectors
This commit is contained in:
Dean Herbert 2022-10-24 16:28:47 +09:00 committed by GitHub
commit e3e88d0d50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 84 additions and 23 deletions

View File

@ -3,18 +3,17 @@
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Tests.Visual.UserInterface;
namespace osu.Game.Tests.Visual.Settings
{
public class TestSceneDirectorySelector : OsuTestScene
public class TestSceneDirectorySelector : ThemeComparisonTestScene
{
[BackgroundDependencyLoader]
private void load()
protected override Drawable CreateContent() => new OsuDirectorySelector
{
Add(new OsuDirectorySelector { RelativeSizeAxes = Axes.Both });
}
RelativeSizeAxes = Axes.Both
};
}
}

View File

@ -4,23 +4,43 @@
#nullable disable
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Tests.Visual.UserInterface;
namespace osu.Game.Tests.Visual.Settings
{
public class TestSceneFileSelector : OsuTestScene
public class TestSceneFileSelector : ThemeComparisonTestScene
{
[Test]
public void TestAllFiles()
{
AddStep("create", () => Child = new OsuFileSelector { RelativeSizeAxes = Axes.Both });
}
[Resolved]
private OsuColour colours { get; set; }
[Test]
public void TestJpgFilesOnly()
{
AddStep("create", () => Child = new OsuFileSelector(validFileExtensions: new[] { ".jpg" }) { RelativeSizeAxes = Axes.Both });
AddStep("create", () =>
{
Cell(0, 0).Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.GreySeaFoam
},
new OsuFileSelector(validFileExtensions: new[] { ".jpg" })
{
RelativeSizeAxes = Axes.Both,
},
};
});
}
protected override Drawable CreateContent() => new OsuFileSelector
{
RelativeSizeAxes = Axes.Both,
};
}
}

View File

@ -26,24 +26,24 @@ namespace osu.Game.Graphics.UserInterface
{
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 @@ namespace osu.Game.Graphics.UserInterface
Children = new Drawable[]
{
labelText = new OsuTextFlowContainer(ApplyLabelParameters)
LabelTextFlowContainer = new OsuTextFlowContainer(ApplyLabelParameters)
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
@ -70,19 +70,19 @@ namespace osu.Game.Graphics.UserInterface
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

@ -31,6 +31,8 @@ namespace osu.Game.Graphics.UserInterfaceV2
protected override DirectorySelectorBreadcrumbDisplay CreateBreadcrumb() => new OsuDirectorySelectorBreadcrumbDisplay();
protected override Drawable CreateHiddenToggleButton() => new OsuDirectorySelectorHiddenToggle { Current = { BindTarget = ShowHiddenItems } };
protected override DirectorySelectorDirectory CreateParentDirectoryItem(DirectoryInfo directory) => new OsuDirectorySelectorParentDirectory(directory);
protected override DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, string displayName = null) => new OsuDirectorySelectorDirectory(directory, displayName);

View File

@ -0,0 +1,38 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Graphics.UserInterfaceV2
{
internal class OsuDirectorySelectorHiddenToggle : OsuCheckbox
{
public OsuDirectorySelectorHiddenToggle()
{
RelativeSizeAxes = Axes.None;
AutoSizeAxes = Axes.None;
Size = new Vector2(100, 50);
Anchor = Anchor.CentreLeft;
Origin = Anchor.CentreLeft;
LabelTextFlowContainer.Anchor = Anchor.CentreLeft;
LabelTextFlowContainer.Origin = Anchor.CentreLeft;
LabelText = @"Show hidden";
}
[BackgroundDependencyLoader(true)]
private void load(OverlayColourProvider? overlayColourProvider, OsuColour colours)
{
if (overlayColourProvider != null)
return;
Nub.AccentColour = colours.GreySeaFoamLighter;
Nub.GlowingAccentColour = Color4.White;
Nub.GlowColour = Color4.White;
}
}
}

View File

@ -33,6 +33,8 @@ namespace osu.Game.Graphics.UserInterfaceV2
protected override DirectorySelectorBreadcrumbDisplay CreateBreadcrumb() => new OsuDirectorySelectorBreadcrumbDisplay();
protected override Drawable CreateHiddenToggleButton() => new OsuDirectorySelectorHiddenToggle { Current = { BindTarget = ShowHiddenItems } };
protected override DirectorySelectorDirectory CreateParentDirectoryItem(DirectoryInfo directory) => new OsuDirectorySelectorParentDirectory(directory);
protected override DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, string displayName = null) => new OsuDirectorySelectorDirectory(directory, displayName);