build: use the masi/craft-libs fork; take the Catppuccin palette from craft-ui
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Generated
+1
-1
@@ -1132,7 +1132,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=5c874d51eeb3de70e735c8ce87a59a7dedd47675#5c874d51eeb3de70e735c8ce87a59a7dedd47675"
|
||||
source = "git+https://git.marcospaulo.dev.br/masi/craft-libs?rev=22544b6d619d4f16779b8bdfa3f0b642a86fc065#22544b6d619d4f16779b8bdfa3f0b642a86fc065"
|
||||
dependencies = [
|
||||
"egui",
|
||||
"serde",
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
|
||||
rust-version = "1.95"
|
||||
|
||||
[workspace.dependencies]
|
||||
craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "5c874d51eeb3de70e735c8ce87a59a7dedd47675", features = ["serde"] }
|
||||
craft-ui = { git = "https://git.marcospaulo.dev.br/masi/craft-libs", rev = "22544b6d619d4f16779b8bdfa3f0b642a86fc065", features = ["serde"] }
|
||||
# internal
|
||||
photocraft-geom = { path = "crates/geom" }
|
||||
photocraft-color = { path = "crates/color" }
|
||||
|
||||
@@ -1,128 +1,53 @@
|
||||
//! Catppuccin Latte, Frappé, Macchiato and Mocha on the Studio layout. Palette: the Catppuccin
|
||||
//! project's colours (https://catppuccin.com/palette, MIT; see LICENSE-catppuccin.txt), accent Mauve.
|
||||
|
||||
use craft_ui::theme::catppuccin::Flavor;
|
||||
use egui::Color32;
|
||||
|
||||
use crate::theme::{ThemeKind, Tokens};
|
||||
|
||||
/// The Catppuccin colours these themes use, as 0xRRGGBB.
|
||||
struct Palette {
|
||||
text: u32,
|
||||
subtext1: u32,
|
||||
subtext0: u32,
|
||||
overlay1: u32,
|
||||
surface1: u32,
|
||||
surface0: u32,
|
||||
base: u32,
|
||||
mantle: u32,
|
||||
crust: u32,
|
||||
mauve: u32,
|
||||
red: u32,
|
||||
yellow: u32,
|
||||
}
|
||||
|
||||
const LATTE: Palette = Palette {
|
||||
text: 0x4c4f69,
|
||||
subtext1: 0x5c5f77,
|
||||
subtext0: 0x6c6f85,
|
||||
overlay1: 0x8c8fa1,
|
||||
surface1: 0xbcc0cc,
|
||||
surface0: 0xccd0da,
|
||||
base: 0xeff1f5,
|
||||
mantle: 0xe6e9ef,
|
||||
crust: 0xdce0e8,
|
||||
mauve: 0x8839ef,
|
||||
red: 0xd20f39,
|
||||
yellow: 0xdf8e1d,
|
||||
};
|
||||
const FRAPPE: Palette = Palette {
|
||||
text: 0xc6d0f5,
|
||||
subtext1: 0xb5bfe2,
|
||||
subtext0: 0xa5adce,
|
||||
overlay1: 0x838ba7,
|
||||
surface1: 0x51576d,
|
||||
surface0: 0x414559,
|
||||
base: 0x303446,
|
||||
mantle: 0x292c3c,
|
||||
crust: 0x232634,
|
||||
mauve: 0xca9ee6,
|
||||
red: 0xe78284,
|
||||
yellow: 0xe5c890,
|
||||
};
|
||||
const MACCHIATO: Palette = Palette {
|
||||
text: 0xcad3f5,
|
||||
subtext1: 0xb8c0e0,
|
||||
subtext0: 0xa5adcb,
|
||||
overlay1: 0x8087a2,
|
||||
surface1: 0x494d64,
|
||||
surface0: 0x363a4f,
|
||||
base: 0x24273a,
|
||||
mantle: 0x1e2030,
|
||||
crust: 0x181926,
|
||||
mauve: 0xc6a0f6,
|
||||
red: 0xed8796,
|
||||
yellow: 0xeed49f,
|
||||
};
|
||||
const MOCHA: Palette = Palette {
|
||||
text: 0xcdd6f4,
|
||||
subtext1: 0xbac2de,
|
||||
subtext0: 0xa6adc8,
|
||||
overlay1: 0x7f849c,
|
||||
surface1: 0x45475a,
|
||||
surface0: 0x313244,
|
||||
base: 0x1e1e2e,
|
||||
mantle: 0x181825,
|
||||
crust: 0x11111b,
|
||||
mauve: 0xcba6f7,
|
||||
red: 0xf38ba8,
|
||||
yellow: 0xf9e2af,
|
||||
};
|
||||
|
||||
fn c(rgb: u32) -> Color32 {
|
||||
Color32::from_rgb((rgb >> 16) as u8, (rgb >> 8) as u8, rgb as u8)
|
||||
}
|
||||
|
||||
fn soft(rgb: u32, alpha: u8) -> Color32 {
|
||||
Color32::from_rgba_unmultiplied((rgb >> 16) as u8, (rgb >> 8) as u8, rgb as u8, alpha)
|
||||
fn soft(c: Color32, alpha: u8) -> Color32 {
|
||||
Color32::from_rgba_unmultiplied(c.r(), c.g(), c.b(), alpha)
|
||||
}
|
||||
|
||||
/// Tokens for a Catppuccin kind. Any other kind falls back to Mocha (never reached: `for_kind` only routes these four here).
|
||||
pub(crate) fn tokens(kind: ThemeKind) -> Tokens {
|
||||
let (p, light) = match kind {
|
||||
ThemeKind::CatppuccinLatte => (&LATTE, true),
|
||||
ThemeKind::CatppuccinFrappe => (&FRAPPE, false),
|
||||
ThemeKind::CatppuccinMacchiato => (&MACCHIATO, false),
|
||||
_ => (&MOCHA, false),
|
||||
let f = match kind {
|
||||
ThemeKind::CatppuccinLatte => Flavor::Latte,
|
||||
ThemeKind::CatppuccinFrappe => Flavor::Frappe,
|
||||
ThemeKind::CatppuccinMacchiato => Flavor::Macchiato,
|
||||
_ => Flavor::Mocha,
|
||||
};
|
||||
let (p, light) = (f.palette(), !f.is_dark());
|
||||
// Dark flavours step up from the darkest surface; Latte steps down from the lightest.
|
||||
let (canvas, chrome, dock, hover, pressed) =
|
||||
if light { (p.crust, p.base, p.mantle, p.crust, p.surface0) } else { (p.base, p.mantle, p.crust, p.surface0, p.surface1) };
|
||||
Tokens {
|
||||
kind,
|
||||
chrome: c(chrome),
|
||||
canvas: c(canvas),
|
||||
canvas_dot: c(p.surface0),
|
||||
dock: c(dock),
|
||||
card: c(chrome),
|
||||
card_border: c(if light { p.surface0 } else { p.crust }),
|
||||
field: c(dock),
|
||||
field_border: c(p.surface1),
|
||||
hover: c(hover),
|
||||
pressed: c(pressed),
|
||||
text: c(p.text),
|
||||
text_dim: c(p.subtext0),
|
||||
text_faint: c(p.overlay1),
|
||||
icon: c(p.subtext1),
|
||||
accent: c(p.mauve),
|
||||
chrome,
|
||||
canvas,
|
||||
canvas_dot: p.surface0,
|
||||
dock,
|
||||
card: chrome,
|
||||
card_border: if light { p.surface0 } else { p.crust },
|
||||
field: dock,
|
||||
field_border: p.surface1,
|
||||
hover,
|
||||
pressed,
|
||||
text: p.text,
|
||||
text_dim: p.subtext0,
|
||||
text_faint: p.overlay1,
|
||||
icon: p.subtext1,
|
||||
accent: p.mauve,
|
||||
accent_soft: soft(p.mauve, if light { 40 } else { 46 }),
|
||||
accent_border: soft(p.mauve, if light { 130 } else { 120 }),
|
||||
accent_text: c(if light { p.mauve } else { p.text }),
|
||||
separator: c(if light { p.surface0 } else { p.crust }),
|
||||
accent_text: if light { p.mauve } else { p.text },
|
||||
separator: if light { p.surface0 } else { p.crust },
|
||||
shadow: Color32::from_black_alpha(if light { 45 } else { 150 }),
|
||||
primary_bg: c(p.mauve),
|
||||
primary_text: c(if light { p.base } else { p.crust }),
|
||||
danger: c(p.red),
|
||||
warning: c(p.yellow),
|
||||
primary_bg: p.mauve,
|
||||
primary_text: if light { p.base } else { p.crust },
|
||||
danger: p.red,
|
||||
warning: p.yellow,
|
||||
radius_sm: 6.0,
|
||||
radius: 8.0,
|
||||
radius_lg: 12.0,
|
||||
@@ -131,10 +56,10 @@ pub(crate) fn tokens(kind: ThemeKind) -> Tokens {
|
||||
round_chips: true,
|
||||
tab_strip: Color32::TRANSPARENT,
|
||||
row_selected: Color32::TRANSPARENT,
|
||||
histogram_bg: if light { Color32::from_gray(40) } else { c(p.base) },
|
||||
histogram_bg: if light { Color32::from_gray(40) } else { p.base },
|
||||
histogram_level: if light { 240 } else { 225 },
|
||||
caption_close: c(p.red),
|
||||
caption_close_text: c(if light { p.base } else { p.crust }),
|
||||
caption_close: p.red,
|
||||
caption_close_text: if light { p.base } else { p.crust },
|
||||
scrim: Color32::from_black_alpha(110),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user