| 1 | pub mod conflict; |
| 2 | pub mod document; |
| 3 | pub mod editor; |
| 4 | pub mod language; |
| 5 | pub mod layout; |
| 6 | pub mod math; |
| 7 | pub mod outline; |
| 8 | pub mod reading; |
| 9 | pub mod search; |
| 10 | pub mod spelling; |
| 11 | pub mod template; |
| 12 | |
| 13 | pub mod date; |
| 14 | #[cfg(feature = "gpu")] |
| 15 | pub mod gpu; |
| 16 | #[cfg(feature = "interaction")] |
| 17 | pub mod interaction; |
| 18 | #[cfg(feature = "pdf")] |
| 19 | pub mod print; |
| 20 | #[cfg(feature = "gpu")] |
| 21 | pub mod recording; |
| 22 | |
| 23 | /// Where an object stored with `layout` lies; an unset coordinate is zero. |
| 24 | pub(crate) fn origin(layout: &onestore::document::Layout) -> [f32; 2] { |
| 25 | [layout.x.unwrap_or(0.0), layout.y.unwrap_or(0.0)] |
| 26 | } |
| 27 | |
| 28 | /// `[x0, y0, x1, y1]` moved by `[x, y]`. |
| 29 | pub(crate) fn translated([x0, y0, x1, y1]: [f32; 4], [x, y]: [f32; 2]) -> [f32; 4] { |
| 30 | [x0 + x, y0 + y, x1 + x, y1 + y] |
| 31 | } |
| 32 | |
| 33 | /// Parley's caret affinity mapped onto the page model's hidden-field affinity. |
| 34 | pub fn affinity(affinity: parley::Affinity) -> onestore::page::text::Affinity { |
| 35 | match affinity { |
| 36 | parley::Affinity::Upstream => onestore::page::text::Affinity::Upstream, |
| 37 | parley::Affinity::Downstream => onestore::page::text::Affinity::Downstream, |
| 38 | } |
| 39 | } |