nandi/rustnimpublic Fork 0
4e4d09dcdd22d17ba510de5639fc3a952ac73f6e
Commits
Clone
git clone https://git.rickub.com/nandi/rustnim.git
git clone ssh://git@rickub.com/nandi/rustnim.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

main.rs · 60 lines · 1.9 KBRust Blame HistoryRaw
Add generics; transpile the part of cosmic-theme that is reachable ff34e1b nandithebull 14h ago1// 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
9mod corner;
10mod layout;
11mod spacing;
12
13use crate::corner::{CornerRadii, Roundness};
14use crate::spacing::{Density, Spacing};
15
16fn 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
33fn 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
40fn 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}