From f200cfe40dec998572f43a1ed1c859c97c7c9d15 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Fri, 20 Jul 2018 13:05:19 +0300 Subject: [PATCH 01/15] Add labelled text box files --- .../LabelledComponents/LabelledTextBox.cs | 207 ++++++++++++++++++ .../Setup/Components/OsuSetupTextBox.cs | 24 ++ 2 files changed, 231 insertions(+) create mode 100644 osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs create mode 100644 osu.Game/Screens/Edit/Screens/Setup/Components/OsuSetupTextBox.cs diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs new file mode 100644 index 0000000000..e0c734f764 --- /dev/null +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs @@ -0,0 +1,207 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using System; + +namespace osu.Game.Screens.Edit.Screens.Setup.Components.LabelledComponents +{ + public class LabelledTextBox : CompositeDrawable + { + private readonly OsuSetupTextBox textBox; + private readonly Container content; + private readonly OsuSpriteText label; + + public const float LABEL_CONTAINER_WIDTH = 150; + public const float OUTER_CORNER_RADIUS = 15; + public const float INNER_CORNER_RADIUS = 10; + public const float DEFAULT_HEIGHT = 40; + public const float DEFAULT_LABEL_LEFT_PADDING = 15; + public const float DEFAULT_LABEL_TOP_PADDING = 12; + public const float DEFAULT_LABEL_TEXT_SIZE = 16; + + public event Action TextBoxTextChanged; + + public void TriggerTextBoxTextChanged(string newText) + { + TextBoxTextChanged?.Invoke(newText); + } + + private bool readOnly; + public bool ReadOnly + { + get => readOnly; + set + { + textBox.ReadOnly = value; + readOnly = value; + } + } + + private string labelText; + public string LabelText + { + get => labelText; + set + { + labelText = value; + label.Text = value; + } + } + + private float labelTextSize; + public float LabelTextSize + { + get => labelTextSize; + set + { + labelTextSize = value; + label.TextSize = value; + } + } + + private string textBoxPlaceholderText; + public string TextBoxPlaceholderText + { + get => textBoxPlaceholderText; + set + { + textBoxPlaceholderText = value; + textBox.PlaceholderText = value; + } + } + + private string textBoxText; + public string TextBoxText + { + get => textBoxText; + set + { + textBoxText = value; + textBox.Text = value; + TextBoxTextChanged?.Invoke(value); + } + } + + private float height = DEFAULT_HEIGHT; + public float Height + { + get => height; + private set + { + height = value; + textBox.Height = value; + content.Height = value; + } + } + + public MarginPadding Padding + { + get => base.Padding; + set + { + base.Padding = value; + base.Height = Height + base.Padding.Top; + } + } + + public MarginPadding LabelPadding + { + get => label.Padding; + set => label.Padding = value; + } + + public MarginPadding TextBoxPadding + { + get => textBox.Padding; + set => textBox.Padding = value; + } + + public Color4 LabelTextColour + { + get => label.Colour; + set => label.Colour = value; + } + + public Color4 BackgroundColour + { + get => content.Colour; + set => content.Colour = value; + } + + public LabelledTextBox() + { + Masking = true; + CornerRadius = OUTER_CORNER_RADIUS; + RelativeSizeAxes = Axes.X; + base.Height = DEFAULT_HEIGHT + Padding.Top; + + InternalChildren = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.X, + Height = DEFAULT_HEIGHT, + CornerRadius = OUTER_CORNER_RADIUS, + Masking = true, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.X, + Height = DEFAULT_HEIGHT, + Colour = OsuColour.FromHex("1c2125"), + }, + new Container + { + RelativeSizeAxes = Axes.X, + Height = DEFAULT_HEIGHT, + Child = new GridContainer + { + RelativeSizeAxes = Axes.X, + Height = DEFAULT_HEIGHT, + Content = new[] + { + new Drawable[] + { + label = new OsuSpriteText + { + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + Padding = new MarginPadding { Left = DEFAULT_LABEL_LEFT_PADDING, Top = DEFAULT_LABEL_TOP_PADDING }, + Colour = Color4.White, + TextSize = DEFAULT_LABEL_TEXT_SIZE, + Text = LabelText, + Font = @"Exo2.0-Bold", + }, + textBox = new OsuSetupTextBox + { + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + RelativeSizeAxes = Axes.X, + Height = DEFAULT_HEIGHT, + ReadOnly = ReadOnly, + CornerRadius = INNER_CORNER_RADIUS, + }, + }, + }, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, LABEL_CONTAINER_WIDTH), + new Dimension() + } + } + } + } + } + }; + + textBox.OnCommit += delegate { TriggerTextBoxTextChanged(textBox.Text); }; + } + } +} diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/OsuSetupTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/OsuSetupTextBox.cs new file mode 100644 index 0000000000..1a31582291 --- /dev/null +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/OsuSetupTextBox.cs @@ -0,0 +1,24 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Screens.Edit.Screens.Setup.Components +{ + public class OsuSetupTextBox : OsuTextBox + { + protected override float LeftRightPadding => 15; + + [BackgroundDependencyLoader] + private void load(OsuColour osuColour) + { + BorderColour = osuColour.Blue; + } + + protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), Colour = BorderColour, TextSize = CalculatedTextSize }; + } +} From 6dd5c7e5ab46b6fe548eff85ffc6871c232b71d9 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Fri, 20 Jul 2018 14:28:39 +0300 Subject: [PATCH 02/15] Add test case --- .../Visual/TestCaseLabelledTextBox.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 osu.Game.Tests/Visual/TestCaseLabelledTextBox.cs diff --git a/osu.Game.Tests/Visual/TestCaseLabelledTextBox.cs b/osu.Game.Tests/Visual/TestCaseLabelledTextBox.cs new file mode 100644 index 0000000000..a9f0375d39 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseLabelledTextBox.cs @@ -0,0 +1,37 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Game.Screens.Edit.Screens.Setup.Components.LabelledComponents; +using System; +using System.Collections.Generic; + +namespace osu.Game.Tests.Visual +{ + [TestFixture] + public class TestCaseLabelledTextBox : OsuTestCase + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(LabelledTextBox), + }; + + [BackgroundDependencyLoader] + private void load() + { + Children = new Drawable[] + { + new LabelledTextBox + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + LabelText = "Testing text", + TextBoxPlaceholderText = "This is definitely working as intended", + Padding = new MarginPadding { Left = 150, Right = 150 } + } + }; + } + } +} From 3c59ccadd05e22af7e8ec7e3dff722e6736ab4dc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 22 Jul 2018 22:19:58 +0200 Subject: [PATCH 03/15] Fix gameplay always skipping to first hitobject time Regresssed with previous build --- osu.Game/Screens/Play/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 4f37b59e6e..e9e353d698 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -139,7 +139,7 @@ private void load(AudioManager audio, APIAccess api, OsuConfigManager config) adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; adjustableClock.Seek(AllowLeadIn - ? Math.Min(RulesetContainer.GameplayStartTime, beatmap.HitObjects.First().StartTime - beatmap.BeatmapInfo.AudioLeadIn) + ? Math.Min(0, beatmap.HitObjects.First().StartTime - beatmap.BeatmapInfo.AudioLeadIn) : RulesetContainer.GameplayStartTime); adjustableClock.ProcessFrame(); From 8501967b6a3a61c38a1499e53914a5d5030860a0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 22 Jul 2018 22:47:25 +0200 Subject: [PATCH 04/15] Fix testing regression --- osu.Game.Tests/Visual/TestCasePlaySongSelect.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs index b94fb42bf0..41c45f00f3 100644 --- a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs @@ -54,6 +54,12 @@ private class TestSongSelect : PlaySongSelect public new BeatmapCarousel Carousel => base.Carousel; } + protected override void Dispose(bool isDisposing) + { + factory.ResetDatabase(); + base.Dispose(isDisposing); + } + [BackgroundDependencyLoader] private void load() { From 44a2ae5f9ac83238d151d848580a8ee33bedfdc8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 23 Jul 2018 08:33:47 +0200 Subject: [PATCH 05/15] Fix incorrect variable usage --- osu.Game/Screens/Play/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index e9e353d698..00ba1a8d12 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -139,7 +139,7 @@ private void load(AudioManager audio, APIAccess api, OsuConfigManager config) adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; adjustableClock.Seek(AllowLeadIn - ? Math.Min(0, beatmap.HitObjects.First().StartTime - beatmap.BeatmapInfo.AudioLeadIn) + ? Math.Min(0, RulesetContainer.GameplayStartTime - beatmap.BeatmapInfo.AudioLeadIn) : RulesetContainer.GameplayStartTime); adjustableClock.ProcessFrame(); From dd56a2d95fc15a3db53fbf4ad5d3252e79686072 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Mon, 23 Jul 2018 15:44:10 +0300 Subject: [PATCH 06/15] Apply proposed changes (untested) --- .../Visual/TestCaseLabelledTextBox.cs | 2 +- .../LabelledComponents/LabelledTextBox.cs | 74 +++++++++---------- .../{OsuSetupTextBox.cs => SetupTextBox.cs} | 2 +- 3 files changed, 36 insertions(+), 42 deletions(-) rename osu.Game/Screens/Edit/Screens/Setup/Components/{OsuSetupTextBox.cs => SetupTextBox.cs} (94%) diff --git a/osu.Game.Tests/Visual/TestCaseLabelledTextBox.cs b/osu.Game.Tests/Visual/TestCaseLabelledTextBox.cs index a9f0375d39..be11562bb0 100644 --- a/osu.Game.Tests/Visual/TestCaseLabelledTextBox.cs +++ b/osu.Game.Tests/Visual/TestCaseLabelledTextBox.cs @@ -28,7 +28,7 @@ private void load() Anchor = Anchor.Centre, Origin = Anchor.Centre, LabelText = "Testing text", - TextBoxPlaceholderText = "This is definitely working as intended", + PlaceholderText = "This is definitely working as intended", Padding = new MarginPadding { Left = 150, Right = 150 } } }; diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs index e0c734f764..806e6b6f6d 100644 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs @@ -8,29 +8,25 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using System; +using static osu.Framework.Graphics.UserInterface.TextBox; namespace osu.Game.Screens.Edit.Screens.Setup.Components.LabelledComponents { public class LabelledTextBox : CompositeDrawable { - private readonly OsuSetupTextBox textBox; + private readonly SetupTextBox textBox; private readonly Container content; private readonly OsuSpriteText label; - public const float LABEL_CONTAINER_WIDTH = 150; - public const float OUTER_CORNER_RADIUS = 15; - public const float INNER_CORNER_RADIUS = 10; - public const float DEFAULT_HEIGHT = 40; - public const float DEFAULT_LABEL_LEFT_PADDING = 15; - public const float DEFAULT_LABEL_TOP_PADDING = 12; - public const float DEFAULT_LABEL_TEXT_SIZE = 16; + private const float label_container_width = 150; + private const float outer_corner_radius = 15; + private const float inner_corner_radius = 10; + private const float default_height = 40; + private const float default_label_left_padding = 15; + private const float default_label_top_padding = 12; + private const float default_label_text_size = 16; - public event Action TextBoxTextChanged; - - public void TriggerTextBoxTextChanged(string newText) - { - TextBoxTextChanged?.Invoke(newText); - } + public event OnCommitHandler TextBoxTextChanged; private bool readOnly; public bool ReadOnly @@ -65,30 +61,30 @@ public float LabelTextSize } } - private string textBoxPlaceholderText; - public string TextBoxPlaceholderText + private string placeholderText; + public string PlaceholderText { - get => textBoxPlaceholderText; + get => placeholderText; set { - textBoxPlaceholderText = value; + placeholderText = value; textBox.PlaceholderText = value; } } - private string textBoxText; - public string TextBoxText + private string text; + public string Text { - get => textBoxText; + get => text; set { - textBoxText = value; + text = value; textBox.Text = value; - TextBoxTextChanged?.Invoke(value); + TextBoxTextChanged?.Invoke(textBox, true); } } - private float height = DEFAULT_HEIGHT; + private float height = default_height; public float Height { get => height; @@ -137,34 +133,32 @@ public Color4 BackgroundColour public LabelledTextBox() { Masking = true; - CornerRadius = OUTER_CORNER_RADIUS; + CornerRadius = outer_corner_radius; RelativeSizeAxes = Axes.X; - base.Height = DEFAULT_HEIGHT + Padding.Top; + base.Height = default_height + Padding.Top; InternalChildren = new Drawable[] { new Container { - RelativeSizeAxes = Axes.X, - Height = DEFAULT_HEIGHT, - CornerRadius = OUTER_CORNER_RADIUS, + RelativeSizeAxes = Axes.Both, + CornerRadius = outer_corner_radius, Masking = true, Children = new Drawable[] { new Box { - RelativeSizeAxes = Axes.X, - Height = DEFAULT_HEIGHT, + RelativeSizeAxes = Axes.Both, Colour = OsuColour.FromHex("1c2125"), }, new Container { RelativeSizeAxes = Axes.X, - Height = DEFAULT_HEIGHT, + Height = default_height, Child = new GridContainer { RelativeSizeAxes = Axes.X, - Height = DEFAULT_HEIGHT, + Height = default_height, Content = new[] { new Drawable[] @@ -173,26 +167,26 @@ public LabelledTextBox() { Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, - Padding = new MarginPadding { Left = DEFAULT_LABEL_LEFT_PADDING, Top = DEFAULT_LABEL_TOP_PADDING }, + Padding = new MarginPadding { Left = default_label_left_padding, Top = default_label_top_padding }, Colour = Color4.White, - TextSize = DEFAULT_LABEL_TEXT_SIZE, + TextSize = default_label_text_size, Text = LabelText, Font = @"Exo2.0-Bold", }, - textBox = new OsuSetupTextBox + textBox = new SetupTextBox { Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, RelativeSizeAxes = Axes.X, - Height = DEFAULT_HEIGHT, + Height = default_height, ReadOnly = ReadOnly, - CornerRadius = INNER_CORNER_RADIUS, + CornerRadius = inner_corner_radius, }, }, }, ColumnDimensions = new[] { - new Dimension(GridSizeMode.Absolute, LABEL_CONTAINER_WIDTH), + new Dimension(GridSizeMode.Absolute, label_container_width), new Dimension() } } @@ -201,7 +195,7 @@ public LabelledTextBox() } }; - textBox.OnCommit += delegate { TriggerTextBoxTextChanged(textBox.Text); }; + textBox.OnCommit += (_, a) => TextBoxTextChanged?.Invoke(textBox, a); } } } diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/OsuSetupTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/SetupTextBox.cs similarity index 94% rename from osu.Game/Screens/Edit/Screens/Setup/Components/OsuSetupTextBox.cs rename to osu.Game/Screens/Edit/Screens/Setup/Components/SetupTextBox.cs index 1a31582291..206170e1eb 100644 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/OsuSetupTextBox.cs +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/SetupTextBox.cs @@ -9,7 +9,7 @@ namespace osu.Game.Screens.Edit.Screens.Setup.Components { - public class OsuSetupTextBox : OsuTextBox + public class SetupTextBox : OsuTextBox { protected override float LeftRightPadding => 15; From a833fa3d924e05df4047d5ba00965819156f4a2a Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Tue, 24 Jul 2018 09:19:45 +0300 Subject: [PATCH 07/15] Update framework and apply suggested changes --- .../Setup/Components/LabelledComponents/LabelledTextBox.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs index 806e6b6f6d..09797e3180 100644 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs @@ -26,7 +26,7 @@ public class LabelledTextBox : CompositeDrawable private const float default_label_top_padding = 12; private const float default_label_text_size = 16; - public event OnCommitHandler TextBoxTextChanged; + public event OnCommitHandler OnCommit; private bool readOnly; public bool ReadOnly @@ -80,7 +80,6 @@ public string Text { text = value; textBox.Text = value; - TextBoxTextChanged?.Invoke(textBox, true); } } @@ -195,7 +194,7 @@ public LabelledTextBox() } }; - textBox.OnCommit += (_, a) => TextBoxTextChanged?.Invoke(textBox, a); + textBox.OnCommit += OnCommit; } } } From 2f452c162cb9b9c09dd21dba9780f6630fdb3270 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Tue, 24 Jul 2018 09:21:01 +0300 Subject: [PATCH 08/15] Make text colour white --- .../Screens/Edit/Screens/Setup/Components/SetupTextBox.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/SetupTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/SetupTextBox.cs index 206170e1eb..c3938fae9c 100644 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/SetupTextBox.cs +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/SetupTextBox.cs @@ -12,13 +12,5 @@ namespace osu.Game.Screens.Edit.Screens.Setup.Components public class SetupTextBox : OsuTextBox { protected override float LeftRightPadding => 15; - - [BackgroundDependencyLoader] - private void load(OsuColour osuColour) - { - BorderColour = osuColour.Blue; - } - - protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), Colour = BorderColour, TextSize = CalculatedTextSize }; } } From 765c6e4eccbe0a3744fd6c3dfca1f42aa1522f34 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Tue, 24 Jul 2018 09:46:24 +0300 Subject: [PATCH 09/15] Remove custom text box --- .../LabelledComponents/LabelledTextBox.cs | 5 +++-- .../Screens/Setup/Components/SetupTextBox.cs | 16 ---------------- 2 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 osu.Game/Screens/Edit/Screens/Setup/Components/SetupTextBox.cs diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs index 09797e3180..15723c0eaf 100644 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; using System; using static osu.Framework.Graphics.UserInterface.TextBox; @@ -14,7 +15,7 @@ namespace osu.Game.Screens.Edit.Screens.Setup.Components.LabelledComponents { public class LabelledTextBox : CompositeDrawable { - private readonly SetupTextBox textBox; + private readonly OsuTextBox textBox; private readonly Container content; private readonly OsuSpriteText label; @@ -172,7 +173,7 @@ public LabelledTextBox() Text = LabelText, Font = @"Exo2.0-Bold", }, - textBox = new SetupTextBox + textBox = new OsuTextBox { Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/SetupTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/SetupTextBox.cs deleted file mode 100644 index c3938fae9c..0000000000 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/SetupTextBox.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; - -namespace osu.Game.Screens.Edit.Screens.Setup.Components -{ - public class SetupTextBox : OsuTextBox - { - protected override float LeftRightPadding => 15; - } -} From 0e50e4ee346d6e7f1d06e89a7749b72d95cd239c Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Tue, 24 Jul 2018 10:10:17 +0300 Subject: [PATCH 10/15] Clean code --- .../LabelledComponents/LabelledTextBox.cs | 82 +++++++++---------- 1 file changed, 38 insertions(+), 44 deletions(-) diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs index 15723c0eaf..5f4e88b52c 100644 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs @@ -8,7 +8,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using System; using static osu.Framework.Graphics.UserInterface.TextBox; namespace osu.Game.Screens.Edit.Screens.Setup.Components.LabelledComponents @@ -132,63 +131,58 @@ public Color4 BackgroundColour public LabelledTextBox() { - Masking = true; - CornerRadius = outer_corner_radius; RelativeSizeAxes = Axes.X; base.Height = default_height + Padding.Top; + CornerRadius = outer_corner_radius; + Masking = true; - InternalChildren = new Drawable[] + InternalChild = new Container { - new Container + RelativeSizeAxes = Axes.Both, + CornerRadius = outer_corner_radius, + Masking = true, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - CornerRadius = outer_corner_radius, - Masking = true, - Children = new Drawable[] + new Box { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex("1c2125"), - }, - new Container + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex("1c2125"), + }, + new Container + { + RelativeSizeAxes = Axes.X, + Height = default_height, + Child = new GridContainer { RelativeSizeAxes = Axes.X, Height = default_height, - Child = new GridContainer + Content = new[] { - RelativeSizeAxes = Axes.X, - Height = default_height, - Content = new[] + new Drawable[] { - new Drawable[] + label = new OsuSpriteText { - label = new OsuSpriteText - { - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - Padding = new MarginPadding { Left = default_label_left_padding, Top = default_label_top_padding }, - Colour = Color4.White, - TextSize = default_label_text_size, - Text = LabelText, - Font = @"Exo2.0-Bold", - }, - textBox = new OsuTextBox - { - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - RelativeSizeAxes = Axes.X, - Height = default_height, - ReadOnly = ReadOnly, - CornerRadius = inner_corner_radius, - }, + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + Padding = new MarginPadding { Left = default_label_left_padding, Top = default_label_top_padding }, + Colour = Color4.White, + TextSize = default_label_text_size, + Font = @"Exo2.0-Bold", + }, + textBox = new OsuTextBox + { + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + RelativeSizeAxes = Axes.X, + Height = default_height, + CornerRadius = inner_corner_radius, }, }, - ColumnDimensions = new[] - { - new Dimension(GridSizeMode.Absolute, label_container_width), - new Dimension() - } + }, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, label_container_width), + new Dimension() } } } From 3ca112aef0779c29fd7eaeca0dd9d9d24656e661 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Tue, 24 Jul 2018 22:04:02 +0300 Subject: [PATCH 11/15] Clean code and apply requested changes --- .../LabelledComponents/LabelledTextBox.cs | 124 ++++++------------ 1 file changed, 39 insertions(+), 85 deletions(-) diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs index 5f4e88b52c..9f364c6cf4 100644 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs @@ -27,82 +27,41 @@ public class LabelledTextBox : CompositeDrawable private const float default_label_text_size = 16; public event OnCommitHandler OnCommit; - - private bool readOnly; + public bool ReadOnly { - get => readOnly; - set - { - textBox.ReadOnly = value; - readOnly = value; - } + get => textBox.ReadOnly; + set => textBox.ReadOnly = value; } - - private string labelText; + public string LabelText { - get => labelText; - set - { - labelText = value; - label.Text = value; - } + get => label.Text; + set => label.Text = value; } - - private float labelTextSize; + public float LabelTextSize { - get => labelTextSize; - set - { - labelTextSize = value; - label.TextSize = value; - } + get => label.TextSize; + set => label.TextSize = value; } - - private string placeholderText; + public string PlaceholderText { - get => placeholderText; - set - { - placeholderText = value; - textBox.PlaceholderText = value; - } + get => textBox.PlaceholderText; + set => textBox.PlaceholderText = value; } - private string text; public string Text { - get => text; - set - { - text = value; - textBox.Text = value; - } - } - - private float height = default_height; - public float Height - { - get => height; - private set - { - height = value; - textBox.Height = value; - content.Height = value; - } + get => textBox.Text; + set => textBox.Text = value; } public MarginPadding Padding { get => base.Padding; - set - { - base.Padding = value; - base.Height = Height + base.Padding.Top; - } + set => base.Padding = value; } public MarginPadding LabelPadding @@ -132,7 +91,7 @@ public Color4 BackgroundColour public LabelledTextBox() { RelativeSizeAxes = Axes.X; - base.Height = default_height + Padding.Top; + Height = default_height; CornerRadius = outer_corner_radius; Masking = true; @@ -148,42 +107,37 @@ public LabelledTextBox() RelativeSizeAxes = Axes.Both, Colour = OsuColour.FromHex("1c2125"), }, - new Container + new GridContainer { RelativeSizeAxes = Axes.X, Height = default_height, - Child = new GridContainer + Content = new[] { - RelativeSizeAxes = Axes.X, - Height = default_height, - Content = new[] + new Drawable[] { - new Drawable[] + label = new OsuSpriteText { - label = new OsuSpriteText - { - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - Padding = new MarginPadding { Left = default_label_left_padding, Top = default_label_top_padding }, - Colour = Color4.White, - TextSize = default_label_text_size, - Font = @"Exo2.0-Bold", - }, - textBox = new OsuTextBox - { - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - RelativeSizeAxes = Axes.X, - Height = default_height, - CornerRadius = inner_corner_radius, - }, + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + Padding = new MarginPadding { Left = default_label_left_padding, Top = default_label_top_padding }, + Colour = Color4.White, + TextSize = default_label_text_size, + Font = @"Exo2.0-Bold", + }, + textBox = new OsuTextBox + { + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + RelativeSizeAxes = Axes.Both, + Height = 1, + CornerRadius = inner_corner_radius, }, }, - ColumnDimensions = new[] - { - new Dimension(GridSizeMode.Absolute, label_container_width), - new Dimension() - } + }, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, label_container_width), + new Dimension() } } } From 6675c455f3d6761343b969849db8d92d376238c5 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Tue, 24 Jul 2018 22:33:19 +0300 Subject: [PATCH 12/15] Trim whitespace that magically appeared --- .../Components/LabelledComponents/LabelledTextBox.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs index 9f364c6cf4..fbfb771c8a 100644 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs @@ -27,25 +27,25 @@ public class LabelledTextBox : CompositeDrawable private const float default_label_text_size = 16; public event OnCommitHandler OnCommit; - + public bool ReadOnly { get => textBox.ReadOnly; set => textBox.ReadOnly = value; } - + public string LabelText { get => label.Text; set => label.Text = value; } - + public float LabelTextSize { get => label.TextSize; set => label.TextSize = value; } - + public string PlaceholderText { get => textBox.PlaceholderText; From b60e4b0728cc24a0067d673c6552f12de6e331e9 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 25 Jul 2018 18:34:47 +0900 Subject: [PATCH 13/15] Cleanup --- .../Components/LabelledComponents/LabelledTextBox.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs index fbfb771c8a..4c8e90400a 100644 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs @@ -5,19 +5,15 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using static osu.Framework.Graphics.UserInterface.TextBox; namespace osu.Game.Screens.Edit.Screens.Setup.Components.LabelledComponents { public class LabelledTextBox : CompositeDrawable { - private readonly OsuTextBox textBox; - private readonly Container content; - private readonly OsuSpriteText label; - private const float label_container_width = 150; private const float outer_corner_radius = 15; private const float inner_corner_radius = 10; @@ -26,7 +22,7 @@ public class LabelledTextBox : CompositeDrawable private const float default_label_top_padding = 12; private const float default_label_text_size = 16; - public event OnCommitHandler OnCommit; + public event TextBox.OnCommitHandler OnCommit; public bool ReadOnly { @@ -88,6 +84,10 @@ public Color4 BackgroundColour set => content.Colour = value; } + private readonly OsuTextBox textBox; + private readonly Container content; + private readonly OsuSpriteText label; + public LabelledTextBox() { RelativeSizeAxes = Axes.X; From 206e3686f2dc2fd98273892f6d5faeee4dfad304 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 25 Jul 2018 18:38:50 +0900 Subject: [PATCH 14/15] Add back blue border --- .../Setup/Components/LabelledComponents/LabelledTextBox.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs index 4c8e90400a..736d785b41 100644 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -145,5 +146,11 @@ public LabelledTextBox() textBox.OnCommit += OnCommit; } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + textBox.BorderColour = colours.Blue; + } } } From c4b1ba2979ede6c0b00c29c6912801ad6e4d0adf Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Wed, 25 Jul 2018 15:14:40 +0300 Subject: [PATCH 15/15] Remove padding, fix corner radiuses --- .../Visual/TestCaseLabelledTextBox.cs | 10 ++++--- .../LabelledComponents/LabelledTextBox.cs | 27 +++---------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseLabelledTextBox.cs b/osu.Game.Tests/Visual/TestCaseLabelledTextBox.cs index be11562bb0..d41739bfb5 100644 --- a/osu.Game.Tests/Visual/TestCaseLabelledTextBox.cs +++ b/osu.Game.Tests/Visual/TestCaseLabelledTextBox.cs @@ -4,6 +4,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Game.Screens.Edit.Screens.Setup.Components.LabelledComponents; using System; using System.Collections.Generic; @@ -21,15 +22,18 @@ public class TestCaseLabelledTextBox : OsuTestCase [BackgroundDependencyLoader] private void load() { - Children = new Drawable[] + Child = new Container { - new LabelledTextBox + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Padding = new MarginPadding { Left = 150, Right = 150 }, + Child = new LabelledTextBox { Anchor = Anchor.Centre, Origin = Anchor.Centre, LabelText = "Testing text", PlaceholderText = "This is definitely working as intended", - Padding = new MarginPadding { Left = 150, Right = 150 } } }; } diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs index 736d785b41..94200b7f4e 100644 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/LabelledComponents/LabelledTextBox.cs @@ -16,8 +16,7 @@ namespace osu.Game.Screens.Edit.Screens.Setup.Components.LabelledComponents public class LabelledTextBox : CompositeDrawable { private const float label_container_width = 150; - private const float outer_corner_radius = 15; - private const float inner_corner_radius = 10; + private const float corner_radius = 15; private const float default_height = 40; private const float default_label_left_padding = 15; private const float default_label_top_padding = 12; @@ -55,24 +54,6 @@ public string Text set => textBox.Text = value; } - public MarginPadding Padding - { - get => base.Padding; - set => base.Padding = value; - } - - public MarginPadding LabelPadding - { - get => label.Padding; - set => label.Padding = value; - } - - public MarginPadding TextBoxPadding - { - get => textBox.Padding; - set => textBox.Padding = value; - } - public Color4 LabelTextColour { get => label.Colour; @@ -93,13 +74,13 @@ public LabelledTextBox() { RelativeSizeAxes = Axes.X; Height = default_height; - CornerRadius = outer_corner_radius; + CornerRadius = corner_radius; Masking = true; InternalChild = new Container { RelativeSizeAxes = Axes.Both, - CornerRadius = outer_corner_radius, + CornerRadius = corner_radius, Masking = true, Children = new Drawable[] { @@ -131,7 +112,7 @@ public LabelledTextBox() Origin = Anchor.TopLeft, RelativeSizeAxes = Axes.Both, Height = 1, - CornerRadius = inner_corner_radius, + CornerRadius = corner_radius, }, }, },