diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-19 13:05:54 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-19 13:05:54 +0200 |
| commit | ee38c6aa9adefe4ca3ddc4aef22a216d7fb4c048 (patch) | |
| tree | 47aeb7f620785c59cd0436adb929436b4aa98955 /src/eval/mod.rs | |
| parent | 91e512069396f1de616ec2b0fe0cd31a76e7f2e9 (diff) | |
Allow configuration of directions in page and box ↗
Diffstat (limited to 'src/eval/mod.rs')
| -rw-r--r-- | src/eval/mod.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/eval/mod.rs b/src/eval/mod.rs index 2cff835b..5a8b857a 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -22,7 +22,7 @@ use fontdock::FontStyle; use crate::diag::Diag; use crate::diag::{Deco, Feedback, Pass}; -use crate::geom::{BoxAlign, Flow, Gen, Length, Linear, Relative, Sides, Size}; +use crate::geom::{BoxAlign, Dir, Flow, Gen, Length, Linear, Relative, Sides, Size}; use crate::layout::{ Document, Expansion, LayoutNode, Pad, Pages, Par, Softness, Spacing, Stack, Text, }; @@ -223,6 +223,23 @@ impl EvalContext { (group, std::mem::replace(&mut self.inner, outer)) } + /// Updates the flow directions if the resulting main and cross directions + /// apply to different axes. Generates an appropriate error, otherwise. + pub fn set_flow(&mut self, new: Gen<Option<Spanned<Dir>>>) { + let flow = Gen::new( + new.main.map(|s| s.v).unwrap_or(self.state.flow.main), + new.cross.map(|s| s.v).unwrap_or(self.state.flow.cross), + ); + + if flow.main.axis() != flow.cross.axis() { + self.state.flow = flow; + } else { + for dir in new.main.iter().chain(new.cross.iter()) { + self.diag(error!(dir.span, "aligned axis")); + } + } + } + /// Construct a text node from the given string based on the active text /// state. pub fn make_text_node(&self, text: String) -> Text { |
