diff --git a/Cargo.lock b/Cargo.lock index 7dae8bb96..44b8b28d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1769,6 +1769,7 @@ dependencies = [ "gosub_render_backend", "gosub_renderer", "gosub_shared", + "image", "log", "slotmap", "url", diff --git a/crates/gosub_styling/src/shorthands.rs b/crates/gosub_styling/src/shorthands.rs index 76232ce90..81386e8e3 100644 --- a/crates/gosub_styling/src/shorthands.rs +++ b/crates/gosub_styling/src/shorthands.rs @@ -74,8 +74,6 @@ pub enum Multiplier { impl Multiplier { fn get_names(self, completed: Vec<&str>, multi: usize) -> Option> { - println!("get names: {completed:?}, {multi}"); - match self { Multiplier::NextProp => Some(vec![completed.get(multi)?]), @@ -386,17 +384,11 @@ impl FixList { match props.properties.entry(name.clone()) { Entry::Occupied(mut entry) => { - println!("Entry occupied"); let prop = entry.get_mut(); - dbg!(&prop); - prop.declared.push(decl); - dbg!(&prop); } Entry::Vacant(entry) => { - println!("Entry vacant"); - let mut prop = CssProperty::new(name); prop.declared.push(decl); diff --git a/crates/gosub_useragent/Cargo.toml b/crates/gosub_useragent/Cargo.toml index ec3fcbf53..c42ca2cbb 100644 --- a/crates/gosub_useragent/Cargo.toml +++ b/crates/gosub_useragent/Cargo.toml @@ -12,3 +12,4 @@ slotmap = "1.0.7" log = "0.4.22" anyhow = "1.0.82" url = "2.5.2" +image = "0.25.2" diff --git a/crates/gosub_useragent/src/window.rs b/crates/gosub_useragent/src/window.rs index 45865f7a5..5cebaebfc 100644 --- a/crates/gosub_useragent/src/window.rs +++ b/crates/gosub_useragent/src/window.rs @@ -1,11 +1,15 @@ use anyhow::anyhow; +use image::imageops::FilterType; +use image::GenericImageView; use log::warn; +use std::cell::LazyCell; +use std::ops::Deref; use std::sync::mpsc::Sender; use std::sync::Arc; use url::Url; use winit::dpi::LogicalSize; use winit::event_loop::ActiveEventLoop; -use winit::window::{Window as WinitWindow, WindowId}; +use winit::window::{Icon, Window as WinitWindow, WindowId}; use gosub_render_backend::geo::SizeU32; use gosub_render_backend::layout::{LayoutTree, Layouter}; @@ -21,6 +25,30 @@ pub enum WindowState<'a, B: RenderBackend> { Suspended, } +thread_local! { +static ICON: LazyCell = LazyCell::new(|| { + let bytes = include_bytes!("../../../resources/gosub-logo.png"); + + let Ok(img) = image::load_from_memory(bytes) else { + return Icon::from_rgba(vec![], 0, 0).unwrap(); + }; + + + println!("size: {:?}", img.dimensions()); + let height = img.height() / (img.width() / 256); + + let rgba = img.resize_exact(256, height, FilterType::Nearest).to_rgba8(); + + println!("size: {:?}", rgba.dimensions()); + + + Icon::from_rgba(rgba.to_vec(), rgba.width(), rgba.height()).unwrap_or( + Icon::from_rgba(vec![], 0, 0).unwrap() + ) + +}); +} + pub struct Window<'a, D: SceneDrawer, B: RenderBackend, L: Layouter, LT: LayoutTree> { pub(crate) state: WindowState<'a, B>, pub(crate) window: Arc, @@ -110,8 +138,11 @@ impl<'a, D: SceneDrawer, B: RenderBackend, L: Layouter, LT: LayoutTree fn create_window(event_loop: &ActiveEventLoop) -> Result> { let attributes = WinitWindow::default_attributes() .with_title("Gosub Browser") + .with_window_icon(Some(ICON.with(|icon| icon.deref().clone()))) .with_inner_size(LogicalSize::new(1920, 1080)); + println!("icon: {:?}", attributes.window_icon.is_some()); + event_loop .create_window(attributes) .map_err(|e| anyhow!(e.to_string())) diff --git a/resources/gosub-logo.png b/resources/gosub-logo.png new file mode 100644 index 000000000..72d0fe52e Binary files /dev/null and b/resources/gosub-logo.png differ