A game framework written with osu! in mind.
at master 83 lines 2.9 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4using System; 5using osu.Framework.Allocation; 6using osu.Framework.Graphics; 7using osu.Framework.Graphics.Containers; 8using osu.Framework.Graphics.Shapes; 9using osu.Framework.Graphics.Sprites; 10using osu.Framework.Testing; 11using osuTK; 12using osuTK.Graphics; 13 14namespace osu.Framework.Tests.Visual.Sprites 15{ 16 public class TestSceneVideoLayout : GridTestScene 17 { 18 public TestSceneVideoLayout() 19 : base(1, 4) 20 { 21 } 22 23 [BackgroundDependencyLoader] 24 private void load() 25 { 26 Cell(0, 0).Child = createTest("video - auto size", () => new TestVideo()); 27 Cell(0, 1).Child = createTest("video - relative size + fit", () => new TestVideo 28 { 29 RelativeSizeAxes = Axes.Both, 30 FillMode = FillMode.Fit 31 }); 32 Cell(0, 2).Child = createTest("video - relative size + fill", () => new TestVideo 33 { 34 RelativeSizeAxes = Axes.Both, 35 FillMode = FillMode.Fill 36 }); 37 Cell(0, 3).Child = createTest("video - fixed size", () => new TestVideo { Size = new Vector2(100, 50) }); 38 } 39 40 private Drawable createTest(string name, Func<Drawable> animationCreationFunc) => new Container 41 { 42 RelativeSizeAxes = Axes.Both, 43 Padding = new MarginPadding(10), 44 Child = new GridContainer 45 { 46 RelativeSizeAxes = Axes.Both, 47 Content = new[] 48 { 49 new Drawable[] 50 { 51 new SpriteText 52 { 53 Anchor = Anchor.TopCentre, 54 Origin = Anchor.TopCentre, 55 Text = name 56 }, 57 }, 58 new Drawable[] 59 { 60 new Container 61 { 62 RelativeSizeAxes = Axes.Both, 63 Masking = true, 64 BorderColour = Color4.OrangeRed, 65 BorderThickness = 2, 66 Children = new[] 67 { 68 new Box 69 { 70 RelativeSizeAxes = Axes.Both, 71 Alpha = 0, 72 AlwaysPresent = true 73 }, 74 animationCreationFunc() 75 } 76 } 77 }, 78 }, 79 RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) } 80 } 81 }; 82 } 83}