summaryrefslogtreecommitdiff
path: root/src/layout/mod.rs
diff options
context:
space:
mode:
authorLaurenz Mädje <laurmaedje@gmail.com>2019-06-02 18:01:22 +0200
committerLaurenz Mädje <laurmaedje@gmail.com>2019-06-02 18:01:22 +0200
commit221934df4b586250b0063282ef8885c475dec7a7 (patch)
treeea91eb6fe6fbad71377f2dbf1c23a3a808dbf970 /src/layout/mod.rs
parentc4eb4ee36261be8832b2649cc075edee188be5c7 (diff)
Add margins with basic box layouter 📖
Diffstat (limited to 'src/layout/mod.rs')
-rw-r--r--src/layout/mod.rs17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index edcd63a7..ab27314d 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -6,9 +6,11 @@ use crate::syntax::{SyntaxTree, Node};
mod size;
mod text;
+mod boxed;
-pub use size::Size;
+pub use size::{Size, Position, Extent};
pub use text::TextLayouter;
+pub use boxed::BoxLayouter;
/// Layout a syntax tree in a given context.
@@ -44,7 +46,7 @@ pub fn layout(tree: &SyntaxTree, ctx: &LayoutContext) -> LayoutResult<Layout> {
#[derive(Debug, Clone)]
pub struct Layout {
/// The extent of this layout into all directions.
- extent: LayoutDimensions,
+ extent: Extent,
/// Actions composing this layout.
actions: Vec<TextAction>,
}
@@ -75,20 +77,11 @@ pub struct LayoutContext<'a, 'p> {
/// Loads fonts matching queries.
pub loader: &'a FontLoader<'p>,
/// The spacial constraints to layout in.
- pub max_extent: LayoutDimensions,
+ pub max_extent: Extent,
/// Base style to set text with.
pub text_style: TextStyle,
}
-/// A space to layout in.
-#[derive(Debug, Clone)]
-pub struct LayoutDimensions {
- /// Horizontal extent.
- pub width: Size,
- /// Vertical extent.
- pub height: Size,
-}
-
/// Default styles for text.
#[derive(Debug, Clone)]
pub struct TextStyle {