diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-04 23:31:35 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-04 23:31:35 +0200 |
| commit | 335fa2d118718b4dba539294a8ef6c96c5bbf09e (patch) | |
| tree | 08e48d0c18c350bc9479d0d801d2320628d8e4a2 /src/layout/line.rs | |
| parent | 605ab104c5e041c345007020d277b4c6267debe6 (diff) | |
Small improvements 🍪
Diffstat (limited to 'src/layout/line.rs')
| -rw-r--r-- | src/layout/line.rs | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/layout/line.rs b/src/layout/line.rs index 9de8348c..baef9fb0 100644 --- a/src/layout/line.rs +++ b/src/layout/line.rs @@ -12,7 +12,9 @@ use super::*; /// Performs the line layouting. pub struct LineLayouter { + /// The context used for line layouting. ctx: LineContext, + /// The underlying layouter that stacks the finished lines. stack: StackLayouter, /// The in-progress line. run: LineRun, @@ -36,27 +38,6 @@ pub struct LineContext { pub line_spacing: f64, } -/// A sequence of boxes with the same alignment. A real line can consist of -/// multiple runs with different alignments. -struct LineRun { - /// The so-far accumulated items of the run. - layouts: Vec<(f64, BoxLayout)>, - /// The summed width and maximal height of the run. - size: Size, - /// The alignment of all layouts in the line. - /// - /// When a new run is created the alignment is yet to be determined and - /// `None` as such. Once a layout is added, its alignment decides the - /// alignment for the whole run. - align: Option<LayoutAlign>, - /// The amount of space left by another run on the same line or `None` if - /// this is the only run so far. - usable: Option<f64>, - /// The spacing state. This influences how new spacing is handled, e.g. hard - /// spacing may override soft spacing. - last_spacing: LastSpacing, -} - impl LineLayouter { /// Create a new line layouter. pub fn new(ctx: LineContext) -> Self { @@ -259,6 +240,27 @@ impl LineLayouter { } } +/// A sequence of boxes with the same alignment. A real line can consist of +/// multiple runs with different alignments. +struct LineRun { + /// The so-far accumulated items of the run. + layouts: Vec<(f64, BoxLayout)>, + /// The summed width and maximal height of the run. + size: Size, + /// The alignment of all layouts in the line. + /// + /// When a new run is created the alignment is yet to be determined and + /// `None` as such. Once a layout is added, its alignment decides the + /// alignment for the whole run. + align: Option<LayoutAlign>, + /// The amount of space left by another run on the same line or `None` if + /// this is the only run so far. + usable: Option<f64>, + /// The spacing state. This influences how new spacing is handled, e.g. hard + /// spacing may override soft spacing. + last_spacing: LastSpacing, +} + impl LineRun { fn new() -> Self { Self { |
