Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::ScrollState Class Reference

Owning one-dimensional logical position with floor quantization to integral rows. Integral and fractional parts are stored separately, preserving every uint64 index even above 2^53. Fractions use double precision; no epsilon snapping is performed. Saturation discards overscroll. No allocation, callbacks, tree invalidation or I/O occurs. The owner serializes access; views use UI only. More...

#include <scroll.hpp>

Public Member Functions

std::uint64_t rasterOffset () const noexcept
double fraction () const noexcept
std::expected< void, TreeError > setOffset (std::uint64_t row, double fraction=0) noexcept
 Replace the unbounded intended position; call clamp when row count is known.
std::expected< bool, TreeError > moveBy (double rows, std::uint64_t count) noexcept
 Accumulate signed fractional wheel movement, saturating at the first/last row.
void clamp (std::uint64_t count) noexcept
 Bound position to the last logical row; an empty model resets both parts.
std::expected< bool, TreeError > ensureVisible (std::uint64_t row, std::uint64_t visibleRows, std::uint64_t count) noexcept
 Reveal an index with minimal integral movement, without changing an already visible position.

Detailed Description

Owning one-dimensional logical position with floor quantization to integral rows. Integral and fractional parts are stored separately, preserving every uint64 index even above 2^53. Fractions use double precision; no epsilon snapping is performed. Saturation discards overscroll. No allocation, callbacks, tree invalidation or I/O occurs. The owner serializes access; views use UI only.

Member Function Documentation

◆ clamp()

void portals::ScrollState::clamp ( std::uint64_t count)
noexcept

Bound position to the last logical row; an empty model resets both parts.

Parameters
countLogical row count, independent of materialized storage.

◆ ensureVisible()

std::expected< bool, TreeError > portals::ScrollState::ensureVisible ( std::uint64_t row,
std::uint64_t visibleRows,
std::uint64_t count )
noexcept

Reveal an index with minimal integral movement, without changing an already visible position.

Parameters
rowTarget logical index, less than count.
visibleRowsNumber of fully visible rows; zero means no movement is possible.
countLogical model row count.
Returns
Whether raster position changed, or INVALID_ARGUMENT for an out-of-bounds target.

◆ fraction()

double portals::ScrollState::fraction ( ) const
noexcept
Returns
Fractional logical remainder in [0,1), in logical rows.

◆ moveBy()

std::expected< bool, TreeError > portals::ScrollState::moveBy ( double rows,
std::uint64_t count )
noexcept

Accumulate signed fractional wheel movement, saturating at the first/last row.

Parameters
rowsFinite signed movement in logical rows; positive moves toward the end.
countLogical model row count; zero resets the position.
Returns
Whether the raster position changed, or INVALID_ARGUMENT without mutation for nonfinite input.

◆ rasterOffset()

std::uint64_t portals::ScrollState::rasterOffset ( ) const
noexcept
Returns
Integral raster position, in logical rows; text is placed on whole cell rows.

◆ setOffset()

std::expected< void, TreeError > portals::ScrollState::setOffset ( std::uint64_t row,
double fraction = 0 )
noexcept

Replace the unbounded intended position; call clamp when row count is known.

Parameters
rowExact integral logical row index.
fractionFractional row remainder in [0,1); finite values only.
Returns
Success, or INVALID_ARGUMENT without changing state.

The documentation for this class was generated from the following file: