summaryrefslogtreecommitdiff
path: root/src/layout/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-10-12 17:10:01 +0200
committerLaurenz <laurmaedje@gmail.com>2020-10-12 17:10:01 +0200
commit38157b0e0cbab22dc3f5fa5cc66d9b673a18a55b (patch)
tree967dab30f04537b93126586dbb7f7b0d166290e4 /src/layout/mod.rs
parente94627721db89c3b08aa17f54d59d19a09f7816f (diff)
Synchronous layout 🪀
Diffstat (limited to 'src/layout/mod.rs')
-rw-r--r--src/layout/mod.rs19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index a6ef4300..643f1a43 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -9,8 +9,6 @@ mod spacing;
mod stack;
mod text;
-use async_trait::async_trait;
-
use crate::font::SharedFontLoader;
use crate::geom::*;
use crate::shaping::Shaped;
@@ -25,9 +23,9 @@ pub use stack::*;
pub use text::*;
/// Layout a document and return the produced layouts.
-pub async fn layout(document: &Document, loader: SharedFontLoader) -> Vec<BoxLayout> {
+pub fn layout(document: &Document, loader: SharedFontLoader) -> Vec<BoxLayout> {
let mut ctx = LayoutContext { loader };
- document.layout(&mut ctx).await
+ document.layout(&mut ctx)
}
/// The context for layouting.
@@ -38,20 +36,9 @@ pub struct LayoutContext {
}
/// Layout a node.
-#[async_trait(?Send)]
pub trait Layout {
/// Layout the node in the given layout context.
- ///
- /// This signature looks pretty horrible due to async in trait methods, but
- /// it's actually just the following:
- /// ```rust,ignore
- /// async fn layout(
- /// &self,
- /// ctx: &mut LayoutContext,
- /// constraints: LayoutConstraints,
- /// ) -> Vec<LayoutItem>;
- /// ```
- async fn layout(&self, ctx: &mut LayoutContext, areas: &Areas) -> Vec<Layouted>;
+ fn layout(&self, ctx: &mut LayoutContext, areas: &Areas) -> Vec<Layouted>;
}
/// A sequence of areas to layout into.