diff --git a/Cargo.lock b/Cargo.lock index 073a3a4..ee60562 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1060,6 +1060,20 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" +[[package]] +name = "embed-resource" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbfdaacccebec3b28e4866b8973543c7647797db5ada1bdab552e48fe665fbbd" +dependencies = [ + "cc", + "memchr", + "rustc_version", + "toml", + "vswhom", + "winreg", +] + [[package]] name = "endi" version = "1.1.1" @@ -1655,6 +1669,7 @@ checksum = "b40ca9252762c466af32d0b1002e91e4e1bc5398f77455e55474deb466355ff5" name = "halation-app" version = "0.1.0" dependencies = [ + "embed-resource", "halation-core", "i-slint-backend-testing", "rfd", @@ -4928,6 +4943,26 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "vswhom" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" +dependencies = [ + "libc", + "vswhom-sys", +] + +[[package]] +name = "vswhom-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb067e4cbd1ff067d1df46c9194b5de0e98efd2810bbc95c5d5e5f25a3231150" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "vtable" version = "0.5.0" @@ -5754,6 +5789,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.55.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb5a765337c50e9ec252c2069be9bf91c7df47afb103b642ba3a53bf8101be97" +dependencies = [ + "cfg-if", + "windows-sys 0.59.0", +] + [[package]] name = "wit-bindgen" version = "0.57.1" diff --git a/assets/README.md b/assets/README.md index 0c8cdff..c09b897 100644 --- a/assets/README.md +++ b/assets/README.md @@ -1,19 +1,16 @@ -# Asset provenance +# Asset provenance -`halation-mark.png` is the Halation logo (Java, 2026-10-22): a hand-drawn vector stroke, +`halation-mark.png` is the Halation logo (Java, 2026-10-22): a hand-drawn vector stroke (one continuous line: an arch, a dip and a hooked rise), `docs/media/brand/source/halation-mark.svg`, rendered at 512 px by `tools/render-brand.js` (an identity asset, drawn for this project). `halation-app-icon.png` is the window and taskbar icon from the same script: the mark on a flat `#111111` rounded square. The static Home reference image is kept outside the source tree under ignored `.tools/ui-rebuild-native/home-reference/`; it is composition guidance only and is not embedded in the application. `halation-wordmark.svg` is the HALATION wordmark (one path, identity asset): Bodoni Moda (SIL OFL 1.1) at weight 600, -optical size 60, tracked 0.20 em, converted to outlines (Java's choice, 2026-10-22). -`halation-wordmark-glow.png` is the wordmark's halation glow (960 x 428, the wordmark plus 180 px around it), drawn -from the wordmark by `tools/render-wordmark-glow.js` with Java's settings (2026-10-22). +drawn for this project. `halation-wordmark-glow.png` is its soft white bloom, rendered by `tools/render-wordmark-glow.js`. `drop-outline.svg` is the dashed outline of Home's drop zone, drawn for this crate. -`fonts/SchibstedGrotesk.ttf` (variable weight, © The Schibsted-Grotesk Project Authors) is the interface face and -`fonts/Italiana.ttf` (© Santiago Orozco, Reserved Font Name "Italiana", unmodified) the page-title face; both SIL Open -Font License 1.1, from the Google Fonts repository. +`fonts/Inter.ttf` is the Inter typeface (variable weight, Latin subset), SIL Open Font License 1.1, © The Inter +Project Authors (https://github.com/rsms/inter); the original app uses the same typeface. `drape-loop.mp4`, `drape-tint.bin` and `drape-still.jpg` are recordings of the original Halation's Drape background: a seamless two-minute loop of 1800 frames of 320 x 180 at 15 fps stored as lifted luma in H.264, the colour of each diff --git a/assets/halation-app-icon.ico b/assets/halation-app-icon.ico new file mode 100644 index 0000000..448c351 Binary files /dev/null and b/assets/halation-app-icon.ico differ diff --git a/assets/halation-app-icon.png b/assets/halation-app-icon.png index e5742f1..7278be5 100644 Binary files a/assets/halation-app-icon.png and b/assets/halation-app-icon.png differ diff --git a/assets/halation-mark.png b/assets/halation-mark.png index 3c9a534..703e7ba 100644 Binary files a/assets/halation-mark.png and b/assets/halation-mark.png differ diff --git a/crates/halation-app/Cargo.toml b/crates/halation-app/Cargo.toml index 10ce70c..6bfe8a2 100644 --- a/crates/halation-app/Cargo.toml +++ b/crates/halation-app/Cargo.toml @@ -60,6 +60,8 @@ diag-skia-vulkan = ["slint/renderer-skia-vulkan"] [build-dependencies] slint-build = { version = "=1.18.1", default-features = false, features = ["compat-1-18"] } +# The Windows executable's icon and version resources (build.rs); it finds rc.exe in the Windows SDK +embed-resource = "=3.0.11" [dev-dependencies] # Headless UI tests (layout bounds at small window sizes); test builds only, never part of the shipped binary. diff --git a/crates/halation-app/build.rs b/crates/halation-app/build.rs index ec3d7e8..02d8989 100644 --- a/crates/halation-app/build.rs +++ b/crates/halation-app/build.rs @@ -16,6 +16,7 @@ fn main() { } copy_assets(); + embed_windows_icon(); let sha = git_output(&["rev-parse", "--short=12", "HEAD"]) .filter(|sha| !sha.is_empty()) @@ -36,6 +37,34 @@ fn main() { .expect("the Slint UI must compile; fix the reported .slint diagnostics"); } +/// The window and taskbar icon (the mark on #111111, `tools/render-brand.js`) is also a resource of the executable: +/// Explorer and the taskbar read it before the window exists, and it is the icon of a shortcut or a pinned app. +fn embed_windows_icon() { + if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") { + return; + } + let icon = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap_or_default()) + .join("../../assets/halation-app-icon.ico"); + if !icon.is_file() { + println!( + "cargo:warning=assets/halation-app-icon.ico is missing; run node tools/render-brand.js" + ); + return; + } + println!("cargo:rerun-if-changed={}", icon.display()); + let script = PathBuf::from(std::env::var_os("OUT_DIR").unwrap_or_default()).join("halation.rc"); + // Forward slashes: rc.exe reads `\t` in a quoted path as an escape (and this tree lives under `\trrax`) + let source = format!( + "1 ICON \"{}\"\n", + icon.display().to_string().replace('\\', "/") + ); + std::fs::write(&script, source).expect("the icon resource script must be written"); + // Only the app binary carries the icon; test and benchmark executables do not need it. + embed_resource::compile_for(&script, ["halation-slint"], embed_resource::NONE) + .manifest_optional() + .expect("the icon resource must compile (rc.exe comes with the Windows SDK)"); +} + /// Development builds run from `target/`: put a copy of the workspace's `assets/` next to the executable there, /// as the installer does beside the installed one. Only changed files are copied. fn copy_assets() { diff --git a/docs/media/brand/halation-app-icon.svg b/docs/media/brand/halation-app-icon.svg index 26e664c..ac6ce6c 100644 --- a/docs/media/brand/halation-app-icon.svg +++ b/docs/media/brand/halation-app-icon.svg @@ -1,5 +1,5 @@ - + diff --git a/docs/media/brand/halation-mark-source.png b/docs/media/brand/halation-mark-source.png index 3c9a534..703e7ba 100644 Binary files a/docs/media/brand/halation-mark-source.png and b/docs/media/brand/halation-mark-source.png differ diff --git a/docs/media/brand/halation-mark.svg b/docs/media/brand/halation-mark.svg index 48c7a90..f9cd329 100644 --- a/docs/media/brand/halation-mark.svg +++ b/docs/media/brand/halation-mark.svg @@ -1 +1 @@ - + diff --git a/docs/media/brand/source/halation-mark.svg b/docs/media/brand/source/halation-mark.svg index 48c7a90..f9cd329 100644 --- a/docs/media/brand/source/halation-mark.svg +++ b/docs/media/brand/source/halation-mark.svg @@ -1 +1 @@ - + diff --git a/tools/render-brand.js b/tools/render-brand.js index ee96b4b..9750dff 100644 --- a/tools/render-brand.js +++ b/tools/render-brand.js @@ -5,6 +5,8 @@ // - assets/halation-mark.png (512 px): the transparent mark. // - assets/halation-app-icon.png (256 px): the window and taskbar icon, the mark at 62% on a flat #111111 rounded // square (the interface's surface grey) with an 8% white hairline. +// - assets/halation-app-icon.ico: the same icon at 16, 24, 32, 48 and 256 px, embedded in the Windows executable +// (crates/halation-app/build.rs) and used for the window and taskbar. // - docs/media/brand/: halation-mark.svg (the source), halation-app-icon.svg, halation-mark-source.png (the mark PNG). // // Usage: node tools/render-brand.js (CHROME and NODE_PATH as needed for Playwright) @@ -14,6 +16,7 @@ const { chromium } = require("playwright"); const MARK_PNG = 512; const ICON_PNG = 256; +const ICO_SIZES = [16, 24, 32, 48, 256]; // Share of the square the mark spans const SPAN = 0.62; @@ -37,7 +40,7 @@ function iconSvg() { } async function rasterize(page, svg, size) { - const base64 = await page.evaluate( + const { png, rgba } = await page.evaluate( async ({ svg, size }) => { const image = new Image(); image.src = "data:image/svg+xml;base64," + btoa(svg); @@ -47,11 +50,62 @@ async function rasterize(page, svg, size) { const context = canvas.getContext("2d"); context.imageSmoothingQuality = "high"; context.drawImage(image, 0, 0, size, size); - return canvas.toDataURL("image/png").split(",")[1]; + return { + png: canvas.toDataURL("image/png").split(",")[1], + rgba: Array.from(context.getImageData(0, 0, size, size).data), + }; }, { svg, size }, ); - return Buffer.from(base64, "base64"); + return { png: Buffer.from(png, "base64"), rgba: Buffer.from(rgba) }; +} + +// One 32-bit bottom-up DIB, the icon format Windows reads without a PNG decoder. The height in the header is twice the +// icon's because the AND mask that follows counts too; the mask is fully transparent (the alpha channel already says +// which pixels show). +function bmpEntry(size, rgba) { + const header = Buffer.alloc(40); + header.writeUInt32LE(40, 0); + header.writeInt32LE(size, 4); + header.writeInt32LE(size * 2, 8); + header.writeUInt16LE(1, 12); + header.writeUInt16LE(32, 14); + header.writeUInt32LE(size * size * 4, 20); + const pixels = Buffer.alloc(size * size * 4); + for (let y = 0; y < size; y += 1) { + for (let x = 0; x < size; x += 1) { + const source = (y * size + x) * 4; + const target = ((size - 1 - y) * size + x) * 4; + pixels[target] = rgba[source + 2]; + pixels[target + 1] = rgba[source + 1]; + pixels[target + 2] = rgba[source]; + pixels[target + 3] = rgba[source + 3]; + } + } + const maskStride = ((size + 31) >> 5) * 4; + return Buffer.concat([header, pixels, Buffer.alloc(maskStride * size)]); +} + +// A Windows .ico: a directory of images at the sizes Explorer, the taskbar and Alt+Tab ask for. PNG compresses the +// 256 px entry (Vista and later read it); the smaller ones stay plain DIBs, the format every Windows version reads. +function ico(entries) { + const header = Buffer.alloc(6); + header.writeUInt16LE(0, 0); + header.writeUInt16LE(1, 2); + header.writeUInt16LE(entries.length, 4); + const directory = Buffer.alloc(16 * entries.length); + let offset = header.length + directory.length; + entries.forEach(({ size, data }, index) => { + const entry = index * 16; + directory.writeUInt8(size === 256 ? 0 : size, entry); + directory.writeUInt8(size === 256 ? 0 : size, entry + 1); + directory.writeUInt16LE(1, entry + 4); + directory.writeUInt16LE(32, entry + 6); + directory.writeUInt32LE(data.length, entry + 8); + directory.writeUInt32LE(offset, entry + 12); + offset += data.length; + }); + return Buffer.concat([header, directory, ...entries.map(({ data }) => data)]); } async function main() { @@ -60,15 +114,21 @@ async function main() { try { const page = await browser.newPage(); const mark = await rasterize(page, markSvg, MARK_PNG); - fs.writeFileSync(path.join(root, "assets", "halation-mark.png"), mark); - fs.writeFileSync(path.join(root, "assets", "halation-app-icon.png"), await rasterize(page, icon, ICON_PNG)); - fs.writeFileSync(path.join(brand, "halation-mark-source.png"), mark); + fs.writeFileSync(path.join(root, "assets", "halation-mark.png"), mark.png); + fs.writeFileSync(path.join(root, "assets", "halation-app-icon.png"), (await rasterize(page, icon, ICON_PNG)).png); + const entries = []; + for (const size of ICO_SIZES) { + const image = await rasterize(page, icon, size); + entries.push({ size, data: size === 256 ? image.png : bmpEntry(size, image.rgba) }); + } + fs.writeFileSync(path.join(root, "assets", "halation-app-icon.ico"), ico(entries)); + fs.writeFileSync(path.join(brand, "halation-mark-source.png"), mark.png); fs.writeFileSync(path.join(brand, "halation-mark.svg"), markSvg); fs.writeFileSync(path.join(brand, "halation-app-icon.svg"), icon); } finally { await browser.close(); } - console.log("wrote assets/halation-mark.png, assets/halation-app-icon.png and docs/media/brand/"); + console.log("wrote assets/halation-mark.png, assets/halation-app-icon.png, assets/halation-app-icon.ico and docs/media/brand/"); } main().catch((error) => {