1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 11:22:58 +08:00

Merge branch 'master' into fix-track-rotation

This commit is contained in:
Dan Balasescu 2017-07-14 19:38:48 +10:00 committed by GitHub
commit fa0c0e3b48
4 changed files with 83 additions and 10 deletions

View File

@ -123,6 +123,8 @@ namespace osu.Game.Graphics.Containers
originalSectionsMargin = sectionsContainer.Margin; originalSectionsMargin = sectionsContainer.Margin;
} }
public void ScrollTo(Drawable section) => ScrollContainer.ScrollTo(ScrollContainer.GetChildPosInContent(section) - FixedHeader.BoundingBox.Height);
private float lastKnownScroll; private float lastKnownScroll;
protected override void UpdateAfterChildren() protected override void UpdateAfterChildren()
{ {

View File

@ -56,6 +56,8 @@ namespace osu.Game
} }
} }
public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight;
private OsuScreen screenStack; private OsuScreen screenStack;
private VolumeControl volume; private VolumeControl volume;
@ -360,7 +362,7 @@ namespace osu.Game
{ {
base.UpdateAfterChildren(); base.UpdateAfterChildren();
mainContent.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight }; mainContent.Padding = new MarginPadding { Top = ToolbarOffset };
Cursor.State = currentScreen?.HasLocalCursorDisplayed == false ? Visibility.Visible : Visibility.Hidden; Cursor.State = currentScreen?.HasLocalCursorDisplayed == false ? Visibility.Visible : Visibility.Hidden;
} }

View File

@ -1,6 +1,8 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -12,7 +14,7 @@ using osu.Game.Overlays.Toolbar;
namespace osu.Game.Overlays.Settings namespace osu.Game.Overlays.Settings
{ {
public class Sidebar : Container public class Sidebar : Container, IStateful<ExpandedState>
{ {
private readonly FillFlowContainer content; private readonly FillFlowContainer content;
internal const float DEFAULT_WIDTH = ToolbarButton.WIDTH; internal const float DEFAULT_WIDTH = ToolbarButton.WIDTH;
@ -47,24 +49,29 @@ namespace osu.Game.Overlays.Settings
} }
private ScheduledDelegate expandEvent; private ScheduledDelegate expandEvent;
private ExpandedState state;
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
{ {
expandEvent = Scheduler.AddDelayed(() => queueExpandIfHovering();
{
expandEvent = null;
ResizeTo(new Vector2(EXPANDED_WIDTH, Height), 150, EasingTypes.OutQuad);
}, 750);
return true; return true;
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(InputState state)
{ {
expandEvent?.Cancel(); expandEvent?.Cancel();
ResizeTo(new Vector2(DEFAULT_WIDTH, Height), 150, EasingTypes.OutQuad); lastHoveredButton = null;
State = ExpandedState.Contracted;
base.OnHoverLost(state); base.OnHoverLost(state);
} }
protected override bool OnMouseMove(InputState state)
{
queueExpandIfHovering();
return base.OnMouseMove(state);
}
private class SidebarScrollContainer : ScrollContainer private class SidebarScrollContainer : ScrollContainer
{ {
public SidebarScrollContainer() public SidebarScrollContainer()
@ -74,5 +81,52 @@ namespace osu.Game.Overlays.Settings
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }
} }
public ExpandedState State
{
get { return state; }
set
{
if (state == value) return;
state = value;
switch (state)
{
default:
ResizeTo(new Vector2(DEFAULT_WIDTH, Height), 500, EasingTypes.OutQuint);
break;
case ExpandedState.Expanded:
ResizeTo(new Vector2(EXPANDED_WIDTH, Height), 500, EasingTypes.OutQuint);
break;
}
}
}
private Drawable lastHoveredButton;
private Drawable hoveredButton => content.Children.FirstOrDefault(c => c.IsHovered);
private void queueExpandIfHovering()
{
// only expand when we hover a different button.
if (lastHoveredButton == hoveredButton) return;
if (!IsHovered) return;
if (State != ExpandedState.Expanded)
{
expandEvent?.Cancel();
expandEvent = Scheduler.AddDelayed(() => State = ExpandedState.Expanded, 750);
}
lastHoveredButton = hoveredButton;
}
}
public enum ExpandedState
{
Contracted,
Expanded,
} }
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq; using System.Linq;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -35,6 +36,8 @@ namespace osu.Game.Overlays
private SearchTextBox searchTextBox; private SearchTextBox searchTextBox;
private Func<float> getToolbarHeight;
public SettingsOverlay() public SettingsOverlay()
{ {
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Y;
@ -93,7 +96,11 @@ namespace osu.Game.Overlays
new SidebarButton new SidebarButton
{ {
Section = section, Section = section,
Action = b => sectionsContainer.ScrollContainer.ScrollTo(b), Action = s =>
{
sectionsContainer.ScrollTo(s);
sidebar.State = ExpandedState.Contracted;
},
} }
).ToArray() ).ToArray()
} }
@ -111,7 +118,7 @@ namespace osu.Game.Overlays
searchTextBox.Current.ValueChanged += newValue => sectionsContainer.SearchContainer.SearchTerm = newValue; searchTextBox.Current.ValueChanged += newValue => sectionsContainer.SearchContainer.SearchTerm = newValue;
sectionsContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 }; getToolbarHeight = () => game?.ToolbarOffset ?? 0;
} }
protected override void PopIn() protected override void PopIn()
@ -148,6 +155,14 @@ namespace osu.Game.Overlays
base.OnFocus(state); base.OnFocus(state);
} }
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
sectionsContainer.Margin = new MarginPadding { Left = sidebar.DrawWidth };
sectionsContainer.Padding = new MarginPadding { Top = getToolbarHeight() };
}
private class SettingsSectionsContainer : SectionsContainer private class SettingsSectionsContainer : SectionsContainer
{ {
public SearchContainer SearchContainer; public SearchContainer SearchContainer;