fix(ui): retail tooltip rendering — formula-first compose and the two-pass sizing every tooltip was missing
All checks were successful
CI / linux-portable (push) Successful in 3m39s
CI / windows-gate (push) Successful in 6m41s
CI / release (push) Successful in 2m10s

Two corrections from the owner's retail-render oracle at the CA5 re-check,
both against readings the TS-85 register row had recorded as settled:

Compose (skill tooltips): retail is formula + newline + description —
GetTooltip @0x004f1fe0's operator+ has the InqSkillFormula output as the
LEFT operand; the old '"\n" + formula, no separator' reading had the
operand order backwards and produced a leading blank line with the formula
and description glued on one line. A formula-less skill (Salvaging) shows
the bare description, matching the failed-InqSkillFormula branch.

Sizing (ALL tooltips, per the owner's direction): retail sizes a tooltip
in TWO passes (StartTooltip @0x0045DE90) — measure-wrap at the max width,
resize the root through the authored ResizeTo clamps, then
RecalculateGlyphList RE-WRAPS the text at its final clamped width and a
second resize grows the root's HEIGHT for the extra lines. The branch the
register called 'a structural no-op' IS that second pass; without it a
description longer than the clamped popup stayed one clipped line, where
retail shows three. ApplyTooltipText now ports the full chain, so every
tooltip surface (items, options rows, character panel, world hover, map)
wraps and grows exactly as retail.

Pinned by BuildTooltip_FormulaFirstThenNewlineThenDescription,
BuildTooltip_FormulaLessSkillShowsBareDescription, and
LongTooltip_RewrapsAtTheClampedPopupWidth_AndGrowsHeightForTheExtraLines.
TS-85 carries both dated corrections. Owner visual re-check owed: skill
tooltip shows formula on line one, description below, long descriptions
wrapping to three-plus lines inside the parchment. Full hermetic suite
15,332 passed / 0 failed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-24 18:09:54 +02:00
parent 51a7c99b94
commit 1e8596a440
5 changed files with 174 additions and 18 deletions

View file

@ -464,6 +464,69 @@ public sealed class RetailTooltipPresenterTests
return target;
}
[Fact]
public void LongTooltip_RewrapsAtTheClampedPopupWidth_AndGrowsHeightForTheExtraLines()
{
// CA5-gate correction: retail sizes tooltips in TWO passes
// (StartTooltip @0x0045DE90) — measure-wrap at the max width, resize
// the root through the authored clamps, then RE-WRAP at the final
// clamped width and grow the root's HEIGHT for the extra lines.
// Pre-correction, a description longer than the clamped popup stayed
// one clipped line (the owner's retail client shows three).
var (root, _, _) = CreateHarness();
string longText = string.Join(
" ", Enumerable.Repeat("description", 40)); // far wider than 200px
var target = new HoverTarget
{
Left = 100, Top = 100, Width = 40, Height = 20,
AuthoredTooltipEnabled = true,
AuthoredTooltipText = longText,
AuthoredTooltipRootElementId = PopupRootId,
AuthoredTooltipLayoutDid = PopupLayoutDid,
};
root.AddChild(target);
int childrenBefore = root.Children.Count;
// Clamp the popup to 200px wide via a max-width-authored skin.
HoverAndDwellWithClampedPopup(root, maxWidth: 200);
UiElement popup = root.Children[^1];
Assert.True(root.Children.Count > childrenBefore, "popup did not mount");
Assert.True(popup.Width <= 200f, $"popup width {popup.Width} escaped the clamp");
var text = FindText(popup);
Assert.NotNull(text);
var lines = text!.LinesProvider();
Assert.True(lines.Count >= 3,
$"expected the clamped width to force >=3 lines, got {lines.Count}");
// Every re-wrapped line must fit the clamped popup.
Assert.All(lines, l => Assert.True(l.Text.Length * 8f <= 200f + 8f));
// The root grew to hold the extra lines.
float lineHeight = 14f;
Assert.True(popup.Height >= lines.Count * lineHeight,
$"popup height {popup.Height} does not fit {lines.Count} lines");
}
private static void HoverAndDwellWithClampedPopup(UiRoot root, int maxWidth)
{
// A presenter whose popup skin authors ResizeMaxWidth, mirroring the
// parchment skins' bounded frames.
var presenter = new RetailTooltipPresenter(root, (_, _) =>
{
ImportedLayout layout = BuildPopup();
layout.Root.AuthoredResizeMaxWidth = maxWidth;
return layout;
});
HoverAndDwell(root);
}
private static UiText? FindText(UiElement element)
{
if (element is UiText text) return text;
foreach (UiElement child in element.Children)
if (FindText(child) is { } found) return found;
return null;
}
private static void HoverAndDwell(UiRoot root)
{
root.OnMouseMove(110, 110);