Skip to main content

teksilo_scene/
lib.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! `teksilo-scene` — pannable / zoomable scene viewport for Teksilo.
5//!
6//! A sub-toolkit for **scene-based applications** — story corkboards,
7//! mind maps, node-graph editors, timeline views — where content is
8//! free-positioned at scene coordinates instead of placed by a layout
9//! algorithm. Two tiers of content coexist under one view transform:
10//!
11//! - **Heavyweight tier:** any `Widget` (Button, TextInput, Panel,
12//!   composite components) at a parent-relative position, fully
13//!   interactive and accessible, with full event / focus / animation /
14//!   a11y machinery intact.
15//! - **Lightweight tier:** [`SceneItem`]s (paths, rects, images,
16//!   custom paint) without arena overhead — for the "background
17//!   furniture" of a scene where thousands of items render cheaply.
18//!
19//! The crate is built on top of teksilo-core's per-node `set_transform`
20//! scope (which composes through hit-test, paint, and a11y) and the
21//! platform's pinch / scroll / animated-`Signal<f32>` infrastructure
22//! — so OS gestures, reduced-motion snapping, and the four-gate idle
23//! scheduler fall out for free.
24//!
25//! See [`docs/teksilo-scene.md`](https://github.com/ferntech-eu/teksilo/blob/main/docs/teksilo-scene.md)
26//! for the user-facing reference and
27//! [`docs/teksilo-scene-a11y.md`](https://github.com/ferntech-eu/teksilo/blob/main/docs/teksilo-scene-a11y.md)
28//! for the accessibility-shaping API.
29//!
30//! ## Quick start
31//!
32//! ```ignore
33//! use teksilo_scene::{ItemId, RectItem, Scene, SceneView};
34//! use teksilo_canvas::{Point, Rect};
35//!
36//! let mut scene = Scene::new();
37//! let _w: ItemId = scene.add_widget(
38//!     my_card_widget(),
39//!     Rect::new(0.0, 0.0, 200.0, 120.0),
40//! );
41//! scene.add_item(
42//!     RectItem::new(Rect::new(0.0, 0.0, 50.0, 50.0)).fill(teksilo_tokens::Color::RED),
43//!     Point::new(220.0, 0.0),
44//! );
45//! let view = SceneView::new(scene);
46//! tree.add(view);
47//! ```
48
49#![allow(clippy::type_complexity)]
50
51// Implementation modules are intentionally `pub(crate)`. The crate's
52// public surface is the re-export block below — every type or trait
53// an external consumer is meant to use is reachable as
54// `teksilo_scene::Foo` (never `teksilo_scene::flags::Foo` etc). Narrowing
55// here lets internal refactors land without ripple effects in
56// downstream apps. Adding a new external-facing type? Re-export it
57// rather than widening a module to `pub`.
58pub(crate) mod a11y;
59pub(crate) mod animation;
60pub(crate) mod cache;
61pub(crate) mod flags;
62pub(crate) mod index;
63pub(crate) mod item;
64pub(crate) mod item_handlers;
65pub(crate) mod items;
66pub(crate) mod magnet;
67pub(crate) mod minimap;
68pub(crate) mod scene;
69pub(crate) mod scene_list_adapter;
70pub(crate) mod scene_model;
71pub(crate) mod scroll_view;
72pub(crate) mod selection;
73pub(crate) mod state;
74pub(crate) mod transform;
75pub(crate) mod view;
76
77pub use a11y::{
78    A11yBoundsSpace, A11yCategory, A11yGroup, A11yGroupBuilder, A11yGroupId, A11yMode, A11yNode,
79    A11yOffScreenMode, A11yRelation,
80};
81pub use animation::{pulse_once, register_animated_item_signal};
82pub use cache::CacheMode;
83pub use flags::ItemFlags;
84pub use index::{GridHashIndex, SpatialIndex};
85pub use item::{ItemId, SceneItem, SceneItemA11yContext, SceneItemPaintContext};
86pub use item_handlers::{DragMode, SceneItemHandlerSet, SceneTapEvent};
87pub use items::AccessSubtreeMode;
88pub use items::{GroupItem, ImageItem, PathItem, RectItem, TextAlign, TextItem};
89pub use magnet::{
90    Magnet, MagnetConnection, MagnetFeedback, MagnetId, MagnetMarker, MagnetRef, MagnetRole,
91    MagnetSnap, MagnetVerdict, MagnetVisualState, MagnetismConfig, MarkerVisibility,
92};
93pub use minimap::SceneMinimap;
94pub use scene::Scene;
95pub use scene::{ItemChange, PanAxes, SceneConstraints, SceneLayer};
96pub use scene_list_adapter::SceneListAdapter;
97pub use scene_model::SceneModel;
98pub use scroll_view::{SceneScrollView, ScrollBarMode, ScrollBarPolicy};
99pub use selection::{SceneSelection, SceneSelectionMode};
100pub use state::SceneViewState;
101pub use view::{DebugOverlay, FocusDirection, SceneView};