Skip to content

Always show settings section text on buttons #26147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Localisation;
using osu.Game.Overlays;
using osu.Game.Overlays.Settings;
using osu.Game.Overlays.Settings.Sections.Input;
using osu.Game.Rulesets.Taiko;
using osuTK.Input;
Expand Down Expand Up @@ -152,7 +151,7 @@ public void TestClearButtonOnBindings()
AddStep("click first row with two bindings", () =>
{
multiBindingRow = panel.ChildrenOfType<KeyBindingRow>().First(row => row.Defaults.Count() > 1);
InputManager.MoveMouseTo(multiBindingRow);
InputManager.MoveMouseTo(multiBindingRow.ChildrenOfType<OsuSpriteText>().First());
InputManager.Click(MouseButton.Left);
});

Expand Down Expand Up @@ -256,7 +255,7 @@ public void TestClickRowSelectsFirstBinding()
AddStep("click first row with two bindings", () =>
{
multiBindingRow = panel.ChildrenOfType<KeyBindingRow>().First(row => row.Defaults.Count() > 1);
InputManager.MoveMouseTo(multiBindingRow);
InputManager.MoveMouseTo(multiBindingRow.ChildrenOfType<OsuSpriteText>().First());
InputManager.Click(MouseButton.Left);
});

Expand Down Expand Up @@ -305,7 +304,6 @@ public void TestBindingConflictResolvedByRollback()
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
});
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
AddUntilStep("wait for collapsed", () => panel.ChildrenOfType<SettingsSidebar>().Single().Expanded.Value, () => Is.False);
scrollToAndStartBinding("Left (rim)");
AddStep("attempt to bind M1 to two keys", () => InputManager.Click(MouseButton.Left));

Expand All @@ -325,7 +323,6 @@ public void TestBindingConflictResolvedByOverwrite()
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
});
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
AddUntilStep("wait for collapsed", () => panel.ChildrenOfType<SettingsSidebar>().Single().Expanded.Value, () => Is.False);
scrollToAndStartBinding("Left (rim)");
AddStep("attempt to bind M1 to two keys", () => InputManager.Click(MouseButton.Left));

Expand All @@ -345,7 +342,6 @@ public void TestBindingConflictCausedByResetToDefaultOfSingleRow()
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
});
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
AddUntilStep("wait for collapsed", () => panel.ChildrenOfType<SettingsSidebar>().Single().Expanded.Value, () => Is.False);
scrollToAndStartBinding("Left (centre)");
AddStep("clear binding", () =>
{
Expand Down Expand Up @@ -377,7 +373,6 @@ public void TestResettingEntireSectionDoesNotCauseBindingConflicts()
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
});
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
AddUntilStep("wait for collapsed", () => panel.ChildrenOfType<SettingsSidebar>().Single().Expanded.Value, () => Is.False);
scrollToAndStartBinding("Left (centre)");
AddStep("clear binding", () =>
{
Expand Down
1 change: 1 addition & 0 deletions osu.Game.Tests/Visual/Settings/TestSceneSettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public void SetUpSteps()
public void TestBasic()
{
AddStep("do nothing", () => { });
AddToggleStep("toggle visibility", visible => settings.State.Value = visible ? Visibility.Visible : Visibility.Hidden);
}

[Test]
Expand Down
21 changes: 0 additions & 21 deletions osu.Game/Graphics/Containers/ExpandingButtonContainer.cs

This file was deleted.

9 changes: 6 additions & 3 deletions osu.Game/Graphics/Containers/ExpandingContainer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// 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.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
Expand All @@ -26,6 +24,8 @@ public partial class ExpandingContainer : Container, IExpandingContainer
/// </summary>
protected virtual double HoverExpansionDelay => 0;

protected virtual bool ExpandOnHover => true;

protected override Container<Drawable> Content => FillFlow;

protected FillFlowContainer FillFlow { get; }
Expand Down Expand Up @@ -53,7 +53,7 @@ protected ExpandingContainer(float contractedWidth, float expandedWidth)
};
}

private ScheduledDelegate hoverExpandEvent;
private ScheduledDelegate? hoverExpandEvent;

