mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:07:52 +08:00
Move back button inside sidebar to fix weird animation
This commit is contained in:
parent
8cd240fbec
commit
901674a130
@ -111,7 +111,7 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
|
||||
AddStep("Press back", () => settings
|
||||
.ChildrenOfType<KeyBindingPanel>().FirstOrDefault()?
|
||||
.ChildrenOfType<SettingsSubPanel.BackButton>().FirstOrDefault()?.TriggerClick());
|
||||
.ChildrenOfType<SettingsSidebar.BackButton>().FirstOrDefault()?.TriggerClick());
|
||||
|
||||
AddUntilStep("top-level textbox focused", () => settings.SectionsContainer.ChildrenOfType<SettingsSearchTextBox>().FirstOrDefault()?.HasFocus == true);
|
||||
}
|
||||
|
@ -1,10 +1,17 @@
|
||||
// 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 System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
@ -13,11 +20,16 @@ namespace osu.Game.Overlays.Settings
|
||||
public const float CONTRACTED_WIDTH = 70;
|
||||
public const int EXPANDED_WIDTH = 170;
|
||||
|
||||
public Action? BackButtonAction;
|
||||
|
||||
protected override bool ExpandOnHover => false;
|
||||
|
||||
public SettingsSidebar()
|
||||
private readonly bool showBackButton;
|
||||
|
||||
public SettingsSidebar(bool showBackButton)
|
||||
: base(CONTRACTED_WIDTH, EXPANDED_WIDTH)
|
||||
{
|
||||
this.showBackButton = showBackButton;
|
||||
Expanded.Value = true;
|
||||
}
|
||||
|
||||
@ -30,6 +42,71 @@ namespace osu.Game.Overlays.Settings
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = float.MaxValue
|
||||
});
|
||||
|
||||
if (showBackButton)
|
||||
{
|
||||
AddInternal(new BackButton
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Action = () => BackButtonAction?.Invoke(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public partial class BackButton : SidebarButton
|
||||
{
|
||||
private Drawable content = null!;
|
||||
|
||||
public BackButton()
|
||||
: base(HoverSampleSet.Default)
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Size = new Vector2(SettingsSidebar.EXPANDED_WIDTH);
|
||||
|
||||
Padding = new MarginPadding(40);
|
||||
|
||||
AddRange(new[]
|
||||
{
|
||||
content = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Direction = FillDirection.Vertical,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Size = new Vector2(30),
|
||||
Shadow = true,
|
||||
Icon = FontAwesome.Solid.ChevronLeft
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Regular),
|
||||
Text = @"back",
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override void UpdateState()
|
||||
{
|
||||
base.UpdateState();
|
||||
|
||||
content.FadeColour(IsHovered ? ColourProvider.Light1 : ColourProvider.Light3, FADE_DURATION, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace osu.Game.Overlays
|
||||
protected override Drawable CreateFooter() => new SettingsFooter();
|
||||
|
||||
public SettingsOverlay()
|
||||
: base(true)
|
||||
: base(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Overlays
|
||||
protected override string PopInSampleName => "UI/settings-pop-in";
|
||||
protected override double PopInOutSampleBalance => -OsuGameBase.SFX_STEREO_STRENGTH;
|
||||
|
||||
private readonly bool showSidebar;
|
||||
private readonly bool showBackButton;
|
||||
|
||||
private LoadingLayer loading;
|
||||
|
||||
@ -72,9 +72,9 @@ namespace osu.Game.Overlays
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
protected SettingsPanel(bool showSidebar)
|
||||
protected SettingsPanel(bool showBackButton)
|
||||
{
|
||||
this.showSidebar = showSidebar;
|
||||
this.showBackButton = showBackButton;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
AutoSizeAxes = Axes.X;
|
||||
}
|
||||
@ -146,10 +146,11 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
});
|
||||
|
||||
if (showSidebar)
|
||||
AddInternal(Sidebar = new SettingsSidebar(showBackButton)
|
||||
{
|
||||
AddInternal(Sidebar = new SettingsSidebar { Width = sidebar_width });
|
||||
}
|
||||
BackButtonAction = Hide,
|
||||
Width = sidebar_width
|
||||
});
|
||||
|
||||
CreateSections()?.ForEach(AddSection);
|
||||
}
|
||||
|
@ -1,17 +1,7 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -25,69 +15,8 @@ namespace osu.Game.Overlays
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AddInternal(new BackButton
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Action = Hide
|
||||
});
|
||||
}
|
||||
|
||||
protected override bool DimMainContent => false; // dimming is handled by main overlay
|
||||
|
||||
public partial class BackButton : SidebarButton
|
||||
{
|
||||
private Drawable content;
|
||||
|
||||
public BackButton()
|
||||
: base(HoverSampleSet.Default)
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Size = new Vector2(SettingsSidebar.EXPANDED_WIDTH);
|
||||
|
||||
Padding = new MarginPadding(40);
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
content = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Direction = FillDirection.Vertical,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Size = new Vector2(30),
|
||||
Shadow = true,
|
||||
Icon = FontAwesome.Solid.ChevronLeft
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Regular),
|
||||
Text = @"back",
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override void UpdateState()
|
||||
{
|
||||
base.UpdateState();
|
||||
|
||||
content.FadeColour(IsHovered ? ColourProvider.Light1 : ColourProvider.Light3, FADE_DURATION, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user