Hide popover on file selection

This commit is contained in:
Salman Ahmed 2021-08-23 18:01:01 +03:00
parent c2c9a93e2c
commit bd42d7aada
2 changed files with 14 additions and 52 deletions

View File

@ -31,11 +31,6 @@ namespace osu.Game.Screens.Edit.Setup
public IEnumerable<string> HandledExtensions => handledExtensions; public IEnumerable<string> HandledExtensions => handledExtensions;
/// <summary>
/// The target container to display the file chooser in.
/// </summary>
public Container Target;
private readonly Bindable<FileInfo> currentFile = new Bindable<FileInfo>(); private readonly Bindable<FileInfo> currentFile = new Bindable<FileInfo>();
[Resolved] [Resolved]
@ -72,7 +67,7 @@ namespace osu.Game.Screens.Edit.Setup
if (file.NewValue == null) if (file.NewValue == null)
return; return;
Target.Clear(); this.HidePopover();
Current.Value = file.NewValue.FullName; Current.Value = file.NewValue.FullName;
} }

View File

@ -6,7 +6,6 @@ using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Graphics.UserInterfaceV2;
@ -39,62 +38,30 @@ namespace osu.Game.Screens.Edit.Setup
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Container audioTrackFileChooserContainer = createFileChooserContainer();
Container backgroundFileChooserContainer = createFileChooserContainer();
Children = new Drawable[] Children = new Drawable[]
{ {
new FillFlowContainer backgroundTextBox = new FileChooserLabelledTextBox(".jpg", ".jpeg", ".png")
{ {
RelativeSizeAxes = Axes.X, Label = "Background",
AutoSizeAxes = Axes.Y, FixedLabelWidth = LABEL_WIDTH,
Direction = FillDirection.Vertical, PlaceholderText = "Click to select a background image",
Children = new Drawable[] Current = { Value = working.Value.Metadata.BackgroundFile },
{ TabbableContentContainer = this
backgroundTextBox = new FileChooserLabelledTextBox(".jpg", ".jpeg", ".png")
{
Label = "Background",
FixedLabelWidth = LABEL_WIDTH,
PlaceholderText = "Click to select a background image",
Current = { Value = working.Value.Metadata.BackgroundFile },
Target = backgroundFileChooserContainer,
TabbableContentContainer = this
},
backgroundFileChooserContainer,
}
}, },
new FillFlowContainer audioTrackTextBox = new FileChooserLabelledTextBox(".mp3", ".ogg")
{ {
RelativeSizeAxes = Axes.X, Label = "Audio Track",
AutoSizeAxes = Axes.Y, FixedLabelWidth = LABEL_WIDTH,
Direction = FillDirection.Vertical, PlaceholderText = "Click to select a track",
Children = new Drawable[] Current = { Value = working.Value.Metadata.AudioFile },
{ TabbableContentContainer = this
audioTrackTextBox = new FileChooserLabelledTextBox(".mp3", ".ogg") },
{
Label = "Audio Track",
FixedLabelWidth = LABEL_WIDTH,
PlaceholderText = "Click to select a track",
Current = { Value = working.Value.Metadata.AudioFile },
Target = audioTrackFileChooserContainer,
TabbableContentContainer = this
},
audioTrackFileChooserContainer,
}
}
}; };
backgroundTextBox.Current.BindValueChanged(backgroundChanged); backgroundTextBox.Current.BindValueChanged(backgroundChanged);
audioTrackTextBox.Current.BindValueChanged(audioTrackChanged); audioTrackTextBox.Current.BindValueChanged(audioTrackChanged);
} }
private static Container createFileChooserContainer() =>
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
};
public bool ChangeBackgroundImage(string path) public bool ChangeBackgroundImage(string path)
{ {
var info = new FileInfo(path); var info = new FileInfo(path);