From fbac5f83a18882f14dc3d981894609d5e75cd8a8 Mon Sep 17 00:00:00 2001 From: Kai Schmidt Date: Wed, 20 Nov 2024 13:13:06 -0800 Subject: [PATCH] add icon to window --- Cargo.toml | 2 +- src/algorithm/encode.rs | 2 +- src/main.rs | 4 +--- src/window.rs | 15 ++++++++++++--- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 36f515818..902a1f1ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -153,7 +153,7 @@ terminal_image = ["viuer", "image", "icy_sixel"] tls = ["httparse", "rustls", "webpki-roots", "rustls-pemfile"] web = ["wasm-bindgen", "js-sys", "web-sys"] webcam = ["image", "uiua-nokhwa"] -window = ["eframe", "rmp-serde"] +window = ["eframe", "rmp-serde", "image"] xlsx = ["calamine", "simple_excel_writer"] # Use system static libraries instead of building them system = ["libffi?/system"] diff --git a/src/algorithm/encode.rs b/src/algorithm/encode.rs index c8630b366..7102fcc05 100644 --- a/src/algorithm/encode.rs +++ b/src/algorithm/encode.rs @@ -34,8 +34,8 @@ impl SmartOutput { } } // Try to convert the value to an image - #[cfg(feature = "image")] const MIN_AUTO_IMAGE_DIM: usize = 30; + #[cfg(feature = "image")] if let Ok(image) = value_to_image(&value) { if image.width() >= MIN_AUTO_IMAGE_DIM as u32 && image.height() >= MIN_AUTO_IMAGE_DIM as u32 diff --git a/src/main.rs b/src/main.rs index 4202e974b..f7159540c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -555,9 +555,7 @@ impl WatchArgs { let mut watcher = notify::recommended_watcher(send)?; watcher.watch(Path::new("."), RecursiveMode::Recursive)?; - if !use_window() { - println!("Watching for changes... (end with ctrl+C, use `uiua help` to see options)"); - } + println!("Watching for changes... (end with ctrl+C, use `uiua help` to see options)"); let config = FormatConfig::from_source(format_config_source, initial_path.as_deref()).ok(); #[cfg(feature = "audio")] diff --git a/src/window.rs b/src/window.rs index 3df083428..7cc6ac0dd 100644 --- a/src/window.rs +++ b/src/window.rs @@ -118,9 +118,19 @@ pub fn run_window() { }; } }); + let icon = + image::load_from_memory(include_bytes!("primitive/assets/uiua-logo-512.png")).unwrap(); + let icon = IconData { + width: icon.width(), + height: icon.height(), + rgba: icon.into_rgba8().into_raw(), + }; eframe::run_native( "Uiua", - eframe::NativeOptions::default(), + eframe::NativeOptions { + viewport: ViewportBuilder::default().with_icon(icon), + ..Default::default() + }, Box::new(|cc| { cc.egui_ctx.set_theme(Theme::Dark); let mut fonts = FontDefinitions::default(); @@ -128,8 +138,7 @@ pub fn run_window() { "Uiua386".into(), FontData::from_static(include_bytes!("algorithm/Uiua386.ttf")), ); - fonts - .families + (fonts.families) .entry(FontFamily::Monospace) .or_default() .insert(0, "Uiua386".into());