Refactor everything so I can read the code

This commit is contained in:
Dean Herbert
2020-03-02 20:16:58 +09:00
parent 23068034b1
commit 69b4713731
3 changed files with 36 additions and 28 deletions

View File

@ -13,17 +13,17 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
public class ExpandingBar : Circle
{
private bool isCollapsed;
private bool expanded = true;
public bool IsCollapsed
public bool Expanded
{
get => isCollapsed;
get => expanded;
set
{
if (value == isCollapsed)
if (value == expanded)
return;
isCollapsed = value;
expanded = value;
updateState();
}
}
@ -83,19 +83,21 @@ namespace osu.Game.Graphics.UserInterface
updateState();
}
public void Collapse() => IsCollapsed = true;
public void Collapse() => Expanded = false;
public void Expand() => IsCollapsed = false;
public void Expand() => Expanded = true;
private void updateState()
{
float newSize = IsCollapsed ? CollapsedSize : ExpandedSize;
Easing easingType = IsCollapsed ? Easing.Out : Easing.OutElastic;
float newSize = expanded ? ExpandedSize : CollapsedSize;
Easing easingType = expanded ? Easing.OutElastic : Easing.Out;
if (RelativeSizeAxes == Axes.X)
this.ResizeHeightTo(newSize, 400, easingType);
else
this.ResizeWidthTo(newSize, 400, easingType);
this.FadeTo(expanded ? 1 : 0.5f, 100, Easing.OutQuint);
}
}
}