fix(ui): preserve cropped chat and button faces
This commit is contained in:
parent
d825572e31
commit
accacecafe
7 changed files with 168 additions and 8 deletions
|
|
@ -1,5 +1,8 @@
|
|||
using AcDream.App.UI;
|
||||
using AcDream.App.UI.Layout;
|
||||
using AcDream.Core.Chat;
|
||||
using AcDream.UI.Abstractions;
|
||||
using AcDream.UI.Abstractions.Panels.Chat;
|
||||
|
||||
namespace AcDream.App.Tests.UI.Layout;
|
||||
|
||||
|
|
@ -10,6 +13,8 @@ namespace AcDream.App.Tests.UI.Layout;
|
|||
/// </summary>
|
||||
public class ChatLayoutConformanceTests
|
||||
{
|
||||
private static (uint, int, int) NoTex(uint _) => (0, 0, 0);
|
||||
|
||||
private static ElementInfo? Find(ElementInfo n, uint id)
|
||||
{
|
||||
if (n.Id == id) return n;
|
||||
|
|
@ -58,4 +63,58 @@ public class ChatLayoutConformanceTests
|
|||
Assert.True(input.OneLine);
|
||||
Assert.Equal(0x10000016u, input.DatElementId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ChatFixture_CroppedDockedRoot_ReflowsContentAcrossMountedWidth()
|
||||
{
|
||||
var infos = FixtureLoader.LoadChatInfos();
|
||||
var layout = LayoutImporter.Build(infos, NoTex, null);
|
||||
var controller = ChatWindowController.Bind(
|
||||
infos,
|
||||
layout,
|
||||
new ChatVM(new ChatLog()),
|
||||
() => NullCommandBus.Instance,
|
||||
null,
|
||||
null,
|
||||
NoTex);
|
||||
Assert.NotNull(controller);
|
||||
|
||||
var root = controller!.Root;
|
||||
root.Width = 490;
|
||||
root.Height = 100;
|
||||
root.RebaseChildLayoutBaselines();
|
||||
root.Width = 615;
|
||||
|
||||
var transcriptPanel = layout.FindElement(0x10000010u)!;
|
||||
var inputBar = layout.FindElement(0x10000013u)!;
|
||||
transcriptPanel.ApplyAnchor(root.Width, root.Height);
|
||||
inputBar.ApplyAnchor(root.Width, root.Height);
|
||||
|
||||
Assert.Equal(615f, transcriptPanel.Width);
|
||||
Assert.Equal(615f, inputBar.Width);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ChatFixture_ChannelCaptionWidth_SurvivesImportedLayoutPass()
|
||||
{
|
||||
var infos = FixtureLoader.LoadChatInfos();
|
||||
var layout = LayoutImporter.Build(infos, NoTex, null);
|
||||
var controller = ChatWindowController.Bind(
|
||||
infos,
|
||||
layout,
|
||||
new ChatVM(new ChatLog()),
|
||||
() => NullCommandBus.Instance,
|
||||
null,
|
||||
null,
|
||||
NoTex);
|
||||
Assert.NotNull(controller);
|
||||
|
||||
controller!.Menu.OnSelect!.Invoke(ChatChannelKind.General);
|
||||
float fittedWidth = controller.Menu.Width;
|
||||
controller.Menu.ApplyAnchor(controller.Menu.Parent!.Width, controller.Menu.Parent.Height);
|
||||
|
||||
Assert.True(fittedWidth > 46f);
|
||||
Assert.Equal(fittedWidth, controller.Menu.Width);
|
||||
Assert.Equal(controller.Menu.Left + fittedWidth, controller.Input.Left);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue