mirror of
https://github.com/storytold/craft-launcher.git
synced 2026-12-02 20:22:35 -05:00
Share the layout steps between the app page, dialogs, toolbar and footer
- theme.rs gains the layout block: PAD, COLUMN_GAP, BOX_MARGIN, the toolbar, dialog and page widths that change the layout, the three title sizes, and the icon-link padding and gap. The app page, Settings, release notes and the small prompts read from it instead of their own 12/14/16/24/32s. - One brand-coloured scroll bar (sheet::accent_scroll takes the colour), used by the app page too instead of a copy. - An app that is not installed draws its text and accent in the theme's muted grey; only the icon is a grey copy of itself. - The compact toolbar puts "Sort" before its picker, like the full row; refresh lights up on hover like the grid/table switch beside it. - The grid keeps its sort rule in one place (views::grid_sort_now), and only the grid groups installed apps first; the table keeps its column's order. - icon_links owns its spacing, so neighbouring targets never touch, and Settings sizes its icon row with icon_links_width. - ATTRIBUTION.md lists discord.svg; a stale comment about the grid's sorts is gone.
This commit is contained in:
1 parent
95f693ecfb
commit
393c1c410d
11 files changed
+131
-108
No files matched your search
+1
-1
@@ -13,7 +13,7 @@ next to them.
|
||||
| `assets/app-icon/` (all files) | ArtCraft Launcher app icon: the ArtCraft "A" mark in blue (getartcraft.com's favicon) | ArtCraft Team | Rendered unmodified from `docs/brand/artcraft-mark.svg` by `packaging/icons.sh`, see [`assets/app-icon/README.md`](assets/app-icon/README.md) | **Not open source; not MIT or Apache-2.0.** ArtCraft trademark, [`docs/brand/LICENSE-brand.txt`](docs/brand/LICENSE-brand.txt) |
|
||||
| `packaging/macos/dmg/` (all files) | macOS DMG window background and layout | ArtCraft Launcher contributors, with the ArtCraft mark | Original work, see [`packaging/macos/dmg/README.md`](packaging/macos/dmg/README.md); the mark is `docs/brand/artcraft-mark-black.svg`, linked from `background.svg` and rendered unmodified into `background.tiff` | MIT OR Apache-2.0, like the code; the ArtCraft mark in it stays an ArtCraft trademark ([`docs/brand/LICENSE-brand.txt`](docs/brand/LICENSE-brand.txt)). The TIFF carries LittleCMS's built-in sRGB profile ("No copyright, use freely") |
|
||||
| `assets/social/linkedin.svg` | LinkedIn logo, linking to ArtCraft's company page | Fonticons, Inc. ([Font Awesome Free](https://fontawesome.com) 6.7.2) | Font Awesome Free `svgs/brands/linkedin.svg`; white fill and a square view box, see [`assets/social/README.md`](assets/social/README.md) | CC BY 4.0. The logo is a trademark of LinkedIn Corporation. |
|
||||
| `assets/social/x.svg`, `youtube.svg`, `tiktok.svg`, `instagram.svg` | X, YouTube, TikTok and Instagram 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/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) |
|
||||
| `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 |
|
||||
|
||||
@@ -661,17 +661,9 @@ impl LauncherUi {
|
||||
.collect();
|
||||
let platform = self.platform;
|
||||
let manage = self.caps.manage_apps;
|
||||
// The grid offers Name and Recently updated only; a table column's sort (or the old suite
|
||||
// order) reads as Name there.
|
||||
// The grid offers its own few orders (`views::grid_sort_now`); the table sorts by its columns.
|
||||
let grid = self.settings.view == ViewMode::Grid;
|
||||
let (sort, desc) = match self.settings.sort {
|
||||
SortKey::Name => (SortKey::Name, self.settings.sort_descending),
|
||||
// Newest and most opened first, whatever the table's columns last did.
|
||||
SortKey::Released | SortKey::Frequent if grid => (self.settings.sort, true),
|
||||
SortKey::Released | SortKey::Frequent => (self.settings.sort, self.settings.sort_descending),
|
||||
_ if grid => (SortKey::Name, false),
|
||||
other => (other, self.settings.sort_descending),
|
||||
};
|
||||
let (sort, desc) = if grid { crate::views::grid_sort_now(&self.settings) } else { (self.settings.sort, self.settings.sort_descending) };
|
||||
let dir = |o: std::cmp::Ordering| if desc { o.reverse() } else { o };
|
||||
// Empty cells (not installed, no release) go last whichever way the column sorts.
|
||||
let opt = |a: Option<std::cmp::Ordering>, a_some: bool, b_some: bool| match (a_some, b_some) {
|
||||
@@ -710,8 +702,11 @@ impl LauncherUi {
|
||||
// Ties keep suite order.
|
||||
ord.then(ia.cmp(ib))
|
||||
});
|
||||
// Installed apps always come first (the sort holds within each group; the sort is stable).
|
||||
list.sort_by_key(|(_, e)| !e.status(platform, manage).is_installed());
|
||||
// The grid shows installed apps first, then the rest under "Not installed" (the sort holds
|
||||
// within each group; the sort is stable). The table keeps the order its column gives.
|
||||
if grid {
|
||||
list.sort_by_key(|(_, e)| !e.status(platform, manage).is_installed());
|
||||
}
|
||||
list.into_iter().map(|(_, e)| e.app.id).collect()
|
||||
}
|
||||
|
||||
|
||||
@@ -60,21 +60,28 @@ pub fn view_toggle(ui: &mut Ui, view: &mut ViewMode, tips: [&str; 2]) {
|
||||
}
|
||||
}
|
||||
|
||||
/// The refresh control: a square in the same hairline box as the grid/table switch. While
|
||||
/// `busy` it shows a spinner and ignores clicks.
|
||||
/// The refresh control: a square in the same hairline box as the grid/table switch, and lit the
|
||||
/// same way on hover (sunken; the switch keeps inverted for the chosen view). While `busy` it shows
|
||||
/// a spinner and ignores clicks.
|
||||
pub fn refresh_button(ui: &mut Ui, tip: &str, busy: bool) -> egui::Response {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let (rect, resp) = ui.allocate_exact_size(vec2(theme::CONTROL_H, theme::CONTROL_H), if busy { Sense::hover() } else { Sense::click() });
|
||||
let hovered = resp.hovered() && !busy;
|
||||
let p = ui.painter();
|
||||
if hovered {
|
||||
p.rect_filled(rect, CornerRadius::ZERO, t.invert_bg);
|
||||
p.rect_filled(rect, CornerRadius::ZERO, t.sunken);
|
||||
}
|
||||
p.rect_stroke(rect, CornerRadius::ZERO, t.hairline(), egui::StrokeKind::Inside);
|
||||
if busy {
|
||||
egui::Spinner::new().size(16.0).color(t.muted).paint_at(ui, Rect::from_center_size(rect.center(), vec2(16.0, 16.0)));
|
||||
} else {
|
||||
p.text(rect.center(), egui::Align2::CENTER_CENTER, "\u{27f3}", egui::FontId::proportional(17.0), if hovered { t.invert_fg } else { t.muted });
|
||||
p.text(
|
||||
rect.center(),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
"\u{27f3}",
|
||||
egui::FontId::proportional(17.0),
|
||||
if hovered { t.ink_strong } else { t.muted },
|
||||
);
|
||||
}
|
||||
resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, !busy, tip));
|
||||
let resp = resp.on_hover_text(tip);
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::widgets::{self, Glyph, Kind};
|
||||
|
||||
/// Screenshots are 8:5.
|
||||
const SHOT_ASPECT: f32 = 0.625;
|
||||
const PAD: f32 = 24.0;
|
||||
const PAD: f32 = theme::PAD;
|
||||
/// As tall as the name, headline, "Like …" and version lines beside it, so the icon fills the row.
|
||||
const ICON: f32 = 112.0;
|
||||
/// The previous / next buttons over a picture.
|
||||
@@ -121,7 +121,7 @@ impl LauncherUi {
|
||||
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));
|
||||
// Wide enough, the page reads in two columns: the pictures and the story, then the facts.
|
||||
let wide = width >= 900.0;
|
||||
let wide = width >= theme::PAGE_COLUMNS_FROM;
|
||||
let panel = Rect::from_center_size(area.center() + vec2(0.0, (1.0 - k) * 24.0), vec2(width, height));
|
||||
let (previous, next) = self.neighbour_apps(&id);
|
||||
self.details_scrim(ctx, area, k, &t);
|
||||
@@ -134,20 +134,8 @@ impl LauncherUi {
|
||||
|
||||
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. egui's default one is
|
||||
// floating and invisible until the pointer is over it, so the page uses the solid style,
|
||||
// and draws it in the app's colour so it stands out from the page.
|
||||
ui.spacing_mut().scroll = egui::style::ScrollStyle::solid();
|
||||
ui.spacing_mut().scroll.bar_width = 10.0;
|
||||
let page_visuals = ui.visuals().clone();
|
||||
let bar = t.app_ink(entry.app);
|
||||
{
|
||||
let v = ui.visuals_mut();
|
||||
v.extreme_bg_color = t.bg.blend(tint(bar, if t.dark { 0.14 } else { 0.10 }));
|
||||
v.widgets.inactive.bg_fill = bar.gamma_multiply(0.8);
|
||||
v.widgets.hovered.bg_fill = bar;
|
||||
v.widgets.active.bg_fill = bar;
|
||||
}
|
||||
// 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.clone())).auto_shrink([false, false]).show(ui, |ui| {
|
||||
// The bar's colours are for the bar alone.
|
||||
@@ -161,7 +149,7 @@ impl LauncherUi {
|
||||
if wide && details.shots.is_empty() {
|
||||
// No pictures to fill the left side: the story and features share it, and the
|
||||
// release facts take the right, so neither side is left empty.
|
||||
let gap = 32.0;
|
||||
let gap = theme::COLUMN_GAP;
|
||||
let total = ui.available_width();
|
||||
let left_w = ((total - gap) * 0.58).floor();
|
||||
let right_w = total - gap - left_w;
|
||||
@@ -183,7 +171,7 @@ impl LauncherUi {
|
||||
});
|
||||
});
|
||||
} else if wide {
|
||||
let gap = 32.0;
|
||||
let gap = theme::COLUMN_GAP;
|
||||
let total = ui.available_width();
|
||||
let left_w = ((total - gap) * 0.58).floor();
|
||||
let right_w = total - gap - left_w;
|
||||
@@ -326,7 +314,7 @@ impl LauncherUi {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(text_w);
|
||||
ui.spacing_mut().item_spacing.y = 5.0;
|
||||
widgets::wordmark(ui, app, 32.0);
|
||||
widgets::wordmark(ui, app, theme::PAGE_TITLE);
|
||||
ui.add(egui::Label::new(RichText::new(details.headline).size(15.0).color(t.ink)).wrap());
|
||||
// "Version 0.5.0 · Oct 8, 2026", or the installed-versus-latest line.
|
||||
let version = crate::views::version_line(entry, &status);
|
||||
@@ -380,7 +368,7 @@ impl LauncherUi {
|
||||
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(Margin::same(12)).show(col, |ui| {
|
||||
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);
|
||||
@@ -567,7 +555,7 @@ fn features(ui: &mut Ui, details: &AppDetails, app: &CraftApp, t: &Tokens) {
|
||||
widgets::eyebrow(ui, "01", tl!("Features"));
|
||||
ui.add_space(4.0);
|
||||
for (i, f) in details.features.iter().enumerate() {
|
||||
egui::Frame::new().stroke(t.hairline()).inner_margin(Margin::symmetric(14, 12)).show(ui, |ui| {
|
||||
egui::Frame::new().stroke(t.hairline()).inner_margin(theme::BOX_MARGIN).show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
ui.spacing_mut().item_spacing.y = 3.0;
|
||||
ui.horizontal(|ui| {
|
||||
|
||||
@@ -23,7 +23,7 @@ impl LauncherUi {
|
||||
let modal = egui::Modal::new(egui::Id::new("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(24)
|
||||
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 close = false;
|
||||
let response = match &mut dialog {
|
||||
@@ -45,8 +45,9 @@ impl LauncherUi {
|
||||
fn alert_popup(&mut self, ctx: &egui::Context) {
|
||||
let Some(alert) = self.alerts.iter().find(|a| !self.settings.dismissed_notices.contains(&a.id)).cloned() else { return };
|
||||
let t = Tokens::get(ctx);
|
||||
let modal = egui::Modal::new(egui::Id::new("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(24));
|
||||
let modal = egui::Modal::new(egui::Id::new("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;
|
||||
modal.show(ctx, |ui| {
|
||||
ui.set_width(440.0f32.min(ctx.content_rect().width() - 80.0));
|
||||
@@ -83,7 +84,7 @@ impl LauncherUi {
|
||||
ui.add_space(4.0);
|
||||
ui.vertical(|ui| {
|
||||
ui.spacing_mut().item_spacing.y = 4.0;
|
||||
ui.label(widgets::heading(title, 22.0, t.ink_strong));
|
||||
ui.label(widgets::heading(title, theme::DIALOG_TITLE, t.ink_strong));
|
||||
if !subtitle.is_empty() {
|
||||
widgets::hud(ui, subtitle, t.faint);
|
||||
}
|
||||
@@ -104,10 +105,10 @@ impl LauncherUi {
|
||||
let hero_h = crate::sheet::hero(ui, crate::icons::app(id), &format!("{} {}", entry.app.name, release.version_label()), &date, |_| {});
|
||||
let footer_h = theme::CONTROL_H + 32.0;
|
||||
let body_h = (size.y - hero_h - footer_h - 2.0).max(0.0);
|
||||
let saved = crate::sheet::accent_scroll(ui, &t);
|
||||
let saved = crate::sheet::accent_scroll(ui, &t, t.accent);
|
||||
egui::ScrollArea::vertical().id_salt("notes-body").max_height(body_h).auto_shrink([false, true]).show(ui, |ui| {
|
||||
*ui.visuals_mut() = saved;
|
||||
egui::Frame::new().inner_margin(egui::Margin::same(24)).show(ui, |ui| {
|
||||
egui::Frame::new().inner_margin(egui::Margin::same(theme::PAD as i8)).show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
if release.notes.is_empty() {
|
||||
ui.label(tl!("These notes weren't fetched (GitHub's request limit was reached). They're on the release page."));
|
||||
@@ -118,7 +119,7 @@ impl LauncherUi {
|
||||
});
|
||||
ui.painter().hline(ui.max_rect().x_range(), ui.cursor().top(), t.hairline());
|
||||
let mut close = false;
|
||||
egui::Frame::new().inner_margin(egui::Margin::symmetric(24, 16)).show(ui, |ui| {
|
||||
egui::Frame::new().inner_margin(egui::Margin::symmetric(theme::PAD as i8, 16)).show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
ui.horizontal(|ui| {
|
||||
widgets::hud_link(ui, tl!("Open on GitHub"), &release.html_url);
|
||||
|
||||
@@ -52,11 +52,11 @@ impl LauncherUi {
|
||||
let footer_h = if stack_actions { 2.0 * theme::CONTROL_H + ui.spacing().item_spacing.y } else { theme::CONTROL_H } + 32.0;
|
||||
let body_h = (size.y - hero_h - footer_h - 2.0).max(0.0);
|
||||
|
||||
let wide = size.x >= sheet::WIDE_FROM;
|
||||
let saved = sheet::accent_scroll(ui, &t);
|
||||
let wide = size.x >= theme::DIALOG_COLUMNS_FROM;
|
||||
let saved = sheet::accent_scroll(ui, &t, t.accent);
|
||||
egui::ScrollArea::vertical().id_salt("settings-body").max_height(body_h).auto_shrink([false, true]).show(ui, |ui| {
|
||||
*ui.visuals_mut() = saved;
|
||||
egui::Frame::new().inner_margin(egui::Margin::same(24)).show(ui, |ui| {
|
||||
egui::Frame::new().inner_margin(egui::Margin::same(theme::PAD as i8)).show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
self.settings_contents(ui, host, wide);
|
||||
});
|
||||
@@ -65,7 +65,7 @@ impl LauncherUi {
|
||||
let rule_y = ui.cursor().top();
|
||||
ui.painter().hline(ui.max_rect().x_range(), rule_y, t.hairline());
|
||||
let mut close = false;
|
||||
egui::Frame::new().inner_margin(egui::Margin::symmetric(24, 16)).show(ui, |ui| {
|
||||
egui::Frame::new().inner_margin(egui::Margin::symmetric(theme::PAD as i8, 16)).show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
let quit = |ui: &mut Ui, host: &mut dyn Host| {
|
||||
if self.caps.manage_apps && widgets::button(ui, tl!("Quit ArtCraft Launcher"), Kind::Secondary, 0.0).clicked() {
|
||||
@@ -96,7 +96,7 @@ impl LauncherUi {
|
||||
sheet::columns(
|
||||
ui,
|
||||
wide,
|
||||
24.0,
|
||||
theme::COLUMN_GAP,
|
||||
|ui| {
|
||||
let (this, _) = &mut *state.borrow_mut();
|
||||
this.settings_language(ui);
|
||||
@@ -281,10 +281,8 @@ impl LauncherUi {
|
||||
ui.ctx().open_url(egui::OpenUrl::new_tab(GITHUB_URL));
|
||||
}
|
||||
// Wrap the social links as a group so their icons stay together.
|
||||
let count = artcraft_launcher_core::catalog::SOCIAL.len() as f32;
|
||||
let width = count * (16.0 + 8.0) + (count - 1.0).max(0.0) * 4.0;
|
||||
let width = widgets::icon_links_width(artcraft_launcher_core::catalog::SOCIAL.len(), 16.0);
|
||||
ui.allocate_ui_with_layout(vec2(width, theme::CONTROL_H), egui::Layout::left_to_right(egui::Align::Center), |ui| {
|
||||
ui.spacing_mut().item_spacing.x = 4.0;
|
||||
widgets::social_icons(ui, 16.0);
|
||||
});
|
||||
});
|
||||
|
||||
+20
-22
@@ -8,12 +8,9 @@
|
||||
|
||||
use egui::{Color32, Context, CornerRadius, Frame, ImageSource, Margin, Ui, Vec2, vec2};
|
||||
|
||||
use crate::theme::{Tokens, tint};
|
||||
use crate::theme::{self, Tokens, tint};
|
||||
use crate::widgets;
|
||||
|
||||
/// The body of a dialog reads in two columns from this width.
|
||||
pub(crate) const WIDE_FROM: f32 = 760.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();
|
||||
@@ -30,37 +27,38 @@ pub(crate) fn frame(t: &Tokens) -> Frame {
|
||||
pub(crate) fn hero(ui: &mut Ui, icon: Option<ImageSource<'static>>, title: &str, caption: &str, right: impl FnOnce(&mut Ui)) -> f32 {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let top = ui.cursor().top();
|
||||
let shown = Frame::new().fill(tint(t.accent, if t.dark { 0.09 } else { 0.07 })).inner_margin(Margin::symmetric(24, 18)).show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
ui.horizontal(|ui| {
|
||||
if let Some(icon) = icon {
|
||||
ui.add(egui::Image::new(icon).fit_to_exact_size(vec2(44.0, 44.0)));
|
||||
ui.add_space(6.0);
|
||||
}
|
||||
ui.vertical(|ui| {
|
||||
ui.spacing_mut().item_spacing.y = 4.0;
|
||||
ui.label(widgets::heading(title, 26.0, t.ink_strong));
|
||||
if !caption.is_empty() {
|
||||
widgets::hud(ui, caption, t.faint);
|
||||
let shown =
|
||||
Frame::new().fill(tint(t.accent, if t.dark { 0.09 } else { 0.07 })).inner_margin(Margin::symmetric(theme::PAD as i8, 18)).show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
ui.horizontal(|ui| {
|
||||
if let Some(icon) = icon {
|
||||
ui.add(egui::Image::new(icon).fit_to_exact_size(vec2(44.0, 44.0)));
|
||||
ui.add_space(6.0);
|
||||
}
|
||||
ui.vertical(|ui| {
|
||||
ui.spacing_mut().item_spacing.y = 4.0;
|
||||
ui.label(widgets::heading(title, theme::SHEET_TITLE, t.ink_strong));
|
||||
if !caption.is_empty() {
|
||||
widgets::hud(ui, caption, t.faint);
|
||||
}
|
||||
});
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), right);
|
||||
});
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), right);
|
||||
});
|
||||
});
|
||||
let r = shown.response.rect;
|
||||
ui.painter().rect_filled(egui::Rect::from_min_size(r.min, vec2(r.width(), 2.0)), CornerRadius::ZERO, t.accent);
|
||||
ui.painter().hline(r.x_range(), r.bottom() - 0.5, t.hairline());
|
||||
ui.cursor().top() - top
|
||||
}
|
||||
|
||||
/// A solid scroll bar in the brand colour on a dark tint of it, so it stands out from the page.
|
||||
/// A solid scroll bar in `bar` (the brand colour, or an app's on its page) on a tint of it, so it
|
||||
/// stands out from the page; egui's floating one is invisible until the pointer is over it.
|
||||
/// Returns the visuals to put back inside the scroll area's contents (the bar's colours are for the
|
||||
/// bar alone).
|
||||
pub(crate) fn accent_scroll(ui: &mut Ui, t: &Tokens) -> egui::Visuals {
|
||||
pub(crate) fn accent_scroll(ui: &mut Ui, t: &Tokens, bar: Color32) -> egui::Visuals {
|
||||
ui.spacing_mut().scroll = egui::style::ScrollStyle::solid();
|
||||
ui.spacing_mut().scroll.bar_width = 10.0;
|
||||
let page = ui.visuals().clone();
|
||||
let bar: Color32 = t.accent;
|
||||
let v = ui.visuals_mut();
|
||||
v.extreme_bg_color = t.bg.blend(tint(bar, if t.dark { 0.14 } else { 0.10 }));
|
||||
v.widgets.inactive.bg_fill = bar.gamma_multiply(0.8);
|
||||
@@ -93,7 +91,7 @@ pub(crate) fn columns(ui: &mut Ui, wide: bool, gap: f32, left: impl FnOnce(&mut
|
||||
/// A titled box: a hairline frame with a small caps heading, for one group of settings.
|
||||
pub(crate) fn panel(ui: &mut Ui, title: &str, body: impl FnOnce(&mut Ui)) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
Frame::new().stroke(t.hairline()).inner_margin(16).show(ui, |ui| {
|
||||
Frame::new().stroke(t.hairline()).inner_margin(theme::BOX_MARGIN).show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
widgets::hud(ui, title, t.faint);
|
||||
ui.add_space(8.0);
|
||||
|
||||
@@ -239,6 +239,31 @@ pub const HUD_SPACING: f32 = HUD_SIZE * 0.15;
|
||||
/// Buttons: 11 px Geist Mono 700, upper case, 0.12 em apart.
|
||||
pub const BUTTON_SPACING: f32 = HUD_SIZE * 0.12;
|
||||
|
||||
// ---- layout ------------------------------------------------------------------------------------
|
||||
// The app page and the large dialogs (Settings, release notes) share these, so they read as one
|
||||
// family; the toolbar and the footer use the same steps.
|
||||
|
||||
/// Padding inside the app page and the dialogs, round their headers, bodies and footers.
|
||||
pub const PAD: f32 = 24.0;
|
||||
/// The gap between the two columns of a page or dialog.
|
||||
pub const COLUMN_GAP: f32 = 32.0;
|
||||
/// Padding inside a hairline box: a group of settings, a feature, a release fact.
|
||||
pub const BOX_MARGIN: egui::Margin = egui::Margin::symmetric(14, 12);
|
||||
/// Below this width the toolbar moves the sort and "Update all" to a second row.
|
||||
pub const TOOLBAR_COMPACT_BELOW: f32 = 640.0;
|
||||
/// From this width the large dialogs read in two columns.
|
||||
pub const DIALOG_COLUMNS_FROM: f32 = 760.0;
|
||||
/// From this width the app page reads in two columns (its pictures need the room).
|
||||
pub const PAGE_COLUMNS_FROM: f32 = 900.0;
|
||||
/// Title sizes, largest first: an app page's name, a large dialog's title, a small prompt's title.
|
||||
pub const PAGE_TITLE: f32 = 32.0;
|
||||
pub const SHEET_TITLE: f32 = 26.0;
|
||||
pub const DIALOG_TITLE: f32 = 22.0;
|
||||
/// A row of icon links (the footer, Settings): the room round each logo, and the gap between their
|
||||
/// targets; neighbours' logos sit `2 × ICON_LINK_PAD + ICON_LINK_GAP` apart.
|
||||
pub const ICON_LINK_PAD: f32 = 6.0;
|
||||
pub const ICON_LINK_GAP: f32 = 2.0;
|
||||
|
||||
/// Inter 500.
|
||||
pub fn medium() -> FontFamily {
|
||||
FontFamily::Name("medium".into())
|
||||
|
||||
@@ -185,7 +185,7 @@ impl LauncherUi {
|
||||
self.settings.filter = if showing { Filter::All } else { Filter::Hidden };
|
||||
}
|
||||
}
|
||||
compact = ui.available_width() < 640.0;
|
||||
compact = ui.available_width() < theme::TOOLBAR_COMPACT_BELOW;
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
// Right to left: the view switch at the far right, then the search.
|
||||
crate::bar::view_toggle(ui, &mut self.settings.view, [tl!("Show apps as cards"), tl!("Show apps as a table")]);
|
||||
@@ -215,8 +215,9 @@ impl LauncherUi {
|
||||
ui.add_space(6.0);
|
||||
ui.horizontal(|ui| {
|
||||
if self.settings.view == ViewMode::Grid {
|
||||
self.sort_picker(ui);
|
||||
// "Sort" before the picker, as in the full-width row.
|
||||
widgets::hud(ui, tl!("Sort"), t.faint);
|
||||
self.sort_picker(ui);
|
||||
}
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
if self.caps.manage_apps && updates > 0 {
|
||||
@@ -331,15 +332,12 @@ impl LauncherUi {
|
||||
tip: fmt(tl!("ArtCraft on {name}"), &[("name", name)]),
|
||||
url,
|
||||
}));
|
||||
let (icon, pad) = (13.0, 7.0);
|
||||
let icon = 13.0;
|
||||
let spacing = ui.spacing().item_spacing.x;
|
||||
// The icons on the right keep their size; the status on the left gets what is left and
|
||||
// is cut short with "…", never drawn under them.
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ui.scope(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = 0.0;
|
||||
widgets::icon_links(ui, icon, pad, &links);
|
||||
});
|
||||
widgets::icon_links(ui, icon, &links);
|
||||
ui.add_space(8.0);
|
||||
ui.with_layout(egui::Layout::left_to_right(egui::Align::Center), |ui| {
|
||||
// While GitHub is rate limited, saying so matters more than when we last checked.
|
||||
@@ -412,13 +410,8 @@ impl LauncherUi {
|
||||
// colours while the pointer is over its card.
|
||||
let installed = entry.status(self.platform, self.caps.manage_apps).is_installed();
|
||||
let in_colour = installed || hovered;
|
||||
let app_color = if installed {
|
||||
rgb(app.color)
|
||||
} else {
|
||||
let c = rgb(app.color);
|
||||
let grey = Color32::from_gray((0.299 * f32::from(c.r()) + 0.587 * f32::from(c.g()) + 0.114 * f32::from(c.b())).round() as u8);
|
||||
grey.lerp_to_gamma(c, lift)
|
||||
};
|
||||
// The text and accent use the theme's muted grey; the icon is a grey copy of itself.
|
||||
let app_color = if installed { rgb(app.color) } else { t.muted.lerp_to_gamma(rgb(app.color), lift) };
|
||||
// The whole card opens the app's page. Added before the card's own links and buttons, so
|
||||
// they sit on top of it and keep their clicks.
|
||||
if AppDetails::by_id(id).is_some() {
|
||||
@@ -958,7 +951,7 @@ const GRID_SORTS: [(SortKey, bool); 4] = [(SortKey::Name, false), (SortKey::Name
|
||||
|
||||
/// Which of [`GRID_SORTS`] the settings come to. Anything else (the old suite order, a table
|
||||
/// column) reads as Name, A to Z.
|
||||
fn grid_sort_now(s: &crate::settings::Settings) -> (SortKey, bool) {
|
||||
pub(crate) fn grid_sort_now(s: &crate::settings::Settings) -> (SortKey, bool) {
|
||||
match s.sort {
|
||||
SortKey::Name => (SortKey::Name, s.sort_descending),
|
||||
SortKey::Released => (SortKey::Released, true),
|
||||
|
||||
@@ -496,7 +496,7 @@ pub fn social_icons(ui: &mut Ui, size: f32) {
|
||||
.iter()
|
||||
.map(|(name, url)| IconLink { name, label: (*name).to_string(), tip: crate::i18n::fmt(tl!("ArtCraft on {name}"), &[("name", name)]), url })
|
||||
.collect();
|
||||
icon_links(ui, size, 4.0, &links);
|
||||
icon_links(ui, size, &links);
|
||||
}
|
||||
|
||||
/// One logo that opens a page: `name` picks the picture, `label` is what a screen reader says,
|
||||
@@ -508,22 +508,39 @@ pub struct IconLink<'a> {
|
||||
pub url: &'a str,
|
||||
}
|
||||
|
||||
/// A row of logo links, given in reading order; each is `size` wide with `pad` on every side.
|
||||
/// In a right-to-left parent they still read in the order given.
|
||||
pub fn icon_links(ui: &mut Ui, size: f32, pad: f32, links: &[IconLink<'_>]) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let rtl = ui.layout().prefer_right_to_left();
|
||||
let ordered: Vec<&IconLink<'_>> = if rtl { links.iter().rev().collect() } else { links.iter().collect() };
|
||||
for link in ordered {
|
||||
let Some(icon) = crate::icons::social(link.name) else { continue };
|
||||
let (rect, resp) = ui.allocate_exact_size(vec2(size + 2.0 * pad, size + 2.0 * pad), Sense::click());
|
||||
let color = if resp.hovered() { t.ink_strong } else { t.faint };
|
||||
egui::Image::new(icon).tint(color).paint_at(ui, rect.shrink(pad));
|
||||
resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Link, true, &link.label));
|
||||
let resp = resp.on_hover_text(&link.tip).on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
if resp.clicked() {
|
||||
ui.ctx().open_url(egui::OpenUrl::new_tab(link.url));
|
||||
/// The width [`icon_links`] takes for `count` logos `size` wide.
|
||||
pub fn icon_links_width(count: usize, size: f32) -> f32 {
|
||||
let n = count as f32;
|
||||
n * (size + 2.0 * crate::theme::ICON_LINK_PAD) + (n - 1.0).max(0.0) * crate::theme::ICON_LINK_GAP
|
||||
}
|
||||
|
||||
/// A row of logo links, given in reading order; each is `size` wide, spaced by the theme's
|
||||
/// `ICON_LINK_PAD` and `ICON_LINK_GAP` wherever the row is. In a right-to-left parent they still
|
||||
/// read in the order given.
|
||||
pub fn icon_links(ui: &mut Ui, size: f32, links: &[IconLink<'_>]) {
|
||||
ui.scope(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = crate::theme::ICON_LINK_GAP;
|
||||
for link in links_in_order(ui, links) {
|
||||
icon_link(ui, size, link);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn links_in_order<'l, 'a>(ui: &Ui, links: &'l [IconLink<'a>]) -> Vec<&'l IconLink<'a>> {
|
||||
if ui.layout().prefer_right_to_left() { links.iter().rev().collect() } else { links.iter().collect() }
|
||||
}
|
||||
|
||||
fn icon_link(ui: &mut Ui, size: f32, link: &IconLink<'_>) {
|
||||
let Some(icon) = crate::icons::social(link.name) else { return };
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let pad = crate::theme::ICON_LINK_PAD;
|
||||
let (rect, resp) = ui.allocate_exact_size(vec2(size + 2.0 * pad, size + 2.0 * pad), Sense::click());
|
||||
let color = if resp.hovered() { t.ink_strong } else { t.faint };
|
||||
egui::Image::new(icon).tint(color).paint_at(ui, rect.shrink(pad));
|
||||
resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Link, true, &link.label));
|
||||
let resp = resp.on_hover_text(&link.tip).on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
if resp.clicked() {
|
||||
ui.ctx().open_url(egui::OpenUrl::new_tab(link.url));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -780,11 +780,12 @@ fn every_table_column_sorts_both_ways() {
|
||||
h.run_steps(3);
|
||||
let o = order(&h);
|
||||
assert_eq!(&o[..4], ["PhotoCraft", "EffectCraft", "LightCraft", "WordCraft"], "{o:?}");
|
||||
// Reversed: the up to date ones first.
|
||||
// Reversed: the apps not installed first, then up to date, then the updates last. The table
|
||||
// keeps its column's order; only the grid puts installed apps above the rest.
|
||||
h.get_by_label("Status").click();
|
||||
h.run_steps(3);
|
||||
let o = order(&h);
|
||||
assert_eq!(&o[..4], ["LightCraft", "WordCraft", "PhotoCraft", "EffectCraft"], "{o:?}");
|
||||
assert_eq!(&o[o.len().saturating_sub(4)..], ["LightCraft", "WordCraft", "PhotoCraft", "EffectCraft"], "{o:?}");
|
||||
// The old Installed and Latest columns are gone; Version shows the number, and from and to for an update.
|
||||
assert!(h.query_by_label("Latest").is_none());
|
||||
h.get_by_label("Version");
|
||||
|
||||
Reference in new issue
Block a user