feat(ui): unify retained window mounts
This commit is contained in:
parent
6e9e10367f
commit
a8e9503d2e
20 changed files with 823 additions and 366 deletions
|
|
@ -145,9 +145,6 @@ public sealed class UiText : UiElement
|
|||
/// <summary>The scroll model — also read by the linked UiScrollbar.</summary>
|
||||
public UiScrollable Scroll { get; } = new();
|
||||
|
||||
/// <summary>True while the view is pinned to the newest line (auto-scrolls as content grows).</summary>
|
||||
private bool _pinBottom = true;
|
||||
|
||||
private const float WheelLines = 1f; // lines advanced per wheel notch (retail = 1 line per notch)
|
||||
|
||||
// ── Cached layout from the last OnDraw, so OnEvent hit-tests the SAME geometry ──
|
||||
|
|
@ -292,9 +289,10 @@ public sealed class UiText : UiElement
|
|||
|
||||
// Drive the shared scroll model with the current geometry.
|
||||
Scroll.LineHeight = (int)MathF.Round(lh);
|
||||
Scroll.ContentHeight = (int)MathF.Ceiling(contentH);
|
||||
Scroll.ViewHeight = (int)MathF.Floor(innerH);
|
||||
if (_pinBottom) Scroll.ScrollToEnd();
|
||||
Scroll.SetExtents(
|
||||
(int)MathF.Ceiling(contentH),
|
||||
(int)MathF.Floor(innerH),
|
||||
preserveEnd: true);
|
||||
|
||||
// UiScrollable: ScrollY=0 is TOP/oldest, ScrollY=MaxScroll is BOTTOM/newest.
|
||||
// Visual layout: newest at bottom → baseY = bottom - contentH (ScrollY at max).
|
||||
|
|
@ -358,7 +356,6 @@ public sealed class UiText : UiElement
|
|||
// ScrollByLines sign: +down/newer, -up/older.
|
||||
// e.Data0 > 0 → wheel up → want older → ScrollByLines with negative lines.
|
||||
Scroll.ScrollByLines((int)(-e.Data0 * WheelLines));
|
||||
_pinBottom = Scroll.AtEnd;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue