mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-26 18:19:24 +01:00
add a test to recreate the issue
This commit is contained in:
parent
78d73c2417
commit
92b94a0357
2 changed files with 34 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MLEM.Data.Content;
|
||||
using MLEM.Font;
|
||||
using MLEM.Startup;
|
||||
|
@ -20,6 +21,10 @@ public class TestGame : MlemGame {
|
|||
protected override void LoadContent() {
|
||||
base.LoadContent();
|
||||
this.RawContent = new RawContentManager(this.Services, this.Content.RootDirectory);
|
||||
|
||||
// make sure that the viewport is always the same size, since RunOneFrame doesn't ensure window size is correct
|
||||
this.UiSystem.Viewport = new Rectangle(0, 0, 1280, 720);
|
||||
|
||||
// we use precompiled fonts and kni uses a different asset compilation system, so we just have both stored
|
||||
this.UiSystem.Style.Font = new GenericSpriteFont(MlemGame.LoadContent<SpriteFont>(
|
||||
#if KNI
|
||||
|
|
|
@ -147,6 +147,34 @@ public class UiTests : GameTestFixture {
|
|||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestIssue27([Values(5, 50, 15)] int numChildren) {
|
||||
// Stack overflow related to panel scrolling and scrollbar auto-hiding
|
||||
|
||||
var group = new SquishingGroup(Anchor.TopLeft, Vector2.One);
|
||||
|
||||
var centerGroup = new ScissorGroup(Anchor.TopCenter, Vector2.One);
|
||||
var centerPanel = new Panel(Anchor.TopRight, Vector2.One);
|
||||
centerPanel.DrawColor = Color.Red;
|
||||
centerPanel.Padding = new MLEM.Maths.Padding(5);
|
||||
centerGroup.AddChild(centerPanel);
|
||||
group.AddChild(centerGroup);
|
||||
|
||||
var leftColumn = new Panel(Anchor.TopLeft, new Vector2(500, 1), scrollOverflow: true);
|
||||
group.AddChild(leftColumn);
|
||||
for (var i = 0; i < numChildren; i++) {
|
||||
var c = new Panel(Anchor.AutoLeft, new Vector2(1, 30));
|
||||
c.DrawColor = Color.Green;
|
||||
c.Padding = new MLEM.Maths.Padding(5);
|
||||
leftColumn.AddChild(c);
|
||||
}
|
||||
|
||||
var bottomPane = new Panel(Anchor.BottomCenter, new Vector2(1, 500));
|
||||
group.AddChild(bottomPane);
|
||||
|
||||
this.AddAndUpdate(group, out _, out _);
|
||||
}
|
||||
|
||||
private void AddAndUpdate(Element element, out TimeSpan addTime, out TimeSpan updateTime) {
|
||||
foreach (var root in this.Game.UiSystem.GetRootElements())
|
||||
this.Game.UiSystem.Remove(root.Name);
|
||||
|
|
Loading…
Reference in a new issue