flowsurface_data/
layout.rs

1pub use dashboard::Dashboard;
2pub use pane::Pane;
3use serde::{Deserialize, Serialize};
4
5pub mod dashboard;
6pub mod pane;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct Layout {
10    pub name: String,
11    pub dashboard: Dashboard,
12}
13
14impl Default for Layout {
15    fn default() -> Self {
16        Self {
17            name: "Default".to_string(),
18            dashboard: Dashboard::default(),
19        }
20    }
21}
22
23#[derive(Debug, Clone, Copy, Deserialize, Serialize)]
24pub struct Window<T = f32> {
25    pub width: T,
26    pub height: T,
27    pub pos_x: T,
28    pub pos_y: T,
29}
30
31impl<T: Copy> Window<T> {
32    pub fn size(&self) -> iced_core::Size<T> {
33        iced_core::Size {
34            width: self.width,
35            height: self.height,
36        }
37    }
38
39    pub fn position(&self) -> iced_core::Point<T> {
40        iced_core::Point {
41            x: self.pos_x,
42            y: self.pos_y,
43        }
44    }
45}
46
47impl Default for Window<f32> {
48    fn default() -> Self {
49        Self {
50            width: 1024.0,
51            height: 768.0,
52            pos_x: 0.0,
53            pos_y: 0.0,
54        }
55    }
56}
57
58pub type WindowSpec = Window<f32>;
59
60impl From<(&iced_core::Point, &iced_core::Size)> for WindowSpec {
61    fn from((point, size): (&iced_core::Point, &iced_core::Size)) -> Self {
62        Self {
63            width: size.width,
64            height: size.height,
65            pos_x: point.x,
66            pos_y: point.y,
67        }
68    }
69}