fix #371: straddling rows clip at the viewport edge instead of vanishing whole

Gate-3 screenshot review (user): 'the chat tab looks like it is missing
per window config' — Chat Window 1's header rendered over a void at the
DEFAULT scroll offset because its 260px self-sized filter block
straddled the viewport's bottom edge and UiScrollablePanel hid
straddling rows WHOLE (AP-201's predicted symptom, now user-observed at
scroll position zero, upgrading it from polish to blocking).

By fix time the UI renderer HAD everything needed: UiRenderContext's
clip stack (PushClip/PopClip with rect intersection + per-draw quad
clipping) and UiElement's ClipsChildren hook, already honored by both
the generic draw walk and hit-testing. The fix is therefore exactly the
shape the filing asked for, in the panel itself:
- ClipsChildren => true: children draw and hit-test clipped to the
  viewport rect.
- The layout cull keeps any INTERSECTING row Visible (was: fully-inside
  only), with a half-pixel margin excluding zero-overlap edge rows;
  fully-outside rows stay hidden as the cheap skip.

AP-201 retired in this commit (AP actives 142 -> 141); #371 closed; the
gate script's Chat-tab steps re-written to expect clean edge clipping
and to treat any whole-block vanish as a regression. Pinned by
StraddlingRow_StaysVisible_AndClipsInsteadOfVanishing (the exact gate-3
geometry: header + 260px straddler in a 430px viewport) and
ViewportClipsChildDrawingAndHitTesting (the clipped slice is not
clickable).

Full Release suite: 13,089 passed / 4 skipped / 0 failed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-11 17:08:21 +02:00
parent a8ce010d02
commit a59e077a66
5 changed files with 118 additions and 20 deletions

View file

@ -7,11 +7,19 @@ namespace AcDream.App.UI;
/// <summary>
/// Simple vertical viewport for controller-built row lists. It shares the same
/// pixel scroll model as chat text and item grids, and clips whole rows because
/// the UI renderer does not have a scissor stack yet.
/// pixel scroll model as chat text and item grids. A row that straddles the
/// viewport edge stays visible and is CLIPPED to the viewport (#371 —
/// <see cref="ClipsChildren"/> routes the draw walk and hit-testing through
/// <see cref="UiRenderContext.PushClip"/>); before that fix this class hid a
/// straddling row WHOLE, which made the Chat tab's 260px per-window filter
/// blocks vanish into a void at the default scroll offset (AP-201's predicted
/// symptom, user-observed at Campaign OP gate 3).
/// </summary>
public sealed class UiScrollablePanel : UiPanel
{
/// <inheritdoc/>
protected override bool ClipsChildren => true;
private readonly Dictionary<UiElement, float> _baseTops = new(ReferenceEqualityComparer.Instance);
public UiScrollable Scroll { get; } = new();
@ -66,7 +74,12 @@ public sealed class UiScrollablePanel : UiPanel
float top = baseTop - Scroll.ScrollY;
child.Top = top;
child.Visible = top >= -0.5f && top + child.Height <= Height + 0.5f;
// #371: INTERSECTION, not full containment — a straddling row stays
// visible and ClipsChildren trims it to the viewport at draw and
// hit-test time. Rows entirely outside stay hidden (cheap skip);
// the half-pixel margin excludes zero-overlap rows sitting exactly
// on either edge.
child.Visible = top + child.Height > 0.5f && top < Height - 0.5f;
}
}