Skip to main content

ui/styles/
platform.rs

1/// The platform style to use when rendering UI.
2///
3/// This can be used to abstract over platform differences.
4#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
5pub enum PlatformStyle {
6    /// Display in macOS style.
7    Mac,
8    /// Display in Linux style.
9    Linux,
10    /// Display in Windows style.
11    Windows,
12}
13
14impl PlatformStyle {
15    /// Returns the [`PlatformStyle`] for the current platform.
16    pub const fn platform() -> Self {
17        if cfg!(any(target_os = "linux", target_os = "freebsd")) {
18            Self::Linux
19        } else if cfg!(target_os = "windows") {
20            Self::Windows
21        } else {
22            Self::Mac
23        }
24    }
25}