rdi_core/lib.rs
1//! Platform-agnostic animation core for `rusty-desktop-icons`.
2//!
3//! This crate defines the pure-Rust, cross-platform surface of the project:
4//!
5//! * Geometry primitives ([`Point`]) and icon identifiers ([`IconId`]).
6//! * The [`Curve`] system with two variants ([`BuiltinEasing`] and
7//! [`KeyframeCurve`]) that share a single [`AnimationCurve`] contract.
8//! * A [`Duration`] policy that resolves to a concrete `std::time::Duration`
9//! either from a fixed value or from movement distance and speed.
10//! * The animation specification types ([`IconAnimationSpec`],
11//! [`AnimationOptions`], [`FolderFlagOp`]).
12//! * Error types shared by all backends.
13//!
14//! The Windows Shell/COM backend, the worker thread, and the Python
15//! bindings live in sibling crates and depend on this one.
16//!
17//! Everything in this crate is `#![forbid(unsafe_code)]` — the only place
18//! `unsafe` is allowed is inside `rdi-platform-windows`.
19//!
20//! ## Quick tour of curves
21//!
22//! ```
23//! use rdi_core::{AnimationCurve, Curve, KeyframeInterp};
24//!
25//! // Predefined easing.
26//! let ease = Curve::ease_in_out();
27//! assert!((ease.eval(0.5) - 0.5).abs() < 1e-3);
28//!
29//! // Data-driven keyframes.
30//! let keys = Curve::keyframes(
31//! vec![
32//! rdi_core::Keyframe::new(0.0, 0.0),
33//! rdi_core::Keyframe::new(0.5, 0.9),
34//! rdi_core::Keyframe::new(1.0, 1.0),
35//! ],
36//! KeyframeInterp::Linear,
37//! ).unwrap();
38//! assert!(keys.eval(0.5) > 0.5);
39//!
40//! // Function-generated curve — sampled once, then pure data at runtime.
41//! let damped = Curve::from_curve_fn(
42//! |t| 1.0 - (1.0 - t).powi(3),
43//! 32,
44//! KeyframeInterp::Linear,
45//! ).unwrap();
46//! assert!(damped.eval(1.0) > 0.9);
47//! ```
48
49pub mod curve;
50pub mod desktop;
51pub mod duration;
52pub mod effect;
53pub mod error;
54pub mod geometry;
55pub mod id;
56pub mod monitor;
57pub mod overlay_plan;
58pub mod procedural;
59pub mod snapshot;
60pub mod scene;
61pub mod spec;
62
63pub mod backend;
64pub mod controller;
65pub mod events;
66pub mod fake;
67pub mod handle;
68pub mod timeline;
69
70mod engine;
71
72pub use backend::DesktopBackend;
73pub use controller::{DesktopController, PreparedAnimation};
74pub use curve::{
75 AnimationCurve, BuiltinEasing, Curve, Keyframe, KeyframeCurve, KeyframeInterp, MotionContext,
76};
77pub use duration::Duration;
78pub use desktop::{DesktopInfo, IconGrid, resolve_grid_targets};
79pub use effect::{Effect, IconFrame, ShaderPipeline, ShaderProgram};
80pub mod effect_graph;
81pub use effect_graph::{DrawSpec, DrawTopology, EffectExecution, EffectParameter, EffectPass, EffectTarget, ParameterKind, PassBlend};
82pub use error::{CurveError, DesktopError};
83pub use events::{
84 FinishReason, IconAnimationState, StartContext, StopMode, TickContext,
85};
86pub use geometry::Point;
87pub use handle::{AnimationHandle, PreObservers};
88pub use id::IconId;
89pub use monitor::{MonitorInfo, Rect};
90pub use overlay_plan::{
91 FinalCommitOutcome, IconBitmap, IconLabel, IconRenderPlan, OverlayRenderOptions,
92 SnapshotFrame, SnapshotIconGeometry,
93};
94pub use snapshot::IconSnapshot;
95pub use scene::{Canvas, CapturedFrame, RenderSession, Scene, SceneIcon, SceneRenderer};
96pub use spec::{AnimationOptions, AnimationPreset, FolderFlagOp, IconAnimationSpec};
97pub use timeline::{PlaybackHandle, PlaybackOutcome, TimelineCloseMode, TimelineSession, TimelineState};