From 6cc2d5a7218337dfe457aedd9e1a8facf9f157ff Mon Sep 17 00:00:00 2001 From: Vulae Date: Sun, 4 Aug 2024 14:54:09 -0500 Subject: [PATCH] add catppuccin_egui themes --- Cargo.lock | 157 +++++++++++++++++++++++++++++++++++++++++++++---- Cargo.toml | 2 + src/app/app.rs | 8 +++ 3 files changed, 156 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9fa1e87..8f940e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -95,6 +95,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "ahash" version = "0.8.11" @@ -825,6 +836,15 @@ dependencies = [ "wayland-client", ] +[[package]] +name = "catppuccin-egui" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b812fd8e72d65e1afefd7c96ca4c919fe4dc34d470aed2cf459acbcb1cd8f64e" +dependencies = [ + "egui", +] + [[package]] name = "cc" version = "1.1.6" @@ -1104,6 +1124,28 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" +[[package]] +name = "dark-light" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a76fa97167fa740dcdbfe18e8895601e1bc36525f09b044e00916e717c03a3c" +dependencies = [ + "dconf_rs", + "detect-desktop-environment", + "dirs", + "objc", + "rust-ini", + "web-sys", + "winreg", + "zbus 4.4.0", +] + +[[package]] +name = "dconf_rs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7046468a81e6a002061c01e6a7c83139daf91b11c30e66795b13217c2d885c8b" + [[package]] name = "derivative" version = "2.2.0" @@ -1115,6 +1157,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "detect-desktop-environment" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21d8ad60dd5b13a4ee6bd8fa2d5d88965c597c67bce32b5fc49c94f55cb50810" + [[package]] name = "digest" version = "0.10.7" @@ -1125,6 +1173,26 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -1140,6 +1208,12 @@ dependencies = [ "libloading 0.8.5", ] +[[package]] +name = "dlv-list" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" + [[package]] name = "document-features" version = "0.2.10" @@ -1171,7 +1245,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6490ef800b2e41ee129b1f32f9ac15f713233fe3bc18e241a1afe1e4fb6811e0" dependencies = [ - "ahash", + "ahash 0.8.11", "bytemuck", "document-features", "egui", @@ -1207,7 +1281,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20c97e70a2768de630f161bb5392cbd3874fcf72868f14df0e002e82e06cb798" dependencies = [ "accesskit", - "ahash", + "ahash 0.8.11", "emath", "epaint", "log", @@ -1220,7 +1294,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47c7a7c707877c3362a321ebb4f32be811c0b91f7aebf345fb162405c0218b4c" dependencies = [ - "ahash", + "ahash 0.8.11", "bytemuck", "document-features", "egui", @@ -1240,7 +1314,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fac4e066af341bf92559f60dbdf2020b2a03c963415349af5f3f8d79ff7a4926" dependencies = [ "accesskit_winit", - "ahash", + "ahash 0.8.11", "arboard", "egui", "log", @@ -1257,7 +1331,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e2bdc8b38cfa17cc712c4ae079e30c71c00cd4c2763c9e16dc7860a02769103" dependencies = [ - "ahash", + "ahash 0.8.11", "bytemuck", "egui", "glow", @@ -1340,7 +1414,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f0dcc0a0771e7500e94cd1cb797bd13c9f23b9409bdc3c824e2cbc562b7fa01" dependencies = [ "ab_glyph", - "ahash", + "ahash 0.8.11", "bytemuck", "ecolor", "emath", @@ -1762,7 +1836,7 @@ checksum = "9c08c1f623a8d0b722b8b99f821eb0ba672a1618f0d3b16ddbee1cedd2dd8557" dependencies = [ "bitflags 2.6.0", "gpu-descriptor-types", - "hashbrown", + "hashbrown 0.14.5", ] [[package]] @@ -1784,13 +1858,22 @@ dependencies = [ "crunchy", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.8", +] + [[package]] name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash", + "ahash 0.8.11", "allocator-api2", ] @@ -1921,7 +2004,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.14.5", ] [[package]] @@ -2087,6 +2170,16 @@ dependencies = [ "redox_syscall 0.4.1", ] +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + [[package]] name = "linux-raw-sys" version = "0.3.8" @@ -2570,7 +2663,17 @@ version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166" dependencies = [ - "libredox", + "libredox 0.0.2", +] + +[[package]] +name = "ordered-multimap" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" +dependencies = [ + "dlv-list", + "hashbrown 0.12.3", ] [[package]] @@ -2942,6 +3045,17 @@ dependencies = [ "bitflags 2.6.0", ] +[[package]] +name = "redox_users" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +dependencies = [ + "getrandom", + "libredox 0.1.3", + "thiserror", +] + [[package]] name = "regex" version = "1.10.5" @@ -3009,6 +3123,16 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "rust-ini" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" +dependencies = [ + "cfg-if", + "ordered-multimap", +] + [[package]] name = "rustc-hash" version = "1.1.0" @@ -3602,7 +3726,9 @@ version = "0.1.0" dependencies = [ "anyhow", "bitflags 2.6.0", + "catppuccin-egui", "clap", + "dark-light", "eframe", "egui", "env_logger", @@ -4340,7 +4466,7 @@ version = "0.29.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d59ad965a635657faf09c8f062badd885748428933dad8e8bdd64064d92e5ca" dependencies = [ - "ahash", + "ahash 0.8.11", "android-activity", "atomic-waker", "bitflags 2.6.0", @@ -4401,6 +4527,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + [[package]] name = "winresource" version = "0.1.17" diff --git a/Cargo.toml b/Cargo.toml index d965b21..bdfe983 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,9 @@ edition = "2021" [dependencies] anyhow = "1.0.86" bitflags = "2.6.0" +catppuccin-egui = { version = "5.2.0", default-features = false, features = ["egui28"] } clap = { version = "4.5.11", features = ["derive"] } +dark-light = "1.1.1" eframe = "0.28.1" egui = "0.28.1" env_logger = { version = "0.11.5", features = ["auto-color", "humantime"] } diff --git a/src/app/app.rs b/src/app/app.rs index acd1fa1..27a3fdd 100644 --- a/src/app/app.rs +++ b/src/app/app.rs @@ -113,6 +113,14 @@ impl SharedAppContext { impl eframe::App for SharedAppContext { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { + + // TODO: Add config.toml with theme selection. (& with custom theme with catppuccin_egui::Theme) + catppuccin_egui::set_theme(ctx, match dark_light::detect() { + dark_light::Mode::Dark => catppuccin_egui::MOCHA, + dark_light::Mode::Light => catppuccin_egui::LATTE, + dark_light::Mode::Default => catppuccin_egui::MOCHA, + }); + self.app_context.borrow_mut().auto_focus_new_explorers = !ctx.input(|i| i.modifiers.shift); let files = ctx.input(|i| i.raw.dropped_files.clone());