mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:23:20 +08:00
Refactor everything so I can read the code
This commit is contained in:
parent
23068034b1
commit
69b4713731
@ -13,17 +13,17 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ExpandingBar : Circle
|
public class ExpandingBar : Circle
|
||||||
{
|
{
|
||||||
private bool isCollapsed;
|
private bool expanded = true;
|
||||||
|
|
||||||
public bool IsCollapsed
|
public bool Expanded
|
||||||
{
|
{
|
||||||
get => isCollapsed;
|
get => expanded;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == isCollapsed)
|
if (value == expanded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
isCollapsed = value;
|
expanded = value;
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,19 +83,21 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Collapse() => IsCollapsed = true;
|
public void Collapse() => Expanded = false;
|
||||||
|
|
||||||
public void Expand() => IsCollapsed = false;
|
public void Expand() => Expanded = true;
|
||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
float newSize = IsCollapsed ? CollapsedSize : ExpandedSize;
|
float newSize = expanded ? ExpandedSize : CollapsedSize;
|
||||||
Easing easingType = IsCollapsed ? Easing.Out : Easing.OutElastic;
|
Easing easingType = expanded ? Easing.OutElastic : Easing.Out;
|
||||||
|
|
||||||
if (RelativeSizeAxes == Axes.X)
|
if (RelativeSizeAxes == Axes.X)
|
||||||
this.ResizeHeightTo(newSize, 400, easingType);
|
this.ResizeHeightTo(newSize, 400, easingType);
|
||||||
else
|
else
|
||||||
this.ResizeWidthTo(newSize, 400, easingType);
|
this.ResizeWidthTo(newSize, 400, easingType);
|
||||||
|
|
||||||
|
this.FadeTo(expanded ? 1 : 0.5f, 100, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
Colour = stream.Colour,
|
Colour = stream.Colour,
|
||||||
ExpandedSize = 4,
|
ExpandedSize = 4,
|
||||||
CollapsedSize = 2,
|
CollapsedSize = 2,
|
||||||
IsCollapsed = true
|
Expanded = true
|
||||||
},
|
},
|
||||||
new HoverClickSounds()
|
new HoverClickSounds()
|
||||||
});
|
});
|
||||||
@ -100,33 +100,39 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
if (SelectedTab.Value == null && !allStreamsDimmed)
|
// highlighted regardless if we are hovered
|
||||||
|
bool textHighlighted = IsHovered;
|
||||||
|
bool barExpanded = IsHovered;
|
||||||
|
|
||||||
|
if (SelectedTab.Value == null)
|
||||||
{
|
{
|
||||||
expandingBar.Expand();
|
// at listing, all badges are highlighted when user is not hovering any badge.
|
||||||
expandingBar.FadeTo(1, transition_duration, Easing.OutQuint);
|
textHighlighted |= !userHoveringArea;
|
||||||
text.FadeTo(1, transition_duration, Easing.OutQuint);
|
barExpanded |= !userHoveringArea;
|
||||||
return;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// bar is always expanded when active
|
||||||
|
barExpanded |= Active.Value;
|
||||||
|
|
||||||
|
// text is highlighted only when hovered or active (but not if in selection mode)
|
||||||
|
textHighlighted |= Active.Value && !userHoveringArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
var shouldExpand = Active.Value || IsHovered;
|
expandingBar.Expanded = barExpanded;
|
||||||
|
text.FadeTo(textHighlighted ? 1 : 0.5f, transition_duration, Easing.OutQuint);
|
||||||
expandingBar.IsCollapsed = !shouldExpand;
|
|
||||||
expandingBar.FadeTo(shouldExpand ? 1 : 0.5f, transition_duration, Easing.OutQuint);
|
|
||||||
|
|
||||||
text.FadeTo(IsHovered || (Active.Value && !allStreamsDimmed) ? 1 : 0.5f, transition_duration, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool allStreamsDimmed;
|
private bool userHoveringArea;
|
||||||
|
|
||||||
public bool AllStreamsDimmed
|
public bool UserHoveringArea
|
||||||
{
|
{
|
||||||
get => allStreamsDimmed;
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == allStreamsDimmed)
|
if (value == userHoveringArea)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
allStreamsDimmed = value;
|
userHoveringArea = value;
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
foreach (var streamBadge in TabContainer.Children.OfType<UpdateStreamBadge>())
|
foreach (var streamBadge in TabContainer.Children.OfType<UpdateStreamBadge>())
|
||||||
streamBadge.AllStreamsDimmed = true;
|
streamBadge.UserHoveringArea = true;
|
||||||
|
|
||||||
return base.OnHover(e);
|
return base.OnHover(e);
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
foreach (var streamBadge in TabContainer.Children.OfType<UpdateStreamBadge>())
|
foreach (var streamBadge in TabContainer.Children.OfType<UpdateStreamBadge>())
|
||||||
streamBadge.AllStreamsDimmed = false;
|
streamBadge.UserHoveringArea = false;
|
||||||
|
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user