// Copied from OxygenHub crates/backdrop/src/scene.rs (6dc080f6) by // scripts/sync-backdrop.sh: change it there, never here. //! A backdrop's scene (docs/backgrounds.md §2): what it draws and how it //! moves. The engine (lib.rs) drives any of them the same way. use crate::backdrop::sky::{Colours, Kind}; pub trait Scene { /// The view is now `w` by `h` CSS pixels, the page's content column /// between `avoid`'s left and right. fn resize(&mut self, w: f32, h: f32, avoid: Option<(f32, f32)>); /// The cursor moved to `(x, y)`, or left the page. fn point(&mut self, at: Option<(f32, f32)>); /// Move on by `dt` seconds. fn step(&mut self, dt: f32); /// The marks, 8 floats each (sky::Sky::instances). fn instances(&self, c: &Colours, out: &mut Vec); /// The links, 12 floats each (sky::Sky::links). fn links(&self, c: &Colours, out: &mut Vec); /// The name a resting cursor shows, and where. fn label(&self) -> Option<(&str, f32, f32)>; /// New activity in repository `repo` (§5, "Live"); only the sky shows it. fn arrive(&mut self, _repo: &str, _kind: Kind, _n: u32) {} /// Whether a frame would show anything new besides the drift, which /// the engine stops drawing a while after the last input (§6). fn busy(&self) -> bool; fn still(&self) -> bool; fn size(&self) -> (f32, f32); } impl Scene for crate::backdrop::sky::Sky { fn resize(&mut self, w: f32, h: f32, avoid: Option<(f32, f32)>) { crate::backdrop::sky::Sky::resize(self, w, h, avoid) } fn point(&mut self, at: Option<(f32, f32)>) { crate::backdrop::sky::Sky::point(self, at) } fn step(&mut self, dt: f32) { crate::backdrop::sky::Sky::step(self, dt) } fn instances(&self, c: &Colours, out: &mut Vec) { crate::backdrop::sky::Sky::instances(self, c, out) } fn links(&self, c: &Colours, out: &mut Vec) { crate::backdrop::sky::Sky::links(self, c, out) } fn label(&self) -> Option<(&str, f32, f32)> { crate::backdrop::sky::Sky::label(self) } fn arrive(&mut self, repo: &str, kind: Kind, n: u32) { crate::backdrop::sky::Sky::arrive(self, repo, kind, n) } fn busy(&self) -> bool { crate::backdrop::sky::Sky::busy(self) } fn still(&self) -> bool { self.still } fn size(&self) -> (f32, f32) { (self.w, self.h) } }