diff --git a/MonoGameGum/Forms/Controls/MenuItem.cs b/MonoGameGum/Forms/Controls/MenuItem.cs index d8f3330a..21eaa2bf 100644 --- a/MonoGameGum/Forms/Controls/MenuItem.cs +++ b/MonoGameGum/Forms/Controls/MenuItem.cs @@ -99,6 +99,8 @@ internal MenuItem ParentMenuItem get;set; } + public VisualTemplate? ScrollViewerVisualTemplate { get; set; } = null; + #endregion #region Events @@ -243,8 +245,17 @@ internal void TryShowPopup() if (this.Items?.Count > 0 && itemsPopup == null) { timeOpened = MainCursor.LastPrimaryPushTime; - itemsPopup = new ScrollViewer(); + var visualTemplateVisual = ScrollViewerVisualTemplate?.CreateContent(null) as InteractiveGue; + + if(visualTemplateVisual == null) + { + itemsPopup = new ScrollViewer(); + } + else + { + itemsPopup = new ScrollViewer(visualTemplateVisual); + } //itemsPopup.InnerPanel.Height = 0; //itemsPopup.InnerPanel.HeightUnits = Gum.DataTypes.DimensionUnitType.RelativeToChildren; //itemsPopup.InnerPanel.ChildrenLayout = Gum.Managers.ChildrenLayout.TopToBottomStack; diff --git a/Samples/GumFormsSample/GumFormsSampleCommon/GumFormsSampleGame.cs b/Samples/GumFormsSample/GumFormsSampleCommon/GumFormsSampleGame.cs index 42ef0684..6d1cd594 100644 --- a/Samples/GumFormsSample/GumFormsSampleCommon/GumFormsSampleGame.cs +++ b/Samples/GumFormsSample/GumFormsSampleCommon/GumFormsSampleGame.cs @@ -52,7 +52,7 @@ protected override void Initialize() var gumProject = GumService.Default.Initialize(_graphics.GraphicsDevice, "FormsGumProject/GumProject.gumx"); FormsUtilities.Cursor.TransformMatrix = Matrix.CreateScale(1/scale); - const int screenNumber = 0; + const int screenNumber = 1; switch (screenNumber) { diff --git a/Samples/GumFormsSample/GumFormsSampleCommon/Screens/FrameworkElementExampleScreen.cs b/Samples/GumFormsSample/GumFormsSampleCommon/Screens/FrameworkElementExampleScreen.cs index 6be6f5ca..0361e27b 100644 --- a/Samples/GumFormsSample/GumFormsSampleCommon/Screens/FrameworkElementExampleScreen.cs +++ b/Samples/GumFormsSample/GumFormsSampleCommon/Screens/FrameworkElementExampleScreen.cs @@ -1,5 +1,6 @@ using Gum.Wireframe; using Microsoft.Xna.Framework; +using MonoGameGum.Forms; using MonoGameGum.Forms.Controls; using MonoGameGum.Forms.DefaultVisuals; using MonoGameGum.GueDeriving; @@ -30,11 +31,11 @@ public void Initialize(List roots) CreateMenu(root); - //CreateColumn1Ui(root); + CreateColumn1Ui(root); - //CreateColumn2Ui(root); + CreateColumn2Ui(root); - //CreateLayeredUi(roots); + CreateLayeredUi(roots); } @@ -74,6 +75,33 @@ private void CreateMenu(GraphicalUiElement root) editItem.Items.Add($"Edit Item {i}"); } menu.Items.Add(editItem); + + + + var customMenuItem = new MenuItem(); + + + customMenuItem.Header = "Custom Dropdown"; + var customScrollViewerVisualTemplate = new VisualTemplate(() => + { + var toReturn = new DefaultScrollViewerRuntime(); + var background = toReturn.GetGraphicalUiElementByName("Background") + as ColoredRectangleRuntime; + + background.Color = Color.Orange; + + return toReturn; + }); + customMenuItem.ScrollViewerVisualTemplate = customScrollViewerVisualTemplate; + + + for (int i = 0; i < 10; i++) + { + customMenuItem.Items.Add($"Custom dropdown item {i}"); + } + menu.Items.Add(customMenuItem); + + menu.Items.Add("Help"); root.Children.Add(menu.Visual); @@ -159,6 +187,7 @@ private void CreateColumn1Ui(GraphicalUiElement root) listBox.Y = currentY; listBox.Width = 200; listBox.Height = 200; + for (int i = 0; i < 20; i++) { listBox.Items.Add($"Item {i}");