From 2e8ffbf869e1ae9872324c9982b6d9310cc74aa0 Mon Sep 17 00:00:00 2001 From: Yarila <102650794+YarilaFox@users.noreply.github.com> Date: Wed, 2 Dec 2026 04:55:22 +0500 Subject: [PATCH] Keep launcher controls accessible above sheets (#1693) * fix(ui): keep launcher controls accessible above sheets * fix(ui): align release cards and anchor platform tooltips * fix(ui): contain details drawer and close lightbox for dialogs * fix(ui): fill the release facts row when metadata is missing --- ATTRIBUTION.md | 1 + NOTICE | 2 + assets/ui-icons/README.md | 5 + assets/ui-icons/apple.svg | 1 + assets/ui-icons/freebsd.svg | 1 + assets/ui-icons/linux.svg | 1 + assets/ui-icons/windows.svg | 1 + crates/ui-egui/src/details.rs | 144 ++++++++++++++++------ crates/ui-egui/src/dialogs.rs | 4 +- crates/ui-egui/src/i18n/bs.tsv | 1 + crates/ui-egui/src/i18n/cs.tsv | 1 + crates/ui-egui/src/i18n/de.tsv | 1 + crates/ui-egui/src/i18n/es.tsv | 1 + crates/ui-egui/src/i18n/fr.tsv | 1 + crates/ui-egui/src/i18n/hu.tsv | 1 + crates/ui-egui/src/i18n/ja.tsv | 1 + crates/ui-egui/src/i18n/ka.tsv | 1 + crates/ui-egui/src/i18n/pl.tsv | 1 + crates/ui-egui/src/i18n/pt-BR.tsv | 1 + crates/ui-egui/src/i18n/ru.tsv | 1 + crates/ui-egui/src/i18n/uk.tsv | 1 + crates/ui-egui/src/i18n/zh-CN.tsv | 1 + crates/ui-egui/src/i18n/zh-TW.tsv | 1 + crates/ui-egui/src/icons.rs | 11 ++ crates/ui-egui/src/nightly.rs | 4 +- crates/ui-egui/src/notes.rs | 21 ++-- crates/ui-egui/src/sheet.rs | 14 ++- crates/ui-egui/src/widgets.rs | 3 +- crates/ui-egui/tests/ui.rs | 194 ++++++++++++++++++++++++++++-- 29 files changed, 356 insertions(+), 65 deletions(-) create mode 100644 assets/ui-icons/apple.svg create mode 100644 assets/ui-icons/freebsd.svg create mode 100644 assets/ui-icons/linux.svg create mode 100644 assets/ui-icons/windows.svg diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 7410ceb0..87ce3ef9 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -16,6 +16,7 @@ next to them. | `assets/social/x.svg`, `youtube.svg`, `tiktok.svg`, `instagram.svg`, `discord.svg` | X, YouTube, TikTok, Instagram and Discord logos, linking to ArtCraft's accounts | [Simple Icons](https://simpleicons.org/) contributors | Simple Icons, `fill` set to white for tinting; see [`assets/social/README.md`](assets/social/README.md) | CC0 1.0. The logos are trademarks of X Corp., Google LLC, TikTok / ByteDance, Meta Platforms, Inc. and Discord Inc. | | `assets/social/github.svg`, `assets/social/globe.svg` | GitHub logo (linking to ArtCraft's GitHub) and a globe (linking to ArtCraft's website) | [Simple Icons](https://simpleicons.org/) contributors; [Lucide](https://lucide.dev) contributors | Simple Icons `github.svg` and Lucide `globe.svg` (lucide-static 0.468.0), white for tinting; see [`assets/social/README.md`](assets/social/README.md) | CC0 1.0 (GitHub logo; a trademark of GitHub, Inc.); ISC (globe) | | `assets/ui-icons/settings.svg`, `assets/ui-icons/bell.svg` | Settings gear and announcements bell in the window header | [Lucide](https://lucide.dev) contributors (portions from Feather, Cole Bemis) | Lucide `settings.svg` and `bell.svg` (lucide-static 0.468.0), white for tinting; see [`assets/ui-icons/README.md`](assets/ui-icons/README.md) | ISC (portions MIT) | +| `assets/ui-icons/apple.svg`, `windows.svg`, `linux.svg`, `freebsd.svg` | Supported platforms in app details | [Simple Icons](https://simpleicons.org/) contributors | Simple Icons 11.10.0, white for tinting; see [`assets/ui-icons/README.md`](assets/ui-icons/README.md) | CC0 1.0. Platform marks belong to their respective owners. | | `docs/screenshots/artcraft-launcher-grid.png`, `artcraft-launcher-table.png` | Screenshots of ArtCraft Launcher (macOS: grid view in dark theme, table view in light theme), used in the README | ArtCraft Launcher contributors | Captured from the app | MIT OR Apache-2.0 for the screenshot itself; the ArtCraft logo in it stays an ArtCraft trademark ([`docs/brand/LICENSE-brand.txt`](docs/brand/LICENSE-brand.txt)) and the app icons in it keep their own licenses (above) | | (not bundled) the pictures on each app's details page | Screenshots of the Craft Apps, fetched when a page is opened and kept in the launcher's cache folder | The apps' contributors | [storytold/craft-launcher-assets](https://github.com/storytold/craft-launcher-assets), pinned to a tag (`SCREENSHOTS_REV` in `crates/core/src/details.rs`); each picture's source and license are listed in that repository's `ATTRIBUTION.md` | Each app's own license for the interface (MIT OR Apache-2.0); the work shown in them is public domain or made in the app, as that file says | | `docs/brand/artcraft-logo.svg`, `artcraft-logo-white.svg` | ArtCraft wordmark, shown in the window header | ArtCraft Team | Supplied brand files, unmodified (same as PhotoCraft's `docs/brand/`) | **Not open source; not MIT or Apache-2.0.** ArtCraft trademark, [`docs/brand/LICENSE-brand.txt`](docs/brand/LICENSE-brand.txt) | diff --git a/NOTICE b/NOTICE index 042dc6f6..0d95c6a7 100644 --- a/NOTICE +++ b/NOTICE @@ -18,6 +18,8 @@ list (author, source, license) is in ATTRIBUTION.md. Social service icons (assets/social/*.svg) — Simple Icons, CC0 1.0 (X, YouTube, TikTok, Instagram), and Font Awesome Free 6.7.2 by Fonticons, Inc., CC BY 4.0 (LinkedIn; https://fontawesome.com/license/free). The logos are trademarks of their respective owners and are used only to link to ArtCraft's accounts. +Platform icons (assets/ui-icons/apple.svg, windows.svg, linux.svg, freebsd.svg) are from Simple Icons +11.10.0, CC0 1.0. See assets/ui-icons/README.md. Inter font (assets/fonts/Inter-Variable.ttf) — SIL Open Font License 1.1. See assets/fonts/OFL-Inter.txt. Archivo font (assets/fonts/Archivo-Variable.ttf) — SIL Open Font License 1.1. See assets/fonts/OFL-Archivo.txt. Geist Mono font (assets/fonts/GeistMono-Variable.ttf) — SIL Open Font License 1.1. See assets/fonts/OFL-GeistMono.txt. diff --git a/assets/ui-icons/README.md b/assets/ui-icons/README.md index 13d6e401..37c86734 100644 --- a/assets/ui-icons/README.md +++ b/assets/ui-icons/README.md @@ -7,3 +7,8 @@ the `settings` and `bell` icons from [Lucide](https://lucide.dev) (lucide-static [ISC](https://github.com/lucide-icons/lucide/blob/main/LICENSE); portions of Lucide come from Feather (MIT, Cole Bemis). The only changes are `stroke="#ffffff"` instead of `currentColor`, so the app can tint them to the theme, and the `class` attribute removed. + +`apple.svg`, `windows.svg`, `linux.svg` and `freebsd.svg` are from [Simple Icons](https://simpleicons.org/) +11.10.0 (`https://cdn.jsdelivr.net/npm/simple-icons@11.10.0/icons/.svg`), released under +[CC0 1.0](https://github.com/simple-icons/simple-icons/blob/11.10.0/LICENSE.md). The root fill is white +so the launcher can tint the icons. The logos identify the platforms listed in app details. diff --git a/assets/ui-icons/apple.svg b/assets/ui-icons/apple.svg new file mode 100644 index 00000000..4c9c9cac --- /dev/null +++ b/assets/ui-icons/apple.svg @@ -0,0 +1 @@ +Apple diff --git a/assets/ui-icons/freebsd.svg b/assets/ui-icons/freebsd.svg new file mode 100644 index 00000000..1a32e219 --- /dev/null +++ b/assets/ui-icons/freebsd.svg @@ -0,0 +1 @@ +FreeBSD diff --git a/assets/ui-icons/linux.svg b/assets/ui-icons/linux.svg new file mode 100644 index 00000000..ee776b8f --- /dev/null +++ b/assets/ui-icons/linux.svg @@ -0,0 +1 @@ +Linux diff --git a/assets/ui-icons/windows.svg b/assets/ui-icons/windows.svg new file mode 100644 index 00000000..99e0b5ef --- /dev/null +++ b/assets/ui-icons/windows.svg @@ -0,0 +1 @@ +Windows diff --git a/crates/ui-egui/src/details.rs b/crates/ui-egui/src/details.rs index 791f6bb2..32c85238 100644 --- a/crates/ui-egui/src/details.rs +++ b/crates/ui-egui/src/details.rs @@ -29,6 +29,29 @@ const ARROW: f32 = 36.0; const SLIDE_SECS: f32 = 0.22; /// The width of the main button and its menu in the page's top, when the page is wide. const ACTION_W: f32 = 300.0; +const PLATFORM_ICON_SIZE: f32 = 18.0; + +fn platform_icons(ui: &mut Ui, platforms: &str, t: &Tokens) { + ui.scope(|ui| { + ui.spacing_mut().interact_size.y = PLATFORM_ICON_SIZE; + ui.horizontal_wrapped(|ui| { + ui.spacing_mut().item_spacing = vec2(5.0, 3.0); + for name in platforms.split(',').map(str::trim).filter(|name| !name.is_empty()) { + if let Some(icon) = crate::icons::platform(name) { + let image = + egui::Image::new(icon).fit_to_exact_size(vec2(PLATFORM_ICON_SIZE, PLATFORM_ICON_SIZE)).tint(t.ink_strong).alt_text(name); + let response = ui.add(image); + let mut tooltip = egui::Tooltip::for_enabled(&response); + let frame = egui::Frame::popup(ui.style()).corner_radius(CornerRadius::ZERO).fill(t.bg).stroke(t.hairline()); + tooltip.popup = tooltip.popup.align(egui::emath::RectAlign::TOP).frame(frame); + tooltip.show(|ui| ui.label(name)); + } else { + ui.label(RichText::new(name).size(14.0).color(t.ink_strong)); + } + } + }); + }); +} /// A details picture, as the backend has sent it. pub(crate) enum Picture { @@ -117,14 +140,15 @@ impl LauncherUi { if self.entry(&id).is_none() { return; } - if !open { + // A dialog opened from the launcher header takes over from the enlarged picture. + if !open || self.dialog.is_some() { self.detail_zoom = false; } self.details_keys(ctx, details, open); let t = Tokens::get(ctx); - // The whole window is the backdrop; the card sits in the middle and rises a little as it fades in. - let area = ctx.content_rect(); + // Keep both the page and its hit-blocking backdrop below the launcher header. + let area = crate::sheet::content_rect(ctx); let width = (area.width() - 64.0).clamp(480.0, 1280.0).min((area.width() - 16.0).max(1.0)); let height = (area.height() - 40.0).clamp(320.0, 1000.0).min((area.height() - 8.0).max(1.0)); let panel = Rect::from_center_size(area.center() + vec2(0.0, (1.0 - k) * 24.0), vec2(width, height)); @@ -149,25 +173,45 @@ impl LauncherUi { .accessible_name(format!("{}: {}", tl!("App details"), entry.app.name)) .show(ctx, |ui| { ui.set_opacity(k.clamp(0.0, 1.0)); + ui.set_clip_rect(ui.clip_rect().intersect(crate::sheet::content_rect(ctx))); let painter = ui.painter(); painter.add(theme::shadow(t).as_shape(panel, CornerRadius::ZERO)); painter.rect_filled(panel, CornerRadius::ZERO, t.bg); painter.rect_stroke(panel, CornerRadius::ZERO, Stroke::new(1.0, t.line_strong), egui::StrokeKind::Inside); - ui.set_min_size(panel.size()); - ui.set_max_size(panel.size()); - // A bar that stays on screen says there is more below the fold; in the app's colour. - let page_visuals = crate::sheet::accent_scroll(ui, t, t.app_ink(entry.app)); - // One scroll position per app, so the next app opens at its top. - egui::ScrollArea::vertical().id_salt(("details-scroll", id.to_string())).auto_shrink([false, false]).show(ui, |ui| { - // The bar's colours are for the bar alone. - *ui.visuals_mut() = page_visuals; - ui.set_width(ui.available_width()); - ui.spacing_mut().item_spacing.y = 8.0; - self.details_hero(ui, &entry, details, t, (previous.as_deref(), next.as_deref()), wide); - egui::Frame::new().inner_margin(Margin::same(PAD as i8)).show(ui, |ui| { - self.details_body(ui, &entry, details, wide, t); - }); + // Keep the scroll area inside the border, including when its contents request extra width. + let interior = panel.shrink(1.0); + let clip = ui.clip_rect().intersect(interior); + ui.scope_builder(egui::UiBuilder::new().max_rect(interior), |ui| { + ui.set_clip_rect(clip); + // One scroll position per app, so the next app opens at its top. + let page_visuals = crate::sheet::accent_scroll(ui, t, t.app_ink(entry.app)); + // Anchor the track to the drawer edge even when a child needs extra width. + // Reserve a gutter so the track never paints over the controls. + let scroll = &mut ui.spacing_mut().scroll; + scroll.floating = true; + scroll.floating_width = scroll.bar_width; + scroll.floating_allocated_width = scroll.bar_width + scroll.bar_inner_margin; + scroll.dormant_handle_opacity = 1.0; + scroll.active_handle_opacity = 1.0; + scroll.dormant_background_opacity = 1.0; + scroll.active_background_opacity = 1.0; + scroll.interact_background_opacity = 1.0; + egui::ScrollArea::vertical() + .id_salt(("details-scroll", id)) + .max_width(interior.width()) + .max_height(interior.height()) + .auto_shrink([false, false]) + .show(ui, |ui| { + // The bar's colours are for the bar alone. + *ui.visuals_mut() = page_visuals; + ui.set_width(ui.available_width()); + ui.spacing_mut().item_spacing.y = 8.0; + self.details_hero(ui, &entry, details, t, (previous.as_deref(), next.as_deref()), wide); + egui::Frame::new().inner_margin(Margin::same(PAD as i8)).show(ui, |ui| { + self.details_body(ui, &entry, details, wide, t); + }); + }); }); }); } @@ -298,7 +342,7 @@ impl LauncherUi { /// The page behind the drawer, dimmed (egui can't blur what is under a layer); a click on it closes the drawer. fn details_scrim(&mut self, ctx: &egui::Context, area: Rect, k: f32, t: &Tokens) { - egui::Area::new(Id::unique("details-scrim")).order(Order::Middle).fixed_pos(area.min).show(ctx, |ui| { + egui::Area::new(Id::unique("details-scrim")).order(Order::Middle).fixed_pos(area.min).constrain(false).show(ctx, |ui| { let (rect, resp) = ui.allocate_exact_size(area.size(), Sense::click()); ui.painter().rect_filled(rect, CornerRadius::ZERO, theme::scrim(t, k)); if resp.on_hover_cursor(egui::CursorIcon::Default).clicked() { @@ -409,32 +453,54 @@ impl LauncherUi { let stems: Vec<&str> = entry.app.stems().collect(); pick_asset(r, &stems, p, p.default_kinds()).map(|(a, _)| widgets::human_bytes(a.size)) }); - let facts: Vec<(&str, String)> = [ - (tl!("Version"), Some(r.version.as_ref().map_or_else(|| r.tag.clone(), |v| v.to_string()))), - (tl!("Released"), r.published_at.map(date_text)), - (tl!("Download"), size), - (tl!("Platforms"), Some(details.platforms.to_string())), + let version = r.version.as_ref().map_or_else(|| r.tag.clone(), |v| v.to_string()); + let released = r.published_at.map(date_text); + let facts = [ + (tl!("Version"), Some(version.as_str()), false), + (tl!("Released"), released.as_deref(), false), + (tl!("Download"), size.as_deref(), false), + (tl!("Platforms"), Some(details.platforms), true), ] .into_iter() - .filter_map(|(label, value)| value.map(|v| (label, v))) - .collect(); + .filter_map(|(label, value, platforms)| value.filter(|value| !value.trim().is_empty()).map(|value| (label, value, platforms))) + .collect::>(); + let per_row = per_row.min(facts.len().max(1)); for pair in facts.chunks(per_row) { - ui.columns(per_row, |cols| { - for (col, (label, value)) in cols.iter_mut().zip(pair) { - egui::Frame::new().stroke(t.hairline()).inner_margin(theme::BOX_MARGIN).show(col, |ui| { - ui.set_width(ui.available_width()); - ui.spacing_mut().item_spacing.y = 2.0; - widgets::hud(ui, label, t.faint); - ui.add(egui::Label::new(RichText::new(value).size(14.0).color(t.ink_strong)).wrap()); - }); - } + let boxes = ui.columns(per_row, |cols| { + cols.iter_mut() + .zip(pair) + .map(|(col, (label, value, platforms))| { + egui::Frame::new() + .inner_margin(theme::BOX_MARGIN) + .show(col, |ui| { + ui.set_width(ui.available_width()); + ui.set_min_height(32.0); + ui.spacing_mut().item_spacing.y = 2.0; + widgets::hud(ui, label, t.faint); + if *platforms { + platform_icons(ui, value, t); + } else { + ui.add(egui::Label::new(RichText::new(*value).size(14.0).color(t.ink_strong)).wrap()); + } + }) + .response + .rect + }) + .collect::>() }); + // If a value wraps, extend the other outlines to the same bottom edge. + let bottom = boxes.iter().map(Rect::bottom).fold(f32::NEG_INFINITY, f32::max); + for mut rect in boxes { + rect.max.y = bottom; + ui.painter().rect_stroke(rect, CornerRadius::ZERO, t.hairline(), egui::StrokeKind::Inside); + } } - ui.add_space(8.0); - crate::notes::show(ui, &r.notes); + ui.add_space(4.0); + widgets::eyebrow(ui, "03", tl!("What's Changed")); + crate::notes::show_in_details(ui, &r.notes); } - /// The current screenshot, large, over the whole window; ‹ › flip through them, a click or Esc closes it. + /// The current screenshot, large, below the header; ‹ › flip through them, a click or Esc closes it. fn lightbox(&mut self, ctx: &egui::Context, details: &AppDetails, t: &Tokens) { let count = details.shots.len(); let at = self.detail_shot.min(count.saturating_sub(1)); @@ -444,13 +510,15 @@ impl LauncherUi { }; let src = self.picture_source(details.id, shot.key); let failed = self.failure(details.id, shot.key); - let full = ctx.content_rect(); + let full = crate::sheet::content_rect(ctx); egui::Area::new(Id::unique("details-lightbox")) .order(Order::Tooltip) .fixed_pos(full.min) + .constrain(false) .role(egui::Role::Dialog) .accessible_name(format!("{}: {}", tl!("Enlarge picture"), CraftApp::by_id(details.id).map_or("", |app| app.name))) .show(ctx, |ui| { + ui.set_clip_rect(ui.clip_rect().intersect(full)); let (rect, backdrop) = ui.allocate_exact_size(full.size(), Sense::click()); ui.painter().rect_filled(rect, CornerRadius::ZERO, theme::backdrop()); // As large as the window allows, but no larger than 1400 points: the files are 1200 px wide. diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index a3dffd7d..00720a27 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -31,7 +31,7 @@ impl LauncherUi { // uninstall prompt would open as tall as Settings and never shrink (#88). // The large dialogs run their header to the card's edges; the small prompts keep a margin. let large = matches!(dialog, Dialog::Settings | Dialog::Notes(_)); - let modal = egui::Modal::new(egui::Id::unique("dialog").with(dialog.key())).frame(if large { + let modal = crate::sheet::modal(egui::Id::unique("dialog").with(dialog.key())).frame(if large { crate::sheet::frame(&t) } else { egui::Frame::new().fill(t.bg).stroke(egui::Stroke::new(1.0, t.line_strong)).shadow(theme::shadow(&t)).inner_margin(theme::PAD as i8) @@ -75,7 +75,7 @@ impl LauncherUi { let now = self.backend.now(); let Some(alert) = self.alerts.iter().find(|a| a.current(now) && !self.settings.dismissed_notices.contains(&a.id)).cloned() else { return }; let t = Tokens::get(ctx); - let modal = egui::Modal::new(egui::Id::unique("feed_alert").with(&alert.id)).frame( + let modal = crate::sheet::modal(egui::Id::unique("feed_alert").with(&alert.id)).frame( egui::Frame::new().fill(t.bg).stroke(egui::Stroke::new(1.0, t.line_strong)).shadow(theme::shadow(&t)).inner_margin(theme::PAD as i8), ); let mut ok = false; diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 1ef24e1d..316d1c78 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -258,6 +258,7 @@ filter Installed Instalirano Close (Esc) Zatvori (Esc) Features Mogućnosti Latest release Najnovije izdanje + What's Changed Šta se promijenilo Version Verzija Platforms Platforme Releases Izdanja diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index aeab66fe..8adf354d 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -281,6 +281,7 @@ filter Installed Nainstalováno Close (Esc) Zavřít (Esc) Features Funkce Latest release Nejnovější verze + What's Changed Co se změnilo Version Verze Platforms Platformy Releases Vydání diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 7a9ff063..f732b3d7 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -378,6 +378,7 @@ filter Installed Installiert Close (Esc) Schließen (Esc) Features Funktionen Latest release Neueste Version + What's Changed Was sich geändert hat Version Version Platforms Plattformen Releases Versionen diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index e25af779..f6f62ada 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -294,6 +294,7 @@ filter Installed Instaladas Close (Esc) Cerrar (Esc) Features Funciones Latest release Última versión + What's Changed Qué ha cambiado Version Versión Platforms Plataformas Releases Versiones diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 3bca4519..8e2da57e 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -376,6 +376,7 @@ filter Installed Installées Close (Esc) Fermer (Esc) Features Fonctionnalités Latest release Dernière version + What's Changed Nouveautés Version Version Platforms Plateformes Releases Versions diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index e7922396..c33b976e 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -305,6 +305,7 @@ filter Installed Telepítve Close (Esc) Bezárás (Esc) Features Funkciók Latest release Legújabb kiadás + What's Changed Változások Version Verzió Platforms Platformok Releases Kiadások diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 2f208310..ac896575 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -307,6 +307,7 @@ filter Installed インストール済み Close (Esc) 閉じる (Esc) Features 機能 Latest release 最新リリース + What's Changed 変更点 Version バージョン Platforms 対応プラットフォーム Releases リリース diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index b500953f..9858dbca 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -308,6 +308,7 @@ filter Installed დაინსტალირებული Close (Esc) დახურვა (Esc) Features შესაძლებლობები Latest release უახლესი გამოშვება + What's Changed რა შეიცვალა Version ვერსია Platforms პლატფორმები Releases გამოშვებები diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 1cf4435b..6312da95 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -306,6 +306,7 @@ filter Installed Zainstalowane Close (Esc) Zamknij (Esc) Features Funkcje Latest release Najnowsze wydanie + What's Changed Co się zmieniło Version Wersja Platforms Platformy Releases Wydania diff --git a/crates/ui-egui/src/i18n/pt-BR.tsv b/crates/ui-egui/src/i18n/pt-BR.tsv index 699c7445..e8d56456 100644 --- a/crates/ui-egui/src/i18n/pt-BR.tsv +++ b/crates/ui-egui/src/i18n/pt-BR.tsv @@ -366,6 +366,7 @@ filter Installed Instalados Close (Esc) Fechar (Esc) Features Recursos Latest release Último lançamento + What's Changed O que mudou Version Versão Platforms Plataformas Releases Lançamentos diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 33843c20..a343a5c2 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -374,6 +374,7 @@ filter Installed Установлены Close (Esc) Закрыть (Esc) Features Возможности Latest release Последний релиз + What's Changed Что изменилось Version Версия Platforms Платформы Releases Релизы diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 352b818b..b8a01041 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -371,6 +371,7 @@ filter Installed Встановлені Close (Esc) Закрити (Esc) Features Можливості Latest release Останній випуск + What's Changed Що змінилося Version Версія Platforms Платформи Releases Випуски diff --git a/crates/ui-egui/src/i18n/zh-CN.tsv b/crates/ui-egui/src/i18n/zh-CN.tsv index 5862a416..59ebfabf 100644 --- a/crates/ui-egui/src/i18n/zh-CN.tsv +++ b/crates/ui-egui/src/i18n/zh-CN.tsv @@ -332,6 +332,7 @@ figcraft Interface design and prototyping 界面设计与原型制作 Close (Esc) 关闭(Esc) Features 功能特性 Latest release 最新发布 + What's Changed 更新内容 Version 版本 Platforms 平台 Releases 版本发布 diff --git a/crates/ui-egui/src/i18n/zh-TW.tsv b/crates/ui-egui/src/i18n/zh-TW.tsv index 2ef0abea..7d80fa21 100644 --- a/crates/ui-egui/src/i18n/zh-TW.tsv +++ b/crates/ui-egui/src/i18n/zh-TW.tsv @@ -330,6 +330,7 @@ figcraft Interface design and prototyping 介面設計與原型製作 Close (Esc) 關閉(Esc) Features 功能 Latest release 最新發行版 + What's Changed 更新內容 Version 版本 Platforms 平台 Releases 發行版本 diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs index 73e44e8a..e7dbd350 100644 --- a/crates/ui-egui/src/icons.rs +++ b/crates/ui-egui/src/icons.rs @@ -87,6 +87,17 @@ pub fn bell() -> ImageSource<'static> { egui::include_image!("../../../assets/ui-icons/bell.svg") } +pub(crate) fn platform(name: &str) -> Option> { + Some(match name { + "macOS" => egui::include_image!("../../../assets/ui-icons/apple.svg"), + "Windows" => egui::include_image!("../../../assets/ui-icons/windows.svg"), + "Linux" => egui::include_image!("../../../assets/ui-icons/linux.svg"), + "FreeBSD" => egui::include_image!("../../../assets/ui-icons/freebsd.svg"), + name if name.eq_ignore_ascii_case("web") => social("Website")?, + _ => return None, + }) +} + /// The ArtCraft "A" mark in blue, as supplied: the launcher's app icon and getartcraft.com's favicon. pub fn artcraft_mark() -> ImageSource<'static> { egui::include_image!("../../../docs/brand/artcraft-mark.svg") diff --git a/crates/ui-egui/src/nightly.rs b/crates/ui-egui/src/nightly.rs index 16ec735a..a5ef04e7 100644 --- a/crates/ui-egui/src/nightly.rs +++ b/crates/ui-egui/src/nightly.rs @@ -1046,7 +1046,7 @@ impl LauncherUi { if let Some(id) = self.nightly.uninstall.clone() { let mut remove = false; let mut cancel = false; - let response = egui::Modal::new(egui::Id::unique("nightly-uninstall-v1")).frame(frame).show(ctx, |ui| { + let response = crate::sheet::modal(egui::Id::unique("nightly-uninstall-v1")).frame(frame).show(ctx, |ui| { ui.set_width(440.0_f32.min(ctx.content_rect().width() - 80.0).max(100.0)); ui.label(crate::widgets::heading(tl!("Uninstall developer build?"), crate::theme::DIALOG_TITLE, tokens.ink_strong)); ui.add_space(8.0); @@ -1073,7 +1073,7 @@ impl LauncherUi { } let mut enable = false; let mut cancel = false; - let response = egui::Modal::new(egui::Id::unique("nightly-consent-v1")).frame(frame).show(ctx, |ui| { + let response = crate::sheet::modal(egui::Id::unique("nightly-consent-v1")).frame(frame).show(ctx, |ui| { ui.set_width(440.0_f32.min(ctx.content_rect().width() - 80.0).max(100.0)); ui.label(crate::widgets::heading(tl!("Enable developer builds?"), crate::theme::DIALOG_TITLE, tokens.ink_strong)); ui.add_space(8.0); diff --git a/crates/ui-egui/src/notes.rs b/crates/ui-egui/src/notes.rs index f34b4711..ed1efbd2 100644 --- a/crates/ui-egui/src/notes.rs +++ b/crates/ui-egui/src/notes.rs @@ -37,8 +37,11 @@ pub(crate) fn classify(line: &str) -> Line<'_> { /// How many changes show before the rest folds away. const SHOWN: usize = 6; -pub(crate) fn show(ui: &mut Ui, notes: &str) { - show_scaled(ui, notes, 1.0); +pub(crate) fn show_in_details(ui: &mut Ui, notes: &str) { + ui.scope(|ui| { + ui.spacing_mut().item_spacing.y = 4.0; + show_lines(ui, notes, 1.0, true); + }); } /// The notes at `scale` times their usual size (the notes dialog's own zoom). @@ -47,19 +50,23 @@ pub(crate) fn show_scaled(ui: &mut Ui, notes: &str, scale: f32) { for font in ui.style_mut().text_styles.values_mut() { font.size *= scale; } - show_lines(ui, notes, scale); + show_lines(ui, notes, scale, false); }); } /// The notes, short: the first few changes in full, the rest behind "Show N more changes", and the /// link to the full changelog always in view. -fn show_lines(ui: &mut Ui, notes: &str, scale: f32) { +fn show_lines(ui: &mut Ui, notes: &str, scale: f32, has_section_heading: bool) { let t = Tokens::get(ui.ctx()); if notes.trim().is_empty() { ui.label(RichText::new(tl!("No notes were published with this release.")).color(t.muted)); return; } - let (changelog, lines): (Vec>, Vec>) = notes.lines().map(classify).partition(|l| full_changelog(l).is_some()); + let (changelog, mut lines): (Vec>, Vec>) = + notes.lines().map(classify).filter(|line| *line != Line::Blank).partition(|l| full_changelog(l).is_some()); + if has_section_heading && matches!(lines.first(), Some(Line::Heading(title)) if title.eq_ignore_ascii_case("What's Changed")) { + lines.remove(0); + } let bullets = lines.iter().filter(|l| matches!(l, Line::Bullet(..))).count(); let (head, rest) = lines.split_at(fold_at(&lines).unwrap_or(lines.len())); for line in head { @@ -118,9 +125,7 @@ fn draw(ui: &mut Ui, line: &Line<'_>, t: &Tokens, scale: f32) { Line::Text(text) => { ui.label(RichText::new(*text).color(t.muted)); } - Line::Blank => { - ui.add_space(2.0); - } + Line::Blank => {} } } diff --git a/crates/ui-egui/src/sheet.rs b/crates/ui-egui/src/sheet.rs index 291ccf60..c2f1fc56 100644 --- a/crates/ui-egui/src/sheet.rs +++ b/crates/ui-egui/src/sheet.rs @@ -11,9 +11,21 @@ use egui::{Color32, Context, CornerRadius, Frame, ImageSource, Margin, Ui, Vec2, use crate::theme::{self, Tokens, tint}; use crate::widgets; +/// The launcher header stays available while a sheet or picture is open. +pub(crate) fn content_rect(ctx: &Context) -> egui::Rect { + let mut rect = ctx.content_rect(); + rect.min.y = (rect.min.y + crate::views::HEADER_H).min(rect.max.y); + rect +} + +/// Center modal content below the header, using egui's modal backdrop and focus behavior. +pub(crate) fn modal(id: egui::Id) -> egui::Modal { + egui::Modal::new(id).area(egui::Modal::default_area(id).anchor(egui::Align2::CENTER_CENTER, vec2(0.0, crate::views::HEADER_H / 2.0))) +} + /// The size of a large dialog: the window less a margin all round, no larger than `max`. pub(crate) fn size(ctx: &Context, max: Vec2) -> Vec2 { - let screen = ctx.content_rect(); + let screen = content_rect(ctx); vec2((screen.width() - 64.0).clamp(1.0, max.x), (screen.height() - 48.0).clamp(1.0, max.y)) } diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs index d4f80284..e98211d8 100644 --- a/crates/ui-egui/src/widgets.rs +++ b/crates/ui-egui/src/widgets.rs @@ -266,8 +266,7 @@ enum WindowButton { /// Minimize, maximize (or restore) and close, `height` tall, for a right-to-left layout: close /// ends up at the right. Under a dialog egui ignores the header, so there they are drawn in a /// layer above the dialog's backdrop, as a system title bar is: the first click on Close closes -/// the window, not the dialog (#853). The details drawer and the lightbox still cover them, since -/// their own controls and the apps' menus can sit in that corner. +/// the window, not the dialog (#853). The details drawer and lightbox start below the header. pub(crate) fn window_buttons_width() -> f32 { 3.0 * CAPTION_W + 1.0 } diff --git a/crates/ui-egui/tests/ui.rs b/crates/ui-egui/tests/ui.rs index 0f60bb27..948326f2 100644 --- a/crates/ui-egui/tests/ui.rs +++ b/crates/ui-egui/tests/ui.rs @@ -3487,21 +3487,26 @@ fn the_lifted_caption_buttons_leave_tab_and_the_backdrop_to_the_dialog() { assert!(h.query_by_label("Done").is_none(), "a click left of Minimize dismisses the dialog"); } -/// The details drawer covers the header, and the window's Close stays under it. +/// The details drawer stays below the caption buttons, including while the page is open. #[test] -fn the_details_drawer_keeps_the_caption_buttons_under_it() { +fn the_details_drawer_keeps_the_caption_buttons_accessible() { let (mut h, _) = harness_with_title_bar(events(), ViewMode::Grid, egui::Theme::Dark, true, 1.0, artcraft_launcher_ui_egui::TitleBar::Custom); h.run_steps(8); - let close = h.get_by_label("Close").rect().center(); h.get_by_label("PhotoCraft details").click(); h.run_steps(10); - let asked = click_at(&mut h, close); - assert!(!asked.contains(&egui::ViewportCommand::Close), "the click reached the window's Close: {asked:?}"); + for (label, command) in [ + ("Minimize", egui::ViewportCommand::Minimized(true)), + ("Maximize", egui::ViewportCommand::Maximized(true)), + ("Close", egui::ViewportCommand::Close), + ] { + let spot = h.get_by_label(label).rect().center(); + let asked = click_at(&mut h, spot); + assert!(asked.contains(&command), "{label} did not reach the launcher window: {asked:?}"); + h.get_by_label("Enlarge picture"); + } } -/// The enlarged picture's own Close sits under the custom title bar's Close. With no dialog open -/// the caption buttons stay in the header, under the picture, so that click closes the picture -/// and not the window. +/// The picture has its own close button below the window's Close. #[test] fn the_enlarged_pictures_close_closes_the_picture_not_the_window() { let (mut h, _) = harness_with_title_bar(events(), ViewMode::Grid, egui::Theme::Dark, true, 1.0, artcraft_launcher_ui_egui::TitleBar::Custom); @@ -3510,14 +3515,42 @@ fn the_enlarged_pictures_close_closes_the_picture_not_the_window() { h.run_steps(10); h.get_by_label("Enlarge picture").click(); h.run_steps(4); - // The drawer's Close is lower down; the picture's is at the top right, under the title bar. let picture = h.query_all_by_label("Close (Esc)").map(|n| n.rect()).min_by(|a, b| a.top().total_cmp(&b.top())).unwrap(); - let spot = picture.intersect(h.get_by_label("Close").rect()); - assert!(spot.is_positive(), "the two buttons don't overlap: {picture:?}"); - let asked = click_at(&mut h, spot.center()); + let window = h.get_by_label("Close").rect(); + assert!(picture.top() >= window.bottom(), "the picture's close overlaps the caption: {picture:?}"); + let asked = click_at(&mut h, window.center()); + assert!(asked.contains(&egui::ViewportCommand::Close), "the title bar did not receive Close: {asked:?}"); + let asked = click_at(&mut h, picture.center()); assert!(!asked.contains(&egui::ViewportCommand::Close), "the click reached the window's Close: {asked:?}"); h.run_steps(4); assert_eq!(h.query_all_by_label("Close (Esc)").count(), 1, "the enlarged picture is still open"); + assert!(h.query_by_label("Enlarge picture").is_some(), "the drawer remains open after closing the enlarged picture"); +} + +#[test] +fn settings_opens_over_the_drawer_and_receives_input_after_enlarging_a_picture() { + use egui::accesskit::Role; + + let (mut h, _) = harness_with_title_bar(events(), ViewMode::Grid, egui::Theme::Dark, true, 1.0, artcraft_launcher_ui_egui::TitleBar::Custom); + h.run_steps(8); + h.get_by_label("PhotoCraft details").click(); + h.run_steps(10); + h.get_by_label("Enlarge picture").click(); + h.run_steps(4); + assert_eq!(h.query_all_by_label("Close (Esc)").count(), 2, "the enlarged picture is open"); + + let settings = h.get_by_label("Settings").rect().center(); + click_at(&mut h, settings); + assert_eq!(h.query_all_by_label("Close (Esc)").count(), 1, "the enlarged picture closes when Settings opens"); + h.key_press(egui::Key::Tab); + h.run_steps(2); + let language = h.get_by_role_and_label(Role::ComboBox, "Language"); + assert!(language.accesskit_node().is_focused(), "Tab focuses the Language control inside Settings"); + + let done = h.get_by_label("Done").rect().center(); + click_at(&mut h, done); + assert!(h.query_by_label("Done").is_none(), "the mouse can activate a control inside Settings"); + h.get_by_label("Enlarge picture"); } /// Maximized, the window's top-right pixel is the screen's corner: there is no resize band there, @@ -3734,6 +3767,8 @@ fn clicking_a_card_opens_its_details_drawer() { h.get_by_label("Website ↗"); h.get_by_label("GitHub ↗"); h.get_by_label("Releases ↗"); + assert_eq!(h.query_all_by_label("What's Changed").count(), 1, "the release heading is shown once"); + h.get_by_role_and_label(egui::accesskit::Role::Image, "Windows"); // The picture arrows wrap around, and the thumbnails jump. h.get_by_label("Previous picture (←)").click(); h.run_steps(3); @@ -3758,6 +3793,60 @@ fn details_drawer_in_the_light_theme() { h.get_all_by_label_contains("The image editor you already know how to use").last().unwrap(); } +#[test] +fn the_details_header_and_scrollbar_stay_inside_the_drawer_after_resize() { + let (mut h, _) = harness(ViewMode::Grid, egui::Theme::Dark, true); + h.run_steps(8); + h.get_by_label("PhotoCraft details").click(); + + for width in [1180.0, 720.0, 1000.0] { + h.set_size(egui::vec2(width, 650.0)); + h.run_steps(12); + let close = h.get_by_label("Close (Esc)").rect(); + let frame = h + .output() + .shapes + .iter() + .find_map(|clipped| match &clipped.shape { + egui::Shape::Rect(shape) if !shape.stroke.is_empty() && shape.rect.contains_rect(close) && shape.rect.height() > 400.0 => { + Some(shape.rect) + } + _ => None, + }) + .expect("the drawer has a frame"); + let photo = artcraft_launcher_core::CraftApp::by_id("photocraft").unwrap(); + let accent = artcraft_launcher_ui_egui::theme::rgb(photo.color); + let stripe = h + .output() + .shapes + .iter() + .find_map(|clipped| match &clipped.shape { + egui::Shape::Rect(shape) if shape.fill == accent && shape.rect.height() <= 2.0 && shape.rect.top() >= frame.top() => { + Some(shape.rect.intersect(clipped.clip_rect)) + } + _ => None, + }) + .expect("the drawer has an accent stripe"); + assert!(frame.contains_rect(stripe), "the stripe crosses the drawer frame at width {width}: {stripe:?} vs {frame:?}"); + let scrollbar = h + .query_all_by_role(egui::accesskit::Role::ScrollBar) + .map(|node| node.rect()) + .filter(|rect| rect.left() > close.right()) + .min_by(|a, b| a.top().total_cmp(&b.top())) + .expect("the details pane has a visible scrollbar"); + assert!(frame.contains_rect(scrollbar), "the scrollbar crosses the drawer frame at width {width}: {scrollbar:?} vs {frame:?}"); + assert!( + h.output().shapes.iter().any(|clipped| match &clipped.shape { + egui::Shape::Rect(shape) => shape.rect.intersect(clipped.clip_rect) == scrollbar && shape.fill != egui::Color32::TRANSPARENT, + _ => false, + }), + "the scrollbar track is painted at width {width}" + ); + } + h.check_accessibility(); + snapshot(&mut h, "details-bounded-dark"); +} + fn fetches(sent: &Rc>>, app: &str) -> usize { sent.borrow().iter().filter(|c| matches!(c, Command::FetchScreenshots { app: a } if a == app)).count() } @@ -3877,6 +3966,87 @@ fn a_page_without_pictures_has_no_gallery() { assert!(h.query_by_label("Next picture (→)").is_none()); } +#[test] +fn release_fact_cards_align_and_platform_names_appear_above_icons() { + use egui::{Shape, accesskit::Role}; + + let (mut h, _) = harness(ViewMode::Grid, egui::Theme::Dark, true); + h.run_steps(8); + h.get_by_label("PdfCraft details").scroll_to_me(); + h.run_steps(3); + h.get_by_label("PdfCraft details").click(); + h.run_steps(10); + + let card_for = |label| { + let label = h.get_by_label(label).rect(); + h.output() + .shapes + .iter() + .filter_map(|shape| match &shape.shape { + Shape::Rect(shape) if !shape.stroke.is_empty() && shape.rect.contains_rect(label) => Some(shape.rect), + _ => None, + }) + .min_by(|a, b| a.area().total_cmp(&b.area())) + .expect("the fact has an outline") + }; + let download = card_for("Download"); + let platforms = card_for("Platforms"); + assert!(!download.intersects(platforms), "each fact has its own card"); + assert!((download.width() - platforms.width()).abs() < 1.0, "the two cards use equal column widths"); + assert!((download.bottom() - platforms.bottom()).abs() < 1.0, "the two cards align at the bottom"); + + let icon = h.get_by_role_and_label(Role::Image, "Windows").rect(); + h.hover_at(icon.center()); + h.run_steps(40); + let tooltip = h.get_by_role_and_label(Role::Label, "Windows").rect(); + assert!(tooltip.bottom() < icon.top(), "the platform name appears above the icon"); + h.check_accessibility(); + snapshot(&mut h, "release-platform-tooltip-dark"); +} + +#[test] +fn release_fact_cards_fill_the_row_even_without_a_release_date() { + let mut events = events(); + for event in &mut events { + if let Event::Latest { app, latest: LatestRelease::Found(release), .. } = event + && app == "photocraft" + { + release.published_at = None; + } + } + let (mut h, _) = harness_with(events, ViewMode::Grid, egui::Theme::Dark, true, 1.0); + h.run_steps(8); + h.get_by_label("PhotoCraft details").click(); + h.run_steps(10); + h.get_by_label("Latest release").scroll_to_me(); + h.run_steps(5); + h.check_accessibility(); + snapshot(&mut h, "release-without-date"); + + assert!(h.query_by_label("Released").is_none()); + let card_for = |label| { + let label = h.get_by_label(label).rect(); + h.output() + .shapes + .iter() + .filter_map(|clipped| match &clipped.shape { + egui::Shape::Rect(shape) if !shape.stroke.is_empty() && shape.rect.contains_rect(label) => Some(shape.rect), + _ => None, + }) + .min_by(|a, b| a.area().total_cmp(&b.area())) + .expect("the fact has an outline") + }; + let [version, download, platforms] = ["Version", "Download", "Platforms"].map(card_for); + assert!(version.right() < download.left() && download.right() < platforms.left()); + for card in [version, download] { + assert!((card.width() - platforms.width()).abs() < 1.0); + assert!((card.bottom() - platforms.bottom()).abs() < 1.0); + } + let download_gap = download.left() - version.right(); + let last_feature = card_for("Serious color"); + assert!((platforms.right() - last_feature.right()).abs() < download_gap, "the release facts should fill the drawer width"); +} + #[test] /// Enlarge adds a second, keyboard-navigable view over the drawer; Esc closes the enlarged /// picture before the drawer.