Skip to content

Commit 2b87260

Browse files
fix tests
1 parent 9f8bd26 commit 2b87260

File tree

9 files changed

+18
-17
lines changed

9 files changed

+18
-17
lines changed

Flamui.Tests/LayoutingTests.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ public void Text_Multiline()
11061106
var expected =
11071107
"""
11081108
FlexContainer = X:0, Y:0, W:400, H:100
1109-
UiText = X:0, Y:0, W:336, H:32
1109+
UiText = X:0, Y:0, W:241, H:32
11101110
Line = Lorem ipsum dolor sit amet, consectetur adipiscing elit.
11111111
Line = Lorem ipsum dolor sit amet, consectetur adipiscing elit.
11121112
""";
@@ -1127,7 +1127,7 @@ public void Text_Wrap()
11271127
var expected =
11281128
"""
11291129
FlexContainer = X:0, Y:0, W:200, H:100
1130-
UiText = X:0, Y:0, W:168, H:32
1130+
UiText = X:0, Y:0, W:126, H:32
11311131
Line = Lorem ipsum dolor sit amet,
11321132
Line = consectetur adipiscing elit.
11331133
""";
@@ -1149,14 +1149,11 @@ public void Multiple_Text_Sizes()
11491149
var expected =
11501150
"""
11511151
FlexContainer = X:0, Y:0, W:400, H:400
1152-
UiText = X:0, Y:0, W:360, H:42
1153-
Line = Lorem ipsum dolor sit amet, consectetur
1154-
Line = adipiscing elit.
1155-
UiText = X:0, Y:42, W:324, H:164
1156-
Line = Lorem ipsum dolor
1157-
Line = sit amet,
1158-
Line = consectetur
1159-
Line = adipiscing elit.
1152+
UiText = X:0, Y:0, W:336, H:21
1153+
Line = Lorem ipsum dolor sit amet, consectetur adipiscing elit.
1154+
UiText = X:0, Y:21, W:367, H:82
1155+
Line = Lorem ipsum dolor sit amet,
1156+
Line = consectetur adipiscing elit.
11601157
""";
11611158

11621159
AssertUi(ui, 400, 400, expected);

Flamui.Tests/TextEditTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ private string ApplyInput(string initialText, Input input)
434434
var virtualBuffer = RenderContext.manager.CreateBuffer("TestArena", (UIntPtr)1_000);
435435
var arena = Ui.Arena = new Arena(virtualBuffer);
436436

437-
var font = FontLoader.LoadFont("JetBrainsMono-Regular.ttf");
437+
var font = FontLoader.LoadFont("segoeui.ttf");
438438
var layoutInfo = FontShaping.LayoutText(new ScaledFont(font, 20), initialText, float.MaxValue, TextAlign.Start, false, arena);
439439

440440
arena.Dispose();

Flamui/Drawing/FontShaping.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static (float totalWidth, Slice<float> charOffsets) MeasureText(ScaledFon
5050
//if we can't even fit a single word on a line, we have to start to split in the middle of the word!
5151
public static TextLayoutInfo LayoutText(ScaledFont scaledFont, ArenaString text, float maxWidth, TextAlign horizontalAlignement, bool multilineAllowed, Arena arena)
5252
{
53-
ArenaList<Line> lines = new ArenaList<Line>(Ui.Arena, 1); //todo, arena allocate
53+
ArenaList<Line> lines = new ArenaList<Line>(Ui.Arena, 1);
5454
float widthOfLongestLine = 0;
5555

5656
int currentBlockStart = 0;
-267 KB
Binary file not shown.

Flamui/Flamui.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
</ItemGroup>
4141

4242
<ItemGroup>
43-
<EmbeddedResource Include="Drawing\JetBrainsMono-Regular.ttf" />
4443
<EmbeddedResource Include="Drawing\Shaders\main_fragment.glsl" />
4544
<EmbeddedResource Include="Drawing\Shaders\main_vertex.glsl" />
4645
</ItemGroup>

Flamui/FlamuiApp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void CreateWindow<TRootComponent>(string title, FlamuiWindowOptions? opti
4949
{
5050
Size = new Vector2D<int>(options.Width, options.Height),
5151
Title = title,
52-
VSync = false, //for some reason this doesn't work on my laptop, so we just sleep ourselves
52+
VSync = true, //for some reason this doesn't work on my laptop, so we just sleep ourselves
5353
ShouldSwapAutomatically = false
5454
};
5555

Flamui/Ui.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private object GetComponentInternal(Type type, UiID id)
4646

4747
public T GetData<T>(UiID id, Func<Ui, UiID, T> factoryMethod) where T : notnull
4848
{
49-
return GetData(id, 0, (ui, uiId, _) => factoryMethod(ui, uiId));
49+
return GetData(id, factoryMethod, static (ui, uiId, f) => f(ui, uiId));
5050
}
5151

5252
public T GetData<T, TContext>(UiID id, TContext context, Func<Ui, UiID, TContext, T> factoryMethod) where T : notnull

Flamui/UiWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private void OnRender(double obj)
112112
if (end.TotalMilliseconds < 16) //todo we should probably also detect the refresh rate of monitor, to know how long to sleep for (or we can try to get vsync working)s
113113
{
114114
// Console.WriteLine($"Sleeping for {end.TotalMilliseconds}");
115-
Thread.Sleep(TimeSpan.FromMilliseconds(16 - end.TotalMilliseconds));
115+
// Thread.Sleep(TimeSpan.FromMilliseconds(16 - end.TotalMilliseconds));
116116
}
117117
}
118118

@@ -437,7 +437,7 @@ private void BuildUi()
437437

438438
_rootComponent.Build(Ui);
439439

440-
Console.WriteLine(Window.Size.X);
440+
// Console.WriteLine(Window.Size.X);
441441

442442
RootContainer.PrepareLayout(Dir.Vertical);
443443
RootContainer.Layout(new BoxConstraint(0, Window.Size.X / GetCompleteScaling().X, 0, Window.Size.Y / GetCompleteScaling().Y));

Sample.LayoutTest/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public override void Build(Ui ui)
4545
app.CreateWindow<LayoutTest>("Anoter Window");
4646
}
4747

48+
using (ui.Div().Color(C.White).ShrinkHeight())
49+
{
50+
ui.Text(loremIpsum).Color(C.Black).Multiline();
51+
}
52+
4853
// var dropdown = ui.CreateDropDown(selectedOption);
4954
// dropdown.Component.Option("Hi");
5055
// dropdown.Component.Option("Anita");

0 commit comments

Comments
 (0)