Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
scroll_controller.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4
5#include <memory>
6#include <portals/scroll_geometry.hpp>
7
8namespace portals {
14
20
26
35
36namespace detail {
37struct ScrollControllerAccess;
38}
39
46class ScrollController {
47public:
54 [[nodiscard]] static std::expected<std::shared_ptr<ScrollController>, TreeError>
56
59 ScrollController(const ScrollController &) = delete;
60 ScrollController &operator=(const ScrollController &) = delete;
61
66 [[nodiscard]] std::expected<ScrollControllerSnapshot, TreeError> snapshot() const noexcept;
67
68private:
69 friend struct detail::ScrollControllerAccess;
70 struct State;
71 explicit ScrollController(std::unique_ptr<State> state) noexcept;
72 std::unique_ptr<State> state_;
73};
74} // namespace portals
std::expected< ScrollControllerSnapshot, TreeError > snapshot() const noexcept
Observe both axes atomically on the creating UI thread.
~ScrollController()
Release values; no callbacks, tree access or thread-affine cleanup occurs.
static std::expected< std::shared_ptr< ScrollController >, TreeError > create(ScrollControllerOptions options=ScrollControllerOptions{})
Validate and atomically create both initial axes on the current UI thread.
Public Portals API.
Definition action.hpp:8
TreeError
Checked tree failures; rejected operations never start the requested callback.
Definition widget_types.hpp:26
Owning initial configuration of one exact scrolling axis.
Definition scroll_controller.hpp:10
ScrollAxisMetrics metrics
Initial logical extent/viewport; a mounted area later owns its actual metrics.
Definition scroll_controller.hpp:11
ScrollOffset offset
Intended offset, clamped to the initial viewport-start range.
Definition scroll_controller.hpp:12
Owning one-axis logical metrics, independent of materialized content.
Definition scroll_geometry.hpp:41
Owning immutable observation of one axis at a controller revision.
Definition scroll_controller.hpp:22
ScrollAxisMetrics metrics
Copied logical extent and viewport.
Definition scroll_controller.hpp:23
ScrollOffset offset
Copied exact position and fractional remainder.
Definition scroll_controller.hpp:24
Owning pre-mount configuration; no callbacks, tree or widget references.
Definition scroll_controller.hpp:16
ScrollAxisConfiguration horizontal
Initial horizontal values, defaulting to an empty range.
Definition scroll_controller.hpp:17
ScrollAxisConfiguration vertical
Initial vertical values, defaulting to an empty range.
Definition scroll_controller.hpp:18
Owning two-axis observation, safe to retain after the controller is destroyed. Values are independent...
Definition scroll_controller.hpp:30
std::uint64_t revision
Nonzero checked revision; never wraps or reuses an exhausted identity.
Definition scroll_controller.hpp:33
ScrollAxisSnapshot horizontal
Horizontal values from this same revision.
Definition scroll_controller.hpp:31
ScrollAxisSnapshot vertical
Vertical values from this same revision.
Definition scroll_controller.hpp:32
Owning exact integral position and sub-cell remainder; no affinity or invalidation.
Definition scroll_geometry.hpp:35