visibility logic adjustments

This commit is contained in:
Andrei Zavatski 2019-07-09 12:16:58 +03:00
parent 8d6af1625a
commit e8b9b1b0bf
2 changed files with 35 additions and 47 deletions

View File

@ -3,12 +3,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.BeatmapSet.Scores; using osu.Game.Overlays.BeatmapSet.Scores;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
@ -16,6 +14,7 @@ using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Users; using osu.Game.Users;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.Online namespace osu.Game.Tests.Visual.Online
{ {
@ -44,7 +43,11 @@ namespace osu.Game.Tests.Visual.Online
Width = 0.8f, Width = 0.8f,
Children = new Drawable[] Children = new Drawable[]
{ {
background = new Box { RelativeSizeAxes = Axes.Both }, background = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
scoresContainer = new ScoresContainer(), scoresContainer = new ScoresContainer(),
} }
}; };
@ -245,11 +248,5 @@ namespace osu.Game.Tests.Visual.Online
}); });
AddStep("Trigger loading", () => scoresContainer.Loading = !scoresContainer.Loading); AddStep("Trigger loading", () => scoresContainer.Loading = !scoresContainer.Loading);
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.Gray2;
}
} }
} }

View File

@ -23,7 +23,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private readonly ScoreTable scoreTable; private readonly ScoreTable scoreTable;
private readonly FillFlowContainer topScoresContainer; private readonly FillFlowContainer topScoresContainer;
private readonly ContentContainer resizableContainer; private readonly ContentContainer contentContainer;
private readonly LoadingContainer loadingContainer; private readonly LoadingContainer loadingContainer;
public ScoresContainer() public ScoresContainer()
@ -49,36 +49,33 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Masking = true, Masking = true,
}, },
resizableContainer = new ContentContainer contentContainer = new ContentContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Masking = true, Masking = true,
Children = new Drawable[] Child = new FillFlowContainer
{ {
new FillFlowContainer Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Width = 0.95f,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, spacing),
Padding = new MarginPadding { Vertical = padding },
Children = new Drawable[]
{ {
Anchor = Anchor.TopCentre, topScoresContainer = new FillFlowContainer
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Width = 0.95f,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, spacing),
Padding = new MarginPadding { Vertical = padding },
Children = new Drawable[]
{ {
topScoresContainer = new FillFlowContainer RelativeSizeAxes = Axes.X,
{ AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X, Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Y, Spacing = new Vector2(0, 5),
Direction = FillDirection.Vertical, },
Spacing = new Vector2(0, 5), scoreTable = new ScoreTable
}, {
scoreTable = new ScoreTable Anchor = Anchor.TopCentre,
{ Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
}
} }
}, },
} }
@ -103,20 +100,21 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
get => loading; get => loading;
set set
{ {
if (loading == value)
return;
loading = value; loading = value;
if (value) if (value)
{ {
loadingContainer.Show(); loadingContainer.Show();
resizableContainer.Hide(); contentContainer.Hide();
} }
else else
{ {
loadingContainer.Hide(); loadingContainer.Hide();
resizableContainer.Show();
if (scores == null || scores?.Scores.Count < 1)
contentContainer.Hide();
else
contentContainer.Show();
} }
} }
} }
@ -171,14 +169,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
if (State.Value == Visibility.Hidden) if (State.Value == Visibility.Hidden)
return; return;
float height = 0; maxHeight = Child.DrawHeight;
foreach (var c in Children)
{
height += c.Height;
}
maxHeight = height;
this.ResizeHeightTo(maxHeight, duration, Easing.OutQuint); this.ResizeHeightTo(maxHeight, duration, Easing.OutQuint);
} }