-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2293 from peppy/farmework-sprite-icon
Add SpriteIcon class and include FontAwesome font Co-authored-by: Dan Balasescu <1329837+smoogipoo@users.noreply.github.com>
- Loading branch information
Showing
21 changed files
with
1,125 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Reflection; | ||
using NUnit.Framework; | ||
using osu.Framework.Extensions.IEnumerableExtensions; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Cursor; | ||
using osu.Framework.Graphics.Shapes; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Framework.Testing; | ||
using osuTK; | ||
using osuTK.Graphics; | ||
|
||
namespace osu.Framework.Tests.Visual.Sprites | ||
{ | ||
[TestFixture] | ||
public class TestCaseSpriteIcon : TestCase | ||
{ | ||
public TestCaseSpriteIcon() | ||
{ | ||
FillFlowContainer<Icon> flow; | ||
|
||
Add(new TooltipContainer | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
Children = new Drawable[] | ||
{ | ||
new Box | ||
{ | ||
Colour = Color4.Teal, | ||
RelativeSizeAxes = Axes.Both, | ||
}, | ||
new ScrollContainer | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
Child = flow = new FillFlowContainer<Icon> | ||
{ | ||
Anchor = Anchor.TopRight, | ||
Origin = Anchor.TopRight, | ||
RelativeSizeAxes = Axes.X, | ||
AutoSizeAxes = Axes.Y, | ||
Direction = FillDirection.Full, | ||
}, | ||
} | ||
} | ||
}); | ||
|
||
foreach (var p in typeof(FontAwesome).GetProperties(BindingFlags.Public | BindingFlags.Static)) | ||
flow.Add(new Icon($"{nameof(FontAwesome)}.{p.Name}", (IconUsage)p.GetValue(null))); | ||
|
||
AddStep("toggle shadows", () => flow.Children.ForEach(i => i.SpriteIcon.Shadow = !i.SpriteIcon.Shadow)); | ||
AddStep("change icons", () => flow.Children.ForEach(i => i.SpriteIcon.Icon = new IconUsage((char)(i.SpriteIcon.Icon.Icon + 1)))); | ||
} | ||
|
||
private class Icon : Container, IHasTooltip | ||
{ | ||
public string TooltipText { get; } | ||
|
||
public SpriteIcon SpriteIcon { get; } | ||
|
||
public Icon(string name, IconUsage icon) | ||
{ | ||
TooltipText = name; | ||
|
||
AutoSizeAxes = Axes.Both; | ||
Child = SpriteIcon = new SpriteIcon | ||
{ | ||
Icon = icon, | ||
Size = new Vector2(60), | ||
}; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.