feat(ui): layout icons on the first ten Window > Arrange entries (#16889)
Tile All Vertically, Tile All Horizontally, the seven n-up entries and Consolidate All to Tabs now show a small icon of the panes they lay out: columns, rows, the n-up splits and one window with a tab row. The other nine entries keep no icon. The icons are original SVGs drawn on the 24 px grid and stroke of the app's icon set, registered with it and attributed in ATTRIBUTION.md. The menu rows draw the icon their command names, so the icons dim with a greyed entry and the labels stay in their column.
No files matched your search
@@ -19,6 +19,7 @@ next to them.
|
||||
| `assets/icons/vector-shape.svg` | Vector path shape-layer glyph with four anchor points | @superplay2021 | Original work for PhotoCraft | MIT OR Apache-2.0 |
|
||||
| `assets/icons/spirit-level.svg` | Straighten tool glyph: a spirit level with its vial and bubble under a dotted arc | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
|
||||
| `assets/icons/path-op-{new-layer,combine,subtract,intersect,exclude,merge}.svg` | Path Operations glyphs (Pen options bar): a single square for New Layer, and two overlapping squares showing the area each operation keeps (union, back minus front, overlap, everything but the overlap, the merged outline), drawn on Lucide's 24 px grid and stroke | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
|
||||
| `assets/icons/arrange-{tile-all-vertically,tile-all-horizontally,two-up-horizontal,two-up-vertical,three-up-horizontal,three-up-vertical,three-up-stacked,four-up,six-up,consolidate-all-to-tabs}.svg` | Window › Arrange layout glyphs: a window outline split into the panes each entry lays out (columns, rows, the n-up splits, and one window with a tab row for Consolidate All to Tabs), drawn on Lucide's 24 px grid and stroke | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
|
||||
| `assets/icons/history-brush.svg` | History Brush tool glyph: Lucide `brush` plus counter-clockwise history rewind arrow | Lucide Icons and Contributors; arrow by PhotoCraft contributors | Derived from <https://github.com/lucide-icons/lucide> `icons/brush.svg` | ISC, [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
|
||||
| `assets/dict/en_US-scowl-50.txt.gz` | English word list for Check Spelling (SCOWL 2020.12.07, size 50, en_US; 72,403 words) | Kevin Atkinson and the SCOWL contributors | <http://wordlist.aspell.net/> | SCOWL license (permissive, keep the notice), [`assets/dict/LICENSE-SCOWL.txt`](assets/dict/LICENSE-SCOWL.txt), which also has the build recipe |
|
||||
| `assets/app-icon/` (all files) | PhotoCraft app icon (nine-tailed kitsune) | The project owner (drawn in ArtCraft, vectorised) | Original work, see [`assets/app-icon/README.md`](assets/app-icon/README.md) | MIT OR Apache-2.0, [`assets/app-icon/LICENSE.txt`](assets/app-icon/LICENSE.txt) |
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||
<path d="M3 9h18" />
|
||||
<path d="M9 4v5" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 306 B |
@@ -0,0 +1,15 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||
<path d="M12 4v16" />
|
||||
<path d="M3 12h18" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 309 B |
@@ -0,0 +1,16 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||
<path d="M9 4v16" />
|
||||
<path d="M15 4v16" />
|
||||
<path d="M3 12h18" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 332 B |
@@ -0,0 +1,15 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||
<path d="M3 9.33h18" />
|
||||
<path d="M3 14.67h18" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 314 B |
@@ -0,0 +1,15 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||
<path d="M12 4v16" />
|
||||
<path d="M12 12h9" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 309 B |
@@ -0,0 +1,15 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||
<path d="M9 4v16" />
|
||||
<path d="M15 4v16" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 308 B |
@@ -0,0 +1,16 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||
<path d="M3 8h18" />
|
||||
<path d="M3 12h18" />
|
||||
<path d="M3 16h18" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 332 B |
@@ -0,0 +1,16 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||
<path d="M7.5 4v16" />
|
||||
<path d="M12 4v16" />
|
||||
<path d="M16.5 4v16" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 336 B |
@@ -0,0 +1,14 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||
<path d="M3 12h18" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 285 B |
@@ -0,0 +1,14 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||
<path d="M12 4v16" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 285 B |
@@ -8,6 +8,16 @@ pub static PHOTOCRAFT_ICONS: AppIcons = AppIcons::new("photocraft", Some(2.0), I
|
||||
|
||||
/// Every icon of the set: name and SVG document.
|
||||
pub static ICONS: &[(&str, &[u8])] = &[
|
||||
("arrange-consolidate-all-to-tabs", include_bytes!("../../../assets/icons/arrange-consolidate-all-to-tabs.svg")),
|
||||
("arrange-four-up", include_bytes!("../../../assets/icons/arrange-four-up.svg")),
|
||||
("arrange-six-up", include_bytes!("../../../assets/icons/arrange-six-up.svg")),
|
||||
("arrange-three-up-horizontal", include_bytes!("../../../assets/icons/arrange-three-up-horizontal.svg")),
|
||||
("arrange-three-up-stacked", include_bytes!("../../../assets/icons/arrange-three-up-stacked.svg")),
|
||||
("arrange-three-up-vertical", include_bytes!("../../../assets/icons/arrange-three-up-vertical.svg")),
|
||||
("arrange-tile-all-horizontally", include_bytes!("../../../assets/icons/arrange-tile-all-horizontally.svg")),
|
||||
("arrange-tile-all-vertically", include_bytes!("../../../assets/icons/arrange-tile-all-vertically.svg")),
|
||||
("arrange-two-up-horizontal", include_bytes!("../../../assets/icons/arrange-two-up-horizontal.svg")),
|
||||
("arrange-two-up-vertical", include_bytes!("../../../assets/icons/arrange-two-up-vertical.svg")),
|
||||
("arrow-left-right", include_bytes!("../../../assets/icons/arrow-left-right.svg")),
|
||||
("circle-dashed", include_bytes!("../../../assets/icons/circle-dashed.svg")),
|
||||
("ellipsis", include_bytes!("../../../assets/icons/ellipsis.svg")),
|
||||
|
||||
@@ -346,6 +346,12 @@ pub(crate) fn command_rows(app: &PhotocraftApp) -> Vec<CommandDef> {
|
||||
if let Some(&at) = index.get(crate::panels::QUICK_MASK) {
|
||||
rows[at].icon = Some("square-dashed".into());
|
||||
}
|
||||
// Window › Arrange's layout entries show their layout (#16889); the menu rows draw their command's icon.
|
||||
for &(id, icon) in crate::menu_catalog::ARRANGE_ICONS {
|
||||
if let Some(&at) = index.get(id) {
|
||||
rows[at].icon = Some(icon.into());
|
||||
}
|
||||
}
|
||||
// Smart Objects › Reveal in Finder names this platform's file manager, in the list as in the menu.
|
||||
if let Some(&at) = index.get("layer.smartObjects.revealInFinder") {
|
||||
rows[at].label = crate::menus::reveal_label().into();
|
||||
|
||||
@@ -810,3 +810,19 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[
|
||||
(&["Window"], "Tools", None, "window.panel.tools"),
|
||||
(&["Window"], "Contextual Task Bar", None, "window.panel.contextualTaskBar"),
|
||||
];
|
||||
|
||||
/// The layout icons of the first ten Window › Arrange entries, by command id: each draws the panes its entry lays out
|
||||
/// (columns, rows, the n-up splits, one tabbed window). Original artwork in `assets/icons/arrange-*.svg`. The other
|
||||
/// Arrange entries have none, as in the reference application (#16889).
|
||||
pub const ARRANGE_ICONS: &[(&str, &str)] = &[
|
||||
("window.arrange.tileAllVertically", "arrange-tile-all-vertically"),
|
||||
("window.arrange.tileAllHorizontally", "arrange-tile-all-horizontally"),
|
||||
("window.arrange.twoUpHorizontal", "arrange-two-up-horizontal"),
|
||||
("window.arrange.twoUpVertical", "arrange-two-up-vertical"),
|
||||
("window.arrange.threeUpHorizontal", "arrange-three-up-horizontal"),
|
||||
("window.arrange.threeUpVertical", "arrange-three-up-vertical"),
|
||||
("window.arrange.threeUpStacked", "arrange-three-up-stacked"),
|
||||
("window.arrange.fourUp", "arrange-four-up"),
|
||||
("window.arrange.sixUp", "arrange-six-up"),
|
||||
("window.arrange.consolidateAllToTabs", "arrange-consolidate-all-to-tabs"),
|
||||
];
|
||||
@@ -121,6 +121,9 @@ mod export_submenu_separator_tests;
|
||||
#[cfg(test)]
|
||||
mod arrange_menu_order_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod arrange_menu_icons_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod bar_cursor_tests;
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
//! #16889: the first ten Window › Arrange entries (Tile All Vertically to Consolidate All to Tabs) show a layout icon;
|
||||
//! the other nine show none. The menu rows draw the icon their command resolves with, so these tests read what the
|
||||
//! running app resolves for each entry.
|
||||
|
||||
use craft::behavior::IconId;
|
||||
use craft::keymap::CommandRef;
|
||||
use craft::ui::primitives::has_icon;
|
||||
use egui::vec2;
|
||||
use egui_kittest::Harness;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::PhotocraftApp;
|
||||
use crate::menu_catalog::{ARRANGE_ICONS, CATALOG};
|
||||
use crate::theme::AppTheme;
|
||||
|
||||
/// The ten entries with a layout icon, in menu order, and the icon of each.
|
||||
const WITH_ICON: [(&str, &str); 10] = [
|
||||
("window.arrange.tileAllVertically", "arrange-tile-all-vertically"),
|
||||
("window.arrange.tileAllHorizontally", "arrange-tile-all-horizontally"),
|
||||
("window.arrange.twoUpHorizontal", "arrange-two-up-horizontal"),
|
||||
("window.arrange.twoUpVertical", "arrange-two-up-vertical"),
|
||||
("window.arrange.threeUpHorizontal", "arrange-three-up-horizontal"),
|
||||
("window.arrange.threeUpVertical", "arrange-three-up-vertical"),
|
||||
("window.arrange.threeUpStacked", "arrange-three-up-stacked"),
|
||||
("window.arrange.fourUp", "arrange-four-up"),
|
||||
("window.arrange.sixUp", "arrange-six-up"),
|
||||
("window.arrange.consolidateAllToTabs", "arrange-consolidate-all-to-tabs"),
|
||||
];
|
||||
|
||||
/// The nine entries without one.
|
||||
const WITHOUT_ICON: [&str; 9] = [
|
||||
"window.arrange.cascade",
|
||||
"window.arrange.tile",
|
||||
"window.arrange.floatInWindow",
|
||||
"window.arrange.floatAllInWindows",
|
||||
"window.arrange.matchZoom",
|
||||
"window.arrange.matchLocation",
|
||||
"window.arrange.matchRotation",
|
||||
"window.arrange.matchAll",
|
||||
"window.arrange.newWindowForDocument",
|
||||
];
|
||||
|
||||
/// The running app with `documents` documents open.
|
||||
fn app(documents: usize) -> Harness<'static, Box<PhotocraftApp>> {
|
||||
let mut h = Harness::builder().with_size(vec2(1000.0, 700.0)).with_max_steps(64).build_eframe(move |cc| {
|
||||
let theme = AppTheme::pro();
|
||||
PhotocraftApp::setup_context(&cc.egui_ctx, theme.clone());
|
||||
let mut app = PhotocraftApp::with_context(cc.egui_ctx.clone(), photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.save_theme(&theme).unwrap();
|
||||
for n in 0..documents {
|
||||
app.run("file.new", json!({"width": 200, "height": 100, "name": format!("W{n}")})).unwrap();
|
||||
}
|
||||
app
|
||||
});
|
||||
h.run_steps(4);
|
||||
h
|
||||
}
|
||||
|
||||
/// The icon the running app resolves command `id` with: the one its menu row draws.
|
||||
fn icon_of(h: &Harness<'_, Box<PhotocraftApp>>, id: &str) -> Option<String> {
|
||||
craft::ui::runtime::commands::resolve(&h.ctx, CommandRef::new(id)).icon.as_ref().map(ToString::to_string)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_ten_layout_entries_resolve_with_their_layout_icon() {
|
||||
for documents in [0, 1, 6] {
|
||||
let h = app(documents);
|
||||
for (id, icon) in WITH_ICON {
|
||||
assert_eq!(icon_of(&h, id).as_deref(), Some(icon), "{documents} documents: {id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_other_nine_entries_have_no_icon() {
|
||||
let h = app(2);
|
||||
for id in WITHOUT_ICON {
|
||||
assert_eq!(icon_of(&h, id), None, "{id} shows no icon");
|
||||
}
|
||||
}
|
||||
|
||||
/// The two lists cover every Window › Arrange entry of the catalog, so a new entry has to pick a side here.
|
||||
#[test]
|
||||
fn every_arrange_entry_is_listed_once() {
|
||||
let catalog: Vec<&str> = CATALOG.iter().filter(|(path, label, _, _)| *path == ["Window", "Arrange"] && *label != "---").map(|row| row.3).collect();
|
||||
let mut listed: Vec<&str> = WITH_ICON.iter().map(|(id, _)| *id).chain(WITHOUT_ICON).collect();
|
||||
let mut sorted = catalog.clone();
|
||||
sorted.sort_unstable();
|
||||
listed.sort_unstable();
|
||||
assert_eq!(listed, sorted);
|
||||
assert_eq!(ARRANGE_ICONS, &WITH_ICON[..], "the icon table holds the ten entries in menu order");
|
||||
assert_eq!(&catalog[..10], &WITH_ICON.map(|(id, _)| id)[..], "and they are the menu's first ten entries");
|
||||
}
|
||||
|
||||
/// Every icon is in PhotoCraft's icon set, so the row paints a glyph rather than nothing.
|
||||
#[test]
|
||||
fn every_layout_icon_is_registered() {
|
||||
crate::icons::register();
|
||||
for (_, icon) in WITH_ICON {
|
||||
assert!(has_icon(&IconId::new(icon)), "{icon} is registered");
|
||||
}
|
||||
}
|
||||
|
||||
/// The icons are files, so each one is listed in ATTRIBUTION.md as original work.
|
||||
#[test]
|
||||
fn the_icon_files_are_attributed() {
|
||||
let attribution = include_str!("../../../../ATTRIBUTION.md");
|
||||
let row = attribution.lines().find(|line| line.contains("assets/icons/arrange-")).expect("ATTRIBUTION.md lists the arrange icons");
|
||||
assert!(row.contains("Original work"), "{row}");
|
||||
for (_, icon) in WITH_ICON {
|
||||
let name = icon.trim_start_matches("arrange-");
|
||||
assert!(row.contains(name), "the row names {icon}: {row}");
|
||||
}
|
||||
}
|
||||