diff options
author | Thomas Leyh <leyh.thomas@web.de> | 2016-07-24 08:14:18 +0200 |
---|---|---|
committer | Thomas Leyh <leyh.thomas@web.de> | 2016-07-24 08:14:18 +0200 |
commit | ced3d03bdb3ce866d832e03fb212865140905a9a (patch) | |
tree | 2a16c2063a46d3c354ce1585029dda3124f6ad93 /V3/Widgets/VerticalMenu.cs | |
parent | 0394dccaf06e1009e591a6ff4d645895574724c1 (diff) | |
download | V3-release.tar.gz V3-release.tar.bz2 |
Diffstat (limited to 'V3/Widgets/VerticalMenu.cs')
-rw-r--r-- | V3/Widgets/VerticalMenu.cs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/V3/Widgets/VerticalMenu.cs b/V3/Widgets/VerticalMenu.cs new file mode 100644 index 0000000..bc18439 --- /dev/null +++ b/V3/Widgets/VerticalMenu.cs @@ -0,0 +1,42 @@ +using Microsoft.Xna.Framework; +using System.Linq; + +namespace V3.Widgets +{ + /// <summary> + /// A simple menu with vertically arranged widgets. All widgets are made + /// the same size (the maximum widget size). + /// </summary> + // ReSharper disable once ClassNeverInstantiated.Global + public sealed class VerticalMenu : AbstractMenu + { + private float mPadding = 10; + + public VerticalMenu(GraphicsDeviceManager graphicsDeviceManager) : base(graphicsDeviceManager) + { + } + + protected override void UpdateWidgetRelativePositions() + { + var y = 0f; + foreach (var widget in Widgets) + { + widget.Position = new Vector2(0, y); + y += widget.Size.Y; + y += mPadding; + } + } + + protected override Vector2 GetTotalSize() + { + var totalX = Widgets.Max(w => w.Size.X); + var totalY = (Widgets.Count - 1) * mPadding + Widgets.Sum(w => w.Size.Y); + return new Vector2(totalX, totalY); + } + + protected override void UpdateWidgetSizes() + { + MakeWidgetsSameSize(Widgets); + } + } +} |