Skip to content

Commit

Permalink
Merge branch 'master' into fix-Displays-allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy authored Oct 4, 2022
2 parents 39cb8dc + 2b6e201 commit 4abcead
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions osu.Framework.Tests/Visual/Sprites/TestSceneSpriteTextSizing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using NUnit.Framework;
using osu.Framework.Graphics.Sprites;

namespace osu.Framework.Tests.Visual.Sprites
{
public class TestSceneSpriteTextSizing : FrameworkTestScene
{
[Test]
public void TestNewSizeImmediatelyAvailableAfterTextChange()
{
SpriteText text = null!;
float initialSize = 0;

AddStep("add initial text and get size", () =>
{
Child = text = new SpriteText { Text = "First" };
initialSize = text.DrawWidth;
});

float updatedSize = 0;
AddStep("set new text and grab size", () =>
{
text.Text = "Second";
updatedSize = text.DrawWidth;
});

AddAssert("updated size is not equal to the initial size", () => updatedSize, () => Is.Not.EqualTo(initialSize));
}
}
}
2 changes: 1 addition & 1 deletion osu.Framework/Graphics/Sprites/SpriteText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ private void invalidate(bool characters = false, bool textBuilder = false)
parentScreenSpaceCache.Invalidate();
localScreenSpaceCache.Invalidate();

Invalidate(Invalidation.DrawNode);
Invalidate(Invalidation.RequiredParentSizeToFit);
}

#endregion
Expand Down

0 comments on commit 4abcead

Please sign in to comment.