feat(ui): unify retained window mounts
This commit is contained in:
parent
6e9e10367f
commit
a8e9503d2e
20 changed files with 823 additions and 366 deletions
|
|
@ -33,6 +33,25 @@ public sealed class UiScrollable
|
|||
/// <summary>True when the offset is at (or past) the bottom — used for bottom-pin.</summary>
|
||||
public bool AtEnd => _scrollY >= MaxScroll;
|
||||
|
||||
/// <summary>
|
||||
/// Update the content/view extents and clamp the current offset. When
|
||||
/// <paramref name="preserveEnd"/> is true, a view that was at the end before
|
||||
/// the geometry change remains at the end afterward. User-driven scrollbar
|
||||
/// changes move <see cref="ScrollY"/> off the end, so later layout passes
|
||||
/// preserve that selected position instead of snapping it back.
|
||||
/// </summary>
|
||||
public void SetExtents(int contentHeight, int viewHeight, bool preserveEnd = false)
|
||||
{
|
||||
bool wasAtEnd = AtEnd;
|
||||
ContentHeight = Math.Max(0, contentHeight);
|
||||
ViewHeight = Math.Max(0, viewHeight);
|
||||
|
||||
if (preserveEnd && wasAtEnd)
|
||||
ScrollToEnd();
|
||||
else
|
||||
SetScrollY(_scrollY);
|
||||
}
|
||||
|
||||
/// <summary>Set the offset, clamped to [0, MaxScroll] (SetScrollableXY clamp).</summary>
|
||||
public void SetScrollY(int y) => _scrollY = Math.Clamp(y, 0, MaxScroll);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue