svg_fmt/
layout.rs

1use crate::svg::{rectangle, Rectangle};
2
3#[derive(Copy, Clone, Debug)]
4pub struct VerticalLayout {
5    pub x: f32,
6    pub y: f32,
7    pub start_y: f32,
8    pub width: f32,
9}
10
11impl VerticalLayout {
12    pub fn new(x: f32, y: f32, width: f32) -> Self {
13        VerticalLayout {
14            x,
15            y,
16            start_y: y,
17            width,
18        }
19    }
20
21    pub fn advance(&mut self, by: f32) {
22        self.y += by;
23    }
24
25    pub fn push_rectangle(&mut self, height: f32) -> Rectangle {
26        let rect = rectangle(self.x, self.y, self.width, height);
27
28        self.y += height;
29
30        rect
31    }
32
33    pub fn total_rectangle(&self) -> Rectangle {
34        rectangle(self.x, self.start_y, self.width, self.y)
35    }
36
37    pub fn start_here(&mut self) {
38        self.start_y = self.y;
39    }
40}