feat(CT-GF1): port retail ancestor-clip to the retained UI tree
Fixes the CT7 gate finding: on the Titles tab, the authored divider 0x10000530 escapes the Character window above its top edge at the CT6-correct 372px mounted default (computed Y ~ -178, matching the owner's screenshot). Retail clips child rendering to the intersected ancestor clip-rect chain -- UIRegion::DrawHere @0x0069FA30 takes the element's screen Box2D plus a SmartArray<Box2D> of inherited clip rects, intersects them (the min/max clamp loop @0x0069FAA7..0x0069FB82), and draws EraseSelf/DrawChildren/DrawSelf with the intersected rect only when non-empty (the var_24 gate @0x0069FB8E). Our UiElement draw walk rendered children unclipped by default, so any authored element relying on clipping -- this divider, and the chat input row at small window sizes (the owner's earlier "text input sticks out on resize" report) -- became a visible artifact. Mechanism (element-level, reusing the existing clip-rect-stack infrastructure in UiRenderContext.PushClip/PopClip): - UiElement.ClipsChildren now defaults to TRUE for every element (was an opt-in used only by UiScrollablePanel/UiItemList). Each element's children draw AND hit-test clipped to the intersection of its own rect with the inherited ancestor clip; an element positioned outside its parent's box silently disappears, matching retail's non-empty-intersection gate. HitTest's existing early bounds check already implemented this shape for ClipsChildren=true elements -- flipping the default aligns hit-testing with the new draw-clip default in one property, per the plan's own point 4. - UiElement.ExpandsClipForPopup (default false) is the one opt-out: retail spawns a menu popup as a SEPARATE top-level region (UIElement_Menu::MakePopup), clipped only by the screen; acdream draws UiMenu's popup inline from the owning button in a second traversal (OnDrawOverlay, pre-existing -- its own doc comment already says "regardless of this element's position in the tree"). DrawOverlays now resets the accumulated clip to unbounded (UiRenderContext.PushClipUnbounded, sharing the existing clip stack) for exactly the OnDrawOverlay call of an opted-in element. UiMenu overrides ExpandsClipForPopup=>true, paired with ClipsChildren=>false so its own out-of-bounds OnHitTest union (the popup occupies ly<0 or ly>=Height depending on open direction) stays reachable through the same early-bounds gate that now defaults on for every other element. Opt-out audit (grep for OnDrawOverlay overrides + negative/overflow OnDraw coordinates across src/AcDream.App/UI): UiMenu's popup is the ONLY OnDrawOverlay override client-wide, so it is the only element needing ExpandsClipForPopup. RetailTooltipPresenter's popup and UiRoot's drag ghost both already escape structurally -- the tooltip mounts as an ordinary UiRoot CHILD (sibling of every window, clipped only by the canvas), and the drag ghost is drawn directly by UiRoot outside the tree entirely -- neither needed a code change, both are covered by new tests proving the invariant. UiResizeGrip and UiNineSlicePanel's frame/bevel draw entirely within their own [0,Width]x[0,Height] (grip flush at the window's own edges; the window's own Width/Height already represents the OUTER frame including its 5px bevel, so its ClipsChildren push already covers the frame's own content children correctly -- no negative insets found). UiScrollbar draws entirely within its own bounds (confirmed by reading OnDraw). Hit-testing: aligned with the new default via the single ClipsChildren flip (see above); UiMenu's own opt-out override keeps its popup hit-test union working, verified by the full UiMenuTests suite staying green. Divergence register: AD-113 filed for the ExpandsClipForPopup adaptation (inline popup drawing vs retail's separate top-level region). Fixed two pre-existing test-harness gaps the new default surfaced (both real bugs in the harnesses, not workarounds around the fix): - ChatLayoutConformanceTests' bottom-right-grip grow test read a STALE (pre-shrink) grip screen position because it drove two resize gestures back-to-back with no intervening Draw pass -- the only place UiElement.ApplyAnchor/LayoutPolicy.Apply run. A real frame draws every tick, so production never hits this; the test now inserts a real DrawSelfAndChildren pass between the two gestures, matching a real frame boundary. - VendorUiControllerTests' hand-built Items/Buying/Selling page containers were left at their bare 0x0 UiElement default (the harness never runs a real DAT-driven layout pass) -- harmless before ancestor clipping existed, but now hides every child of an unsized page. Sized them to the window's own content root, matching production's shape (a tab page fills the window body). Tests (all confirmed as genuine regression pins by temporarily reverting the relevant default/override and observing the exact predicted failure, then reverting back): - CharacterTitlesControllerTests.TitlesPage_Divider_ClipsAwayAtThe CT6Default_AndAppearsWhenTheWindowGrowsTaller: the literal gate repro against the real character_2100002E.json fixture through RetailWindowFrame.Mount at the CT6 372px default -- the divider renders nothing (computed Y ~ -173, matching the owner's ~-178); growing the window to 600px renders it at its authored spot. - ChatLayoutConformanceTests.ResizingTheWindowSmall_NoInputRowQuad RendersOutsideTheWindowRect: no input-row quad escapes the chat window rect at three small sizes (300x100 sanity control, 120x40/80x30 genuine pre-fix overflow -- verified failing without the fix at Y=38/55 past the window edge). - UiAncestorClipTests (new file): the core mechanism against plain synthetic elements (culled-outside / clipped-at-the-edge / hit-test parity), UiMenu's popup escaping a tiny owning window (and staying clipped while closed), and the tooltip's structural immunity (mounts as a UiRoot sibling, unaffected by a tiny ancestor window). Verification: full solution build green; hermetic suite green (--filter "Lane!=InstalledDat&Lane!=PreparedPackage&Lane!=Live& Lane!=Manual&Lane!=Timing&Lane!=Windows&Lane!=Linux& Lane!=SystemFont&Purpose!=Diagnostic&Status!=KnownFailure", 14,000+ tests across every project); InstalledDat lane green (ACDREAM_RUN_INSTALLED_DAT_TESTS=1, Status!=KnownFailure, 205+34+3+172 tests). CharacterTitlesControllerTests' existing suite and the full UiMenuTests/UiScrollbarTests suites are unaffected. src/AcDream.App/UI/UiRoot.cs carries an unrelated, pre-existing uncommitted owner probe (ACDREAM_PROBE_UI_HOVER) -- untouched by this change and deliberately left out of this commit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
6561d08fa8
commit
989f665214
8 changed files with 627 additions and 6 deletions
|
|
@ -603,6 +603,23 @@ public class ChatLayoutConformanceTests
|
|||
Assert.Equal(390f, handle.Width);
|
||||
Assert.Equal(100f, handle.Height);
|
||||
|
||||
// CT-GF1: a real frame draws every tick, which is what reflows an
|
||||
// anchored child's Left/Top against its parent's CURRENT size
|
||||
// (UiElement.ApplyAnchor runs only from DrawSelfAndChildren) — so by
|
||||
// the time a player's next click lands, the grip is already
|
||||
// repositioned for the just-shrunk window. This test drives the resize
|
||||
// directly without an intervening render, so without this draw pass the
|
||||
// grip's ScreenPosition below stays at its PRE-shrink (now stale, wider)
|
||||
// anchor and lands outside the shrunk window's own bounds — UiElement's
|
||||
// new default ancestor clip (ClipsChildren) then refuses the press
|
||||
// before it ever reaches the grip. Matches a real frame boundary, not a
|
||||
// workaround for the clip.
|
||||
var device = new RecordingGpuDevice();
|
||||
var renderer = new TextRenderer(device, new NullGpuFrameSource(), "unused");
|
||||
renderer.Begin(new Vector2(root.Width, root.Height));
|
||||
var drawCtx = new UiRenderContext(renderer, new Vector2(root.Width, root.Height));
|
||||
root.DrawSelfAndChildren(drawCtx);
|
||||
|
||||
// Now grow from the shrunken state — this is the reported-broken direction.
|
||||
var brGripAfterShrink = Assert.IsType<UiResizeGrip>(layout.FindElement(0x100006A1u));
|
||||
var gs2 = brGripAfterShrink.ScreenPosition;
|
||||
|
|
@ -732,6 +749,82 @@ public class ChatLayoutConformanceTests
|
|||
$"input ends {input.Left + input.Width} past send start {send.Left}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CT-GF1 regression pin — companion to
|
||||
/// <see cref="ResizingTheWindow_KeepsTheInputRowInsideIt"/> above, which
|
||||
/// only proves the input row's Left/Width GEOMETRY stays inside the
|
||||
/// window: that test's <c>LayoutImporter.Build</c> call resolves every
|
||||
/// sprite through <see cref="NoTex"/> (texture 0), and
|
||||
/// <c>UiDatElement.OnDraw</c>'s own <c>tex == 0</c> guard means nothing
|
||||
/// ever reaches a quad — exactly why the owner's "text input sticks out
|
||||
/// on resize" report was previously unreproducible in a fixture. This
|
||||
/// test resolves REAL non-zero textures (same <c>id => (id, 8, 8)</c>
|
||||
/// pattern as <c>MountedChatWindow_LiveGrip_ActuallyEmitsASpriteDraw_
|
||||
/// NotJustResolvesSpriteFile</c> above) and draws the whole mounted
|
||||
/// window through a <see cref="RecordingGpuDevice"/> at small sizes, then
|
||||
/// asserts every emitted quad's vertices stay inside the window's own
|
||||
/// [0,width]x[0,height] rect. The mechanism CT-GF1 ports
|
||||
/// (<c>UiElement.ClipsChildren</c>'s new client-wide default,
|
||||
/// retail's <c>UIRegion::DrawHere @0x0069FA30</c> ancestor-clip
|
||||
/// intersection) is what makes this true now — confirmed a real
|
||||
/// regression pin (not vacuous) by temporarily reverting the default:
|
||||
/// the 120x40/80x30 cases fail without the fix (a quad renders ~15-38px
|
||||
/// past the window's bottom edge, the input row's authored ~72px extent
|
||||
/// no longer fitting a window shrunk below the ~100px it was designed
|
||||
/// for) and pass with it; 300x100 is the "still comfortably fits, sanity"
|
||||
/// control case.
|
||||
/// </summary>
|
||||
[Theory]
|
||||
[InlineData(300f, 100f)]
|
||||
[InlineData(120f, 40f)]
|
||||
[InlineData(80f, 30f)]
|
||||
public void ResizingTheWindowSmall_NoInputRowQuadRendersOutsideTheWindowRect(float width, float height)
|
||||
{
|
||||
var infos = FixtureLoader.LoadChatInfos();
|
||||
ImportedLayout layout = LayoutImporter.Build(infos, id => (id, 8, 8), null);
|
||||
var controller = ChatWindowController.Bind(
|
||||
infos, layout, new ChatVM(new ChatLog()), () => NullCommandBus.Instance,
|
||||
new ChatWindowState(), null, null, NoTex);
|
||||
Assert.NotNull(controller);
|
||||
UiElement window = layout.FindElement(0x10000600u)!;
|
||||
var root = new UiRoot { Width = 800f, Height = 600f };
|
||||
root.AddChild(window);
|
||||
|
||||
var device = new RecordingGpuDevice();
|
||||
var renderer = new TextRenderer(device, new NullGpuFrameSource(), "unused");
|
||||
renderer.Begin(new Vector2(root.Width, root.Height));
|
||||
var ctx = new UiRenderContext(renderer, new Vector2(root.Width, root.Height));
|
||||
window.DrawSelfAndChildren(ctx);
|
||||
|
||||
window.Width = width;
|
||||
window.Height = height;
|
||||
window.ResetAnchorCapture();
|
||||
// Two frames — same "raw-edge LayoutPolicy needs a settle pass" reasoning
|
||||
// as the geometry sibling test above.
|
||||
renderer.Begin(new Vector2(root.Width, root.Height));
|
||||
window.DrawSelfAndChildren(ctx);
|
||||
renderer.Begin(new Vector2(root.Width, root.Height));
|
||||
window.DrawSelfAndChildren(ctx);
|
||||
|
||||
float windowLeft = window.ScreenPosition.X;
|
||||
float windowTop = window.ScreenPosition.Y;
|
||||
const float Slop = 0.5f;
|
||||
foreach (var seg in renderer.DebugSpriteSegmentVerts)
|
||||
{
|
||||
for (int i = 0; i < seg.Verts.Count / 8; i++)
|
||||
{
|
||||
float vx = seg.Verts[i * 8];
|
||||
float vy = seg.Verts[i * 8 + 1];
|
||||
Assert.True(
|
||||
vx >= windowLeft - Slop && vx <= windowLeft + width + Slop
|
||||
&& vy >= windowTop - Slop && vy <= windowTop + height + Slop,
|
||||
$"quad vertex ({vx},{vy}) escapes the {width}x{height} chat window rect " +
|
||||
$"[{windowLeft},{windowTop}]-[{windowLeft + width},{windowTop + height}] " +
|
||||
$"(texture {seg.Texture})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyLayoutPassLocal(UiElement parent)
|
||||
{
|
||||
foreach (var child in parent.Children)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue