Skip to content

Commit

Permalink
Allow (mutable) access to inline boxes within a layout
Browse files Browse the repository at this point in the history
This allows consumers of Parley to set the size of boxes before running
layout.
  • Loading branch information
nicoburns committed Jul 20, 2024
1 parent 4b3d4cc commit d8c5b7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion parley/src/layout/line/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub enum PositionedLayoutItem<'a, B: Brush> {
InlineBox(PositionedInlineBox),
}

#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct PositionedInlineBox {
pub x: f32,
pub y: f32,
Expand Down
10 changes: 9 additions & 1 deletion parley/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub mod cursor;
use self::alignment::align;

use super::style::Brush;
use crate::Font;
use crate::{Font, InlineBox};
use core::ops::Range;
use data::*;
use swash::text::cluster::{Boundary, ClusterInfo};
Expand Down Expand Up @@ -98,6 +98,14 @@ impl<B: Brush> Layout<B> {
})
}

pub fn inline_boxes(&self) -> &[InlineBox] {
&self.data.inline_boxes
}

pub fn inline_boxes_mut(&mut self) -> &mut [InlineBox] {
&mut self.data.inline_boxes
}

/// Returns an iterator over the lines in the layout.
pub fn lines(&self) -> impl Iterator<Item = Line<B>> + '_ + Clone {
self.data.lines.iter().map(move |data| Line {
Expand Down

0 comments on commit d8c5b7e

Please sign in to comment.