Compare commits

...
Author SHA1 Message Date
Martin BallandClaude Opus 5.5 b000357c8f #7149 item 8: review fixes: text glyphs at the remaining call sites, grey when disabled
Home (group icons, grow/shrink, clear/phonetic, enclose, sort, Show/Hide
pilcrow, Paragraph Tools), the mini toolbar, Developer controls and the Draw
font colour use icons::spec so they draw the text glyph. A disabled glyph
paints both inks in text.disabled, as production did. The icon-name scan fails
on a glyph name passed through IconId::new or icons::id. Doc link and
ATTRIBUTION.md order fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 10:26:04 +00:00
Martin Ball 2f4d459900 Merge remote-tracking branch 'origin/main' into fix/7149-item8-ribbon-icons 2026-11-21 10:07:11 +00:00
Martin BallandClaude Opus 5.5 2da5e37b70 #7149 item 8: for_command picks the text glyph before the own SVG alias
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 21:32:15 +00:00
Martin BallandClaude Sonnet 5.5 6a663796ec #7149 item 8: ribbon glyph icons drawn as text, four missing icons
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 16:06:47 +00:00
25 changed files with 709 additions and 126 deletions
+3
View File
@@ -332,6 +332,7 @@ The UI icons are SVG files in `crates/ui-egui/icons/`, one row each below. Gener
| `crates/ui-egui/icons/size.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/smartArt.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/smartArtColors.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/smartArtLayouts.svg` | WordCraft contributors | original: drawn for WordCraft in the style of the code-drawn icon set (#7149) | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/sort.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/sources.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/spaceAfter.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
@@ -351,6 +352,8 @@ The UI icons are SVG files in `crates/ui-egui/icons/`, one row each below. Gener
| `crates/ui-egui/icons/table.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/tableOfAuthorities.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/tableOfFigures.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/tableStyleOptions.svg` | WordCraft contributors | original: drawn for WordCraft in the style of the code-drawn icon set (#7149) | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/tableStyles.svg` | WordCraft contributors | original: drawn for WordCraft in the style of the code-drawn icon set (#7149) | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/textBox.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/textBoxLink.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
| `crates/ui-egui/icons/textBoxUnlink.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20">
<rect x="3" y="3" width="6" height="6" rx="1" fill="#1E6FD9" class="accent" fill-opacity="0.251"/>
<rect x="3" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.25"/>
<rect x="11" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.25"/>
<rect x="3" y="11" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.25"/>
<rect x="11" y="11" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.25"/>
</svg>

After

Width:  |  Height:  |  Size: 612 B

@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20">
<rect x="3" y="3" width="14" height="4" rx="1" fill="#1E6FD9" class="accent"/>
<rect x="3" y="3" width="14" height="14" rx="1" fill="none" stroke="currentColor" stroke-width="1.25"/>
<path d="M3 7 L17 7" fill="none" stroke="currentColor" stroke-width="1.25"/>
<rect x="5" y="9" width="2.5" height="2.5" fill="none" stroke="currentColor" stroke-width="1.25"/>
<path d="M9.5 10.25 L15 10.25" fill="none" stroke="currentColor" stroke-width="1.25"/>
<rect x="5" y="13" width="2.5" height="2.5" fill="none" stroke="currentColor" stroke-width="1.25"/>
<path d="M9.5 14.25 L15 14.25" fill="none" stroke="currentColor" stroke-width="1.25"/>
</svg>

After

Width:  |  Height:  |  Size: 738 B

+9
View File
@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20">
<rect x="3" y="3" width="14" height="4" rx="1" fill="#1E6FD9" class="accent"/>
<rect x="3" y="11" width="14" height="3" fill="#1E6FD9" class="accent" fill-opacity="0.251"/>
<rect x="3" y="3" width="14" height="14" rx="1" fill="none" stroke="currentColor" stroke-width="1.25"/>
<path d="M3 7 L17 7" fill="none" stroke="currentColor" stroke-width="1.25"/>
<path d="M3 11 L17 11" fill="none" stroke="currentColor" stroke-width="1.25"/>
<path d="M3 14 L17 14" fill="none" stroke="currentColor" stroke-width="1.25"/>
<path d="M8 7 L8 17" fill="none" stroke="currentColor" stroke-width="1.25"/>
</svg>

After

Width:  |  Height:  |  Size: 694 B

+1 -1
View File
@@ -309,7 +309,7 @@ fn page_rows(ui: &mut Ui, current: &str, has_document: bool, choice: &MenuChoice
let on = has_document || works_without_document(id);
let row = Button::new(label(name))
.id_salt(("backstage-page", id))
.icon(crate::icons::id(icon))
.icon(crate::icons::spec(icon))
.variant(Variant::GHOST)
.sizing(Sizing::FillWidth)
// Icon and name at the reading start of the full-width row, as production's menu.
+2 -3
View File
@@ -3,7 +3,7 @@
use std::borrow::Cow;
use craft::behavior::{IconId, keyed};
use craft::behavior::keyed;
use craft::theme::variant::Tone;
use craft::ui::buttons::Button;
use craft::ui::contract::{
@@ -12,7 +12,6 @@ use craft::ui::contract::{
use craft::ui::layout_components::Stack;
use craft::ui::list::ThumbAspect;
use craft::ui::notices::Notice;
use craft::ui::primitives::IconSpec;
use craft::ui::runtime::env::Label;
use craft::ui::shell::{Template, ThumbKey};
use craft::ui::text::TextField;
@@ -133,7 +132,7 @@ pub(super) fn show(ui: &mut Ui, app: &mut WordApp) {
let name = if category.is_empty() { label("Personal templates") } else { Label::from(category.to_owned()) };
let out = grid(name).id_salt(("personal-templates", category.to_owned())).show_items(ui, &items, &mut |path, _| {
let Some(p) = tiles.iter().find(|p| &p.path == path) else { return Tile::new(Label::Empty) };
Tile::new(Label::from(p.label.clone())).icon(IconSpec::svg(IconId::new("documentTemplate"))).tooltip(p.path.clone())
Tile::new(Label::from(p.label.clone())).icon(crate::icons::spec("documentTemplate")).tooltip(p.path.clone())
});
for path in activated(out.response.events) {
let failed = open_personal(app, &path, &ctx).err();
+1 -1
View File
@@ -231,7 +231,7 @@ fn controls(app: &mut WordApp, ui: &mut Ui, fit: usize) -> Option<egui::Rect> {
// No command carries a checked state, so the view is given at the button (S-L415).
let out = ToggleButton::new(name.to_string(), Bind::given(on))
.command(CommandRef::new(id))
.icon(crate::icons::id(icon))
.icon(crate::icons::spec(icon))
.icon_only()
.tooltip(TooltipSpec::new(name.to_string()))
.show(ui);
+10 -10
View File
@@ -208,7 +208,7 @@ fn builtin_menu(ui: &mut Ui, cx: &mut BodyCx<'_>, app: &mut WordApp) {
pub fn insert_button(ui: &mut Ui, app: &mut WordApp) {
SplitButton::<bool>::command("insert.equation", SplitMenu::Body(Box::new(|ui, cx| builtin_menu(ui, cx, app))))
.label(tl!("Equation").to_string())
.icon(IconId::new("equation"))
.icon(crate::icons::spec("equation"))
.arrangement(Arrangement::Stacked)
.show(ui);
}
@@ -279,22 +279,22 @@ pub fn show(row: &mut RibbonRow<'_>, app: &mut WordApp) {
let numbered = info.is_some_and(|(_, linear)| linear.contains('#'));
let latex = app.session.math_latex;
let normal_text = app.session.math_normal_text;
row.group(RibbonGroup::new("tools", tl!("Tools").to_string(), IconId::new("equation").into()), |ui| {
row.group(RibbonGroup::new("tools", tl!("Tools").to_string(), crate::icons::spec("equation")), |ui| {
math_menu_button(ui, EQUATION_PICTURE, "Equation", |ui, cx| builtin_menu(ui, cx, app));
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
ToggleButton::command(CommandRef::with_params("equation.inputFormat", json!({"format": "unicode"})))
.label(tl!("Unicode").to_string())
.icon(IconId::new("equation"))
.icon(crate::icons::spec("equation"))
.tooltip(tl!("Type equations in the linear format (UnicodeMath)").to_string())
.selected(!latex)
.show(ui);
ToggleButton::command(CommandRef::with_params("equation.inputFormat", json!({"format": "latex"})))
.label(tl!("LaTeX").to_string())
.icon(IconId::new("formula"))
.icon(crate::icons::spec("formula"))
.tooltip(tl!("Type equations in LaTeX").to_string())
.selected(latex)
.show(ui);
let face = Button::new(tl!("Convert").to_string()).icon(IconId::new("replace"));
let face = Button::new(tl!("Convert").to_string()).icon(crate::icons::spec("replace"));
let _ = menu_button(ui, face, tl!("Convert").to_string(), None, |ui, _| {
for (label, to, all) in [
("Current - Professional", "professional", false),
@@ -311,20 +311,20 @@ pub fn show(row: &mut RibbonRow<'_>, app: &mut WordApp) {
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
ToggleButton::command(CommandRef::new("equation.normalText"))
.label(tl!("Normal Text").to_string())
.icon(IconId::new("case"))
.icon(crate::icons::spec("case"))
.tooltip(tl!("Type normal (non-math) text in the equation").to_string())
.selected(normal_text)
.show(ui);
});
});
row.group(RibbonGroup::new("symbols", tl!("Symbols").to_string(), IconId::new("symbol").into()), |ui| symbols(ui, app));
row.group(RibbonGroup::new("structures", tl!("Structures").to_string(), IconId::new("equation").into()), |ui| {
row.group(RibbonGroup::new("symbols", tl!("Symbols").to_string(), crate::icons::spec("symbol")), |ui| symbols(ui, app));
row.group(RibbonGroup::new("structures", tl!("Structures").to_string(), crate::icons::spec("equation")), |ui| {
for g in STRUCTURES {
let id = g.id;
math_menu_button(ui, button_picture(id), g.label, |ui, cx| structure_menu(ui, cx, app, id));
}
});
row.group(RibbonGroup::new("equationOptions", tl!("Equation Options").to_string(), IconId::new("equation").into()), |ui| {
row.group(RibbonGroup::new("equationOptions", tl!("Equation Options").to_string(), crate::icons::spec("equation")), |ui| {
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
ToggleButton::command(CommandRef::with_params("equation.display", json!({"value": true})))
.label(tl!("Display").to_string())
@@ -340,7 +340,7 @@ pub fn show(row: &mut RibbonRow<'_>, app: &mut WordApp) {
.show(ui);
ToggleButton::command(CommandRef::new("equation.number"))
.label(tl!("Number").to_string())
.icon(IconId::new("numbering"))
.icon(crate::icons::spec("numbering"))
.tooltip(tl!("Number the equation; the number sits at the right margin (or type # then the number)").to_string())
.selected(numbered)
.show(ui);
+80 -5
View File
@@ -4,6 +4,8 @@
use std::borrow::Cow;
use craft::behavior::IconId;
mod glyphs;
use craft::ui::primitives::{AppIcons, Glyph, IconSpec, register_app_icons};
use craft::ui::style::UiTokens;
use egui::{Color32, Painter, Pos2, Rect, Shape, Stroke, pos2, vec2};
@@ -285,6 +287,7 @@ static WORDCRAFT_ICONS_TABLE: &[(&str, &[u8])] = &[
("size", include_bytes!("../icons/size.svg")),
("smartArt", include_bytes!("../icons/smartArt.svg")),
("smartArtColors", include_bytes!("../icons/smartArtColors.svg")),
("smartArtLayouts", include_bytes!("../icons/smartArtLayouts.svg")),
("sort", include_bytes!("../icons/sort.svg")),
("sources", include_bytes!("../icons/sources.svg")),
("spaceAfter", include_bytes!("../icons/spaceAfter.svg")),
@@ -304,6 +307,8 @@ static WORDCRAFT_ICONS_TABLE: &[(&str, &[u8])] = &[
("table", include_bytes!("../icons/table.svg")),
("tableOfAuthorities", include_bytes!("../icons/tableOfAuthorities.svg")),
("tableOfFigures", include_bytes!("../icons/tableOfFigures.svg")),
("tableStyleOptions", include_bytes!("../icons/tableStyleOptions.svg")),
("tableStyles", include_bytes!("../icons/tableStyles.svg")),
("textBox", include_bytes!("../icons/textBox.svg")),
("textBoxLink", include_bytes!("../icons/textBoxLink.svg")),
("textBoxUnlink", include_bytes!("../icons/textBoxUnlink.svg")),
@@ -387,6 +392,15 @@ pub fn id(name: &'static str) -> IconId {
}
}
/// The icon `name` shows in a ribbon button or group: the icon is drawn as text in the interface font
/// when it shows a letter or a symbol (see `glyphs`), else it is the SVG document of [`id`].
pub fn spec(name: &'static str) -> IconSpec<'static> {
match glyphs::ICONS.iter().find(|icon| icon.0 == name) {
Some(icon) => IconSpec::glyph(icon),
None => IconSpec::svg(id(name)),
}
}
/// The icon a command's button shows outside its own ribbon group (custom groups, the Quick
/// Access Toolbar): the one its ribbon button uses, which is usually named after the id's last
/// part. A name the set doesn't have draws the framework's fallback tile.
@@ -418,11 +432,15 @@ pub fn for_command(id: &str) -> IconSpec<'static> {
Some((_, icon)) => Cow::Borrowed(icon),
None => Cow::Owned(id.rsplit('.').next().unwrap_or(id).to_owned()),
};
let name = match OWN_OVER_CATALOG.iter().find(|(plain, _)| *plain == name) {
Some((_, own)) => Cow::Borrowed(*own),
None => name,
};
IconSpec::svg(IconId::from(name))
// A text glyph is found by the plain name (`pilcrow`); the app's own SVG of a catalog name
// (`wordcraft.pilcrow`) applies only to the SVG fallback.
if let Some(icon) = glyphs::ICONS.iter().find(|icon| icon.0 == name) {
return IconSpec::glyph(icon);
}
match OWN_OVER_CATALOG.iter().find(|(plain, _)| *plain == name) {
Some((_, own)) => IconSpec::svg(IconId::new(own)),
None => IconSpec::svg(IconId::from(name)),
}
}
/// An Insert › Icons library icon as a value glyph, drawn from the same path data the inserted
@@ -495,6 +513,13 @@ mod tests {
assert_eq!(undo, "wordcraft.undo");
}
/// QAT and custom-group buttons draw `view.marks` as the pilcrow text glyph, as the ribbon does, not the
/// app's SVG of the same name.
#[test]
fn for_command_picks_the_text_glyph_before_the_own_svg() {
assert!(matches!(for_command("view.marks").source, craft::ui::primitives::IconSource::Glyph(_)));
}
/// #6768: the Insert › Shapes Arrow tile is the block arrow that tile inserts, outlined as the
/// document draws it, not a thin line with a head.
#[test]
@@ -509,4 +534,54 @@ mod tests {
assert!((x - ex).abs() < 0.05 && (y - ey).abs() < 0.05, "({x}, {y}) vs ({ex}, {ey})");
}
}
/// #7149 item 8: every icon name the UI source gives a button, group or menu exists in the app set or the
/// catalog; a name that does not paints nothing. Names built at run time are not found here.
#[test]
fn every_icon_name_the_ui_uses_resolves() {
fn rs_files(dir: &std::path::Path, out: &mut Vec<std::path::PathBuf>) {
for entry in std::fs::read_dir(dir).into_iter().flatten().flatten() {
let path = entry.path();
if path.is_dir() {
rs_files(&path, out);
} else if path.extension().is_some_and(|e| e == "rs") {
out.push(path);
}
}
}
register();
let mut files = Vec::new();
rs_files(&std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src"), &mut files);
let (mut seen, mut missing, mut svg_only) = (0, Vec::new(), Vec::new());
for file in files.iter().filter(|f| !f.ends_with("icons.rs")) {
let text = std::fs::read_to_string(file).unwrap_or_default();
for call in ["IconId::new(\"", "icons::id(\"", "icons::spec(\""] {
for part in text.split(call).skip(1) {
let Some(name) = part.split('"').next() else { continue };
seen += 1;
// A text glyph resolves only through `icons::spec`; the SVG-only calls draw its SVG instead.
if call != "icons::spec(\"" && glyphs::ICONS.iter().any(|g| g.0 == name) {
svg_only.push(format!("{name} ({}): use icons::spec", file.display()));
continue;
}
let known = match call {
"IconId::new(\"" => craft::ui::primitives::has_icon(&IconId::from(Cow::Owned(name.to_owned()))),
_ => {
glyphs::ICONS.iter().any(|g| g.0 == name)
|| craft::ui::primitives::has_icon(&match OWN_OVER_CATALOG.iter().find(|(p, _)| *p == name) {
Some((_, own)) => IconId::new(own),
None => IconId::from(Cow::Owned(name.to_owned())),
})
}
};
if !known {
missing.push(format!("{name} ({})", file.display()));
}
}
}
}
assert!(seen > 200, "the scan found only {seen} names");
assert!(missing.is_empty(), "icons used but not in the app set or the catalog: {missing:?}");
assert!(svg_only.is_empty(), "text glyphs passed through the SVG-only IconId::new / icons::id: {svg_only:?}");
}
}
+471
View File
@@ -0,0 +1,471 @@
//! The ribbon icons that show a letter or a symbol, drawn as text in the interface font.
//!
//! The SVG icon documents have no `<text>` element (the framework's icon parser takes shapes only), so a
//! letter in them is a hand-built path that differs from the interface font's letter. These icons are drawn
//! as a framework value glyph instead: the 20-unit grid, the pen width 1.25 and the text positions of the
//! code-drawn set the icons were exported from. Original artwork; the letters come from the theme's fonts.
use craft::ui::primitives::Glyph;
use craft::ui::style::{UiTokens, rgba_color};
use egui::{Color32, FontId, Painter, Pos2, Rect, Shape, Stroke, pos2, vec2};
/// Every icon `paint` knows.
pub(super) static ICONS: &[TextIcon] = &[
TextIcon("addressBlock"),
TextIcon("bold"),
TextIcon("case"),
TextIcon("ccPlainText"),
TextIcon("ccRichText"),
TextIcon("charborder"),
TextIcon("citation"),
TextIcon("clear"),
TextIcon("documentTemplate"),
TextIcon("dropCap"),
TextIcon("editor"),
TextIcon("effects"),
TextIcon("enclose"),
TextIcon("endnote"),
TextIcon("equation"),
TextIcon("fontcolor"),
TextIcon("fonts"),
TextIcon("footnote"),
TextIcon("formula"),
TextIcon("greetingLine"),
TextIcon("grow"),
TextIcon("help"),
TextIcon("highlightFields"),
TextIcon("hyphenation"),
TextIcon("index"),
TextIcon("inkToMath"),
TextIcon("italic"),
TextIcon("language"),
TextIcon("lineNumbers"),
TextIcon("markCitation"),
TextIcon("markEntry"),
TextIcon("matchFields"),
TextIcon("mergeField"),
TextIcon("multilevel"),
TextIcon("nextFootnote"),
TextIcon("numbering"),
TextIcon("pageNumber"),
TextIcon("phonetic"),
TextIcon("pilcrow"),
TextIcon("preview"),
TextIcon("readAloud"),
TextIcon("replace"),
TextIcon("rules"),
TextIcon("shrink"),
TextIcon("sort"),
TextIcon("spelling"),
TextIcon("strike"),
TextIcon("styles"),
TextIcon("stylesPane"),
TextIcon("subscript"),
TextIcon("superscript"),
TextIcon("symbol"),
TextIcon("tableOfAuthorities"),
TextIcon("textBox"),
TextIcon("textDirection"),
TextIcon("textFill"),
TextIcon("textOutline"),
TextIcon("thesaurus"),
TextIcon("transform"),
TextIcon("translate"),
TextIcon("underline"),
TextIcon("watermark"),
TextIcon("wordArt"),
TextIcon("wordCount"),
TextIcon("zoom100"),
];
/// An icon drawn as text and lines; the name picks the drawing.
pub(super) struct TextIcon(pub(super) &'static str);
impl Glyph for TextIcon {
fn paint(&self, painter: &Painter, tokens: &UiTokens, rect: Rect, color: Color32, _mirrored: bool) {
// The framework passes `text.disabled` as `color` to a disabled button, and a glyph has no other way
// to learn that; then both inks go grey (the accent ink would stay bright on a disabled button).
let disabled = color == rgba_color(tokens.color.text.disabled);
let accent = if disabled { color } else { rgba_color(tokens.color.accent.solid) };
let pen = Pen { p: painter, r: rect, c: color, a: accent, w: 1.25 };
paint(&pen, self.0);
}
}
struct Pen<'a> {
p: &'a Painter,
r: Rect,
c: Color32,
a: Color32,
w: f32,
}
impl Pen<'_> {
fn s(&self) -> f32 {
self.r.width().min(self.r.height()) / 20.0
}
fn pt(&self, x: f32, y: f32) -> Pos2 {
let s = self.s();
let o = self.r.center() - vec2(10.0 * s, 10.0 * s);
pos2(o.x + x * s, o.y + y * s)
}
fn stroke(&self, c: Color32) -> Stroke {
Stroke::new(self.w * self.s(), c)
}
fn line(&self, pts: &[(f32, f32)]) {
self.line_c(pts, self.c);
}
fn line_c(&self, pts: &[(f32, f32)], c: Color32) {
let v: Vec<Pos2> = pts.iter().map(|&(x, y)| self.pt(x, y)).collect();
self.p.add(Shape::line(v, self.stroke(c)));
}
fn closed(&self, pts: &[(f32, f32)], c: Color32) {
let v: Vec<Pos2> = pts.iter().map(|&(x, y)| self.pt(x, y)).collect();
self.p.add(Shape::closed_line(v, self.stroke(c)));
}
fn fill(&self, pts: &[(f32, f32)], c: Color32) {
let v: Vec<Pos2> = pts.iter().map(|&(x, y)| self.pt(x, y)).collect();
self.p.add(Shape::convex_polygon(v, c, Stroke::NONE));
}
fn rect(&self, x0: f32, y0: f32, x1: f32, y1: f32, c: Color32) {
self.p.rect_stroke(Rect::from_min_max(self.pt(x0, y0), self.pt(x1, y1)), 1.0, self.stroke(c), egui::StrokeKind::Middle);
}
fn frect(&self, x0: f32, y0: f32, x1: f32, y1: f32, c: Color32) {
self.p.rect_filled(Rect::from_min_max(self.pt(x0, y0), self.pt(x1, y1)), 0.5, c);
}
fn circle(&self, x: f32, y: f32, r: f32, c: Color32) {
self.p.circle_stroke(self.pt(x, y), r * self.s(), self.stroke(c));
}
fn text(&self, x: f32, y: f32, size: f32, t: &str, c: Color32, bold: bool) {
let font = if bold { crate::theme::semibold(size * self.s()) } else { FontId::proportional(size * self.s()) };
self.p.text(self.pt(x, y), egui::Align2::CENTER_CENTER, t, font, c);
}
/// Horizontal text lines (a paragraph).
fn lines(&self, x0: f32, x1: f32, ys: &[f32]) {
for y in ys {
self.line(&[(x0, *y), (x1, *y)]);
}
}
/// A page outline with a folded corner.
fn page(&self, x0: f32, y0: f32, x1: f32, y1: f32) {
self.closed(&[(x0, y0), (x1 - 4.0, y0), (x1, y0 + 4.0), (x1, y1), (x0, y1)], self.c);
self.line(&[(x1 - 4.0, y0), (x1 - 4.0, y0 + 4.0), (x1, y0 + 4.0)]);
}
}
/// Draws `name`; false when it is not one of [`ICONS`].
fn paint(pen: &Pen, name: &str) -> bool {
let (c, a) = (pen.c, pen.a);
let red = Color32::from_rgb(0xD1, 0x3B, 0x3B);
let green = Color32::from_rgb(0x2E, 0x8B, 0x57);
let orange = Color32::from_rgb(0xE0, 0x7B, 0x1F);
match name {
"bold" => pen.text(10.0, 10.5, 15.0, "B", c, true),
"italic" => pen.text(10.0, 10.5, 15.0, "I", c, false),
"underline" => {
pen.text(10.0, 9.0, 14.0, "U", c, false);
pen.line(&[(5.0, 17.0), (15.0, 17.0)]);
}
"strike" => {
pen.text(10.0, 10.0, 12.0, "ab", c, false);
pen.line_c(&[(3.0, 10.5), (17.0, 10.5)], c);
}
"charborder" => {
pen.rect(3.0, 3.0, 17.0, 17.0, a);
pen.text(10.0, 6.0, 9.0, "A", c, false);
}
"enclose" => {
pen.circle(10.0, 10.5, 7.5, a);
pen.text(10.0, 10.5, 9.0, "A", c, false);
}
"subscript" => {
pen.text(8.0, 9.0, 13.0, "x", c, false);
pen.text(15.0, 14.5, 8.0, "2", a, true);
}
"superscript" => {
pen.text(8.0, 11.0, 13.0, "x", c, false);
pen.text(15.0, 5.0, 8.0, "2", a, true);
}
"grow" => {
pen.text(8.0, 11.0, 15.0, "A", c, false);
pen.fill(&[(14.5, 6.0), (18.5, 6.0), (16.5, 3.0)], a);
}
"shrink" => {
pen.text(8.0, 12.0, 11.0, "A", c, false);
pen.fill(&[(14.5, 4.0), (18.5, 4.0), (16.5, 7.0)], a);
}
"case" => pen.text(10.0, 10.5, 12.0, "Aa", c, false),
"clear" => {
pen.text(8.0, 9.0, 13.0, "A", c, false);
pen.fill(&[(10.0, 15.0), (14.0, 11.0), (18.0, 15.0), (14.0, 19.0)], Color32::from_rgb(0xE8, 0x6F, 0xA0));
}
"phonetic" => {
pen.text(10.0, 5.0, 7.5, "abc", a, false);
pen.text(10.0, 13.5, 12.5, "A", c, false);
}
"fontcolor" => {
pen.text(10.0, 9.0, 14.0, "A", c, false);
pen.frect(2.0, 16.5, 18.0, 19.0, red);
}
"effects" => {
pen.text(10.0, 10.0, 15.0, "A", a, true);
pen.text(10.5, 10.5, 15.0, "A", Color32::from_rgba_unmultiplied(0, 0, 0, 40), true);
}
"numbering" => {
for (i, y) in [5.0, 10.0, 15.0].iter().enumerate() {
pen.text(4.0, *y, 6.0, &(i + 1).to_string(), if i == 0 { a } else { c }, true);
pen.line(&[(7.5, *y), (17.0, *y)]);
}
}
"multilevel" => {
pen.text(3.5, 4.5, 5.5, "1", a, true);
pen.line(&[(6.5, 4.5), (17.0, 4.5)]);
pen.text(6.5, 10.0, 5.5, "a", c, true);
pen.line(&[(9.5, 10.0), (17.0, 10.0)]);
pen.text(9.5, 15.5, 5.5, "i", c, true);
pen.line(&[(12.0, 15.5), (17.0, 15.5)]);
}
"sort" => {
pen.text(6.0, 5.5, 7.0, "A", c, true);
pen.text(6.0, 14.5, 7.0, "Z", c, true);
pen.line_c(&[(14.0, 3.0), (14.0, 17.0)], a);
pen.line_c(&[(11.5, 14.5), (14.0, 17.0), (16.5, 14.5)], a);
}
"pilcrow" => pen.text(10.0, 10.5, 15.0, "", c, false),
"replace" => {
pen.text(6.0, 6.0, 8.0, "ab", c, false);
pen.text(13.0, 15.0, 8.0, "ac", a, false);
pen.line(&[(13.0, 3.5), (16.0, 3.5), (16.0, 8.5)]);
pen.line(&[(14.5, 7.0), (16.0, 8.5), (17.5, 7.0)]);
}
"editor" | "spelling" => {
pen.text(8.0, 7.0, 9.0, "abc", c, true);
pen.line_c(&[(5.0, 13.0), (8.5, 16.5), (16.0, 9.0)], green);
}
"styles" => {
pen.text(10.0, 10.0, 14.0, "A", a, false);
pen.line(&[(13.0, 15.0), (17.0, 11.0)]);
}
"stylesPane" => {
pen.rect(3.0, 3.0, 17.0, 17.0, c);
pen.line(&[(11.0, 3.0), (11.0, 17.0)]);
pen.text(7.0, 10.0, 8.0, "A", a, false);
}
"pageNumber" => {
pen.page(4.0, 2.0, 16.0, 18.0);
pen.text(10.0, 13.0, 7.0, "#", a, true);
}
"textBox" => {
pen.rect(3.0, 3.0, 17.0, 17.0, c);
pen.text(10.0, 10.0, 10.0, "A", a, false);
}
"wordArt" => {
pen.text(10.0, 10.5, 15.0, "A", a, true);
pen.line_c(&[(3.0, 17.5), (17.0, 17.5)], orange);
}
"textFill" => {
pen.text(10.0, 8.5, 13.0, "A", c, true);
pen.frect(3.0, 15.0, 17.0, 18.5, a);
}
"textOutline" => {
pen.text(10.0, 8.5, 13.0, "A", a, false);
pen.rect(3.0, 15.0, 17.0, 18.5, c);
}
"transform" => {
// Letters along an arch.
let arc: Vec<(f32, f32)> = (0..=12)
.map(|i| {
let t = std::f32::consts::PI * (1.0 - i as f32 / 12.0);
(10.0 + 7.5 * t.cos(), 15.0 - 9.0 * t.sin())
})
.collect();
pen.line_c(&arc, a);
pen.text(10.0, 13.0, 8.0, "A", c, true);
pen.line(&[(2.5, 17.5), (17.5, 17.5)]);
}
"dropCap" => {
pen.text(6.0, 8.0, 12.0, "A", a, true);
pen.lines(11.0, 17.0, &[4.0, 8.0, 12.0]);
pen.lines(3.0, 17.0, &[16.0]);
}
"equation" => pen.text(10.0, 10.0, 17.0, "π", a, false),
"symbol" => pen.text(10.0, 10.0, 17.0, "Ω", c, false),
"inkToMath" => {
pen.line_c(&[(3.0, 12.0), (5.0, 7.0), (7.0, 12.0)], a);
pen.text(13.5, 10.0, 11.0, "√", c, false);
}
"fonts" => pen.text(10.0, 10.0, 13.0, "Aa", a, false),
"watermark" => {
pen.page(4.0, 2.0, 16.0, 18.0);
pen.text(10.0, 11.0, 7.0, "W", a.linear_multiply(0.6), true);
}
"lineNumbers" => {
for (i, y) in [4.0, 8.0, 12.0, 16.0].iter().enumerate() {
pen.text(4.0, *y, 5.0, &(i + 1).to_string(), a, true);
pen.line(&[(7.0, *y), (17.0, *y)]);
}
}
"hyphenation" => {
pen.text(7.0, 7.0, 8.0, "ab-", c, false);
pen.text(9.0, 14.5, 8.0, "cd", a, false);
}
"footnote" => {
pen.text(6.5, 7.0, 10.0, "ab", c, false);
pen.text(13.5, 4.5, 6.0, "1", a, true);
pen.line(&[(3.0, 13.0), (9.0, 13.0)]);
pen.lines(3.0, 17.0, &[16.0]);
}
"endnote" => {
pen.text(6.5, 7.0, 10.0, "ab", c, false);
pen.text(13.5, 4.5, 6.0, "i", a, true);
pen.lines(3.0, 17.0, &[13.0, 16.0]);
}
"nextFootnote" => {
pen.text(7.0, 7.0, 8.0, "ab", c, false);
pen.text(13.0, 5.0, 6.0, "1", a, true);
pen.line_c(&[(6.0, 15.0), (14.0, 15.0)], a);
pen.line_c(&[(11.5, 12.5), (14.0, 15.0), (11.5, 17.5)], a);
}
"citation" => {
pen.text(6.0, 9.0, 14.0, "“", a, true);
pen.lines(9.0, 17.0, &[6.0, 10.0, 14.0]);
}
"markEntry" | "index" | "markCitation" | "tableOfAuthorities" => {
pen.page(4.0, 2.0, 16.0, 18.0);
pen.text(10.0, 10.0, 8.0, if name == "index" || name == "markEntry" { "A" } else { "§" }, a, true);
}
"mergeField" | "addressBlock" | "greetingLine" | "rules" | "matchFields" | "highlightFields" => {
pen.rect(2.5, 6.0, 17.5, 14.0, c);
pen.text(10.0, 10.0, 7.0, "«»", a, true);
}
"preview" => {
pen.text(10.0, 10.0, 8.0, "ABC", a, true);
pen.rect(2.5, 5.0, 17.5, 15.0, c);
}
"thesaurus" => {
pen.rect(3.5, 2.5, 16.5, 17.5, c);
pen.text(10.0, 9.5, 8.0, "Aa", a, true);
}
"wordCount" => pen.text(10.0, 10.0, 9.0, "123", a, true),
"readAloud" => {
pen.text(6.0, 10.0, 10.0, "A", c, false);
pen.line_c(&[(12.0, 7.0), (13.5, 10.0), (12.0, 13.0)], a);
pen.line_c(&[(14.5, 5.0), (17.0, 10.0), (14.5, 15.0)], a);
}
"translate" | "language" => {
pen.text(6.5, 7.0, 9.0, "A", c, true);
// あ drawn as strokes, like the rest of the icon set: the interface fonts need not
// carry Japanese (craft-fonts is optional), and a letter without a glyph drew a box.
pen.line_c(&[(11.6, 10.8), (15.4, 10.8)], a);
pen.line_c(&[(13.5, 8.8), (13.5, 13.9)], a);
pen.line_c(&[(11.0, 13.9), (16.2, 13.9)], a);
pen.circle(13.5, 16.1, 1.8, a);
pen.line_c(&[(15.0, 17.1), (15.8, 18.0)], a);
}
"zoom100" => pen.text(10.0, 10.0, 7.5, "100", a, true),
"documentTemplate" => {
pen.page(4.0, 2.0, 16.0, 18.0);
pen.frect(6.0, 5.0, 11.5, 7.0, a);
pen.text(10.0, 13.0, 8.0, "A", a, false);
}
"textDirection" => {
pen.text(9.0, 10.0, 10.0, "A", c, false);
pen.line_c(&[(15.5, 4.0), (15.5, 16.0)], a);
pen.line_c(&[(13.5, 14.0), (15.5, 16.0), (17.5, 14.0)], a);
}
"formula" => pen.text(10.0, 10.0, 12.0, "fx", a, false),
"help" => {
pen.circle(10.0, 10.0, 7.0, c);
pen.text(10.0, 10.0, 10.0, "?", a, true);
}
"ccRichText" => {
pen.rect(2.5, 5.0, 17.5, 15.0, a);
pen.text(7.5, 10.0, 8.0, "A", c, true);
pen.text(13.0, 10.5, 7.0, "a", c, false);
}
"ccPlainText" => {
pen.rect(2.5, 5.0, 17.5, 15.0, a);
pen.text(8.0, 10.0, 8.0, "A", c, false);
pen.line(&[(12.0, 7.5), (12.0, 12.5)]);
}
_ => return false,
}
true
}
#[cfg(test)]
mod tests {
use super::*;
/// Every name in `ICONS` has a drawing, and a name outside it has none.
#[test]
fn every_text_icon_has_a_drawing() {
let ctx = egui::Context::default();
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {
let painter = ui.painter().clone();
let pen = Pen { p: &painter, r: Rect::from_min_size(pos2(0.0, 0.0), vec2(20.0, 20.0)), c: Color32::BLACK, a: Color32::BLUE, w: 1.25 };
for icon in ICONS {
assert!(paint(&pen, icon.0), "{} has no drawing", icon.0);
}
assert!(!paint(&pen, "notAnIcon"));
});
out.textures_delta.clear();
assert_eq!(ICONS.len(), 65);
}
/// Every colour the shapes of `shape` paint with.
fn ink_of(shape: &Shape, out: &mut Vec<Color32>) {
match shape {
Shape::Vec(v) => v.iter().for_each(|s| ink_of(s, out)),
Shape::LineSegment { stroke, .. } => out.push(stroke.color),
Shape::Path(p) => {
out.push(p.fill);
if let egui::epaint::ColorMode::Solid(c) = p.stroke.color {
out.push(c);
}
}
Shape::Circle(c) => out.extend([c.stroke.color, c.fill]),
Shape::Rect(r) => out.extend([r.stroke.color, r.fill]),
Shape::Text(t) => {
out.push(t.fallback_color);
out.extend(t.galley.job.sections.iter().map(|s| s.format.color));
}
_ => {}
}
}
/// A disabled button hands its glyph `text.disabled` as the colour: no shape may then be in the accent
/// colour (production painted both inks grey). Enabled, the glyphs do use the accent.
#[test]
fn a_disabled_text_glyph_paints_no_accent_colour() {
use craft::theme::{Appearance, Contrast, Mode, Size, TextSize};
let themes = craft::theme::builtins();
let theme = themes.iter().find(|theme| theme.id.as_str() == craft::theme::SUITE_DEFAULT).unwrap();
let appearance = Appearance {
mode: Mode::Light,
contrast: Contrast::Standard,
size: Size::Compact,
text_size: TextSize::default(),
reduced_motion: false,
};
let tokens = UiTokens::new(std::sync::Arc::new(craft::theme::resolve(theme, appearance, None).tokens), Contrast::Standard, Size::Compact);
let (accent, disabled, normal) =
(rgba_color(tokens.color.accent.solid), rgba_color(tokens.color.text.disabled), rgba_color(tokens.color.text.normal));
assert_ne!(accent, disabled);
let inks = |color: Color32| {
let mut out = Vec::new();
let ctx = egui::Context::default();
let mut run = ctx.run_ui(egui::RawInput::default(), |ui| {
let painter = ui.painter().clone();
for icon in ICONS {
icon.paint(&painter, &tokens, Rect::from_min_size(pos2(0.0, 0.0), vec2(20.0, 20.0)), color, false);
}
});
run.textures_delta.clear();
run.shapes.iter().for_each(|clipped| ink_of(&clipped.shape, &mut out));
out
};
assert!(inks(normal).contains(&accent), "an enabled glyph uses the accent ink");
assert!(!inks(disabled).contains(&accent), "a disabled glyph painted in the accent colour");
}
}
+2 -2
View File
@@ -173,7 +173,7 @@ pub(crate) fn members(app: &mut WordApp, ui: &mut Ui, preview: bool) {
}
for (id, icon) in [("format.growFont", "grow"), ("format.shrinkFont", "shrink")] {
let b = IconButton::command(crate::icons::id(icon), CommandRef::new(id)).show(ui);
let b = IconButton::command(crate::icons::spec(icon), CommandRef::new(id)).show(ui);
preview_on_hover(app, b.hover, b.response.enabled(), id, json!({}), preview);
}
});
@@ -239,7 +239,7 @@ fn follow_list<T>(app: &mut WordApp, preview: bool, event: &Preview<T>, command:
/// command carries no checked state, so the value is bound here and only draws the button.
fn toggle(ui: &mut Ui, app: &mut WordApp, id: &str, icon: &'static str, on: bool, preview: bool) {
let r = <ToggleButton as Props>::command(ToggleButton::new(Label::Empty, Bind::given(on)), CommandRef::new(id))
.icon(crate::icons::id(icon))
.icon(crate::icons::spec(icon))
.icon_only()
.show(ui);
preview_on_hover(app, r.hover, r.response.enabled(), id, json!({}), preview);
+1 -3
View File
@@ -1,9 +1,7 @@
use craft::behavior::IconId;
use craft::ui::buttons::{Button, IconButton};
use craft::ui::contract::{Props, Show, ShowContainer};
use craft::ui::display::{Shade, Text};
use craft::ui::layout_components::{Row, Stack};
use craft::ui::primitives::IconSpec;
use craft::ui::sections::GroupBox;
use egui::Ui;
use serde_json::{Value, json};
@@ -79,7 +77,7 @@ fn level_row(ui: &mut Ui, caption: &str, value: &str, none: bool, tip: &str, not
Text::new(tl!(caption).to_owned()).shade(Shade::Muted).show(ui);
Row::new().show(ui, |ui, _| {
Text::new(value.to_owned()).shade(if none { Shade::Faint } else { Shade::Normal }).show(ui);
let clear = IconButton::new(IconSpec::svg(IconId::new("clear"))).label(tl!(tip).to_owned()).enabled(!nothing_to_clear).show(ui);
let clear = IconButton::new(crate::icons::spec("clear")).label(tl!(tip).to_owned()).enabled(!nothing_to_clear).show(ui);
clicked = clear.clicked();
});
});
+1 -3
View File
@@ -1,6 +1,5 @@
//! Language-aware proofing task pane, laid out from black-box observation of Word on Windows.
use craft::behavior::IconId;
use craft::behavior::{DisplayOrder, ItemSource};
use craft::theme::variant::Tone;
use craft::ui::buttons::{Button, IconButton};
@@ -10,7 +9,6 @@ use craft::ui::layout_components::{Row, Stack};
use craft::ui::list::{List, ListRow};
use craft::ui::menu::Menu;
use craft::ui::notices::Notice;
use craft::ui::primitives::IconSpec;
use craft::ui::style::{Span, TypeRole};
use craft::ui::text::TextField;
use egui::Ui;
@@ -184,7 +182,7 @@ fn body(app: &mut WordApp, ui: &mut Ui, form: &mut SpellingForm) {
Row::new().show(ui, |ui, _| {
Text::styled(spans.clone()).show(ui);
// PLAN: assumed IconSpec::svg("readAloud") from WORDCRAFT_ICONS (rb.A7, ribbon-w13); the icon is registered by name
if IconButton::new(IconSpec::svg(IconId::new("readAloud"))).label(tl!("Read Aloud")).show(ui).clicked() {
if IconButton::new(crate::icons::spec("readAloud")).label(tl!("Read Aloud")).show(ui).clicked() {
ask = Some(Ask::ReadAloud);
}
});
+5 -2
View File
@@ -40,7 +40,7 @@ pub(super) fn design(row: &mut RibbonRow<'_>, app: &mut WordApp) {
);
menu_button(
ui,
Button::new(crate::tl!("Fonts")).icon(IconId::new("fonts")).tooltip(crate::tl!("Theme Fonts")),
Button::new(crate::tl!("Fonts")).icon(crate::icons::spec("fonts")).tooltip(crate::tl!("Theme Fonts")),
crate::tl!("Theme Fonts"),
Some("design.themeFonts"),
|ui, _| {
@@ -87,7 +87,10 @@ pub(super) fn design(row: &mut RibbonRow<'_>, app: &mut WordApp) {
row.group(RibbonGroup::new("Page Background", crate::tl!("Page Background"), IconId::new("pageColor").into()), |ui| {
menu_button(
ui,
Button::new(crate::tl!("Watermark")).icon(IconId::new("watermark")).tooltip(crate::tl!("Watermark")).arrangement(Arrangement::Stacked),
Button::new(crate::tl!("Watermark"))
.icon(crate::icons::spec("watermark"))
.tooltip(crate::tl!("Watermark"))
.arrangement(Arrangement::Stacked),
crate::tl!("Watermark"),
Some("design.watermark"),
|ui, _| {
+3 -3
View File
@@ -33,7 +33,7 @@ pub(super) fn draw(row: &mut RibbonRow<'_>, app: &mut WordApp) {
] {
ToggleButton::command(CommandRef::with_params(id, json!({})))
.label(crate::tl!(label))
.icon(crate::icons::id(key))
.icon(crate::icons::spec(key))
.arrangement(Arrangement::Stacked)
.selected(on)
.show(ui);
@@ -75,7 +75,7 @@ pub(super) fn draw(row: &mut RibbonRow<'_>, app: &mut WordApp) {
})),
)
.label(crate::tl!("Color"))
.icon(IconSpec::from(IconId::new("fontcolor")).with_mark(IconMark::bar(DataColor::new(ink))))
.icon(crate::icons::spec("fontcolor").with_mark(IconMark::bar(DataColor::new(ink))))
.show(ui);
menu_button(
ui,
@@ -111,7 +111,7 @@ pub(super) fn draw(row: &mut RibbonRow<'_>, app: &mut WordApp) {
.show(ui);
Button::command(CommandRef::with_params("draw.inkToMath", json!({})))
.label(crate::tl!("Ink to\nMath"))
.icon(IconId::new("inkToMath"))
.icon(crate::icons::spec("inkToMath"))
.arrangement(Arrangement::Stacked)
.show(ui);
});
+18 -18
View File
@@ -24,7 +24,7 @@ use crate::colors::{Remember, Target};
/// A ribbon group titled `title`, with the Dialog Launcher `launcher` when it has one.
fn ribbon_group(key: &'static str, title: &str, icon: &'static str, launcher: Option<&str>) -> RibbonGroup<'static> {
let group = RibbonGroup::new(key, tl!(title).to_string(), crate::icons::id(icon).into());
let group = RibbonGroup::new(key, tl!(title).to_string(), crate::icons::spec(icon));
match launcher {
Some(id) => group.launcher(CommandRef::new(id)),
None => group,
@@ -165,7 +165,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
for (icon, label, id) in [("cut", "Cut", "edit.cut"), ("copy", "Copy", "edit.copy")] {
Button::command(CommandRef::new(id))
.icon(crate::icons::id(icon))
.icon(crate::icons::spec(icon))
.label(tl!(label).to_string())
.tooltip(tl!(label).to_string())
.show(ui);
@@ -193,12 +193,12 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
let _ = app.run("format.size", json!({"size": x}));
}
for (icon, tip, id) in [("grow", "Increase Font Size", "format.growFont"), ("shrink", "Decrease Font Size", "format.shrinkFont")] {
IconButton::command(crate::icons::id(icon), CommandRef::new(id))
IconButton::command(crate::icons::spec(icon), CommandRef::new(id))
.label(tl!(tip).to_string())
.tooltip(tl!(tip).to_string())
.show(ui);
}
let face = Button::new(tl!("Change Case").to_string()).icon(IconId::new("case")).tooltip(tl!("Change Case").to_string());
let face = Button::new(tl!("Change Case").to_string()).icon(crate::icons::spec("case")).tooltip(tl!("Change Case").to_string());
menu_button(ui, face, tl!("Change Case").to_string(), Some("format.changeCase"), |ui, _| {
for (label, mode) in [
("Sentence case.", "sentence"),
@@ -211,7 +211,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
}
});
for (icon, tip, id) in [("clear", "Clear All Formatting", "format.clear"), ("phonetic", "Phonetic Guide", "format.phonetic")] {
IconButton::command(crate::icons::id(icon), CommandRef::new(id))
IconButton::command(crate::icons::spec(icon), CommandRef::new(id))
.label(tl!(tip).to_string())
.tooltip(tl!(tip).to_string())
.show(ui);
@@ -220,7 +220,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
Row::new().gap(Gap::None).show(ui, |ui, _| {
for (icon, tip, id, on) in [("bold", "Bold", "format.bold", flag("bold")), ("italic", "Italic", "format.italic", flag("italic"))] {
ToggleButton::command(CommandRef::new(id))
.icon(crate::icons::id(icon))
.icon(crate::icons::spec(icon))
.icon_only()
.selected(on)
.tooltip(tl!(tip).to_string())
@@ -230,7 +230,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
CommandRef::with_params("format.underline", json!({})),
SplitMenu::Body(Box::new(|ui, _| underline_menu(ui, app))),
)
.icon(IconId::new("underline"))
.icon(crate::icons::spec("underline"))
.selected(flag("underline"))
.tooltip(tl!("Underline").to_string())
.show(ui);
@@ -241,18 +241,18 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
("charborder", "Character Border", "format.border", flag("border")),
] {
ToggleButton::command(CommandRef::new(id))
.icon(crate::icons::id(icon))
.icon(crate::icons::spec(icon))
.icon_only()
.selected(on)
.tooltip(tl!(tip).to_string())
.show(ui);
}
IconButton::command(IconId::new("enclose"), CommandRef::new("format.enclose"))
IconButton::command(crate::icons::spec("enclose"), CommandRef::new("format.enclose"))
.label(tl!("Enclose Characters").to_string())
.tooltip(tl!("Enclose Characters").to_string())
.show(ui);
let face = Button::new(tl!("Text Effects and Typography").to_string())
.icon(IconId::new("effects"))
.icon(crate::icons::spec("effects"))
.tooltip(tl!("Text Effects and Typography").to_string());
menu_button(ui, face, tl!("Text Effects and Typography").to_string(), None, |ui, cx| text_effects_menu(ui, cx, app));
crate::colors::highlight_split(ui, app, tl!("Text Highlight Color"));
@@ -294,7 +294,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
MenuItem::command(CommandRef::with_params("para.numbering", json!({"off": true}))).label(tl!("None").to_string()).show(ui);
})),
)
.icon(IconId::new("numbering"))
.icon(crate::icons::spec("numbering"))
.selected(lists.numbering)
.tooltip(tl!("Numbering").to_string())
.show(ui);
@@ -331,20 +331,20 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
}
})),
)
.icon(IconId::new("multilevel"))
.icon(crate::icons::spec("multilevel"))
.selected(lists.multilevel)
.tooltip(tl!("Multilevel List").to_string())
.show(ui);
for (icon, tip, id) in
[("outdent", "Decrease Indent", "para.outdent"), ("indent", "Increase Indent", "para.indent"), ("sort", "Sort", "para.sort")]
{
IconButton::command(crate::icons::id(icon), CommandRef::new(id))
IconButton::command(crate::icons::spec(icon), CommandRef::new(id))
.label(tl!(tip).to_string())
.tooltip(tl!(tip).to_string())
.show(ui);
}
ToggleButton::command(CommandRef::new("view.marks"))
.icon(IconId::new("wordcraft.pilcrow"))
.icon(crate::icons::spec("pilcrow"))
.icon_only()
.selected(marks)
.tooltip(tl!("Show/Hide ¶").to_string())
@@ -360,7 +360,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
("textRtl", "Right-to-Left Text Direction", "para.rtl", rtl),
] {
ToggleButton::command(CommandRef::new(id))
.icon(crate::icons::id(icon))
.icon(crate::icons::spec(icon))
.icon_only()
.selected(on)
.tooltip(tl!(tip).to_string())
@@ -413,7 +413,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
// whole document with Ctrl+A first (the commands take `scope: "all"` for that as well).
row.group(ribbon_group("paragraphTools", "Paragraph Tools", "pilcrow", None), |ui| {
let face = Button::new(tl!("Paragraph\nTools").to_string())
.icon(IconId::new("wordcraft.pilcrow"))
.icon(crate::icons::spec("pilcrow"))
.tooltip(tl!("Paragraph Tools").to_string())
.arrangement(Arrangement::Stacked);
menu_button(ui, face, tl!("Paragraph Tools").to_string(), None, |ui, _| {
@@ -459,7 +459,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
}
});
Button::command(CommandRef::with_params("ui.dialog", json!({"name": "replace"})))
.icon(IconId::new("replace"))
.icon(crate::icons::spec("replace"))
.label(tl!("Replace").to_string())
.tooltip(tl!("Replace").to_string())
.show(ui);
@@ -480,7 +480,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
});
row.group(ribbon_group("editor", "Editor", "editor", None), |ui| {
Button::command(CommandRef::new("review.spelling"))
.icon(IconId::new("editor"))
.icon(crate::icons::spec("editor"))
.label(tl!("Editor").to_string())
.arrangement(Arrangement::Stacked)
.show(ui);
+9 -9
View File
@@ -125,7 +125,7 @@ pub(super) fn insert(row: &mut RibbonRow<'_>, app: &mut WordApp) {
] {
MenuItem::command(CommandRef::with_params("insert.shape", json!({"kind": kind, "arrow": arrow})))
.label(crate::tl!(label))
.icon(crate::icons::id(glyph))
.icon(crate::icons::spec(glyph))
.show(ui);
}
let _ = cx;
@@ -135,7 +135,7 @@ pub(super) fn insert(row: &mut RibbonRow<'_>, app: &mut WordApp) {
for (key, label, id) in
[("icons", "Icons", "insert.icon"), ("smartArt", "Diagram", "insert.smartArt"), ("chart", "Chart", "insert.chart")]
{
Button::command(CommandRef::with_params(id, json!({}))).label(crate::tl!(label)).icon(crate::icons::id(key)).show(ui);
Button::command(CommandRef::with_params(id, json!({}))).label(crate::tl!(label)).icon(crate::icons::spec(key)).show(ui);
}
});
});
@@ -196,7 +196,7 @@ pub(super) fn insert(row: &mut RibbonRow<'_>, app: &mut WordApp) {
menu_button(
ui,
Button::new(crate::tl!("Page\nNumber"))
.icon(IconId::new("pageNumber"))
.icon(crate::icons::spec("pageNumber"))
.tooltip(crate::tl!("Page Number"))
.arrangement(Arrangement::Stacked),
crate::tl!("Page Number"),
@@ -216,10 +216,10 @@ pub(super) fn insert(row: &mut RibbonRow<'_>, app: &mut WordApp) {
},
);
});
row.group(RibbonGroup::new("Text", crate::tl!("Text"), IconId::new("textBox").into()), |ui| {
row.group(RibbonGroup::new("Text", crate::tl!("Text"), crate::icons::spec("textBox")), |ui| {
Button::command(CommandRef::with_params("insert.textBox", json!({})))
.label(crate::tl!("Text\nBox"))
.icon(IconId::new("textBox"))
.icon(crate::icons::spec("textBox"))
.arrangement(Arrangement::Stacked)
.show(ui);
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
@@ -242,7 +242,7 @@ pub(super) fn insert(row: &mut RibbonRow<'_>, app: &mut WordApp) {
);
menu_button(
ui,
Button::new(crate::tl!("Decorative Text")).icon(IconId::new("wordArt")).tooltip(crate::tl!("Decorative Text")),
Button::new(crate::tl!("Decorative Text")).icon(crate::icons::spec("wordArt")).tooltip(crate::tl!("Decorative Text")),
crate::tl!("Decorative Text"),
Some("insert.wordArt"),
|ui, cx| {
@@ -251,7 +251,7 @@ pub(super) fn insert(row: &mut RibbonRow<'_>, app: &mut WordApp) {
);
menu_button(
ui,
Button::new(crate::tl!("Drop Cap")).icon(IconId::new("dropCap")).tooltip(crate::tl!("Drop Cap")),
Button::new(crate::tl!("Drop Cap")).icon(crate::icons::spec("dropCap")).tooltip(crate::tl!("Drop Cap")),
crate::tl!("Drop Cap"),
Some("insert.dropCap"),
|ui, _| drop_cap_items(ui, app),
@@ -270,11 +270,11 @@ pub(super) fn insert(row: &mut RibbonRow<'_>, app: &mut WordApp) {
}
});
});
row.group(RibbonGroup::new("Symbols", crate::tl!("Symbols"), IconId::new("symbol").into()), |ui| {
row.group(RibbonGroup::new("Symbols", crate::tl!("Symbols"), crate::icons::spec("symbol")), |ui| {
crate::equation_tab::insert_button(ui, app);
menu_button(
ui,
Button::new(crate::tl!("Symbol")).icon(IconId::new("symbol")).tooltip(crate::tl!("Symbol")).arrangement(Arrangement::Stacked),
Button::new(crate::tl!("Symbol")).icon(crate::icons::spec("symbol")).tooltip(crate::tl!("Symbol")).arrangement(Arrangement::Stacked),
crate::tl!("Symbol"),
Some("insert.symbol"),
|ui, cx| {
+2 -2
View File
@@ -75,7 +75,7 @@ pub(super) fn layout(row: &mut RibbonRow<'_>, app: &mut WordApp) {
// Text Direction works on what the caret is in: table cells, a text box, else the section.
let dir = wordcraft_engine::cmd::page::text_direction_at(&app.session);
let stacked =
|label: &'static str, icon: &'static str| Button::new(tl!(label)).icon(crate::icons::id(icon)).arrangement(Arrangement::Stacked);
|label: &'static str, icon: &'static str| Button::new(tl!(label)).icon(crate::icons::spec(icon)).arrangement(Arrangement::Stacked);
menu_button(ui, stacked("Text\nDirection", "textDirection"), tl!("Text Direction"), Some("layout.textDirection"), |ui, _| {
use wordcraft_doc::props::TextDirection;
for (label, d) in [
@@ -96,7 +96,7 @@ pub(super) fn layout(row: &mut RibbonRow<'_>, app: &mut WordApp) {
menu_button(ui, stacked("Size", "size"), tl!("Size"), Some("layout.size"), |ui, _| size_menu(ui, app));
menu_button(ui, stacked("Columns", "columns"), tl!("Columns"), Some("layout.columns"), |ui, _| columns_items(ui, app));
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
let inline = |label: &'static str, icon: &'static str| Button::new(tl!(label)).icon(crate::icons::id(icon));
let inline = |label: &'static str, icon: &'static str| Button::new(tl!(label)).icon(crate::icons::spec(icon));
menu_button(ui, inline("Breaks", "breaks"), tl!("Breaks"), Some("layout.break"), |ui, _| {
MenuItem::heading(tl!("Page Breaks")).show(ui);
for (l, k) in [("Page", "page"), ("Column", "column"), ("Text Wrapping", "textWrapping")] {
+7 -7
View File
@@ -15,7 +15,7 @@ pub(super) fn mailings(row: &mut RibbonRow<'_>, app: &mut WordApp) {
for (key, label, id) in [("envelope", "Envelopes", "mailings.envelopes"), ("labels", "Labels", "mailings.labels")] {
Button::command(CommandRef::with_params(id, json!({})))
.label(crate::tl!(label))
.icon(crate::icons::id(key))
.icon(crate::icons::spec(key))
.arrangement(Arrangement::Stacked)
.show(ui);
}
@@ -70,7 +70,7 @@ pub(super) fn mailings(row: &mut RibbonRow<'_>, app: &mut WordApp) {
.arrangement(Arrangement::Stacked)
.show(ui);
});
row.group(RibbonGroup::new("Write & Insert Fields", crate::tl!("Write & Insert Fields"), IconId::new("mergeField").into()), |ui| {
row.group(RibbonGroup::new("Write & Insert Fields", crate::tl!("Write & Insert Fields"), crate::icons::spec("mergeField")), |ui| {
for (key, label, id) in [
("highlightFields", "Highlight\nMerge Fields", "mailings.highlightFields"),
("addressBlock", "Address\nBlock", "mailings.addressBlock"),
@@ -79,7 +79,7 @@ pub(super) fn mailings(row: &mut RibbonRow<'_>, app: &mut WordApp) {
] {
Button::command(CommandRef::with_params(id, json!({})))
.label(crate::tl!(label))
.icon(crate::icons::id(key))
.icon(crate::icons::spec(key))
.arrangement(Arrangement::Stacked)
.show(ui);
}
@@ -87,7 +87,7 @@ pub(super) fn mailings(row: &mut RibbonRow<'_>, app: &mut WordApp) {
// The merge rules the engine knows; If and Skip Record If ask for their condition.
menu_button(
ui,
Button::new(crate::tl!("Rules")).icon(IconId::new("rules")).tooltip(crate::tl!("Rules")),
Button::new(crate::tl!("Rules")).icon(crate::icons::spec("rules")).tooltip(crate::tl!("Rules")),
crate::tl!("Rules"),
Some("mailings.rules"),
|ui, _| {
@@ -100,14 +100,14 @@ pub(super) fn mailings(row: &mut RibbonRow<'_>, app: &mut WordApp) {
);
Button::command(CommandRef::with_params("mailings.matchFields", json!({})))
.label(crate::tl!("Match Fields"))
.icon(IconId::new("matchFields"))
.icon(crate::icons::spec("matchFields"))
.show(ui);
});
});
row.group(RibbonGroup::new("Preview Results", crate::tl!("Preview Results"), IconId::new("preview").into()), |ui| {
row.group(RibbonGroup::new("Preview Results", crate::tl!("Preview Results"), crate::icons::spec("preview")), |ui| {
Button::command(CommandRef::with_params("mailings.preview", json!({})))
.label(crate::tl!("Preview\nResults"))
.icon(IconId::new("preview"))
.icon(crate::icons::spec("preview"))
.arrangement(Arrangement::Stacked)
.show(ui);
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
+17 -17
View File
@@ -57,10 +57,10 @@ pub(super) fn references(row: &mut RibbonRow<'_>, app: &mut WordApp) {
.show(ui);
});
});
row.group(RibbonGroup::new("Footnotes", crate::tl!("Footnotes"), IconId::new("footnote").into()).launcher("references.noteOptions"), |ui| {
row.group(RibbonGroup::new("Footnotes", crate::tl!("Footnotes"), crate::icons::spec("footnote")).launcher("references.noteOptions"), |ui| {
Button::command(CommandRef::with_params("references.footnote", json!({})))
.label(crate::tl!("Insert\nFootnote"))
.icon(IconId::new("footnote"))
.icon(crate::icons::spec("footnote"))
.arrangement(Arrangement::Stacked)
.show(ui);
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
@@ -69,7 +69,7 @@ pub(super) fn references(row: &mut RibbonRow<'_>, app: &mut WordApp) {
("nextFootnote", "Next Footnote", "references.nextFootnote"),
("showNotes", "Show Notes", "references.notes"),
] {
Button::command(CommandRef::with_params(id, json!({}))).label(crate::tl!(label)).icon(crate::icons::id(key)).show(ui);
Button::command(CommandRef::with_params(id, json!({}))).label(crate::tl!(label)).icon(crate::icons::spec(key)).show(ui);
}
});
});
@@ -80,12 +80,12 @@ pub(super) fn references(row: &mut RibbonRow<'_>, app: &mut WordApp) {
.arrangement(Arrangement::Stacked)
.show(ui);
});
row.group(RibbonGroup::new("Citations & Bibliography", crate::tl!("Citations & Bibliography"), IconId::new("citation").into()), |ui| {
row.group(RibbonGroup::new("Citations & Bibliography", crate::tl!("Citations & Bibliography"), crate::icons::spec("citation")), |ui| {
// The document's sources to cite, then a new one (Create Source, #402).
menu_button(
ui,
Button::new(crate::tl!("Insert\nCitation"))
.icon(IconId::new("citation"))
.icon(crate::icons::spec("citation"))
.tooltip(crate::tl!("Insert Citation"))
.arrangement(Arrangement::Stacked),
crate::tl!("Insert Citation"),
@@ -112,7 +112,7 @@ pub(super) fn references(row: &mut RibbonRow<'_>, app: &mut WordApp) {
let label = crate::i18n::fmt(crate::tl!("Style: {style}"), &[("style", &current)]);
menu_button(
ui,
Button::new(label).icon(IconId::new("styles")).tooltip(crate::tl!("Citation Style")),
Button::new(label).icon(crate::icons::spec("styles")).tooltip(crate::tl!("Citation Style")),
crate::tl!("Citation Style"),
Some("references.citationStyle"),
|ui, _| {
@@ -144,28 +144,28 @@ pub(super) fn references(row: &mut RibbonRow<'_>, app: &mut WordApp) {
] {
Button::command(CommandRef::with_params(id, json!({})))
.label(crate::tl!(label))
.icon(crate::icons::id(key))
.icon(crate::icons::spec(key))
.tooltip(crate::tl!(tip))
.show(ui);
}
});
});
row.group(RibbonGroup::new("Index", crate::tl!("Index"), IconId::new("index").into()), |ui| {
row.group(RibbonGroup::new("Index", crate::tl!("Index"), crate::icons::spec("index")), |ui| {
Button::command(CommandRef::with_params("references.markEntry", json!({})))
.label(crate::tl!("Mark\nEntry"))
.icon(IconId::new("markEntry"))
.icon(crate::icons::spec("markEntry"))
.arrangement(Arrangement::Stacked)
.show(ui);
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
for (key, label, id) in [("index", "Insert Index", "references.index"), ("update", "Update Index", "references.updateIndex")] {
Button::command(CommandRef::with_params(id, json!({}))).label(crate::tl!(label)).icon(crate::icons::id(key)).show(ui);
Button::command(CommandRef::with_params(id, json!({}))).label(crate::tl!(label)).icon(crate::icons::spec(key)).show(ui);
}
});
});
row.group(RibbonGroup::new("Table of Authorities", crate::tl!("Table of Authorities"), IconId::new("tableOfAuthorities").into()), |ui| {
row.group(RibbonGroup::new("Table of Authorities", crate::tl!("Table of Authorities"), crate::icons::spec("tableOfAuthorities")), |ui| {
Button::command(CommandRef::with_params("references.markCitation", json!({})))
.label(crate::tl!("Mark\nCitation"))
.icon(IconId::new("markCitation"))
.icon(crate::icons::spec("markCitation"))
.arrangement(Arrangement::Stacked)
.show(ui);
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
@@ -173,7 +173,7 @@ pub(super) fn references(row: &mut RibbonRow<'_>, app: &mut WordApp) {
("tableOfAuthorities", "Insert Table of Authorities", "references.tableOfAuthorities"),
("update", "Update Table", "references.updateAuthorities"),
] {
Button::command(CommandRef::with_params(id, json!({}))).label(crate::tl!(label)).icon(crate::icons::id(key)).show(ui);
Button::command(CommandRef::with_params(id, json!({}))).label(crate::tl!(label)).icon(crate::icons::spec(key)).show(ui);
}
});
});
@@ -184,14 +184,14 @@ pub(super) fn zotero(row: &mut RibbonRow<'_>, _app: &mut WordApp) {
let big = |ui: &mut egui::Ui, key: &'static str, label: &'static str, id: &'static str| {
Button::command(CommandRef::with_params(id, json!({})))
.label(crate::tl!(label))
.icon(crate::icons::id(key))
.icon(crate::icons::spec(key))
.arrangement(Arrangement::Stacked)
.show(ui);
};
row.group(RibbonGroup::new("Provider", crate::tl!("Provider"), IconId::new("citation").into()), |ui| {
row.group(RibbonGroup::new("Provider", crate::tl!("Provider"), crate::icons::spec("citation")), |ui| {
menu_button(
ui,
Button::new(crate::tl!("Provider")).icon(IconId::new("citation")).tooltip(crate::tl!("Citation Provider")),
Button::new(crate::tl!("Provider")).icon(crate::icons::spec("citation")).tooltip(crate::tl!("Citation Provider")),
crate::tl!("Citation Provider"),
Some("ui.citations.provider"),
|ui, _| {
@@ -202,7 +202,7 @@ pub(super) fn zotero(row: &mut RibbonRow<'_>, _app: &mut WordApp) {
},
);
});
row.group(RibbonGroup::new("Citations", crate::tl!("Citations"), IconId::new("citation").into()), |ui| {
row.group(RibbonGroup::new("Citations", crate::tl!("Citations"), crate::icons::spec("citation")), |ui| {
big(ui, "citation", "Add/Edit\nCitation", "ui.zotero.addEditCitation");
big(ui, "addNote", "Add\nNote", "ui.zotero.addNote");
big(ui, "pastCitation", "Move Past\nCitation", "caret.pastCitation");
+14 -14
View File
@@ -12,24 +12,24 @@ use super::{WordApp, json};
/// The Review tab.
pub(super) fn review(row: &mut RibbonRow<'_>, app: &mut WordApp) {
row.group(RibbonGroup::new("review.proofing", tl!("Proofing").to_string(), IconId::new("spelling").into()), |ui| {
row.group(RibbonGroup::new("review.proofing", tl!("Proofing").to_string(), crate::icons::spec("spelling")), |ui| {
Button::command(CommandRef::new("review.spelling"))
.label(tl!("Spelling &\nGrammar").to_string())
.icon(IconId::new("spelling"))
.icon(crate::icons::spec("spelling"))
.arrangement(Arrangement::Stacked)
.show(ui);
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
Button::command(CommandRef::new("review.thesaurus")).label(tl!("Thesaurus").to_string()).icon(IconId::new("thesaurus")).show(ui);
Button::command(CommandRef::new("review.thesaurus")).label(tl!("Thesaurus").to_string()).icon(crate::icons::spec("thesaurus")).show(ui);
Button::command(CommandRef::with_params("ui.dialog", json!({"name": "wordCount"})))
.label(tl!("Word Count").to_string())
.icon(IconId::new("wordCount"))
.icon(crate::icons::spec("wordCount"))
.show(ui);
});
});
row.group(RibbonGroup::new("review.speech", tl!("Speech").to_string(), IconId::new("readAloud").into()), |ui| {
row.group(RibbonGroup::new("review.speech", tl!("Speech").to_string(), crate::icons::spec("readAloud")), |ui| {
Button::command(CommandRef::new("review.readAloud"))
.label(tl!("Read\nAloud").to_string())
.icon(IconId::new("readAloud"))
.icon(crate::icons::spec("readAloud"))
.arrangement(Arrangement::Stacked)
.show(ui);
});
@@ -40,13 +40,13 @@ pub(super) fn review(row: &mut RibbonRow<'_>, app: &mut WordApp) {
.arrangement(Arrangement::Stacked)
.show(ui);
});
row.group(RibbonGroup::new("review.language", tl!("Language").to_string(), IconId::new("language").into()), |ui| {
row.group(RibbonGroup::new("review.language", tl!("Language").to_string(), crate::icons::spec("language")), |ui| {
Button::command(CommandRef::new("review.translate"))
.label(tl!("Translate").to_string())
.icon(IconId::new("translate"))
.icon(crate::icons::spec("translate"))
.arrangement(Arrangement::Stacked)
.show(ui);
let face = Button::new(tl!("Language").to_string()).icon(IconId::new("language")).arrangement(Arrangement::Stacked);
let face = Button::new(tl!("Language").to_string()).icon(crate::icons::spec("language")).arrangement(Arrangement::Stacked);
menu_button(ui, face, tl!("Language").to_string(), None, |ui, _| language_menu(ui, app));
});
row.group(RibbonGroup::new("review.comments", tl!("Comments").to_string(), IconId::new("newComment").into()), |ui| {
@@ -188,7 +188,7 @@ pub(super) fn review(row: &mut RibbonRow<'_>, app: &mut WordApp) {
/// Developer › Controls: content controls.
pub(super) fn developer(row: &mut RibbonRow<'_>, app: &mut WordApp) {
let design = app.session.view.design_mode;
row.group(RibbonGroup::new("developer.controls", tl!("Controls").to_string(), IconId::new("ccRichText").into()), |ui| {
row.group(RibbonGroup::new("developer.controls", tl!("Controls").to_string(), crate::icons::spec("ccRichText")), |ui| {
let rows: [[(&'static str, &str); 3]; 3] = [
[("ccRichText", "developer.richText"), ("ccPlainText", "developer.plainText"), ("ccPicture", "developer.picture")],
[("ccGallery", "developer.buildingBlock"), ("ccCheckBox", "developer.checkBox"), ("ccComboBox", "developer.comboBox")],
@@ -199,7 +199,7 @@ pub(super) fn developer(row: &mut RibbonRow<'_>, app: &mut WordApp) {
for cells in rows {
Row::new().show(ui, |ui, _| {
for (icon_name, id) in cells {
IconButton::command(crate::icons::id(icon_name), CommandRef::new(id)).show(ui);
IconButton::command(crate::icons::spec(icon_name), CommandRef::new(id)).show(ui);
}
});
}
@@ -217,15 +217,15 @@ pub(super) fn developer(row: &mut RibbonRow<'_>, app: &mut WordApp) {
/// The Help tab.
pub(super) fn help(row: &mut RibbonRow<'_>, _app: &mut WordApp) {
row.group(RibbonGroup::new("help.help", tl!("Help").to_string(), IconId::new("help").into()), |ui| {
row.group(RibbonGroup::new("help.help", tl!("Help").to_string(), crate::icons::spec("help")), |ui| {
Button::command(CommandRef::with_params("ui.dialog", json!({"name": "about"})))
.label(tl!("Help").to_string())
.icon(IconId::new("help"))
.icon(crate::icons::spec("help"))
.arrangement(Arrangement::Stacked)
.show(ui);
Button::command(CommandRef::new("ui.checkForUpdates"))
.label(tl!("Check for\nUpdates…").to_string())
.icon(IconId::new("checkForUpdates"))
.icon(IconId::new("update"))
.arrangement(Arrangement::Stacked)
.show(ui);
Button::command(CommandRef::new("ui.discord"))
+6 -5
View File
@@ -116,17 +116,18 @@ pub(super) fn shape_format(row: &mut RibbonRow<'_>, app: &mut WordApp) {
});
}
row.group(RibbonGroup::new("shape.wordart", tl!("Decorative Text Styles"), IconId::new("wordcraft.more").into()), |ui| {
let styles = Button::new(tl!("Styles")).icon(IconId::new("wordArt")).tooltip(tl!("Decorative Text Styles")).arrangement(Arrangement::Stacked);
let styles =
Button::new(tl!("Styles")).icon(crate::icons::spec("wordArt")).tooltip(tl!("Decorative Text Styles")).arrangement(Arrangement::Stacked);
menu_button(ui, styles, tl!("Decorative Text Styles"), None, |ui, cx| super::galleries::wordart(ui, cx, app, "wordArt.style"));
let outline = crate::wordart_menus::current_outline(app);
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
menu_button(ui, Button::new(tl!("Text Fill")).icon(IconId::new("textFill")), tl!("Text Fill"), None, |ui, cx| {
menu_button(ui, Button::new(tl!("Text Fill")).icon(crate::icons::spec("textFill")), tl!("Text Fill"), None, |ui, cx| {
crate::wordart_menus::fill_menu(ui, cx, app, &theme)
});
menu_button(ui, Button::new(tl!("Text Outline")).icon(IconId::new("textOutline")), tl!("Text Outline"), None, |ui, _| {
menu_button(ui, Button::new(tl!("Text Outline")).icon(crate::icons::spec("textOutline")), tl!("Text Outline"), None, |ui, _| {
crate::wordart_menus::outline_menu(ui, app, outline)
});
menu_button(ui, Button::new(tl!("Text Effects")).icon(IconId::new("transform")), tl!("Text Effects"), None, |ui, _| {
menu_button(ui, Button::new(tl!("Text Effects")).icon(crate::icons::spec("transform")), tl!("Text Effects"), None, |ui, _| {
crate::wordart_menus::effects_menu(ui, app, true)
});
});
@@ -162,7 +163,7 @@ fn shape_text_group(row: &mut RibbonRow<'_>, app: &mut WordApp) {
let body = target.and_then(|(_, id)| app.session.doc.parts.get(&id).map(|p| p.body)).unwrap_or_default();
row.group(RibbonGroup::new("shape.text", tl!("Text"), IconId::new("wordcraft.more").into()), |ui| {
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
menu_button(ui, Button::new(tl!("Text Direction")).icon(IconId::new("textDirection")), tl!("Text Direction"), None, |ui, _| {
menu_button(ui, Button::new(tl!("Text Direction")).icon(crate::icons::spec("textDirection")), tl!("Text Direction"), None, |ui, _| {
for (label, vert) in [
("Horizontal", TextVert::Horz),
("Rotate all text 90°", TextVert::Vert),
+23 -17
View File
@@ -57,19 +57,25 @@ pub(super) fn table_design(row: &mut RibbonRow<'_>, app: &mut WordApp) {
row.group(RibbonGroup::new("tableStyles", tl!("Table Styles").to_string(), IconId::new("tableStyles").into()), |ui| {
super::galleries::table_styles(ui, app);
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
let _ = menu_button(ui, Button::new(tl!("Styles").to_string()).icon(IconId::new("styles")), tl!("Styles").to_string(), None, |ui, _| {
MenuItem::command(CommandRef::with_params("ui.dialog", json!({"name": "newTableStyle"})))
.label(tl!("New Table Style…").to_string())
.show(ui);
MenuItem::command(CommandRef::with_params("ui.dialog", json!({"name": "modifyTableStyle"})))
.label(tl!("Modify Table Style…").to_string())
.enabled(can_modify)
.show(ui);
MenuItem::command(CommandRef::with_params("table.deleteStyle", json!({})))
.label(tl!("Delete Table Style").to_string())
.enabled(can_delete)
.show(ui);
});
let _ = menu_button(
ui,
Button::new(tl!("Styles").to_string()).icon(crate::icons::spec("styles")),
tl!("Styles").to_string(),
None,
|ui, _| {
MenuItem::command(CommandRef::with_params("ui.dialog", json!({"name": "newTableStyle"})))
.label(tl!("New Table Style…").to_string())
.show(ui);
MenuItem::command(CommandRef::with_params("ui.dialog", json!({"name": "modifyTableStyle"})))
.label(tl!("Modify Table Style…").to_string())
.enabled(can_modify)
.show(ui);
MenuItem::command(CommandRef::with_params("table.deleteStyle", json!({})))
.label(tl!("Delete Table Style").to_string())
.enabled(can_delete)
.show(ui);
},
);
let _ = crate::colors::shading_split(ui, app, tl!("Shading").to_string(), Target::cmd("table.shading").remember(Remember::Shading));
});
});
@@ -250,7 +256,7 @@ pub(super) fn table_layout(row: &mut RibbonRow<'_>, app: &mut WordApp) {
});
Button::command(CommandRef::new("table.textDirection"))
.label(tl!("Text\nDirection").to_string())
.icon(IconId::new("textDirection"))
.icon(crate::icons::spec("textDirection"))
.arrangement(Arrangement::Stacked)
.show(ui);
Button::command(CommandRef::new("table.cellMargins"))
@@ -259,10 +265,10 @@ pub(super) fn table_layout(row: &mut RibbonRow<'_>, app: &mut WordApp) {
.arrangement(Arrangement::Stacked)
.show(ui);
});
row.group(RibbonGroup::new("data", tl!("Data").to_string(), IconId::new("sort").into()), |ui| {
row.group(RibbonGroup::new("data", tl!("Data").to_string(), crate::icons::spec("sort")), |ui| {
Button::command(CommandRef::new("table.sort"))
.label(tl!("Sort").to_string())
.icon(IconId::new("sort"))
.icon(crate::icons::spec("sort"))
.arrangement(Arrangement::Stacked)
.show(ui);
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
@@ -271,7 +277,7 @@ pub(super) fn table_layout(row: &mut RibbonRow<'_>, app: &mut WordApp) {
.icon(IconId::new("repeatHeader"))
.show(ui);
Button::command(CommandRef::new("table.toText")).label(tl!("Convert to Text").to_string()).icon(IconId::new("toText")).show(ui);
Button::command(CommandRef::new("table.formula")).label(tl!("Formula").to_string()).icon(IconId::new("formula")).show(ui);
Button::command(CommandRef::new("table.formula")).label(tl!("Formula").to_string()).icon(crate::icons::spec("formula")).show(ui);
});
});
}
+3 -3
View File
@@ -86,7 +86,7 @@ pub(super) fn view(row: &mut RibbonRow<'_>, app: &mut WordApp) {
.show(ui);
Button::command(CommandRef::new("view.zoom100"))
.label(tl!("100%").to_string())
.icon(IconId::new("zoom100"))
.icon(crate::icons::spec("zoom100"))
.arrangement(Arrangement::Stacked)
.show(ui);
// Step the zoom up and down by 10% (issue #67), from whatever the page shows now.
@@ -191,10 +191,10 @@ pub(super) fn view(row: &mut RibbonRow<'_>, app: &mut WordApp) {
.arrangement(Arrangement::Stacked)
.show(ui);
});
row.group(RibbonGroup::new("view.templates", tl!("Templates").to_string(), IconId::new("documentTemplate").into()), |ui| {
row.group(RibbonGroup::new("view.templates", tl!("Templates").to_string(), crate::icons::spec("documentTemplate")), |ui| {
Button::command(CommandRef::new("tools.templates"))
.label(tl!("Templates").to_string())
.icon(IconId::new("documentTemplate"))
.icon(crate::icons::spec("documentTemplate"))
.arrangement(Arrangement::Stacked)
.show(ui);
});
+5 -1
View File
@@ -974,7 +974,11 @@ mod tests {
for path in crate::rust_sources(&dir) {
let name = path.file_name().unwrap().to_string_lossy().to_string();
// This file holds the banned strings in the list above; theme.rs and icons.rs hold the theme's own colours.
if path == dir.join("theme.rs") || path == dir.join("theme").join("legacy.rs") || path == dir.join("icons.rs") {
if path == dir.join("theme.rs")
|| path == dir.join("theme").join("legacy.rs")
|| path == dir.join("icons.rs")
|| path == dir.join("icons").join("glyphs.rs")
{
continue;
}
let src = std::fs::read_to_string(&path).unwrap();