From 3ef26a6bf0ccde8e45cf59dba96879004c1a672f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Nov 2016 20:07:28 +0900 Subject: [PATCH] Fix paddings, transitions, const variable names. --- osu.Game/Overlays/Options/OptionsSection.cs | 4 +- osu.Game/Overlays/Options/OptionsSidebar.cs | 13 ++---- osu.Game/Overlays/OptionsOverlay.cs | 52 ++++++++++++--------- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/osu.Game/Overlays/Options/OptionsSection.cs b/osu.Game/Overlays/Options/OptionsSection.cs index 57b48c17b5..b6d2f4634c 100644 --- a/osu.Game/Overlays/Options/OptionsSection.cs +++ b/osu.Game/Overlays/Options/OptionsSection.cs @@ -35,8 +35,8 @@ namespace osu.Game.Overlays.Options Padding = new MarginPadding { Top = 10 + borderSize, - Left = OptionsOverlay.SideMargins, - Right = OptionsOverlay.SideMargins, + Left = OptionsOverlay.CONTENT_MARGINS, + Right = OptionsOverlay.CONTENT_MARGINS, Bottom = 10, }, RelativeSizeAxes = Axes.X, diff --git a/osu.Game/Overlays/Options/OptionsSidebar.cs b/osu.Game/Overlays/Options/OptionsSidebar.cs index 810265cf5d..aba1c050af 100644 --- a/osu.Game/Overlays/Options/OptionsSidebar.cs +++ b/osu.Game/Overlays/Options/OptionsSidebar.cs @@ -19,6 +19,11 @@ namespace osu.Game.Overlays.Options RelativeSizeAxes = Axes.Y; InternalChildren = new Drawable[] { + new Box + { + Colour = Color4.Black, + RelativeSizeAxes = Axes.Both, + }, new SidebarScrollContainer { Children = new [] @@ -33,14 +38,6 @@ namespace osu.Game.Overlays.Options } } }, - new Box - { - Colour = new Color4(30, 30, 30, 255), - RelativeSizeAxes = Axes.Y, - Width = 2, - Origin = Anchor.TopRight, - Anchor = Anchor.TopRight, - } }; } diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index e855cc0c89..66e41ccf51 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -24,20 +24,18 @@ namespace osu.Game.Overlays { public class OptionsOverlay : OverlayContainer { - internal const float SideMargins = 10; + internal const float CONTENT_MARGINS = 10; + private const float width = 400; - private const float sideNavWidth = 60; - private const float sideNavPadding = 0; + private const float sidebar_width = 60; + private const float sidebar_padding = 10; + private const float sidebar_total = sidebar_width + sidebar_padding; private ScrollContainer scrollContainer; - private FlowContainer flowContainer; + private OptionsSidebar sidebar; public OptionsOverlay() { - RelativeSizeAxes = Axes.Y; - Size = new Vector2(width, 1); - Position = new Vector2(-width, 0); - var sections = new OptionsSection[] { new GeneralSection(), @@ -51,20 +49,23 @@ namespace osu.Game.Overlays new MaintenanceSection(), }; + RelativeSizeAxes = Axes.Y; + AutoSizeAxes = Axes.X; + Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.Black, - Alpha = 0.8f, + Alpha = 0.6f, }, - scrollContainer = new ScrollContainer + scrollContainer = new PaddedScrollContainer { ScrollDraggerAnchor = Anchor.TopLeft, RelativeSizeAxes = Axes.Y, - Width = width - (sideNavWidth + sideNavPadding * 2), - Position = new Vector2(sideNavWidth + sideNavPadding * 2, 0), + Width = width, + Padding = new MarginPadding { Left = sidebar_width }, Children = new[] { new FlowContainer @@ -78,29 +79,29 @@ namespace osu.Game.Overlays { Text = "settings", TextSize = 40, - Margin = new MarginPadding { Left = SideMargins, Top = 30 }, + Margin = new MarginPadding { Left = CONTENT_MARGINS, Top = 30 }, }, new SpriteText { Colour = new Color4(235, 117, 139, 255), Text = "Change the way osu! behaves", TextSize = 18, - Margin = new MarginPadding { Left = SideMargins, Bottom = 30 }, + Margin = new MarginPadding { Left = CONTENT_MARGINS, Bottom = 30 }, }, - flowContainer = new FlowContainer + new FlowContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Direction = FlowDirection.VerticalOnly, + Children = sections, } } } } }, - new OptionsSidebar + sidebar = new OptionsSidebar { - Padding = new MarginPadding { Left = sideNavPadding, Right = sideNavPadding }, - Width = sideNavWidth + sideNavPadding * 2, + Width = sidebar_width, Children = sections.Select(section => new OptionsSidebar.SidebarButton { @@ -110,7 +111,6 @@ namespace osu.Game.Overlays ) } }; - flowContainer.Add(sections); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; @@ -129,14 +129,24 @@ namespace osu.Game.Overlays protected override void PopIn() { - MoveToX(0, 300, EasingTypes.Out); + scrollContainer.MoveToX(0, 600, EasingTypes.OutQuint); + sidebar.MoveToX(0, 800, EasingTypes.OutQuint); FadeTo(1, 300); } protected override void PopOut() { - MoveToX(-width, 300, EasingTypes.Out); + scrollContainer.MoveToX(-width, 600, EasingTypes.OutQuint); + sidebar.MoveToX(-sidebar_width, 600, EasingTypes.OutQuint); FadeTo(0, 300); } + + private class PaddedScrollContainer : ScrollContainer + { + public PaddedScrollContainer() + { + Content.Padding = new MarginPadding { Left = sidebar_padding }; + } + } } }