A game framework written with osu! in mind.
at master 72 lines 2.6 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 osu.Framework.Graphics.Containers; 5using osu.Framework.Graphics.Sprites; 6using osu.Framework.Localisation; 7 8namespace osu.Framework.Graphics.UserInterface 9{ 10 public class BasicDropdown<T> : Dropdown<T> 11 { 12 protected override DropdownMenu CreateMenu() => new BasicDropdownMenu(); 13 14 protected override DropdownHeader CreateHeader() => new BasicDropdownHeader(); 15 16 public class BasicDropdownHeader : DropdownHeader 17 { 18 private readonly SpriteText label; 19 20 protected internal override LocalisableString Label 21 { 22 get => label.Text; 23 set => label.Text = value; 24 } 25 26 public BasicDropdownHeader() 27 { 28 var font = FrameworkFont.Condensed; 29 30 Foreground.Padding = new MarginPadding(5); 31 BackgroundColour = FrameworkColour.Green; 32 BackgroundColourHover = FrameworkColour.YellowGreen; 33 34 Children = new[] 35 { 36 label = new SpriteText 37 { 38 AlwaysPresent = true, 39 Font = font, 40 Height = font.Size, 41 }, 42 }; 43 } 44 } 45 46 public class BasicDropdownMenu : DropdownMenu 47 { 48 protected override Menu CreateSubMenu() => new BasicMenu(Direction.Vertical); 49 50 protected override DrawableDropdownMenuItem CreateDrawableDropdownMenuItem(MenuItem item) => new DrawableBasicDropdownMenuItem(item); 51 52 protected override ScrollContainer<Drawable> CreateScrollContainer(Direction direction) => new BasicScrollContainer(direction); 53 54 private class DrawableBasicDropdownMenuItem : DrawableDropdownMenuItem 55 { 56 public DrawableBasicDropdownMenuItem(MenuItem item) 57 : base(item) 58 { 59 Foreground.Padding = new MarginPadding(2); 60 BackgroundColour = FrameworkColour.BlueGreen; 61 BackgroundColourHover = FrameworkColour.Green; 62 BackgroundColourSelected = FrameworkColour.GreenDark; 63 } 64 65 protected override Drawable CreateContent() => new SpriteText 66 { 67 Font = FrameworkFont.Condensed 68 }; 69 } 70 } 71 } 72}