Skip to main content

ferroui_pretext_layout/
layout_primitives.rs

1/// Aggregate geometry of wrapped text.
2#[derive(Clone, Copy, Debug, Default, PartialEq)]
3pub struct WrapMetrics {
4    pub line_count: usize,
5    pub height: f64,
6    pub max_line_width: f64,
7}
8
9#[derive(Clone, Debug, PartialEq)]
10pub struct PositionedLine {
11    pub text: String,
12    pub x: f64,
13    pub y: f64,
14    pub width: f64,
15}
16
17#[derive(Clone, Copy, Debug, Default, PartialEq)]
18pub struct RectObstacle {
19    pub x: f64,
20    pub y: f64,
21    pub width: f64,
22    pub height: f64,
23}
24
25impl RectObstacle {
26    pub fn right(self) -> f64 {
27        self.x + self.width
28    }
29
30    pub fn bottom(self) -> f64 {
31        self.y + self.height
32    }
33}
34
35/// A circle whose `x` and `y` identify the center.
36#[derive(Clone, Copy, Debug, Default, PartialEq)]
37pub struct CircleObstacle {
38    pub x: f64,
39    pub y: f64,
40    pub radius: f64,
41}
42
43#[derive(Clone, Copy, Debug, Default, PartialEq)]
44pub struct Interval {
45    pub left: f64,
46    pub right: f64,
47}
48
49impl Interval {
50    pub fn width(self) -> f64 {
51        self.right - self.left
52    }
53}