From f8009b5b59660b8252bd3ee2cedfd234a1c30cb1 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 27 May 2022 14:33:00 +0200 Subject: Reuse location type --- src/model/locate.rs | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'src/model') diff --git a/src/model/locate.rs b/src/model/locate.rs index 05204d2e..c61facc5 100644 --- a/src/model/locate.rs +++ b/src/model/locate.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use super::Content; use crate::diag::TypResult; use crate::eval::{Args, Array, Dict, Func, Value}; -use crate::frame::{Element, Frame}; +use crate::frame::{Element, Frame, Location}; use crate::geom::{Point, Transform}; use crate::syntax::Spanned; use crate::util::EcoString; @@ -296,7 +296,7 @@ fn locate_in_frame( } /// A document pin. -#[derive(Debug, Default, Clone, PartialEq, Hash)] +#[derive(Debug, Clone, PartialEq, Hash)] pub struct Pin { /// The physical location of the pin in the document. loc: Location, @@ -330,22 +330,13 @@ impl Pin { } } -/// A physical location in a document. -#[derive(Debug, Default, Copy, Clone, PartialEq, Hash)] -struct Location { - /// The page, starting at 1. - page: usize, - /// The exact coordinates on the page (from the top left, as usual). - pos: Point, -} - -impl Location { - /// Encode into a user-facing dictionary. - fn encode(&self) -> Dict { - dict! { - "page" => Value::Int(self.page as i64), - "x" => Value::Length(self.pos.x.into()), - "y" => Value::Length(self.pos.y.into()), +impl Default for Pin { + fn default() -> Self { + Self { + loc: Location { page: 0, pos: Point::zero() }, + flow: 0, + group: None, + value: None, } } } -- cgit v1.2.3