summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/source/MonoGame.Extended.Gui/Controls/ListBox.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins/MonoGame.Extended/source/MonoGame.Extended.Gui/Controls/ListBox.cs')
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Gui/Controls/ListBox.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Gui/Controls/ListBox.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Gui/Controls/ListBox.cs
new file mode 100644
index 0000000..d456e07
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Gui/Controls/ListBox.cs
@@ -0,0 +1,42 @@
+using Microsoft.Xna.Framework;
+
+namespace MonoGame.Extended.Gui.Controls
+{
+ public class ListBox : SelectorControl
+ {
+ public ListBox()
+ {
+ }
+
+ public override Size GetContentSize(IGuiContext context)
+ {
+ var width = 0;
+ var height = 0;
+
+ foreach (var item in Items)
+ {
+ var itemSize = GetItemSize(context, item);
+
+ if (itemSize.Width > width)
+ width = itemSize.Width;
+
+ height += itemSize.Height;
+ }
+
+ return new Size(width + ClipPadding.Width, height + ClipPadding.Height);
+ }
+
+ public override void Draw(IGuiContext context, IGuiRenderer renderer, float deltaSeconds)
+ {
+ base.Draw(context, renderer, deltaSeconds);
+
+ ScrollIntoView(context);
+ DrawItemList(context, renderer);
+ }
+
+ protected override Rectangle GetListAreaRectangle(IGuiContext context)
+ {
+ return ContentRectangle;
+ }
+ }
+} \ No newline at end of file