diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 203e00fe..72248a64 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -76,4 +76,6 @@ contributors, and where a line says so by Skryx Dev: | `assets/app-icon/src/draftcraft-icon.svg` | WithShalom Studios (DraftCraft) | original work for DraftCraft, drawn by `packaging/compass-icon.py` in [withshalom/draftcraft](https://github.com/withshalom/draftcraft) (2026) | MIT OR Apache-2.0 (the DraftCraft name and marks: [docs/brand/LICENSE-brand.txt](docs/brand/LICENSE-brand.txt)) | DraftCraft app icon master (full bleed): a drafting compass and the arc it drew on a blueprint-blue tile with a drafting grid; the PNGs, `.ico`, `.icns` and the Icon Composer art layer are rendered from it | | `assets/app-icon/src/draftcraft-icon-macos.svg` | WithShalom Studios (DraftCraft) | original work for DraftCraft, drawn by `packaging/compass-icon.py` in [withshalom/draftcraft](https://github.com/withshalom/draftcraft) (2026) | MIT OR Apache-2.0 (the DraftCraft name and marks: [docs/brand/LICENSE-brand.txt](docs/brand/LICENSE-brand.txt)) | the same icon on Apple's icon grid (with its margin), for `draftcraft-macos-512.png` and `draftcraft.icns` | | `docs/brand/draftcraft-logo.svg` | WithShalom Studios (DraftCraft) | original work for DraftCraft, drawn by `packaging/draftcraft-logo.py` in [withshalom/draftcraft](https://github.com/withshalom/draftcraft): the app icon beside the wordmark with ™, Source Sans 3 (SIL OFL 1.1, from storytold/craft-fonts) converted to outlines | MIT OR Apache-2.0 (the wordmark's glyph outlines: SIL OFL 1.1; the DraftCraft name and marks: [docs/brand/LICENSE-brand.txt](docs/brand/LICENSE-brand.txt)) | README logo | +| `assets/brand/draftcraft-logo-light-text.png` | WithShalom Studios (DraftCraft) | original work for DraftCraft: the full logo (the icon beside the wordmark with ™) as in `docs/brand/draftcraft-logo.svg` (Source Sans 3, SIL OFL 1.1, from storytold/craft-fonts, converted to outlines), cropped to its ink and scaled to 96 px tall | MIT OR Apache-2.0 (the wordmark's glyph outlines: SIL OFL 1.1; the DraftCraft name and marks: [docs/brand/LICENSE-brand.txt](docs/brand/LICENSE-brand.txt)) | The full logo at the left of the top row (dark chrome, light text) | +| `assets/brand/draftcraft-logo-dark-text.png` | WithShalom Studios (DraftCraft) | original work for DraftCraft: the full logo (the icon beside the wordmark with ™) as in `docs/brand/draftcraft-logo.svg` (Source Sans 3, SIL OFL 1.1, from storytold/craft-fonts, converted to outlines), cropped to its ink and scaled to 96 px tall | MIT OR Apache-2.0 (the wordmark's glyph outlines: SIL OFL 1.1; the DraftCraft name and marks: [docs/brand/LICENSE-brand.txt](docs/brand/LICENSE-brand.txt)) | The full logo at the left of the top row (light chrome, dark text) | | `docs/brand/draftcraft-logo-dark.svg` | WithShalom Studios (DraftCraft) | as `docs/brand/draftcraft-logo.svg`, light type | as `docs/brand/draftcraft-logo.svg` | README logo for dark backgrounds | diff --git a/assets/brand/draftcraft-logo-dark-text.png b/assets/brand/draftcraft-logo-dark-text.png new file mode 100644 index 00000000..f123d748 Binary files /dev/null and b/assets/brand/draftcraft-logo-dark-text.png differ diff --git a/assets/brand/draftcraft-logo-light-text.png b/assets/brand/draftcraft-logo-light-text.png new file mode 100644 index 00000000..d0d85dc0 Binary files /dev/null and b/assets/brand/draftcraft-logo-light-text.png differ diff --git a/crates/ui-egui/src/brand.rs b/crates/ui-egui/src/brand.rs index 047673ce..48a85a13 100644 --- a/crates/ui-egui/src/brand.rs +++ b/crates/ui-egui/src/brand.rs @@ -1,7 +1,7 @@ //! The DraftCraft logo in the interface: the app icon (a drafting compass and the arc it drew on a -//! blueprint-blue tile, `assets/app-icon/`), drawn on the application button, the Start page, the About -//! window and DraftCraft's own title bar. The icon is WithShalom Studios' mark, used by agreement -//! (`docs/brand/LICENSE-brand.txt`). +//! blueprint-blue tile, `assets/app-icon/`), drawn on the application button, the Start page and the About +//! window, and the full logo (the icon and the wordmark as one piece, `assets/brand/`) at the left of the +//! top row. Both are WithShalom Studios' marks, used by agreement (`docs/brand/LICENSE-brand.txt`). use egui::{Align2, Color32, FontId, Rect, pos2}; @@ -10,6 +10,11 @@ const ICON_SMALL: &[u8] = include_bytes!("../../../assets/app-icon/hicolor/64x64 /// The icon at 256 px, for larger marks. const ICON_LARGE: &[u8] = include_bytes!("../../../assets/app-icon/draftcraft-256.png"); +/// The full logo (icon and wordmark) with light text, for dark chrome; cropped to its ink, 96 px tall. +const FULL_LIGHT: &[u8] = include_bytes!("../../../assets/brand/draftcraft-logo-light-text.png"); +/// The full logo with dark text, for light chrome. +const FULL_DARK: &[u8] = include_bytes!("../../../assets/brand/draftcraft-logo-dark-text.png"); + /// DraftCraft's blueprint blue, behind the fallback mark. const BLUEPRINT: Color32 = Color32::from_rgb(0x0e, 0x34, 0x63); @@ -40,6 +45,43 @@ pub fn paint(p: &egui::Painter, r: Rect) { p.text(r.center(), Align2::CENTER_CENTER, "DC", FontId::proportional(r.height() * 0.5), Color32::WHITE); } +/// The full-logo texture for light or dark text, decoded once per context. `None` if it doesn't decode. +fn full_texture(ctx: &egui::Context, light_text: bool) -> Option { + let (bytes, key, name) = + if light_text { (FULL_LIGHT, "dc_full_light", "draftcraft-logo-light") } else { (FULL_DARK, "dc_full_dark", "draftcraft-logo-dark") }; + let id = egui::Id::unique(key); + if let Some(tex) = ctx.data(|d| d.get_temp::(id)) { + return Some(tex); + } + let img = image::load_from_memory_with_format(bytes, image::ImageFormat::Png).ok()?.to_rgba8(); + let size = [usize::try_from(img.width()).ok()?, usize::try_from(img.height()).ok()?]; + let tex = ctx.load_texture(name, egui::ColorImage::from_rgba_unmultiplied(size, img.as_raw()), egui::TextureOptions::LINEAR); + ctx.data_mut(|d| d.insert_temp(id, tex.clone())); + Some(tex) +} + +/// Paint the full logo (icon and wordmark) `height` points tall with its left edge at `left`, centred on +/// `center_y`, in the version that reads on `chrome` (light text on dark chrome, dark text on light). +/// Returns the width used. If the image can't be drawn, the icon and the name in plain text are drawn instead. +pub fn paint_full(p: &egui::Painter, left: f32, center_y: f32, height: f32, chrome: Color32) -> f32 { + let light_text = u32::from(chrome.r()) + u32::from(chrome.g()) + u32::from(chrome.b()) < 384; + if let Some(tex) = full_texture(p.ctx(), light_text) { + let [w, h] = tex.size(); + let aspect = if h == 0 { 1.0 } else { w as f32 / h as f32 }; + let r = Rect::from_min_size(pos2(left, center_y - height / 2.0), egui::vec2(height * aspect, height)); + p.image(tex.id(), r, Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), Color32::WHITE); + return r.width(); + } + let icon = Rect::from_min_size(pos2(left, center_y - height / 2.0), egui::vec2(height, height)); + paint(p, icon); + let ink = if light_text { Color32::WHITE } else { Color32::BLACK }; + let galley = p.layout_no_wrap("DraftCraft".to_string(), FontId::proportional(height * 0.55), ink); + let text_left = icon.right() + height * 0.3; + let width = text_left - left + galley.size().x; + p.galley(pos2(text_left, center_y - galley.size().y / 2.0), galley, ink); + width +} + /// The logo as a widget of `size` points (square). pub fn show(ui: &mut egui::Ui, size: f32) -> egui::Response { let (r, response) = ui.allocate_exact_size(egui::vec2(size, size), egui::Sense::hover()); @@ -57,6 +99,30 @@ mod tests { } } + #[test] + fn both_full_logos_decode_and_match() { + let mut sizes = Vec::new(); + for bytes in [super::FULL_LIGHT, super::FULL_DARK] { + let img = image::load_from_memory_with_format(bytes, image::ImageFormat::Png).unwrap(); + assert!(img.width() > img.height() * 3, "the full logo is wide"); + sizes.push((img.width(), img.height())); + } + assert_eq!(sizes[0], sizes[1]); + } + + #[test] + fn the_full_logo_takes_its_width_from_its_height() { + let ctx = egui::Context::default(); + let mut out = ctx.run_ui(Default::default(), |ui| { + let p = ui.painter().clone(); + let a = super::paint_full(&p, 0.0, 10.0, 16.0, egui::Color32::from_rgb(0x31, 0x38, 0x44)); + let b = super::paint_full(&p, 0.0, 10.0, 32.0, egui::Color32::from_rgb(0xd5, 0xd9, 0xdf)); + assert!(a > 16.0 * 3.0); + assert!((b - a * 2.0).abs() < 0.01); + }); + out.textures_delta.clear(); + } + #[test] fn the_texture_is_made_once_per_size() { let ctx = egui::Context::default(); diff --git a/crates/ui-egui/src/window_frame.rs b/crates/ui-egui/src/window_frame.rs index 87801a2a..f69eb1a3 100644 --- a/crates/ui-egui/src/window_frame.rs +++ b/crates/ui-egui/src/window_frame.rs @@ -8,13 +8,16 @@ //! `DRAFTCRAFT_TITLEBAR=app` draws this frame on any desktop (to try it). macOS keeps its own //! integrated title bar and Linux the desktop's. -use egui::{Color32, CursorIcon, FontId, Rect, ResizeDirection, Sense, Stroke, StrokeKind, ViewportCommand, pos2, vec2}; +use egui::{Color32, CursorIcon, Rect, ResizeDirection, Sense, Stroke, StrokeKind, ViewportCommand, pos2, vec2}; use crate::CadApp; use crate::theme::Tokens; /// Height of the title bar row. pub const TITLE_H: f32 = 30.0; + +/// Height of the full logo (icon and wordmark) in the title bar, in points. +const LOGO_H: f32 = 24.0; /// Width of each window button, as Windows draws them. const BUTTON_W: f32 = 46.0; /// How far in from the window's edge a press resizes it. @@ -56,14 +59,10 @@ pub fn title_bar(app: &mut CadApp, ui: &mut egui::Ui) { // First, so the controls drawn over it keep their own clicks. craft_window::title_bar::empty_area(ui, free).on_hover_text("DraftCraft"); let p = ui.painter().clone(); - let logo = Rect::from_center_size(pos2(r.left() + 17.0, r.center().y), vec2(18.0, 18.0)); - paint_logo(&p, logo); - let name = p.layout_no_wrap("DraftCraft".to_string(), FontId::proportional(13.0), t.text); - let name_x = logo.right() + 7.0; - let name_w = name.size().x; - p.galley(pos2(name_x, r.center().y - name.size().y / 2.0), name, t.text); + let logo_left = r.left() + 8.0; + let logo_w = crate::brand::paint_full(&p, logo_left, r.center().y, LOGO_H, t.chrome_dark); if app.ui.in_window_menu { - let menus = Rect::from_min_max(pos2(name_x + name_w + 12.0, r.top()), pos2(free.right(), r.bottom())); + let menus = Rect::from_min_max(pos2(logo_left + logo_w + 12.0, r.top()), pos2(free.right(), r.bottom())); ui.scope_builder(egui::UiBuilder::new().max_rect(menus).layout(egui::Layout::left_to_right(egui::Align::Center)), |ui| { ui.set_clip_rect(menus); clicked = crate::menus::menu_titles(app, ui); @@ -76,11 +75,6 @@ pub fn title_bar(app: &mut CadApp, ui: &mut egui::Ui) { } } -/// The app icon, small, drawn in the title bar. -fn paint_logo(p: &egui::Painter, r: Rect) { - crate::brand::paint(p, r); -} - fn caption_buttons(ui: &mut egui::Ui, area: Rect) { let t = Tokens::get(); let maximized = ui.input(|i| i.viewport().maximized).unwrap_or(false);