mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-26 08:29:14 +00:00
Merge branch 'look-fix/chrome' into area/app-1
This commit is contained in:
@@ -49,7 +49,7 @@ pub(super) enum Notice {
|
||||
LockSignatures,
|
||||
}
|
||||
|
||||
/// One inline notice with the icon named `icon`.
|
||||
/// One page notice bar with the icon named `icon`.
|
||||
fn bar(tone: Tone, icon: &'static str, text: String) -> Bar<'static> {
|
||||
Bar::new(tone, text).layout(NoticeLayout::Bar).icon(NoticeIcon::Custom(IconId::new(icon).into()))
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ pub(crate) mod doc_tabs;
|
||||
mod mode_bar;
|
||||
pub(crate) mod view_rail;
|
||||
|
||||
pub(crate) const HOME_ICON: &str = "home";
|
||||
|
||||
/// Compose the window: title bar, mode bar, view rail and the dock, whose document panel holds the
|
||||
/// pages.
|
||||
///
|
||||
@@ -100,14 +102,18 @@ fn title_bar(app: &mut PdfCraftApp, ui: &mut egui::Ui) {
|
||||
title,
|
||||
|ui, _| {
|
||||
let home = app.active.is_none() && !app.combine_showing();
|
||||
if IconButton::new(IconId::new("house")).label(tl!("Home")).selected(home).show(ui).clicked() {
|
||||
if IconButton::new(IconId::new(HOME_ICON)).label(tl!("Home")).selected(home).show(ui).clicked() {
|
||||
app.active = None;
|
||||
app.combine_tab.focused = false;
|
||||
}
|
||||
doc_tabs::strip(app, ui, Place::Main);
|
||||
},
|
||||
|ui, _| {
|
||||
IconButton::command(IconId::new("messages-square"), "help.discord").show(ui);
|
||||
Button::command("help.discord")
|
||||
.label("Discord")
|
||||
.icon(IconId::new("messages-square"))
|
||||
.tooltip(tl!("Join the ArtCraft Discord"))
|
||||
.show(ui);
|
||||
IconButton::command(IconId::new("circle-help"), "help.shortcuts").show(ui);
|
||||
let theme_button = IconButton::command(IconId::new(theme_icon), ThemeChoice::NextMode.command()).label(theme_label.clone()).show(ui);
|
||||
let opener = theme_button.response().clone();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Help ▸ About: the framework's hosted About dialog over the app's info and the baked credits.
|
||||
|
||||
use craft::behavior::IconId;
|
||||
use craft::ui::patterns::form_dialogs::{AboutImage, AboutInfo, AboutLink, AboutTab, HostedAbout};
|
||||
|
||||
use crate::PdfCraftApp;
|
||||
@@ -13,7 +14,7 @@ const LOGO_WHITE: &[u8] = include_bytes!("../../../../docs/brand/artcraft-logo-w
|
||||
|
||||
/// What the About tab shows: PdfCraft's name, blurb and version, the ArtCraft brand, and the community links.
|
||||
fn info() -> AboutInfo {
|
||||
let mut info = AboutInfo::new(
|
||||
let info = AboutInfo::new(
|
||||
"PdfCraft",
|
||||
tl!("A clean-room, open-source PDF application written in Rust. MIT OR Apache-2.0."),
|
||||
pdfcraft_engine::build_info::version(),
|
||||
@@ -21,12 +22,7 @@ fn info() -> AboutInfo {
|
||||
.mark(AboutImage::svg("ArtCraft", MARK))
|
||||
.part_of(AboutImage::svg("ArtCraft", LOGO).dark(LOGO_WHITE))
|
||||
.built_with("Rendering: hayro (bootstrap) · UI: egui · Icons: Lucide (ISC) · Fonts: Inter, JetBrains Mono, Dancing Script (OFL)");
|
||||
let (community, others): (Vec<&pdfcraft_engine::links::Link>, Vec<&pdfcraft_engine::links::Link>) =
|
||||
pdfcraft_engine::links::LINKS.iter().partition(|l| l.url == pdfcraft_engine::links::DISCORD);
|
||||
if let Some(l) = community.first() {
|
||||
info = info.community(AboutLink::new(tl!(l.label).to_string(), l.url));
|
||||
}
|
||||
info.links(others.into_iter().map(|l| AboutLink::new(tl!(l.label).to_string(), l.url)))
|
||||
info.links(pdfcraft_engine::links::LINKS.iter().map(|l| AboutLink::new(tl!(l.label).to_string(), l.url).icon(IconId::new(l.icon))))
|
||||
}
|
||||
|
||||
impl PdfCraftApp {
|
||||
@@ -43,3 +39,16 @@ impl PdfCraftApp {
|
||||
self.open_url(&url);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn about_community_links_keep_their_icons_and_destinations() {
|
||||
let info = super::info();
|
||||
assert_eq!(info.links.len(), pdfcraft_engine::links::LINKS.len());
|
||||
for (shown, expected) in info.links.iter().zip(pdfcraft_engine::links::LINKS) {
|
||||
assert_eq!(shown.url, expected.url);
|
||||
assert_eq!(shown.icon, Some(craft::behavior::IconId::new(expected.icon)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,9 @@ const ICONS: &[(&str, &[u8])] = &[
|
||||
icon!("braces"),
|
||||
icon!("camera"),
|
||||
icon!("check-circle-2"),
|
||||
icon!("circle-check"),
|
||||
icon!("circle-help"),
|
||||
icon!("circle-x"),
|
||||
icon!("clipboard-paste"),
|
||||
icon!("clock-3"),
|
||||
icon!("cloud-upload"),
|
||||
@@ -99,6 +101,7 @@ const ICONS: &[(&str, &[u8])] = &[
|
||||
icon!("text-cursor-input"),
|
||||
icon!("text-select"),
|
||||
icon!("trash-2"),
|
||||
icon!("triangle-alert"),
|
||||
icon!("type"),
|
||||
icon!("user-round"),
|
||||
icon!("wrench"),
|
||||
@@ -147,6 +150,10 @@ mod tests {
|
||||
let missing: Vec<String> =
|
||||
engine_icons().into_iter().filter(|(_, name)| !has_icon(&IconId::new(name))).map(|(owner, name)| format!("{owner}: {name}")).collect();
|
||||
assert!(missing.is_empty(), "icons nobody has: {missing:?}");
|
||||
assert!(has_icon(&IconId::new(crate::chrome::HOME_ICON)), "the title bar Home icon resolves");
|
||||
for name in ["circle-check", "circle-x", "triangle-alert"] {
|
||||
assert!(has_icon(&IconId::new(name)), "signature notice icon {name}");
|
||||
}
|
||||
// The eight documents the comment tools name stay served.
|
||||
for name in
|
||||
["message-square-plus", "type", "highlighter", "move-right", "message-square-quote", "message-square-text", "replace", "paperclip"]
|
||||
|
||||
@@ -713,7 +713,7 @@ fn tabs_shrink_to_fit_then_arrows_step_through_them_and_open_stays_in_sight() {
|
||||
}
|
||||
});
|
||||
let open = h.get_by_label("Open…").rect();
|
||||
let discord = h.get_by_label("Join the ArtCraft Discord").rect();
|
||||
let discord = h.get_by_label("Discord").rect();
|
||||
assert!(open.right() <= discord.left(), "Open {open:?} must not run under Discord {discord:?}");
|
||||
let mut previous_right = f32::MIN;
|
||||
for i in 0..5 {
|
||||
@@ -728,7 +728,7 @@ fn tabs_shrink_to_fit_then_arrows_step_through_them_and_open_stays_in_sight() {
|
||||
h.state_mut().open_bytes(&ctx_h, &name(i), None, FIXTURE.to_vec()).unwrap();
|
||||
}
|
||||
h.run_steps(6);
|
||||
let (open, discord) = (h.get_by_label("Open…").rect(), h.get_by_label("Join the ArtCraft Discord").rect());
|
||||
let (open, discord) = (h.get_by_label("Open…").rect(), h.get_by_label("Discord").rect());
|
||||
assert!(open.right() <= discord.left(), "Open {open:?} stays left of Discord {discord:?} with seven tabs");
|
||||
for i in 0..13 {
|
||||
let ctx_h = h.ctx.clone();
|
||||
@@ -736,7 +736,7 @@ fn tabs_shrink_to_fit_then_arrows_step_through_them_and_open_stays_in_sight() {
|
||||
}
|
||||
h.run_steps(4);
|
||||
let open = h.get_by_label("Open…").rect();
|
||||
let discord = h.get_by_label("Join the ArtCraft Discord").rect();
|
||||
let discord = h.get_by_label("Discord").rect();
|
||||
assert!(open.left() > 0.0 && open.right() <= discord.left(), "Open {open:?} stays in sight left of Discord {discord:?}");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user