diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-03-19 17:57:31 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-03-19 17:57:31 +0100 |
| commit | 264a7dedd42e27cd9e604037640cf0594b2ec46b (patch) | |
| tree | d26feea399d54bb86bd44878f40293983bf5251d /src/library/image.rs | |
| parent | ca3df70e2a5069832d7d2135967674c34a155442 (diff) | |
Scheduled maintenance 🔨
- New naming scheme
- TextNode instead of NodeText
- CallExpr instead of ExprCall
- ...
- Less glob imports
- Removes Value::Args variant
- Removes prelude
- Renames Layouted to Fragment
- Moves font into env
- Moves shaping into layout
- Moves frame into separate module
Diffstat (limited to 'src/library/image.rs')
| -rw-r--r-- | src/library/image.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/library/image.rs b/src/library/image.rs index c3200e93..8cb09463 100644 --- a/src/library/image.rs +++ b/src/library/image.rs @@ -2,7 +2,9 @@ use ::image::GenericImageView; use super::*; use crate::env::{ImageResource, ResourceId}; -use crate::layout::*; +use crate::layout::{ + AnyNode, Areas, Element, Fragment, Frame, Image, Layout, LayoutContext, +}; /// `image`: Insert an image. /// @@ -13,7 +15,7 @@ use crate::layout::*; /// /// # Return value /// A template that inserts an image. -pub fn image(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value { +pub fn image(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { let path = args.require::<Spanned<String>>(ctx, "path to image file"); let width = args.get(ctx, "width"); let height = args.get(ctx, "height"); @@ -53,7 +55,7 @@ struct NodeImage { } impl Layout for NodeImage { - fn layout(&self, _: &mut LayoutContext, areas: &Areas) -> Layouted { + fn layout(&self, _: &mut LayoutContext, areas: &Areas) -> Fragment { let Areas { current, full, .. } = areas; let pixel_width = self.dimensions.0 as f64; @@ -84,11 +86,11 @@ impl Layout for NodeImage { let mut frame = Frame::new(size); frame.push(Point::ZERO, Element::Image(Image { res: self.res, size })); - Layouted::Frame(frame, self.aligns) + Fragment::Frame(frame, self.aligns) } } -impl From<NodeImage> for NodeAny { +impl From<NodeImage> for AnyNode { fn from(image: NodeImage) -> Self { Self::new(image) } |
