| 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 | #[cfg(feature = "gpu")] |
| 23 | pub mod site; |
| 24 | |
| 25 | /// Points in the half inch rule line spacings are stored in. |
| 26 | pub(crate) const HALF_INCH: f32 = 36.0; |
| 27 | /// How thick rule lines draw at the least, in points. |
| 28 | pub(crate) const RULE_WIDTH: f32 = 0.75; |
| 29 | /// How far left of the margin origin a page's margin rule runs, in points. |
| 30 | pub(crate) const MARGIN_RULE: f32 = 0.75; |
| 31 | |
| 32 | /// Where an object stored with `layout` lies; an unset coordinate is zero. |
| 33 | pub(crate) fn origin(layout: &onestore::document::Layout) -> [f32; 2] { |
| 34 | [layout.x.unwrap_or(0.0), layout.y.unwrap_or(0.0)] |
| 35 | } |
| 36 | |
| 37 | /// `[x0, y0, x1, y1]` moved by `[x, y]`. |
| 38 | pub(crate) fn translated([x0, y0, x1, y1]: [f32; 4], [x, y]: [f32; 2]) -> [f32; 4] { |
| 39 | [x0 + x, y0 + y, x1 + x, y1 + y] |
| 40 | } |
| 41 | |
| 42 | /// Parley's caret affinity mapped onto the page model's hidden-field affinity. |
| 43 | pub fn affinity(affinity: parley::Affinity) -> onestore::page::text::Affinity { |
| 44 | match affinity { |
| 45 | parley::Affinity::Upstream => onestore::page::text::Affinity::Upstream, |
| 46 | parley::Affinity::Downstream => onestore::page::text::Affinity::Downstream, |
| 47 | } |
| 48 | } |