Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
scroll.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4
5#include <cstdint>
6#include <expected>
7#include <portals/widget_types.hpp>
8
9namespace portals {
16public:
18 std::uint64_t rasterOffset() const noexcept;
20 double fraction() const noexcept;
26 std::expected<void, TreeError> setOffset(std::uint64_t row, double fraction = 0) noexcept;
32 std::expected<bool, TreeError> moveBy(double rows, std::uint64_t count) noexcept;
36 void clamp(std::uint64_t count) noexcept;
43 std::expected<bool, TreeError> ensureVisible(std::uint64_t row, std::uint64_t visibleRows,
44 std::uint64_t count) noexcept;
45
46private:
47 std::uint64_t row_{};
48 double fraction_{};
49};
50} // namespace portals
Owning one-dimensional logical position with floor quantization to integral rows. Integral and fracti...
Definition scroll.hpp:15
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.
double fraction() const noexcept
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.
std::uint64_t rasterOffset() const noexcept
void clamp(std::uint64_t count) noexcept
Bound position to the last logical row; an empty model resets both parts.
std::expected< bool, TreeError > moveBy(double rows, std::uint64_t count) noexcept
Accumulate signed fractional wheel movement, saturating at the first/last row.
Public Portals API.
Definition action.hpp:8
TreeError
Checked tree failures; rejected operations never start the requested callback.
Definition widget_types.hpp:26