Files
designcraft/crates/tools/src/catalog.rs
T
aiongg f314aea711 #1298: typing chords, Ctrl+Alt and clipboard chords on craft-keymap 9aaf9df
Undo, Redo, Select All and Story Editor keep running while typing in a
text frame through Text-context copies of their defaults. Tests for
Ctrl+Alt+Shift+N and AltGr while typing, and for Cmd+Shift+C as the
desktop and the web send it. window.setShortcut leaves a panel's twin
out of its conflicts. Removes the unused tool_for_shortcut, and moves
effective_shortcuts and shortcut_string out of the app code.
2026-10-20 18:04:46 +00:00

88 lines
3.7 KiB
Rust

//! The tool catalogue: ids, labels, shortcuts and Tools-panel groups (InDesign's order).
use serde::Serialize;
#[derive(Clone, Copy, Debug, Serialize)]
pub struct ToolInfo {
pub id: &'static str,
pub label: &'static str,
pub shortcut: Option<&'static str>,
pub icon: &'static str,
}
const fn t(id: &'static str, label: &'static str, shortcut: Option<&'static str>, icon: &'static str) -> ToolInfo {
ToolInfo { id, label, shortcut, icon }
}
/// Tools-panel groups in order (the first tool of each group shows by default). A `None` group
/// marks a separator.
///
/// In two columns InDesign lays some groups out tool by tool (Content Collector and Content
/// Placer side by side): see [`SPLIT_IN_TWO_COLUMNS`].
pub const TOOL_GROUPS: &[&[ToolInfo]] = &[
&[t("selection", "Selection Tool", Some("V"), "tool-selection")],
&[t("directSelection", "Direct Selection Tool", Some("A"), "tool-direct")],
&[t("page", "Page Tool", Some("Shift+P"), "tool-page")],
&[t("gap", "Gap Tool", Some("U"), "tool-gap")],
&[
t("contentCollector", "Content Collector Tool", Some("B"), "tool-collector"),
t("contentPlacer", "Content Placer Tool", Some("B"), "tool-placer"),
],
&[],
&[
t("type", "Type Tool", Some("T"), "tool-type"),
t("typeOnPath", "Type on a Path Tool", Some("Shift+T"), "tool-type-path"),
t("verticalType", "Vertical Type Tool", None, "tool-type-vertical"),
t("verticalTypeOnPath", "Vertical Type on a Path Tool", None, "tool-type-path"),
],
&[t("line", "Line Tool", Some("\\"), "tool-line")],
&[
t("pen", "Pen Tool", Some("P"), "tool-pen"),
t("addAnchor", "Add Anchor Point Tool", Some("="), "tool-pen-add"),
t("deleteAnchor", "Delete Anchor Point Tool", Some("-"), "tool-pen-delete"),
t("convertDirection", "Convert Direction Point Tool", Some("Shift+C"), "tool-anchor"),
],
&[
t("pencil", "Pencil Tool", Some("N"), "tool-pencil"),
t("smooth", "Smooth Tool", None, "tool-smooth"),
t("erase", "Erase Tool", None, "tool-erase"),
],
&[
t("rectangleFrame", "Rectangle Frame Tool", Some("F"), "tool-rect-frame"),
t("ellipseFrame", "Ellipse Frame Tool", None, "tool-ellipse-frame"),
t("polygonFrame", "Polygon Frame Tool", None, "tool-polygon-frame"),
],
&[
t("rectangle", "Rectangle Tool", Some("M"), "tool-rect"),
t("ellipse", "Ellipse Tool", Some("L"), "tool-ellipse"),
t("polygon", "Polygon Tool", None, "tool-polygon"),
],
&[],
&[t("scissors", "Scissors Tool", Some("C"), "tool-scissors")],
&[
t("freeTransform", "Free Transform Tool", Some("E"), "tool-free-transform"),
t("rotate", "Rotate Tool", Some("R"), "tool-rotate"),
t("scale", "Scale Tool", Some("S"), "tool-scale"),
t("shear", "Shear Tool", Some("O"), "tool-shear"),
],
&[t("gradientSwatch", "Gradient Swatch Tool", Some("G"), "tool-gradient")],
&[t("gradientFeather", "Gradient Feather Tool", Some("Shift+G"), "tool-gradient-feather")],
&[],
&[t("note", "Note Tool", None, "tool-note")],
&[
t("colorTheme", "Color Theme Tool", Some("Shift+I"), "tool-color-theme"),
t("eyedropper", "Eyedropper Tool", Some("I"), "tool-eyedropper"),
t("measure", "Measure Tool", Some("K"), "tool-measure"),
],
&[t("hand", "Hand Tool", Some("H"), "tool-hand")],
&[t("zoom", "Zoom Tool", Some("Z"), "tool-zoom")],
];
/// Groups (by their first tool) whose tools get a button each when the Tools panel has two
/// columns, as InDesign's does.
pub const SPLIT_IN_TWO_COLUMNS: &[&str] = &["contentCollector"];
pub fn tool_info(id: &str) -> Option<ToolInfo> {
TOOL_GROUPS.iter().flat_map(|g| g.iter()).find(|t| t.id == id).copied()
}