From 10b8708d4e11314fd45c56d8307dfa648ca9f198 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 1 Aug 2018 17:47:32 +0900 Subject: [PATCH] Make SetupCircularButton adjust corner radius by height --- .../TestCaseEditorSetupCircularButton.cs | 45 +++++++++++++++++++ .../Setup/Components/SetupCircularButton.cs | 7 ++- 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 osu.Game.Tests/Visual/TestCaseEditorSetupCircularButton.cs diff --git a/osu.Game.Tests/Visual/TestCaseEditorSetupCircularButton.cs b/osu.Game.Tests/Visual/TestCaseEditorSetupCircularButton.cs new file mode 100644 index 0000000000..c6037b706b --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseEditorSetupCircularButton.cs @@ -0,0 +1,45 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Graphics.Containers; +using osu.Game.Screens.Edit.Screens.Setup.Components; +using OpenTK; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseEditorSetupCircularButton : OsuTestCase + { + [BackgroundDependencyLoader] + private void load() + { + Child = new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new[] + { + new SetupCircularButton { Text = "Default" }, + new SetupCircularButton + { + Width = 200, + Text = "Wide", + }, + new SetupCircularButton + { + Height = 100, + Text = "High" + }, + new SetupCircularButton + { + Size = new Vector2(200, 100), + Text = "Wide 'n' High" + } + } + }; + } + } +} diff --git a/osu.Game/Screens/Edit/Screens/Setup/Components/SetupCircularButton.cs b/osu.Game/Screens/Edit/Screens/Setup/Components/SetupCircularButton.cs index 093598be7a..d46fb2f269 100644 --- a/osu.Game/Screens/Edit/Screens/Setup/Components/SetupCircularButton.cs +++ b/osu.Game/Screens/Edit/Screens/Setup/Components/SetupCircularButton.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using osu.Framework.Allocation; using osu.Game.Graphics.UserInterface; namespace osu.Game.Screens.Edit.Screens.Setup.Components @@ -17,10 +16,10 @@ namespace osu.Game.Screens.Edit.Screens.Setup.Components Size = new Vector2(width, height); } - [BackgroundDependencyLoader] - private void load() + protected override void Update() { - Content.CornerRadius = 15; + base.Update(); + Content.CornerRadius = DrawHeight / 2f; } } }