Skip to main content

flowsurface_data/
config.rs

1use serde::{Deserialize, Serialize};
2
3pub mod auth;
4pub mod network;
5pub mod sidebar;
6pub mod state;
7pub mod theme;
8pub mod timezone;
9
10pub const MIN_SCALE: f32 = 0.8;
11pub const MAX_SCALE: f32 = 1.5;
12
13#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq)]
14pub struct ScaleFactor(f32);
15
16impl Default for ScaleFactor {
17    fn default() -> Self {
18        Self(1.0)
19    }
20}
21
22impl From<f32> for ScaleFactor {
23    fn from(value: f32) -> Self {
24        ScaleFactor(value.clamp(MIN_SCALE, MAX_SCALE))
25    }
26}
27
28impl From<ScaleFactor> for f32 {
29    fn from(value: ScaleFactor) -> Self {
30        value.0
31    }
32}