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 // 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; 5 using osu.Framework.Graphics.Containers; 6 using osu.Framework.Graphics.Cursor; ··· 19 20 private readonly ContextMenuBox movingBox; 21 22 private ContextMenuBox makeBox(Anchor anchor) => 23 new ContextMenuBox 24 { ··· 37 38 public TestCaseContextMenu() 39 { 40 - Add(new ContextMenuContainer 41 { 42 RelativeSizeAxes = Axes.Both, 43 Children = new[]
··· 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 System; 5 + using System.Collections.Generic; 6 using osu.Framework.Graphics; 7 using osu.Framework.Graphics.Containers; 8 using osu.Framework.Graphics.Cursor; ··· 21 22 private readonly ContextMenuBox movingBox; 23 24 + public override IReadOnlyList<Type> RequiredTypes => new[] 25 + { 26 + typeof(Menu), 27 + typeof(BasicMenu), 28 + typeof(ContextMenuContainer), 29 + typeof(BasicContextMenuContainer) 30 + }; 31 + 32 private ContextMenuBox makeBox(Anchor anchor) => 33 new ContextMenuBox 34 { ··· 47 48 public TestCaseContextMenu() 49 { 50 + Add(new BasicContextMenuContainer 51 { 52 RelativeSizeAxes = Axes.Both, 53 Children = new[]
+6 -2
osu.Framework.Tests/Visual/UserInterface/TestCaseNestedMenus.cs
··· 19 private const int max_depth = 5; 20 private const int max_count = 5; 21 22 - public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Menu) }; 23 24 private Random rng; 25 ··· 58 } 59 }; 60 61 - private class ClickOpenMenu : Menu 62 { 63 protected override Menu CreateSubMenu() => new ClickOpenMenu(HoverOpenDelay, false); 64
··· 19 private const int max_depth = 5; 20 private const int max_count = 5; 21 22 + public override IReadOnlyList<Type> RequiredTypes => new[] 23 + { 24 + typeof(Menu), 25 + typeof(BasicMenu) 26 + }; 27 28 private Random rng; 29 ··· 62 } 63 }; 64 65 + private class ClickOpenMenu : BasicMenu 66 { 67 protected override Menu CreateSubMenu() => new ClickOpenMenu(HoverOpenDelay, false); 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 + }