Skip to content

Commit

Permalink
add icon to window
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Nov 20, 2024
1 parent 430e701 commit fbac5f8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
15 changes: 12 additions & 3 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,27 @@ 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();
fonts.font_data.insert(
"Uiua386".into(),
FontData::from_static(include_bytes!("algorithm/Uiua386.ttf")),
);
fonts
.families
(fonts.families)
.entry(FontFamily::Monospace)
.or_default()
.insert(0, "Uiua386".into());
Expand Down

0 comments on commit fbac5f8

Please sign in to comment.