mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
Use GridContainer for layout
This commit is contained in:
@ -29,37 +29,22 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
User = { BindTarget = user },
|
User = { BindTarget = user },
|
||||||
};
|
};
|
||||||
|
|
||||||
AddStep("single username", () => user.Value = new User
|
User[] users = new[]
|
||||||
{
|
{
|
||||||
PreviousUsernames = new[] { "username1" },
|
new User { PreviousUsernames = new[] { "username1" } },
|
||||||
});
|
new User { PreviousUsernames = new[] { "longusername", "longerusername" } },
|
||||||
|
new User { PreviousUsernames = new[] { "test", "angelsim", "verylongusername" } },
|
||||||
|
new User { PreviousUsernames = new[] { "ihavenoidea", "howcani", "makethistext", "anylonger" } },
|
||||||
|
new User { PreviousUsernames = new string[0] },
|
||||||
|
null
|
||||||
|
};
|
||||||
|
|
||||||
AddStep("two usernames", () => user.Value = new User
|
AddStep("single username", () => user.Value = users[0]);
|
||||||
{
|
AddStep("two usernames", () => user.Value = users[1]);
|
||||||
PreviousUsernames = new[] { "longusername", "longerusername" },
|
AddStep("three usernames", () => user.Value = users[2]);
|
||||||
});
|
AddStep("four usernames", () => user.Value = users[3]);
|
||||||
|
AddStep("no username", () => user.Value = users[4]);
|
||||||
AddStep("three usernames", () => user.Value = new User
|
AddStep("null user", () => user.Value = users[5]);
|
||||||
{
|
|
||||||
PreviousUsernames = new[] { "test", "angelsim", "verylongusername" },
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep("four usernames", () => user.Value = new User
|
|
||||||
{
|
|
||||||
PreviousUsernames = new[] { "ihavenoidea", "howcani", "makethistext", "anylonger" },
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep("many usernames", () => user.Value = new User
|
|
||||||
{
|
|
||||||
PreviousUsernames = new[] { "ihavenoidea", "howcani", "makethistext", "anylonger", "but", "ican", "try", "tomake", "this" },
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep("no username", () => user.Value = new User
|
|
||||||
{
|
|
||||||
PreviousUsernames = new string[0],
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep("null user", () => user.Value = null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -25,7 +25,9 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
|
|
||||||
public readonly Bindable<User> User = new Bindable<User>();
|
public readonly Bindable<User> User = new Bindable<User>();
|
||||||
|
|
||||||
private readonly ContentContainer contentContainer;
|
private readonly TextFlowContainer text;
|
||||||
|
private readonly Box background;
|
||||||
|
private readonly SpriteText header;
|
||||||
|
|
||||||
public PreviousUsernamesContainer()
|
public PreviousUsernamesContainer()
|
||||||
{
|
{
|
||||||
@ -33,18 +35,68 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
|
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
Width = width;
|
Width = width;
|
||||||
|
Masking = true;
|
||||||
|
CornerRadius = 5;
|
||||||
|
|
||||||
AddRangeInternal(new Drawable[]
|
AddRangeInternal(new Drawable[]
|
||||||
{
|
{
|
||||||
contentContainer = new ContentContainer(),
|
background = new Box
|
||||||
hoverIcon = new HoverIconContainer(),
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
new GridContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
RowDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(GridSizeMode.AutoSize)
|
||||||
|
},
|
||||||
|
ColumnDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(GridSizeMode.Distributed)
|
||||||
|
},
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
hoverIcon = new HoverIconContainer(),
|
||||||
|
header = new SpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Text = @"formerly known as",
|
||||||
|
Font = OsuFont.GetFont(size: 10, italics: true)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
text = new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold, italics: true))
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Full,
|
||||||
|
Margin = new MarginPadding { Bottom = margin, Top = margin / 2 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
hoverIcon.ActivateHover += () =>
|
hoverIcon.ActivateHover += showContent;
|
||||||
{
|
hideContent();
|
||||||
contentContainer.Show();
|
}
|
||||||
this.MoveToY(-move_offset, duration, Easing.OutQuint);
|
|
||||||
};
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
background.Colour = colours.GreySeafoamDarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -55,13 +107,13 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
|
|
||||||
private void onUserChanged(ValueChangedEvent<User> user)
|
private void onUserChanged(ValueChangedEvent<User> user)
|
||||||
{
|
{
|
||||||
contentContainer.Text = string.Empty;
|
text.Text = string.Empty;
|
||||||
|
|
||||||
var usernames = user.NewValue?.PreviousUsernames;
|
var usernames = user.NewValue?.PreviousUsernames;
|
||||||
|
|
||||||
if (usernames?.Any() ?? false)
|
if (usernames?.Any() ?? false)
|
||||||
{
|
{
|
||||||
contentContainer.Text = string.Join(", ", usernames);
|
text.Text = string.Join(", ", usernames);
|
||||||
Show();
|
Show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -72,82 +124,23 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
contentContainer.Hide();
|
hideContent();
|
||||||
this.MoveToY(0, duration, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ContentContainer : VisibilityContainer
|
private void showContent()
|
||||||
{
|
{
|
||||||
private const int header_height = 20;
|
text.FadeIn(duration, Easing.OutQuint);
|
||||||
private const int content_padding = 40;
|
header.FadeIn(duration, Easing.OutQuint);
|
||||||
|
background.FadeIn(duration, Easing.OutQuint);
|
||||||
|
this.MoveToY(-move_offset, duration, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
public string Text
|
private void hideContent()
|
||||||
{
|
{
|
||||||
set => usernames.Text = value;
|
text.FadeOut(duration, Easing.OutQuint);
|
||||||
}
|
header.FadeOut(duration, Easing.OutQuint);
|
||||||
|
background.FadeOut(duration, Easing.OutQuint);
|
||||||
private readonly TextFlowContainer usernames;
|
this.MoveToY(0, duration, Easing.OutQuint);
|
||||||
private readonly Box background;
|
|
||||||
|
|
||||||
public ContentContainer()
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Y;
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
Masking = true;
|
|
||||||
AlwaysPresent = true;
|
|
||||||
CornerRadius = 5;
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
background = new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
Spacing = new Vector2(0, 5),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = header_height,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Origin = Anchor.BottomLeft,
|
|
||||||
Padding = new MarginPadding { Left = content_padding },
|
|
||||||
Text = @"formerly known as",
|
|
||||||
Font = OsuFont.GetFont(size: 10, italics: true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
usernames = new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold, italics: true))
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Direction = FillDirection.Full,
|
|
||||||
Spacing = new Vector2(0, 5),
|
|
||||||
Padding = new MarginPadding { Left = content_padding, Bottom = margin },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuColour colours)
|
|
||||||
{
|
|
||||||
background.Colour = colours.GreySeafoamDarker;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void PopIn() => this.FadeIn(duration, Easing.OutQuint);
|
|
||||||
|
|
||||||
protected override void PopOut() => this.FadeOut(duration, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class HoverIconContainer : Container
|
private class HoverIconContainer : Container
|
||||||
@ -159,7 +152,7 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
Child = new SpriteIcon
|
Child = new SpriteIcon
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding(margin) { Top = 6 },
|
Margin = new MarginPadding { Top = 6, Left = margin, Right = margin * 2 },
|
||||||
Size = new Vector2(15),
|
Size = new Vector2(15),
|
||||||
Icon = FontAwesome.Solid.IdCard,
|
Icon = FontAwesome.Solid.IdCard,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user