summaryrefslogtreecommitdiff
path: root/src/layout/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-10-03 13:23:59 +0200
committerLaurenz <laurmaedje@gmail.com>2020-10-03 13:23:59 +0200
commit0fc25d732d7cbc37cf801645849d1060f2cec4a3 (patch)
tree706aa8d1bf4135d1dd3ac17a5023bc5e24ded69d /src/layout/mod.rs
parent8dbc5b60cc4a88f68ee82607af3a3c454cd8f68b (diff)
Port to kurbo 🎋
Diffstat (limited to 'src/layout/mod.rs')
-rw-r--r--src/layout/mod.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index fcaab372..11c03b0b 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -10,9 +10,10 @@ mod tree;
pub use primitive::*;
pub use tree::layout_tree as layout;
+use crate::geom::{Insets, Point, Rect, RectExt, Sides, Size, SizeExt};
+
use crate::eval::Scope;
use crate::font::SharedFontLoader;
-use crate::geom::{Margins, Size};
use crate::style::{LayoutStyle, PageStyle, TextStyle};
use crate::syntax::SynTree;
@@ -67,22 +68,21 @@ pub struct LayoutSpace {
/// The maximum size of the rectangle to layout into.
pub size: Size,
/// Padding that should be respected on each side.
- pub padding: Margins,
+ pub insets: Insets,
/// Whether to expand the size of the resulting layout to the full size of
/// this space or to shrink it to fit the content.
pub expansion: LayoutExpansion,
}
impl LayoutSpace {
- /// The offset from the origin to the start of content, i.e.
- /// `(padding.left, padding.top)`.
- pub fn start(&self) -> Size {
- Size::new(self.padding.left, self.padding.top)
+ /// The position of the padded start in the space.
+ pub fn start(&self) -> Point {
+ Point::new(-self.insets.x0, -self.insets.y0)
}
/// The actually usable area (size minus padding).
pub fn usable(&self) -> Size {
- self.size.unpadded(self.padding)
+ self.size + self.insets.size()
}
/// The inner layout space with size reduced by the padding, zero padding of
@@ -90,7 +90,7 @@ impl LayoutSpace {
pub fn inner(&self) -> Self {
Self {
size: self.usable(),
- padding: Margins::ZERO,
+ insets: Insets::ZERO,
expansion: LayoutExpansion::new(false, false),
}
}