Scroll editor setup screen to file selector on display

Previously the file selector would potentially display off-screen,
making for confusing UX.

Closes #10942.
This commit is contained in:
Dean Herbert
2020-11-23 13:49:14 +09:00
parent 417d6d4915
commit 3ed7868801
2 changed files with 12 additions and 3 deletions

View File

@ -3,10 +3,12 @@
using System;
using System.IO;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
@ -21,6 +23,9 @@ namespace osu.Game.Screens.Edit.Setup
private readonly IBindable<FileInfo> currentFile = new Bindable<FileInfo>();
[Resolved]
private SectionsContainer<SetupSection> sectionsContainer { get; set; }
public FileChooserLabelledTextBox()
{
currentFile.BindValueChanged(onFileSelected);
@ -47,14 +52,16 @@ namespace osu.Game.Screens.Edit.Setup
public void DisplayFileChooser()
{
Target.Child = new FileSelector(validFileExtensions: ResourcesSection.AudioExtensions)
FileSelector fileSelector;
Target.Child = fileSelector = new FileSelector(validFileExtensions: ResourcesSection.AudioExtensions)
{
RelativeSizeAxes = Axes.X,
Height = 400,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
CurrentFile = { BindTarget = currentFile }
};
sectionsContainer?.ScrollTo(fileSelector);
}
internal class FileChooserOsuTextBox : OsuTextBox