A game framework written with osu! in mind.

add basic variant of menu and context menu

jorolf 04d5061a ab794709

+70 -3
+11 -1
osu.Framework.Tests/Visual/UserInterface/TestCaseContextMenu.cs
··· 1 1 // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2 2 // See the LICENCE file in the repository root for full licence text. 3 3 4 + using System; 5 + using System.Collections.Generic; 4 6 using osu.Framework.Graphics; 5 7 using osu.Framework.Graphics.Containers; 6 8 using osu.Framework.Graphics.Cursor; ··· 19 21 20 22 private readonly ContextMenuBox movingBox; 21 23 24 + public override IReadOnlyList<Type> RequiredTypes => new[] 25 + { 26 + typeof(Menu), 27 + typeof(BasicMenu), 28 + typeof(ContextMenuContainer), 29 + typeof(BasicContextMenuContainer) 30 + }; 31 + 22 32 private ContextMenuBox makeBox(Anchor anchor) => 23 33 new ContextMenuBox 24 34 { ··· 37 47 38 48 public TestCaseContextMenu() 39 49 { 40 - Add(new ContextMenuContainer 50 + Add(new BasicContextMenuContainer 41 51 { 42 52 RelativeSizeAxes = Axes.Both, 43 53 Children = new[]
+6 -2
osu.Framework.Tests/Visual/UserInterface/TestCaseNestedMenus.cs
··· 19 19 private const int max_depth = 5; 20 20 private const int max_count = 5; 21 21 22 - public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Menu) }; 22 + public override IReadOnlyList<Type> RequiredTypes => new[] 23 + { 24 + typeof(Menu), 25 + typeof(BasicMenu) 26 + }; 23 27 24 28 private Random rng; 25 29 ··· 58 62 } 59 63 }; 60 64 61 - private class ClickOpenMenu : Menu 65 + private class ClickOpenMenu : BasicMenu 62 66 { 63 67 protected override Menu CreateSubMenu() => new ClickOpenMenu(HoverOpenDelay, false); 64 68
+12
osu.Framework/Graphics/Cursor/BasicContextMenuContainer.cs
··· 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 + 4 + using osu.Framework.Graphics.UserInterface; 5 + 6 + namespace osu.Framework.Graphics.Cursor 7 + { 8 + public class BasicContextMenuContainer : ContextMenuContainer 9 + { 10 + protected override Menu CreateMenu() => new BasicMenu(Direction.Vertical); 11 + } 12 + }
+41
osu.Framework/Graphics/UserInterface/BasicMenu.cs
··· 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 + 4 + using osu.Framework.Graphics.Sprites; 5 + 6 + namespace osu.Framework.Graphics.UserInterface 7 + { 8 + public class BasicMenu : Menu 9 + { 10 + public BasicMenu(Direction direction, bool topLevelMenu = false) 11 + : base(direction, topLevelMenu) 12 + { 13 + BackgroundColour = FrameworkColour.Blue; 14 + } 15 + 16 + protected override Menu CreateSubMenu() => new BasicMenu(Direction.Vertical) 17 + { 18 + Anchor = Direction == Direction.Horizontal ? Anchor.BottomLeft : Anchor.TopRight 19 + }; 20 + 21 + protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new BasicDrawableMenuItem(item); 22 + 23 + public class BasicDrawableMenuItem : DrawableMenuItem 24 + { 25 + public BasicDrawableMenuItem(MenuItem item) 26 + : base(item) 27 + { 28 + BackgroundColour = FrameworkColour.BlueGreen; 29 + BackgroundColourHover = FrameworkColour.Green; 30 + } 31 + 32 + protected override Drawable CreateContent() => new SpriteText 33 + { 34 + Anchor = Anchor.CentreLeft, 35 + Origin = Anchor.CentreLeft, 36 + Padding = new MarginPadding(2), 37 + Font = new FontUsage("RobotoCondensed", weight: "Regular"), 38 + }; 39 + } 40 + } 41 + }