| Add generics; transpile the part of cosmic-theme that is reachable ff34e1b nandithebull 17h ago | 1 | // cosmic-theme 1.0.0, the part of it that does not depend on `palette`. |
| 2 | // |
| 3 | // `corner.rs`, `spacing.rs` and `layout.rs` are the crate's own files, |
| 4 | // byte-for-byte. They are the spacing scale, corner radii and density model |
| 5 | // that a COSMIC-native UI needs in order to match the desktop. The rest of |
| 6 | // cosmic-theme is colour work built on `palette` (40,874 lines, plus a |
| 7 | // proc-macro crate), which is out of reach. |
| 8 | |
| 9 | mod corner; |
| 10 | mod layout; |
| 11 | mod spacing; |
| 12 | |
| 13 | use crate::corner::{CornerRadii, Roundness}; |
| 14 | use crate::spacing::{Density, Spacing}; |
| 15 | |
| 16 | fn show_spacing(tag: &str, s: Spacing) { |
| 17 | println!( |
| 18 | "{} {} {} {} {} {} {} {} {} {} {}", |
| 19 | tag, |
| 20 | s.space_none, |
| 21 | s.space_xxxs, |
| 22 | s.space_xxs, |
| 23 | s.space_xs, |
| 24 | s.space_s, |
| 25 | s.space_m, |
| 26 | s.space_l, |
| 27 | s.space_xl, |
| 28 | s.space_xxl, |
| 29 | s.space_xxxl |
| 30 | ); |
| 31 | } |
| 32 | |
| 33 | fn show_corner(tag: &str, c: CornerRadii) { |
| 34 | println!( |
| 35 | "{} {} {} {} {} {} {}", |
| 36 | tag, c.radius_0[0], c.radius_xs[0], c.radius_s[0], c.radius_m[0], c.radius_l[0], c.radius_xl[0] |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | fn main() { |
| 41 | show_spacing("default", Spacing::default()); |
| 42 | show_spacing("compact", Spacing::from(Density::Compact)); |
| 43 | show_spacing("spacious", Spacing::from(Density::Spacious)); |
| 44 | show_spacing("standard", Spacing::from(Density::Standard)); |
| 45 | |
| 46 | // Density round-trips through Spacing. |
| 47 | for d in [Density::Compact, Density::Spacious, Density::Standard] { |
| 48 | let s: Spacing = Spacing::from(d); |
| 49 | let back: Density = Density::from(s); |
| 50 | println!("roundtrip {:?} -> {:?}", d, back); |
| 51 | } |
| 52 | |
| 53 | show_corner("default", CornerRadii::default()); |
| 54 | for r in [Roundness::Round, Roundness::SlightlyRound, Roundness::Square] { |
| 55 | let c: CornerRadii = CornerRadii::from(r); |
| 56 | let back: Roundness = Roundness::from(c); |
| 57 | println!("corner {:?} -> {:?}", r, back); |
| 58 | show_corner(" radii", CornerRadii::from(r)); |
| 59 | } |
| 60 | } |