EN
RU
Portals
0.7.0 · dev
0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Toggle main menu visibility
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
9
namespace
portals
{
15
class
ScrollState
{
16
public
:
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
46
private:
47
std::uint64_t row_{};
48
double
fraction_{};
49
};
50
}
// namespace portals
portals::ScrollState
Owning one-dimensional logical position with floor quantization to integral rows. Integral and fracti...
Definition
scroll.hpp:15
portals::ScrollState::setOffset
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.
portals::ScrollState::fraction
double fraction() const noexcept
portals::ScrollState::ensureVisible
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.
portals::ScrollState::rasterOffset
std::uint64_t rasterOffset() const noexcept
portals::ScrollState::clamp
void clamp(std::uint64_t count) noexcept
Bound position to the last logical row; an empty model resets both parts.
portals::ScrollState::moveBy
std::expected< bool, TreeError > moveBy(double rows, std::uint64_t count) noexcept
Accumulate signed fractional wheel movement, saturating at the first/last row.
portals
Public Portals API.
Definition
action.hpp:8
portals::TreeError
TreeError
Checked tree failures; rejected operations never start the requested callback.
Definition
widget_types.hpp:26
include
portals
scroll.hpp