Use SearchTextBox

Correctly handle focus.
This commit is contained in:
Dean Herbert 2017-05-11 13:19:31 +09:00
parent 6c5490e31c
commit 7d8af5f1da
1 changed files with 12 additions and 6 deletions

View File

@ -13,7 +13,7 @@
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Options.Sections; using osu.Game.Overlays.Options.Sections;
using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Select;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
@ -33,7 +33,10 @@ public class OptionsOverlay : FocusedOverlayContainer
private Sidebar sidebar; private Sidebar sidebar;
private SidebarButton[] sidebarButtons; private SidebarButton[] sidebarButtons;
private OptionsSection[] sections; private OptionsSection[] sections;
private SearchContainer searchContainer; private SearchContainer searchContainer;
private SearchTextBox searchTextBox;
private float lastKnownScroll; private float lastKnownScroll;
public OptionsOverlay() public OptionsOverlay()
@ -45,8 +48,6 @@ public OptionsOverlay()
[BackgroundDependencyLoader(permitNulls: true)] [BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuGame game, OsuColour colours) private void load(OsuGame game, OsuColour colours)
{ {
OsuTextBox textBox;
sections = new OptionsSection[] sections = new OptionsSection[]
{ {
new GeneralSection(), new GeneralSection(),
@ -96,11 +97,11 @@ private void load(OsuGame game, OsuColour colours)
TextSize = 18, TextSize = 18,
Margin = new MarginPadding { Left = CONTENT_MARGINS, Bottom = 30 }, Margin = new MarginPadding { Left = CONTENT_MARGINS, Bottom = 30 },
}, },
textBox = new OsuTextBox searchTextBox = new SearchTextBox
{ {
PlaceholderText = "Type to search!",
Width = width - CONTENT_MARGINS * 2, Width = width - CONTENT_MARGINS * 2,
Margin = new MarginPadding { Left = CONTENT_MARGINS }, Margin = new MarginPadding { Left = CONTENT_MARGINS },
Exit = () => Hide(),
}, },
searchContainer = new SearchContainer searchContainer = new SearchContainer
{ {
@ -128,7 +129,7 @@ private void load(OsuGame game, OsuColour colours)
} }
}; };
textBox.Current.ValueChanged += newValue => searchContainer.SearchTerm = newValue; searchTextBox.Current.ValueChanged += newValue => searchContainer.SearchTerm = newValue;
scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 }; scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 };
} }
@ -169,6 +170,8 @@ protected override void PopIn()
scrollContainer.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint); scrollContainer.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint);
sidebar.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint); sidebar.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint);
FadeTo(1, TRANSITION_LENGTH / 2); FadeTo(1, TRANSITION_LENGTH / 2);
searchTextBox.HoldFocus = true;
} }
protected override void PopOut() protected override void PopOut()
@ -178,6 +181,9 @@ protected override void PopOut()
scrollContainer.MoveToX(-width, TRANSITION_LENGTH, EasingTypes.OutQuint); scrollContainer.MoveToX(-width, TRANSITION_LENGTH, EasingTypes.OutQuint);
sidebar.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, EasingTypes.OutQuint); sidebar.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, EasingTypes.OutQuint);
FadeTo(0, TRANSITION_LENGTH / 2); FadeTo(0, TRANSITION_LENGTH / 2);
searchTextBox.HoldFocus = false;
searchTextBox.TriggerFocusLost();
} }
} }
} }