ui_layout/fragment.rs
1//! Fragment types for inline layout.
2//!
3//! This module defines the fragment model used for inline content layout,
4//! including splittable content fragments and control characters.
5
6/// An item fragment for inline layout.
7///
8/// Represents the smallest splittable unit of inline content or a control character.
9/// Each fragment carries size information and can be positioned independently.
10#[derive(Debug, Clone, Copy)]
11pub enum ItemFragment {
12 /// A splittable fragment of inline content with dimensions.
13 Fragment(Fragment),
14 /// A control character representing a line break.
15 LineBreak,
16}
17
18/// A splittable fragment of inline content.
19///
20/// Fragments are the smallest logical units for inline layout.
21/// They carry size information only; positional data is computed during layout.
22#[derive(Debug, Clone, Copy)]
23pub struct Fragment {
24 /// Fragment width
25 pub width: f32,
26 /// Fragment height
27 pub height: f32,
28}
29
30/// Layout result for an inline fragment placement.
31///
32/// Represents where a fragment is positioned after layout computation.
33/// Each placement corresponds 1:1 to a fragment in the input.
34#[derive(Debug, Clone, Copy, PartialEq)]
35pub struct FragmentPlacement {
36 /// Offset position (x, y) relative to the container
37 pub offset: (f32, f32),
38 /// Line index where this fragment is placed
39 pub line_index: usize,
40}