diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-08-02 22:05:49 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-08-02 22:05:49 +0200 |
| commit | 266d457292e7461d448f9141030028ea68b573d1 (patch) | |
| tree | ff3ff3cc289d34040db421b6a7faa1f2aa402b05 /src/style.rs | |
| parent | cbbc46215fe0a0ad8a50e991ec442890b8eadc0a (diff) | |
Refactor model into tree 🛒
Diffstat (limited to 'src/style.rs')
| -rw-r--r-- | src/style.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/style.rs b/src/style.rs index 0490ef07..9dce381e 100644 --- a/src/style.rs +++ b/src/style.rs @@ -97,7 +97,7 @@ pub struct PageStyle { /// The class of this page. pub class: PaperClass, /// The width and height of the page. - pub dimensions: Size, + pub size: Size, /// The amount of white space on each side. If a side is set to `None`, the /// default for the paper class is used. pub margins: Value4<Option<ScaleLength>>, @@ -108,21 +108,20 @@ impl PageStyle { pub fn new(paper: Paper) -> PageStyle { PageStyle { class: paper.class, - dimensions: paper.size(), + size: paper.size(), margins: Value4::with_all(None), } } /// The absolute margins. pub fn margins(&self) -> Margins { - let dims = self.dimensions; + let size = self.size; let default = self.class.default_margins(); - Margins { - left: self.margins.left.unwrap_or(default.left).raw_scaled(dims.x), - top: self.margins.top.unwrap_or(default.top).raw_scaled(dims.y), - right: self.margins.right.unwrap_or(default.right).raw_scaled(dims.x), - bottom: self.margins.bottom.unwrap_or(default.bottom).raw_scaled(dims.y), + left: self.margins.left.unwrap_or(default.left).raw_scaled(size.x), + top: self.margins.top.unwrap_or(default.top).raw_scaled(size.y), + right: self.margins.right.unwrap_or(default.right).raw_scaled(size.x), + bottom: self.margins.bottom.unwrap_or(default.bottom).raw_scaled(size.y), } } } |