protected override void LoadComplete()
{
Expand Down Expand Up @@ -93,6 +93,9 @@ protected override void OnHoverLost(HoverLostEvent e)

private void updateHoverExpansion()
{
if (!ExpandOnHover)
return;

hoverExpandEvent?.Cancel();

if (IsHovered && !Expanded.Value)
Expand Down
11 changes: 7 additions & 4 deletions osu.Game/Overlays/Settings/SettingsSidebar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@

namespace osu.Game.Overlays.Settings
{
public partial class SettingsSidebar : ExpandingButtonContainer
public partial class SettingsSidebar : ExpandingContainer
{
public const float DEFAULT_WIDTH = 70;
public const int EXPANDED_WIDTH = 200;
public const float CONTRACTED_WIDTH = 70;
public const int EXPANDED_WIDTH = 170;

protected override bool ExpandOnHover => false;

public SettingsSidebar()
: base(DEFAULT_WIDTH, EXPANDED_WIDTH)
: base(CONTRACTED_WIDTH, EXPANDED_WIDTH)
{
Expanded.Value = true;
}

[BackgroundDependencyLoader]
Expand Down
7 changes: 6 additions & 1 deletion osu.Game/Overlays/Settings/SidebarButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;

Expand All @@ -23,6 +24,7 @@ protected SidebarButton(HoverSampleSet? hoverSounds = HoverSampleSet.ButtonSideb
private void load()
{
BackgroundColour = ColourProvider.Background5;
Hover.Colour = ColourProvider.Light4;
}

protected override void LoadComplete()
Expand All @@ -40,6 +42,9 @@ protected override bool OnHover(HoverEvent e)

protected override void OnHoverLost(HoverLostEvent e) => UpdateState();

protected abstract void UpdateState();
protected virtual void UpdateState()
{
Hover.FadeTo(IsHovered ? 0.1f : 0, FADE_DURATION, Easing.OutQuint);
}
}
}
20 changes: 12 additions & 8 deletions osu.Game/Overlays/Settings/SidebarIconButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,28 @@ public SidebarIconButton()
RelativeSizeAxes = Axes.X;
Height = 46;

Padding = new MarginPadding(5);

AddRange(new Drawable[]
{
textIconContent = new Container
{
Width = SettingsSidebar.DEFAULT_WIDTH,
RelativeSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.6f),
Children = new Drawable[]
{
headerText = new OsuSpriteText
iconContainer = new ConstrainedIconContainer
{
Position = new Vector2(SettingsSidebar.DEFAULT_WIDTH + 10, 0),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Size = new Vector2(20),
Margin = new MarginPadding { Left = 25 }
},
iconContainer = new ConstrainedIconContainer
headerText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(20),
Position = new Vector2(60, 0),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
}
},
Expand Down Expand Up @@ -113,6 +115,8 @@ private void load()

protected override void UpdateState()
{
base.UpdateState();

if (Selected)
{
textIconContent.FadeColour(ColourProvider.Content1, FADE_DURATION, Easing.OutQuint);
Expand Down
7 changes: 5 additions & 2 deletions osu.Game/Overlays/SettingsOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,19 @@ private void subPanelStateChanged(SettingsSubPanel panel, ValueChangedEvent<Visi
switch (state.NewValue)
{
case Visibility.Visible:
Sidebar?.FadeColour(Color4.DarkGray, 300, Easing.OutQuint);
Sidebar.Expanded.Value = false;
Sidebar.FadeColour(Color4.DarkGray, 300, Easing.OutQuint);

SectionsContainer.FadeOut(300, Easing.OutQuint);
ContentContainer.MoveToX(-PANEL_WIDTH, 500, Easing.OutQuint);

lastOpenedSubPanel = panel;

break;

case Visibility.Hidden:
Sidebar?.FadeColour(Color4.White, 300, Easing.OutQuint);
Sidebar.Expanded.Value = true;
Sidebar.FadeColour(Color4.White, 300, Easing.OutQuint);

SectionsContainer.FadeIn(500, Easing.OutQuint);
ContentContainer.MoveToX(0, 500, Easing.OutQuint);
Expand Down
3 changes: 1 addition & 2 deletions osu.Game/Overlays/SettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract partial class SettingsPanel : OsuFocusedOverlayContainer

public const float TRANSITION_LENGTH = 600;

private const float sidebar_width = SettingsSidebar.DEFAULT_WIDTH;
private const float sidebar_width = SettingsSidebar.EXPANDED_WIDTH;

/// <summary>
/// The width of the settings panel content, excluding the sidebar.
Expand Down Expand Up @@ -285,7 +285,6 @@ private IEnumerable<SidebarIconButton> createSidebarButtons()
return;

SectionsContainer.ScrollTo(section);
Sidebar.Expanded.Value = false;
},
};
}
Expand Down
13 changes: 9 additions & 4 deletions osu.Game/Overlays/SettingsSubPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public BackButton()
[BackgroundDependencyLoader]
private void load()
{
Size = new Vector2(SettingsSidebar.DEFAULT_WIDTH);
Size = new Vector2(SettingsSidebar.EXPANDED_WIDTH);

Padding = new MarginPadding(5);

AddRange(new Drawable[]
{
Expand All @@ -61,16 +63,17 @@ private void load()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(15),
Y = -5,
Size = new Vector2(30),
Shadow = true,
Icon = FontAwesome.Solid.ChevronLeft
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Y = 15,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
Y = 30,
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Regular),
Text = @"back",
},
}
Expand All @@ -80,6 +83,8 @@ private void load()

protected override void UpdateState()
{
base.UpdateState();

content.FadeColour(IsHovered ? ColourProvider.Light1 : ColourProvider.Light3, FADE_DURATION, Easing.OutQuint);
}
}
Expand Down