Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Discord, website and GitHub links; fix AppStream validation on 22.04

Brandon Thomas08c6c08e2eb6
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index 1cb34a5f3..c48bed5cb 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -559,7 +559,7 @@ fn start_screen(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = crate::theme::Tokens::get(ui.ctx());
let area = ui.available_rect_before_wrap();
paint_dots(ui, area);
- let card = Rect::from_center_size(area.center(), egui::vec2(460.0, 250.0));
+ let card = Rect::from_center_size(area.center(), egui::vec2(460.0, 330.0));
ui.scope_builder(egui::UiBuilder::new().max_rect(card), |ui| {
ui.vertical_centered(|ui| {
ui.horizontal(|ui| {
@@ -594,6 +594,10 @@ fn start_screen(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
crate::icons::paint(ui, r, "image", 15.0, t.text_faint);
ui.label(egui::RichText::new(msg).color(t.text_faint));
});
+ ui.add_space(26.0);
+ crate::links::discord_button(app, ui, 190.0);
+ ui.add_space(10.0);
+ crate::links::link_row(ui);
});
});
}
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index 529929347..a6d67768c 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -29,6 +29,13 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
DialogKind::About => {
ui.label("PhotoCraft — an open-source, native image editor written in Rust.");
ui.label(format!("Version {}", photocraft_engine::build_info::long_version()));
+ ui.add_space(12.0);
+ ui.vertical_centered(|ui| {
+ crate::links::discord_button(app, ui, 220.0);
+ ui.add_space(8.0);
+ crate::links::link_row(ui);
+ });
+ ui.add_space(10.0);
ui.weak("egui · wgpu · photocraft-engine");
}
DialogKind::Command if crate::prefs_ui::owns(&fields) => crate::prefs_ui::body(app, ui, &mut fields),
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index b59518f7b..b6d1fc90e 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -21,6 +21,7 @@ pub mod gpu_canvas;
pub mod filter_dialog;
pub mod icons;
pub mod layer_style;
+pub mod links;
pub mod menu_catalog;
pub mod menus;
pub mod outline;
diff --git a/crates/ui-egui/src/links.rs b/crates/ui-egui/src/links.rs
new file mode 100644
index 000000000..a4525ebb7
--- /dev/null
+++ b/crates/ui-egui/src/links.rs
@@ -0,0 +1,88 @@
+//! Community and project links: the Help menu, the About dialog, the start screen and the title
+//! bar all open these. URLs follow the crafting-app pattern (`getartcraft.com/apps/<app>`,
+//! `github.com/storytold/<app>`).
+
+use serde_json::{Value, json};
+
+use crate::PhotocraftApp;
+
+pub const DISCORD: &str = "https://discord.gg/artcraft";
+pub const ARTCRAFT_WEBSITE: &str = "https://getartcraft.com";
+pub const APP_PAGE: &str = "https://getartcraft.com/apps/photocraft";
+pub const GITHUB: &str = "https://github.com/storytold/photocraft";
+pub const ISSUES: &str = "https://github.com/storytold/photocraft/issues";
+
+/// Help-menu link commands: (id, url). Labels live in `menus::UI_COMMANDS`.
+pub const COMMANDS: &[(&str, &str)] = &[
+ ("help.discord", DISCORD),
+ ("help.website", APP_PAGE),
+ ("help.artcraftWebsite", ARTCRAFT_WEBSITE),
+ ("help.github", GITHUB),
+ ("help.reportIssue", ISSUES),
+];
+
+pub fn url_for(id: &str) -> Option<&'static str> {
+ COMMANDS.iter().find(|c| c.0 == id).map(|c| c.1)
+}
+
+/// Open `url` in the system browser (a new tab on the web) and note it in the status bar.
+pub fn open(app: &mut PhotocraftApp, ctx: &egui::Context, url: &str) -> Value {
+ ctx.open_url(egui::OpenUrl::new_tab(url));
+ app.ui.status = format!("Opened {url}");
+ json!({"url": url})
+}
+
+/// The prominent "Join us on Discord" button.
+pub fn discord_button(app: &mut PhotocraftApp, ui: &mut egui::Ui, min_width: f32) -> egui::Response {
+ let r = crate::widgets::primary_button(ui, "Join us on Discord", min_width).on_hover_text(DISCORD);
+ if r.clicked() {
+ open(app, ui.ctx(), DISCORD);
+ }
+ r
+}
+
+/// "PhotoCraft website · GitHub · ArtCraft" as hyperlinks, centred in the available width.
+pub fn link_row(ui: &mut egui::Ui) {
+ let t = crate::theme::Tokens::get(ui.ctx());
+ let links = [("PhotoCraft website", APP_PAGE), ("GitHub", GITHUB), ("ArtCraft", ARTCRAFT_WEBSITE)];
+ let font = egui::FontId::proportional(12.5);
+ let sep = " · ";
+ let width: f32 = links.iter().map(|(l, _)| ui.painter().layout_no_wrap((*l).into(), font.clone(), t.text).size().x).sum::<f32>()
+ + 2.0 * ui.painter().layout_no_wrap(sep.into(), font.clone(), t.text).size().x;
+ ui.horizontal(|ui| {
+ ui.spacing_mut().item_spacing.x = 0.0;
+ ui.add_space(((ui.available_width() - width) / 2.0).max(0.0));
+ for (i, (label, url)) in links.iter().enumerate() {
+ if i > 0 {
+ ui.label(egui::RichText::new(sep).font(font.clone()).color(t.text_faint));
+ }
+ ui.hyperlink_to(egui::RichText::new(*label).font(font.clone()), *url).on_hover_text(*url);
+ }
+ });
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn help_menu_lists_links_then_separator_then_about() {
+ let app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default());
+ let help: Vec<String> = crate::menus::menu_items(&app).into_iter().filter(|i| i.path == ["Help"]).map(|i| i.id).collect();
+ assert_eq!(help, ["help.discord", "help.website", "help.artcraftWebsite", "help.github", "help.reportIssue", "---", "help.about"]);
+ for (id, _) in COMMANDS {
+ assert!(crate::menus::is_live(id) && crate::menus::is_enabled(&app, id), "{id}");
+ }
+ }
+
+ #[test]
+ fn link_commands_open_their_urls() {
+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default());
+ let ctx = egui::Context::default();
+ for (id, url) in [("help.discord", "https://discord.gg/artcraft"), ("help.website", "https://getartcraft.com/apps/photocraft"), ("help.github", "https://github.com/storytold/photocraft")] {
+ let r = crate::menus::invoke(&mut app, &ctx, id, serde_json::json!({})).unwrap();
+ assert_eq!(r["url"], url);
+ assert_eq!(app.ui.status, format!("Opened {url}"));
+ }
+ }
+}
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index 9d4fbe274..87b13cde8 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -49,6 +49,11 @@ pub const UI_COMMANDS: &[(&str, &str, &[&str], Option<&str>)] = &[
("window.theme.studioLight", "Studio Light Theme", &["Window", "Theme"], None),
("window.theme.classic", "Classic Theme", &["Window", "Theme"], None),
("edit.search", "Search…", &["Edit"], Some("Cmd+K")),
+ ("help.discord", "Join the ArtCraft Discord…", &["Help"], None),
+ ("help.website", "PhotoCraft Website", &["Help"], None),
+ ("help.artcraftWebsite", "ArtCraft Website", &["Help"], None),
+ ("help.github", "PhotoCraft on GitHub", &["Help"], None),
+ ("help.reportIssue", "Report an Issue…", &["Help"], None),
("help.about", "About PhotoCraft", &["Help"], None),
];
@@ -91,6 +96,10 @@ fn workspace_name(id: &str) -> Option<&'static str> {
/// Run a command id from any source (menu, shortcut, palette, automation).
pub fn invoke(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, params: Value) -> Result<Value, String> {
+ // Help › Discord, website, GitHub, Report an Issue.
+ if let Some(url) = crate::links::url_for(id) {
+ return Ok(crate::links::open(app, ctx, url));
+ }
if id == "view.proofSetup.custom" {
return Ok(json!({"dialog": crate::filter_dialog::open(app, "view.proofSetup")}));
}
@@ -315,6 +324,7 @@ pub fn is_enabled(app: &PhotocraftApp, id: &str) -> bool {
}
match id {
"file.open" | "help.about" | "edit.search" => true,
+ i if crate::links::url_for(i).is_some() => true,
i if i.starts_with("window.theme.") => true,
"file.save" | "file.saveAs" | "file.export.exportAs" | "file.export.quickExportAsPng" => app.session.active().is_some() && app.services.export.is_some(),
i if i.starts_with("window.toggle.") => true,
@@ -438,6 +448,10 @@ pub fn menu_items(app: &PhotocraftApp) -> Vec<MenuItem> {
items.insert(at, e);
}
}
+ // Help: the link items, a separator, then About.
+ if let Some(at) = items.iter().position(|i| i.id == "help.about") {
+ items.insert(at, MenuItem { id: "---".into(), label: "---".into(), path: vec!["Help".into()], shortcut: None, enabled: false, checked: None, color: None });
+ }
// Edit › Keyboard Shortcuts overrides, Edit › Menus hidden items and colours.
let prefs = app.session.prefs();
if !prefs.shortcuts.is_empty() {
diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs
index d7bf28350..084ceb4c9 100644
--- a/crates/ui-egui/src/panels.rs
+++ b/crates/ui-egui/src/panels.rs
@@ -222,6 +222,11 @@ pub fn title_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let next = app.ui.theme.next();
app.set_theme(ui.ctx(), next);
}
+ // Always one click away: the community Discord.
+ let discord = egui::Button::image_and_text(icons::image("message-square", 14.0, t.text_dim), egui::RichText::new("Discord").color(t.text_dim).size(12.0)).frame(false);
+ if ui.add(discord).on_hover_text(format!("Join the ArtCraft Discord ({})", crate::links::DISCORD)).clicked() {
+ crate::links::open(app, ui.ctx(), crate::links::DISCORD);
+ }
});
});
});
diff --git a/packaging/linux/ai.storyteller.photocraft.metainfo.xml.in b/packaging/linux/ai.storyteller.photocraft.metainfo.xml.in
index 2bd2d0227..72649a501 100644
--- a/packaging/linux/ai.storyteller.photocraft.metainfo.xml.in
+++ b/packaging/linux/ai.storyteller.photocraft.metainfo.xml.in
@@ -25,9 +25,11 @@
</description>
<launchable type="desktop-id">ai.storyteller.photocraft.desktop</launchable>
<icon type="stock">ai.storyteller.photocraft</icon>
- <url type="homepage">https://github.com/storytold/photocraft</url>
+ <!-- Only url types known to appstream 0.15 (Ubuntu 22.04, where CI validates): no vcs-browser. -->
+ <url type="homepage">https://getartcraft.com/apps/photocraft</url>
<url type="bugtracker">https://github.com/storytold/photocraft/issues</url>
- <url type="vcs-browser">https://github.com/storytold/photocraft</url>
+ <url type="help">https://github.com/storytold/photocraft</url>
+ <url type="contact">https://discord.gg/artcraft</url>
<categories>
<category>Graphics</category>
<category>RasterGraphics</category>
diff --git a/packaging/linux/nfpm.yaml b/packaging/linux/nfpm.yaml
index 5f3af0463..2ce838a95 100644
--- a/packaging/linux/nfpm.yaml
+++ b/packaging/linux/nfpm.yaml
@@ -13,7 +13,7 @@ section: graphics
priority: optional
maintainer: ${PHOTOCRAFT_MAINTAINER}
vendor: Learning Machines LLC
-homepage: https://github.com/storytold/photocraft
+homepage: https://getartcraft.com/apps/photocraft
license: MIT OR Apache-2.0
description: |-
Open-source, native image editor that works the way Photoshop users expect.
diff --git a/packaging/windows/photocraft.wxs b/packaging/windows/photocraft.wxs
index c6e3910e3..8d97f9bc9 100644
--- a/packaging/windows/photocraft.wxs
+++ b/packaging/windows/photocraft.wxs
@@ -26,8 +26,9 @@
<Icon Id="PhotocraftIcon" SourceFile="$(var.IconPath)" />
<Property Id="ARPPRODUCTICON" Value="PhotocraftIcon" />
- <Property Id="ARPURLINFOABOUT" Value="https://github.com/storytold/photocraft" />
- <Property Id="ARPHELPLINK" Value="https://github.com/storytold/photocraft/issues" />
+ <Property Id="ARPURLINFOABOUT" Value="https://getartcraft.com/apps/photocraft" />
+ <Property Id="ARPURLUPDATEINFO" Value="https://getartcraft.com/apps/photocraft" />
+ <Property Id="ARPHELPLINK" Value="https://discord.gg/artcraft" />
<StandardDirectory Id="ProgramFiles6432Folder">
<Directory Id="INSTALLFOLDER" Name="PhotoCraft" />