UI port regressions vs v0.18.1: focus after reopen, Cut/Copy state, menu shortcuts, File pages (#7671) (#7711)
* #7677: register ui.backstage in the app command catalog with the label File The File keytips fire ui.backstage, but it had no catalog entry, so the command runtime warned and showed its id as the label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCZhHKRuRB5wZUiw6BE * #7675: Command catalog: leave Cut, Copy and Paste to the linked edit set, keep the engine's chords The app catalog defined edit.cut, edit.copy and edit.paste, which the framework's linked edit set also defines; the set's definition wins, so each logged a "the app catalog defines ..." warning at startup. The three go in as the set's replaced default chords instead (Mod+Insert, Shift+Insert stay bound). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCZhHKRuRB5wZUiw6BE * #7673: Cut and Copy are disabled in the ribbon with no selection The focused page answers for the linked Cut and Copy, so the app's command state (the engine's "nothing is selected") never reached the Home > Clipboard buttons. The buttons now read the engine's enabled state, and Copy gets Cut's has-selection rule. craft-libs' inactive_edits would also cover shortcuts and menus once the page view is given it; this works on the current pin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCZhHKRuRB5wZUiw6BE * #7675: leave Undo and Redo to the linked edit set as well The linked EditCommands set also defines edit.undo and edit.redo, so the board warned and dropped the app's definitions for them too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCZhHKRuRB5wZUiw6BE * #7672: File pages hand the keyboard back to the page after the click's pass Opening a template or a recent document from File › Home after Ctrl+W left the page without keyboard input until it was clicked. The Home, New, Back, Save, personal-template and Recover actions asked for the page's focus in the pass of the press that ran them; the press moves egui focus to the pressed tile at the pass's end, so the request was lost while the canvas still recorded it as taken. They now ask after the pass, as ribbon tabs do (`focus_page_after_pass`). Drops the `ctx` parameters that only carried it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCZhHKRuRB5wZUiw6BE * #7703: context menu rows show their shortcuts again The rows were bound with the props builder (MenuItem::new(label).command(..)), which never sets the row's own command, so MenuItem::keys found no chord. MenuItem::command(..).label(..) keeps the binding and the chord. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCZhHKRuRB5wZUiw6BE * #7704: Table Layout cell size fields get their labels and two decimals back A Height: and Width: caption beside each field and fixed two decimals, as Layout > Paragraph's indent fields and v0.18.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCZhHKRuRB5wZUiw6BE * #7705: File > Export keeps the format buttons in a dialog-width column They filled the whole page; the Print page already gives them its column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCZhHKRuRB5wZUiw6BE * #7706: File > Home drops the duplicate New and Open buttons The File rail beside the page has them, as in v0.18.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCZhHKRuRB5wZUiw6BE * #7673: the page marks Cut and Copy inactive with nothing selected PageView answers for the linked edit commands while it has focus, so the engine's 'nothing is selected' never reached the context menu or other surfaces. inactive_edits passes it on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCZhHKRuRB5wZUiw6BE * #7694: ribbon letter icons drawn as text, with a filled italic I (#7149 item 8) Ports #7153 (text-drawn letter/symbol icons) onto the craft-ui code: new icons/glyphs.rs, icons::spec and the text-glyph path in for_command, three missing SVGs (smartArtLayouts, tableStyleOptions, tableStyles), and every button, group and tile that shows one of those icons now resolves through icons::spec (status bar, Home, Table, Insert, Mailings, Draw, galleries, backstage, mini toolbar, QAT). U, strikethrough, Change Case, clear formatting and the other letter/symbol icons are drawn as text. The mix Martin chose: Bold keeps main's bold.svg (removed from the glyph table); Italic uses the filled italic.svg from #7690 (removed from the glyph table, ATTRIBUTION row updated). Underline stays a text glyph. Test every_icon_name_the_ui_uses_resolves guards that glyph names never go through the SVG-only IconId::new / icons::id. Co-authored-by: batistalucasv <batistalucasv@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCZhHKRuRB5wZUiw6BE * #7676: Comments and Editing strip ends use the ghost look, so the narrow icon face stops asking IconButton for Outline/Neutral Also drops their outlines (#7682, buttons part). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * #7675: Cut and Copy keys stay silent with nothing selected edit.cut and edit.copy are disabled with a caret only, but the key still reached edit_command, which ran them and put 'not available: ...' on the status bar. Guard both arms with command_enabled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * #7694: Underline icon is a filled SVG like Bold and Italic Underline was drawn as a text U with a stroked bar. It now uses a new filled-path underline.svg (a heavy U and a separate solid bar, our own drawing) at Bold's cap height, registered as an SVG like Bold and Italic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * #7694: Underline's U is the same height as Bold's B and Italic's I The U now starts and ends where B and I do (y 5.4 to 16.5 in the 20-unit box), and the bar sits below that shared baseline (17.7 to 19.2), so the three letters line up in the Font group and the mini toolbar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * #7675: empty-copy clipboard test expects Copy to be refused With nothing selected Copy is now greyed (`when(has_sel)`), so the restored #7544 test's empty copy is refused before it reaches the clipboard; it now asserts the refusal and keeps its checks that the clipboard and its published state are untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * #7694: glyph icons take their fixed inks from one named icon-art palette The text-drawn glyphs' red, green, orange, pink and shadow inks are now named constants in icons.rs (ART_*), the same values the SVG icon set draws with, so glyphs.rs is checked by `interface_colours_come_from_the_theme` again instead of being exempt as a whole file. Every other glyph ink still comes from the theme. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCWNarDG3QfXK2YMzdx --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: batistalucasv <batistalucasv@gmail.com>
No files matched your search
@@ -202,7 +202,7 @@ The UI icons are SVG files in `crates/ui-egui/icons/`, one row each below. Gener
|
||||
| `crates/ui-egui/icons/insertLeft.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/insertRight.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/interfaceTheme.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/italic.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/italic.svg` | WordCraft contributors | original: redrawn for #7694 | MIT OR Apache-2.0 | UI icon |
|
||||
| `crates/ui-egui/icons/justify.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/labels.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/language.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 |
|
||||
@@ -339,6 +339,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 |
|
||||
@@ -358,6 +359,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 |
|
||||
@@ -375,7 +378,7 @@ The UI icons are SVG files in `crates/ui-egui/icons/`, one row each below. Gener
|
||||
| `crates/ui-egui/icons/trackChanges.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/transform.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/translate.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/underline.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/underline.svg` | WordCraft contributors | original: redrawn for #7694 | MIT OR Apache-2.0 | UI icon |
|
||||
| `crates/ui-egui/icons/undo.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/unlinkCitations.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/update.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 |
|
||||
|
||||
@@ -73,7 +73,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
.key("Mod+Y / Mod+Shift+Z")
|
||||
.pure(),
|
||||
CommandSpec::new("edit.cut", "Cut", "Home › Clipboard", cut).key("Mod+X").when(has_sel),
|
||||
CommandSpec::new("edit.copy", "Copy", "Home › Clipboard", copy).key("Mod+C / Mod+Insert").pure(),
|
||||
CommandSpec::new("edit.copy", "Copy", "Home › Clipboard", copy).key("Mod+C / Mod+Insert").pure().when(has_sel),
|
||||
// Word's Spike (Ctrl+F3, Ctrl+Shift+F3; ⌘ on the Mac): the AutoText entry "Spike", so Quick
|
||||
// Parts and AutoText insert it without emptying it, as in Word.
|
||||
CommandSpec::new("edit.spike", "Spike", "Editing", spike).key("Mod+F3").when(has_text_sel),
|
||||
|
||||
@@ -1663,10 +1663,9 @@ fn copying_puts_rtf_on_the_clipboard() {
|
||||
assert!(r["rtf"].as_str().is_some_and(|t| t.starts_with("{\\rtf1") && t.contains("bold")), "{r}");
|
||||
assert_eq!(text(&s).lines().next(), Some("plain "));
|
||||
|
||||
// Nothing selected: nothing copied, no RTF.
|
||||
// Nothing selected: Copy is refused, so nothing is copied.
|
||||
run(&mut s, "caret.docEnd", json!({}));
|
||||
let r = run(&mut s, "edit.copy", json!({}));
|
||||
assert!(r.get("rtf").is_none(), "{r}");
|
||||
assert!(s.run("edit.copy", &json!({})).is_err(), "Copy with nothing selected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -2636,6 +2635,20 @@ fn tracked_cut_of_a_table_or_row_marks_text_deleted() {
|
||||
assert_eq!(body_table_final(&s), full);
|
||||
}
|
||||
|
||||
/// Cut and Copy are off with nothing selected (the ribbon buttons read this) and on with text selected.
|
||||
#[test]
|
||||
fn cut_and_copy_are_disabled_without_a_selection() {
|
||||
let mut s = Session::new(wordcraft_doc::Document::new());
|
||||
run(&mut s, "text.insert", json!({"text": "Hello"}));
|
||||
for id in ["edit.cut", "edit.copy"] {
|
||||
assert!(s.why_disabled(id).is_some(), "{id} with a caret only");
|
||||
}
|
||||
run(&mut s, "select.text", json!({"text": "Hello"}));
|
||||
for id in ["edit.cut", "edit.copy"] {
|
||||
assert!(s.why_disabled(id).is_none(), "{id} with a selection");
|
||||
}
|
||||
}
|
||||
|
||||
/// #1744 review: Cut of a table, or of cells, holding a content control locked against deletion
|
||||
/// is refused and changes nothing in the document; the copy is made first, so the clipboard
|
||||
/// holds the table, as for any refused Cut.
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20">
|
||||
<path d="M8.6 5.4 L13.2 5.4 M6.8 16.5 L11.4 16.5 M10.9 5.4 L9.1 16.5" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round"/>
|
||||
<path d="M8 5.4 L13.8 5.4 L13.8 7 L11.6 7 L10.3 14.9 L12 14.9 L12 16.5 L6.2 16.5 L6.2 14.9 L8.4 14.9 L9.7 7 L8 7 Z" fill="currentColor"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 242 B After Width: | Height: | Size: 231 B |
@@ -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 |
@@ -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,4 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20">
|
||||
<path d="M5.8 4.24 L5.8 10.4 C5.8 13.1 7.4 14.6 10 14.6 C12.6 14.6 14.2 13.1 14.2 10.4 L14.2 4.24" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round"/>
|
||||
<path d="M5 17 L15 17" fill="none" stroke="currentColor" stroke-width="1.25"/>
|
||||
<path d="M5.4 5.4 L7.8 5.4 L7.8 11.45 C7.8 13.57 8.6 14.38 10 14.38 C11.4 14.38 12.2 13.57 12.2 11.45 L12.2 5.4 L14.6 5.4 L14.6 11.66 C14.6 14.89 12.8 16.5 10 16.5 C7.2 16.5 5.4 14.89 5.4 11.66 Z M4.6 17.7 L15.4 17.7 L15.4 19.2 L4.6 19.2 Z" fill="currentColor"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 352 B After Width: | Height: | Size: 356 B |
@@ -5,6 +5,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
|
||||
use craft::keymap::Overrides;
|
||||
use craft::ui::runtime::commands::CommandSet as _;
|
||||
use craft::ui::runtime::commands::{
|
||||
AppCatalog, Binding, CommandDef, CommandInput, CommandRef, CommandState, CommandStates, FireSource, Scope, TypingRule,
|
||||
};
|
||||
@@ -139,6 +140,13 @@ fn gate_registered(app: &WordApp, id: &str) -> (bool, Option<&'static str>) {
|
||||
(reason.is_none(), reason)
|
||||
}
|
||||
|
||||
/// The framework edit commands the app's engine commands of the same id run through: the linked set owns their
|
||||
/// definition, the engine owns their chords.
|
||||
const LINKED_EDIT: [craft::ui::runtime::commands::EditCommands; 5] = {
|
||||
use craft::ui::runtime::commands::EditCommands::{Copy, Cut, Paste, Redo, Undo};
|
||||
[Cut, Copy, Paste, Undo, Redo]
|
||||
};
|
||||
|
||||
impl WordApp {
|
||||
/// The app's commands as the keymap knows them: every engine command with its default
|
||||
/// chords, then the interface commands. The interface commands come last because a tie in the
|
||||
@@ -171,7 +179,9 @@ impl WordApp {
|
||||
}
|
||||
defs.push(def);
|
||||
}
|
||||
for spec in registry.all().iter().filter(|spec| seen.insert(spec.id)) {
|
||||
// The framework's edit set defines Cut, Copy, Paste, Undo and Redo: a catalog def for them is shadowed (and
|
||||
// warned about), so their chords go in as the set's replaced defaults (the `LINKED_EDIT` fold below).
|
||||
for spec in registry.all().iter().filter(|spec| seen.insert(spec.id) && !LINKED_EDIT.iter().any(|c| c.id() == spec.id)) {
|
||||
let mut def = CommandDef::new(CommandRef::new(spec.id), tl!(spec.label), Scope::app());
|
||||
for binding in default_bindings(spec.shortcut) {
|
||||
def = def.with_default(binding);
|
||||
@@ -191,6 +201,8 @@ impl WordApp {
|
||||
interface(CommandRef::new("ui.collapseRibbon"), "Collapse the Ribbon", "Mod+Alt+R");
|
||||
}
|
||||
interface(CommandRef::new("ui.resetInterfaceSize"), "Reset Interface Size", "Mod+Shift+0");
|
||||
// The File keytips fire it (one badge per page); without an entry it shows its id as its label.
|
||||
defs.push(CommandDef::new(CommandRef::new("ui.backstage"), tl!("File"), Scope::app()));
|
||||
for (id, label) in GATED_UI_COMMANDS {
|
||||
defs.push(CommandDef::new(CommandRef::new(*id), tl!(*label), Scope::app()));
|
||||
}
|
||||
@@ -204,6 +216,10 @@ impl WordApp {
|
||||
match AppCatalog::new(defs, generation) {
|
||||
Ok(catalog) => {
|
||||
let catalog = catalog.typing_rule(TypingRule::PlainKeysWait);
|
||||
let catalog = LINKED_EDIT.iter().fold(catalog, |catalog, command| {
|
||||
let chords = registry.get(command.id()).map(|spec| default_bindings(spec.shortcut).collect()).unwrap_or_default();
|
||||
catalog.replace_defaults(command.id(), chords)
|
||||
});
|
||||
self.command_catalog = Some((registry, with_word_chords(catalog)));
|
||||
}
|
||||
Err(error) => {
|
||||
|
||||
@@ -176,7 +176,7 @@ pub(crate) fn show(ui: &mut Ui, cx: &mut BodyCx<'_>, app: &mut WordApp) {
|
||||
match command {
|
||||
BackstagePageCommand::Back => {
|
||||
let _ = app.run("ui.backstage", json!({"value": false}));
|
||||
app.canvas.focus_page(&ctx);
|
||||
app.canvas.focus_page_after_pass();
|
||||
}
|
||||
// PLAN: `print_requested(app, ctx)` is chrome-w10's new `pub(crate)` fn in print_page.rs (S-L263).
|
||||
BackstagePageCommand::Print if app.ui.backstage_page == "print" => crate::print_page::print_requested(app, &ctx),
|
||||
@@ -209,7 +209,7 @@ pub(crate) fn show(ui: &mut Ui, cx: &mut BodyCx<'_>, app: &mut WordApp) {
|
||||
});
|
||||
});
|
||||
if let Some(id) = choice.page.take() {
|
||||
go_to_page(app, id, &ctx);
|
||||
go_to_page(app, id);
|
||||
}
|
||||
if choice.about.get() {
|
||||
let _ = crate::dialogs::open(app, "about", &json!({}));
|
||||
@@ -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.
|
||||
@@ -325,7 +325,7 @@ fn page_rows(ui: &mut Ui, current: &str, has_document: bool, choice: &MenuChoice
|
||||
|
||||
/// Opens a side-menu page, as a click on it (or its keytip) does. Without a document only the
|
||||
/// pages that work without one open.
|
||||
pub(crate) fn go_to_page(app: &mut WordApp, id: &str, ctx: &egui::Context) {
|
||||
pub(crate) fn go_to_page(app: &mut WordApp, id: &str) {
|
||||
if !app.has_document() && !works_without_document(id) {
|
||||
return;
|
||||
}
|
||||
@@ -340,7 +340,7 @@ pub(crate) fn go_to_page(app: &mut WordApp, id: &str, ctx: &egui::Context) {
|
||||
let r = app.run("file.save", json!({}));
|
||||
if r.is_ok_and(|v| v.get("saved").and_then(serde_json::Value::as_bool) == Some(true) || v.get("downloaded").is_some()) {
|
||||
app.ui.backstage = false;
|
||||
app.canvas.focus_page(ctx);
|
||||
app.canvas.focus_page_after_pass();
|
||||
} else {
|
||||
app.ui.backstage_page = "saveAs".into();
|
||||
}
|
||||
@@ -391,10 +391,10 @@ fn matching_personal(query: &str, list: &[PersonalTemplate]) -> Vec<PersonalTemp
|
||||
|
||||
/// Make a new document from the personal template at `path` and close File; a template that
|
||||
/// can't be read keeps File open so the gallery can say why.
|
||||
fn open_personal(app: &mut WordApp, path: &str, ctx: &egui::Context) -> Result<(), String> {
|
||||
fn open_personal(app: &mut WordApp, path: &str) -> Result<(), String> {
|
||||
app.run("file.newFromTemplate", json!({"path": path}))?;
|
||||
app.ui.backstage = false;
|
||||
app.canvas.focus_page(ctx);
|
||||
app.canvas.focus_page_after_pass();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ pub(super) fn template_cards(list: &[(&str, &str)]) -> Vec<Template> {
|
||||
|
||||
/// Runs what the user did on a start screen or recent list. A failed open stays on the page as its
|
||||
/// error (`BackstageState::open_error`); a later success clears it.
|
||||
fn run_actions(app: &mut WordApp, ctx: &egui::Context, actions: Vec<StartAction>) {
|
||||
fn run_actions(app: &mut WordApp, actions: Vec<StartAction>) {
|
||||
for action in actions {
|
||||
match action {
|
||||
StartAction::New | StartAction::MoreTemplates => app.ui.backstage_page = "new".into(),
|
||||
@@ -40,7 +40,7 @@ fn run_actions(app: &mut WordApp, ctx: &egui::Context, actions: Vec<StartAction>
|
||||
StartAction::OpenRecent(path) => {
|
||||
let failed = open_recent(app, &path.to_string_lossy()).err();
|
||||
if failed.is_none() {
|
||||
app.canvas.focus_page(ctx);
|
||||
app.canvas.focus_page_after_pass();
|
||||
}
|
||||
app.backstage_state.open_error = failed;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ fn run_actions(app: &mut WordApp, ctx: &egui::Context, actions: Vec<StartAction>
|
||||
StartAction::UseTemplate(id) => {
|
||||
let _ = app.run("file.new", json!({"template": id}));
|
||||
app.ui.backstage = false;
|
||||
app.canvas.focus_page(ctx);
|
||||
app.canvas.focus_page_after_pass();
|
||||
}
|
||||
// Pins, folders and reveal are not part of File.
|
||||
_ => {}
|
||||
@@ -84,6 +84,9 @@ pub(super) fn home(ui: &mut Ui, app: &mut WordApp) {
|
||||
let (mut view, mut sort) = (RecentView::List, RecentSort::Opened);
|
||||
let out = StartScreen::new(Bind::bound(&mut view), Bind::bound(&mut sort), &recent)
|
||||
.layout(StartLayout::Greeting)
|
||||
// The File rail beside the page has New and Open; production's Home had no second pair.
|
||||
.offers_new(false)
|
||||
.offers_open(false)
|
||||
.title(label(greeting))
|
||||
.templates(&cards)
|
||||
.more_templates(label("More templates →"))
|
||||
@@ -93,12 +96,11 @@ pub(super) fn home(ui: &mut Ui, app: &mut WordApp) {
|
||||
.page_paper(DataColor::new(Color32::WHITE))
|
||||
.thumbnails(&store, &source)
|
||||
.show(ui);
|
||||
run_actions(app, &ctx, out.actions);
|
||||
run_actions(app, out.actions);
|
||||
}
|
||||
|
||||
/// Open: Browse for a file, then the recent documents.
|
||||
pub(super) fn open(ui: &mut Ui, app: &mut WordApp) {
|
||||
let ctx = ui.ctx().clone();
|
||||
heading(ui, "Open");
|
||||
if clicked(&Button::new(label("Browse…")).id_salt("open-browse").show(ui)) {
|
||||
let _ = app.run("ui.openFileDialog", json!({}));
|
||||
@@ -119,5 +121,5 @@ pub(super) fn open(ui: &mut Ui, app: &mut WordApp) {
|
||||
}
|
||||
let recent = recent_files(app);
|
||||
let out = RecentList::new(&recent).max_recent(app.ui.recent_shown()).empty(label("Documents you open will show up here.")).show(ui);
|
||||
run_actions(app, &ctx, out.actions);
|
||||
run_actions(app, out.actions);
|
||||
}
|
||||
@@ -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,7 @@ use craft::ui::contract::{
|
||||
use craft::ui::layout_components::Stack;
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::notices::Notice;
|
||||
use craft::ui::primitives::{ContentPainterCx, IconSpec};
|
||||
use craft::ui::primitives::ContentPainterCx;
|
||||
use craft::ui::runtime::env::Label;
|
||||
use craft::ui::shell::{Template, ThumbKey};
|
||||
use craft::ui::style::DataColor;
|
||||
@@ -64,7 +64,7 @@ fn read_listing(app: &WordApp) -> PersonalListing {
|
||||
pub(super) fn paint_personal_card(cx: &ContentPainterCx, rect: Rect) {
|
||||
cx.data_shapes([Shape::rect_filled(rect, 2.0, Color32::WHITE)]);
|
||||
let icon_rect = Rect::from_center_size(rect.center(), vec2(44.0, 44.0));
|
||||
cx.icon(icon_rect, &IconSpec::svg(IconId::new("documentTemplate")).data_color(DataColor::new(Color32::from_gray(150))));
|
||||
cx.icon(icon_rect, &crate::icons::spec("documentTemplate").data_color(DataColor::new(Color32::from_gray(150))));
|
||||
}
|
||||
|
||||
/// New: the whole template gallery with a search box, then the personal templates (#2852); no
|
||||
@@ -112,7 +112,7 @@ pub(super) fn show(ui: &mut Ui, app: &mut WordApp) {
|
||||
for id in activated(out.response.events) {
|
||||
let _ = app.run("file.new", json!({"template": id}));
|
||||
app.ui.backstage = false;
|
||||
app.canvas.focus_page(&ctx);
|
||||
app.canvas.focus_page_after_pass();
|
||||
}
|
||||
}
|
||||
// Personal: the user templates folder's templates; a folder per category, as in Word.
|
||||
@@ -147,7 +147,7 @@ pub(super) fn show(ui: &mut Ui, app: &mut WordApp) {
|
||||
Tile::new(Label::from(p.label.clone())).thumb(ThumbAspect::new(PAGE_WIDE, PAGE_HIGH), paint_personal_card).tooltip(p.path.clone())
|
||||
});
|
||||
for path in activated(out.response.events) {
|
||||
let failed = open_personal(app, &path, &ctx).err();
|
||||
let failed = open_personal(app, &path).err();
|
||||
app.backstage_state.personal_error = failed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use craft::i18n::Direction;
|
||||
use craft::ui::buttons::Button;
|
||||
use craft::ui::choice::Checkbox;
|
||||
use craft::ui::contract::{Bind, Gap, Props as _, Show as _, ShowContainer as _, Sizing, clicked};
|
||||
use craft::ui::contract::{Bind, Gap, LeastWidth, Props as _, Show as _, ShowContainer as _, Sizing, clicked};
|
||||
use craft::ui::display::Text;
|
||||
use craft::ui::form::{Field, FieldGroup};
|
||||
use craft::ui::layout_components::{Row, Stack};
|
||||
@@ -16,7 +16,6 @@ use crate::WordApp;
|
||||
|
||||
/// Recovery is a separate copy. Leaving this page never discards it.
|
||||
pub(super) fn recovery(ui: &mut Ui, app: &mut WordApp) {
|
||||
let ctx = ui.ctx().clone();
|
||||
heading(ui, "Recover documents");
|
||||
let _ = Text::new(label("Restore opens an unsaved copy. Your original file stays unchanged.")).show(ui);
|
||||
if app.session.password.is_some() {
|
||||
@@ -48,7 +47,7 @@ pub(super) fn recovery(ui: &mut Ui, app: &mut WordApp) {
|
||||
let _ = Row::new().gap(Gap::Tight).show(ui, |ui, _| {
|
||||
if clicked(&Button::new(label("Continue without restoring")).id_salt("recover-continue").show(ui)) {
|
||||
let _ = app.run("ui.backstage", json!({"value": false}));
|
||||
app.canvas.focus_page(&ctx);
|
||||
app.canvas.focus_page_after_pass();
|
||||
}
|
||||
if clicked(&Button::new(label("Refresh")).id_salt("recover-refresh").enabled(!busy && app.session.recovery_ready()).show(ui)) {
|
||||
let _ = app.run("file.recover", json!({"refresh": true}));
|
||||
@@ -209,5 +208,9 @@ pub(super) fn export(ui: &mut Ui, app: &mut WordApp) {
|
||||
}
|
||||
heading(ui, "Export");
|
||||
let _ = Text::new(label("Save a copy in another format. Printing goes through a PDF you can print from any viewer.")).show(ui);
|
||||
crate::print_page::export_formats(app, ui);
|
||||
// The Print page's settings column: the format buttons fill it, not the page (as production's 320 pt rows).
|
||||
// The row keeps the page's width from reaching the column, so the column is as wide as its least width.
|
||||
let _ = Row::new().show(ui, |ui, _| {
|
||||
let _ = Stack::new().least_width(LeastWidth::Dialog).gap(Gap::Stack).show(ui, |ui, _| crate::print_page::export_formats(app, ui));
|
||||
});
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use std::cell::Cell;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::sync::Arc;
|
||||
|
||||
use craft::behavior::intent::EditCommand;
|
||||
use craft::behavior::kurbo::{Point, Size};
|
||||
use craft::pages::layout::{Fit, LayoutOptions, PageDisplay, SCREEN_POINTS_PER_POINT};
|
||||
use craft::pages::ui::reading::{ReadingMetrics, reading_size};
|
||||
@@ -17,7 +18,7 @@ use craft::ui::canvas::{Autoscroll, ContextSource, MiddleButton, NavigationOptio
|
||||
use craft::ui::contract::Show as _;
|
||||
|
||||
use craft::ui::runtime::env::Env;
|
||||
use craft::ui::runtime::focus::{self, FocusTarget};
|
||||
use craft::ui::runtime::focus::{self, EditSet, FocusTarget};
|
||||
use craft::ui::style::DataColor;
|
||||
use egui::{Color32, Pos2, Rect, Ui, pos2, vec2};
|
||||
use serde_json::json;
|
||||
@@ -808,12 +809,19 @@ fn show_pages(app: &mut WordApp, ui: &mut Ui, layout: &Arc<DocLayout>, full: Rec
|
||||
let mut fix = ScrollFix::default();
|
||||
// The caret the follow wants whose page the pass did not place: its page, the page's height and the caret.
|
||||
let mut unplaced = None;
|
||||
// The page answers for the linked Cut and Copy while it has focus: with nothing selected they are inactive, so the
|
||||
// ribbon, the context menu and the command search grey them as production did.
|
||||
let inactive_edits = [(EditCommand::Cut, "edit.cut"), (EditCommand::Copy, "edit.copy")]
|
||||
.into_iter()
|
||||
.filter(|(_, id)| !crate::app::command_board::command_enabled(app, id))
|
||||
.fold(EditSet::NONE, |set, (command, _)| set.with(command));
|
||||
let out = PageView::new(tl!("Document"), &source, &mut state, paper)
|
||||
.options(options)
|
||||
// Hide White Space cuts each page to its text area: without the bodies the pages show whole.
|
||||
.bodies(&bodies)
|
||||
.navigation(navigation_options())
|
||||
.editor(craft::ui::primitives::EditorPurpose::Text)
|
||||
.inactive_edits(inactive_edits)
|
||||
.rulers(show_rulers)
|
||||
.snap(crate::objects::snap(app, layout))
|
||||
.tool_regions(regions)
|
||||
|
||||
@@ -107,7 +107,8 @@ pub(crate) fn show(app: &mut WordApp, ui: &mut Ui, opener: &Response, ask: Optio
|
||||
/// A row labelled `label` that runs command `id` with `params`; its chord, enabled state and
|
||||
/// action come from the command, its wording from the menu (one command id serves several rows).
|
||||
fn item(ui: &mut Ui, label: &str, id: &str, params: Value) {
|
||||
let _ = MenuItem::new(tl!(label).to_string()).command(CommandRef::with_params(id, params)).show(ui);
|
||||
// `MenuItem::command`, not `new(..).command(..)`: only the row's own binding shows the command's chord.
|
||||
let _ = MenuItem::command(CommandRef::with_params(id, params)).label(tl!(label).to_string()).show(ui);
|
||||
}
|
||||
|
||||
fn rule(ui: &mut Ui) {
|
||||
|
||||
@@ -235,7 +235,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);
|
||||
|
||||
@@ -439,4 +439,28 @@ mod tests {
|
||||
a.run("file.new", json!({})).unwrap();
|
||||
assert_eq!(titles(&a), ["Document1", "Document2"]);
|
||||
}
|
||||
|
||||
/// #7672: a template opened from File › Home after Ctrl+W takes typing without a click on the page. The tile's
|
||||
/// press moves egui focus at the end of its pass, so a focus request made in that pass was lost.
|
||||
#[test]
|
||||
fn a_template_opened_from_home_after_closing_takes_typing() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let mut h = harness(app());
|
||||
crate::test_harness::frames(&mut h, 3);
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::W);
|
||||
crate::test_harness::frames(&mut h, 4);
|
||||
h.state_mut().run("ui.backstage", json!({"page": "home"})).unwrap();
|
||||
crate::test_harness::frames(&mut h, 4);
|
||||
let at = h.get_by_label("Studio handbook (sample)").rect().center();
|
||||
let button =
|
||||
|pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE };
|
||||
h.input_mut().events.extend([egui::Event::PointerMoved(at), button(true)]);
|
||||
crate::test_harness::frames(&mut h, 1);
|
||||
h.event(button(false));
|
||||
crate::test_harness::frames(&mut h, 6);
|
||||
assert!(!h.state().ui.backstage, "the tile opened the template");
|
||||
h.event(egui::Event::Text("QQ".into()));
|
||||
crate::test_harness::frames(&mut h, 3);
|
||||
assert!(text(h.state()).contains("QQ"), "the typing reached the page");
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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};
|
||||
@@ -286,6 +288,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")),
|
||||
@@ -305,6 +308,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")),
|
||||
@@ -352,6 +357,15 @@ pub fn register() {
|
||||
|
||||
/// The app icons whose names the framework's catalog also has. The catalog wins a clash, so the
|
||||
/// app registers its own drawings of these as `wordcraft.<name>`, and [`id`] names them so.
|
||||
/// The icon art's fixed inks, the same in every theme: the red, green, orange and pink the SVG
|
||||
/// icon set draws with (`icons/*.svg`), and the soft shadow under the Text Effects letter. The
|
||||
/// text-drawn glyphs (`glyphs.rs`) take theirs from here; every other ink comes from the theme.
|
||||
pub(crate) const ART_RED: Color32 = Color32::from_rgb(0xD1, 0x3B, 0x3B);
|
||||
pub(crate) const ART_GREEN: Color32 = Color32::from_rgb(0x2E, 0x8B, 0x57);
|
||||
pub(crate) const ART_ORANGE: Color32 = Color32::from_rgb(0xE0, 0x7B, 0x1F);
|
||||
pub(crate) const ART_PINK: Color32 = Color32::from_rgb(0xE8, 0x6F, 0xA0);
|
||||
pub(crate) const ART_SHADOW: Color32 = Color32::from_rgba_premultiplied(0, 0, 0, 40);
|
||||
|
||||
const OWN_OVER_CATALOG: &[(&str, &str)] = &[
|
||||
("bookmark", "wordcraft.bookmark"),
|
||||
("check", "wordcraft.check"),
|
||||
@@ -388,6 +402,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.
|
||||
@@ -419,11 +442,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
|
||||
@@ -466,6 +493,17 @@ impl Glyph for LibraryGlyph {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// #7694: Bold, Italic and Underline draw their filled SVGs while the other letter icons beside them are
|
||||
/// drawn as text.
|
||||
#[test]
|
||||
fn bold_italic_and_underline_are_svgs_beside_the_text_letters() {
|
||||
use craft::ui::primitives::IconSource;
|
||||
for name in ["bold", "italic", "underline"] {
|
||||
assert!(matches!(spec(name).source, IconSource::Svg(_)), "{name} should draw its SVG");
|
||||
}
|
||||
assert!(matches!(spec("strike").source, IconSource::Glyph(_)));
|
||||
}
|
||||
|
||||
/// The numbers of the outline path's `d` attribute, in order (the arrow's paths are only M, L, Z). The
|
||||
/// icon fills the tail and the head as two translucent paths and ends with the stroked outline of the
|
||||
/// whole arrow, which is the last.
|
||||
@@ -498,6 +536,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]
|
||||
@@ -513,6 +558,56 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// #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:?}");
|
||||
}
|
||||
|
||||
/// #7317: the `fitOnePage` app icon is a document the registry resolves and the rasteriser draws.
|
||||
/// A document the engine fails to parse or draw gives no texture, and so no shape: the tile would
|
||||
/// be blank. The pre-#7101 test painted the hand-written vector path; this checks the same icon
|
||||
|
||||
@@ -0,0 +1,477 @@
|
||||
//! 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("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("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("watermark"),
|
||||
TextIcon("wordArt"),
|
||||
TextIcon("wordCount"),
|
||||
TextIcon("zoom100"),
|
||||
];
|
||||
|
||||
/// An icon drawn as text and lines; the name picks the drawing.
|
||||
#[derive(craft::ui::contract::MemoProps)]
|
||||
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, d: disabled };
|
||||
paint(&pen, self.0);
|
||||
}
|
||||
}
|
||||
|
||||
struct Pen<'a> {
|
||||
p: &'a Painter,
|
||||
r: Rect,
|
||||
c: Color32,
|
||||
a: Color32,
|
||||
w: f32,
|
||||
/// Disabled: the fixed colours (a red bar, a green tick) go grey too, as an SVG's fixed layers do.
|
||||
d: bool,
|
||||
}
|
||||
|
||||
impl Pen<'_> {
|
||||
/// `colour`, or the disabled ink when the button is disabled.
|
||||
fn fixed(&self, colour: Color32) -> Color32 {
|
||||
if self.d { self.c } else { colour }
|
||||
}
|
||||
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 = pen.fixed(super::ART_RED);
|
||||
let green = pen.fixed(super::ART_GREEN);
|
||||
let orange = pen.fixed(super::ART_ORANGE);
|
||||
match name {
|
||||
"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)], pen.fixed(super::ART_PINK));
|
||||
}
|
||||
"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);
|
||||
let shadow = if pen.d { Color32::TRANSPARENT } else { super::ART_SHADOW };
|
||||
pen.text(10.5, 10.5, 15.0, "A", shadow, 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, d: false };
|
||||
for icon in ICONS {
|
||||
assert!(paint(&pen, icon.0), "{} has no drawing", icon.0);
|
||||
}
|
||||
assert!(!paint(&pen, "notAnIcon"));
|
||||
});
|
||||
out.textures_delta.clear();
|
||||
}
|
||||
|
||||
/// 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: every shape is then in that colour
|
||||
/// or invisible, with no accent and no fixed colour such as the font colour's red bar (production painted
|
||||
/// a disabled icon all grey). Enabled, the glyphs do use the accent.
|
||||
#[test]
|
||||
fn a_disabled_text_glyph_paints_only_the_disabled_ink() {
|
||||
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");
|
||||
// A shade of the disabled ink (a lighter "W" behind a letter) counts as that ink.
|
||||
let same_hue = |ink: Color32| {
|
||||
let (x, y) = (ink.to_opaque(), disabled.to_opaque());
|
||||
[x.r().abs_diff(y.r()), x.g().abs_diff(y.g()), x.b().abs_diff(y.b())].iter().all(|d| *d <= 2)
|
||||
};
|
||||
let stray: Vec<Color32> = inks(disabled).into_iter().filter(|ink| ink.a() > 0 && !same_hue(*ink)).collect();
|
||||
assert!(stray.is_empty(), "a disabled glyph painted in another colour: {stray:?}");
|
||||
}
|
||||
}
|
||||
@@ -489,7 +489,7 @@ fn show_replay(app: &mut WordApp, ui: &mut Ui, body: &PageBody) {
|
||||
}
|
||||
let playing = r.playing_from.is_some();
|
||||
let (icon, name) = if playing { ("replayPause", tl!("Pause")) } else { ("replayPlay", tl!("Play")) };
|
||||
if IconButton::new(crate::icons::id(icon)).label(name.to_string()).show(ui).clicks > 0 {
|
||||
if IconButton::new(crate::icons::spec(icon)).label(name.to_string()).show(ui).clicks > 0 {
|
||||
let here = r.at(now);
|
||||
if playing {
|
||||
r.pause_at(here);
|
||||
|
||||
@@ -553,13 +553,20 @@ fn move_input(app: &mut WordApp, mv: NavMove, m: MoveMods) {
|
||||
|
||||
fn edit_command(app: &mut WordApp, ctx: &egui::Context, cmd: EditCommand) {
|
||||
match cmd {
|
||||
// The chord runs only what the greyed button would (`command_enabled`): with nothing selected, and for Cut
|
||||
// also where protection or Markdown Source greys the button, it does nothing, silently, rather than put
|
||||
// "not available" on the status bar.
|
||||
EditCommand::Cut => {
|
||||
if let Ok(r) = app.run("edit.cut", json!({})) {
|
||||
if crate::app::command_board::command_enabled(app, "edit.cut")
|
||||
&& let Ok(r) = app.run("edit.cut", json!({}))
|
||||
{
|
||||
crate::system_clipboard::put_result(app, ctx, &r);
|
||||
}
|
||||
}
|
||||
EditCommand::Copy => {
|
||||
let _ = app.run("edit.copy", json!({}));
|
||||
if crate::app::command_board::command_enabled(app, "edit.copy") {
|
||||
let _ = app.run("edit.copy", json!({}));
|
||||
}
|
||||
}
|
||||
EditCommand::Paste => paste(app, ctx),
|
||||
EditCommand::SelectAll => {
|
||||
@@ -758,3 +765,22 @@ fn inserted_literal_at(app: &WordApp, text: &str, start: &wordcraft_doc::Pos) ->
|
||||
let Some(end) = start.off.checked_add(text.len()) else { return false };
|
||||
para.text.get(start.off..end) == Some(text)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// #7675: Cut and Copy with only a caret are silent (no "not available" status line) and change nothing.
|
||||
#[test]
|
||||
fn cut_and_copy_with_nothing_selected_stay_silent() {
|
||||
let mut app = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
|
||||
app.run("text.insert", json!({"text": "Kilns fire clay"})).unwrap();
|
||||
assert!(app.session.sel.is_collapsed());
|
||||
let ctx = egui::Context::default();
|
||||
for cmd in [EditCommand::Copy, EditCommand::Cut] {
|
||||
edit_command(&mut app, &ctx, cmd);
|
||||
assert!(app.status.is_none(), "{cmd:?}: nothing selected, nothing said");
|
||||
assert_eq!(app.session.doc.plain_text(wordcraft_doc::StoryRef::Body), "Kilns fire clay", "{cmd:?}: the text is untouched");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ pub(crate) fn members(app: &mut WordApp, ui: &mut Ui, preview: bool) {
|
||||
for (id, icon, tip) in
|
||||
[("format.growFont", "grow", tl!("Increase Font Size")), ("format.shrinkFont", "shrink", tl!("Decrease Font Size"))]
|
||||
{
|
||||
let b = Button::command(CommandRef::new(id)).icon(crate::icons::id(icon)).tooltip(tip.to_string()).show(ui);
|
||||
let b = Button::command(CommandRef::new(id)).icon(crate::icons::spec(icon)).tooltip(tip.to_string()).show(ui);
|
||||
preview_on_hover(app, b.hover, b.response.enabled(), id, json!({}), preview);
|
||||
}
|
||||
});
|
||||
@@ -289,7 +289,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,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,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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -114,7 +114,7 @@ pub(crate) fn show(app: &mut WordApp, ui: &mut Ui) {
|
||||
run = Some(("readAloud.previous", json!({})));
|
||||
}
|
||||
let (icon, tip) = if state == State::Playing { ("pause", tl!("Pause")) } else { ("play", tl!("Play")) };
|
||||
if IconButton::new(crate::icons::id(icon)).label(tip).tooltip(tip).show(ui).clicked() {
|
||||
if IconButton::new(crate::icons::spec(icon)).label(tip).tooltip(tip).show(ui).clicked() {
|
||||
run = Some(("readAloud.playPause", json!({})));
|
||||
}
|
||||
let next = IconButton::new(IconId::new("step_forward"))
|
||||
|
||||
@@ -150,11 +150,10 @@ pub fn show(app: &mut WordApp, ui: &mut Ui) -> RibbonOutput<String> {
|
||||
.checked(track),
|
||||
];
|
||||
let ends = [
|
||||
// The strip lays these out start to end, so Share, the old strip's outermost button, comes last. As the old
|
||||
// strip drew them: Comments and Editing outlined, Share a filled accent button.
|
||||
StripEnd::command(tl!("Comments").to_string(), IconSpec::svg(IconId::new("comment")), CommandRef::new("view.commentsPane"))
|
||||
.variant(Variant::SECONDARY),
|
||||
StripEnd::menu(editing_label.to_string(), IconSpec::svg(IconId::new("wordcraft.pencil")), &modes).variant(Variant::SECONDARY),
|
||||
// The strip lays these out start to end, so Share, the old strip's outermost button, comes last. Comments and
|
||||
// Editing are plain (ghost) buttons, as in v0.18.1; Share is a filled accent button.
|
||||
StripEnd::command(tl!("Comments").to_string(), IconSpec::svg(IconId::new("comment")), CommandRef::new("view.commentsPane")),
|
||||
StripEnd::menu(editing_label.to_string(), IconSpec::svg(IconId::new("wordcraft.pencil")), &modes),
|
||||
StripEnd::command(
|
||||
tl!("Share").to_string(),
|
||||
IconSpec::svg(IconId::new("share")),
|
||||
|
||||
@@ -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, _| {
|
||||
|
||||
@@ -8,7 +8,7 @@ use craft::ui::buttons::{Arrangement, Button, SplitButton, SplitMenu, ToggleButt
|
||||
use craft::ui::contract::{Gap, Props as _, Show as _, ShowContainer as _};
|
||||
use craft::ui::layout_components::Stack;
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::primitives::{IconMark, IconSpec};
|
||||
use craft::ui::primitives::IconMark;
|
||||
use craft::ui::style::DataColor;
|
||||
use wordcraft_doc::freeform::InkTool;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
@@ -169,7 +169,7 @@ fn gallery_pen(ui: &mut egui::Ui, i: usize, pen: wordcraft_engine::cmd::draw::Cu
|
||||
let tip = format!("{kind}: {size}, #{}", pen.color.hex());
|
||||
let response = ToggleButton::command(CommandRef::with_params(pen_command(pen.kind), json!({"color": pen.color.hex(), "width": pen.width})))
|
||||
.label(kind)
|
||||
.icon(IconSpec::from(crate::icons::id(glyph)).with_mark(IconMark::weighted_bar(DataColor::new(color), bar)))
|
||||
.icon(crate::icons::spec(glyph).with_mark(IconMark::weighted_bar(DataColor::new(color), bar)))
|
||||
.arrangement(Arrangement::Stacked)
|
||||
.tooltip(tip)
|
||||
.selected(active)
|
||||
|
||||
@@ -11,7 +11,6 @@ use craft::ui::contract::{
|
||||
};
|
||||
use craft::ui::list::{ThumbAspect, ThumbSize};
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::primitives::IconSpec;
|
||||
use craft::ui::primitives::textures::Revision;
|
||||
use craft::ui::runtime::commands::resolve;
|
||||
use craft::ui::runtime::env::Env;
|
||||
@@ -283,7 +282,7 @@ pub(crate) fn shapes(ui: &mut Ui, cx: &mut BodyCx<'_>, app: &mut WordApp) {
|
||||
.enabled(enabled)
|
||||
.show_items(ui, &Indexed(SHAPE_TILES.len()), &mut |at, _| {
|
||||
let (label, _, icon) = SHAPE_TILES.get(*at).copied().unwrap_or(("", "", "shape.rectangle"));
|
||||
Tile::new(crate::tl!(label)).icon(IconSpec::svg(crate::icons::id(icon)))
|
||||
Tile::new(crate::tl!(label)).icon(crate::icons::spec(icon))
|
||||
});
|
||||
if let Some((_, kind, _)) = picked(&out.response.events).and_then(|at| SHAPE_TILES.get(at))
|
||||
&& app.run("insert.shape", json!({"kind": kind})).is_ok()
|
||||
|
||||
@@ -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,
|
||||
@@ -166,7 +166,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);
|
||||
@@ -197,12 +197,12 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
|
||||
}
|
||||
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"),
|
||||
@@ -217,7 +217,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);
|
||||
@@ -227,7 +227,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
|
||||
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())
|
||||
@@ -237,7 +237,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);
|
||||
@@ -248,18 +248,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"));
|
||||
@@ -305,7 +305,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
|
||||
.show(ui);
|
||||
})),
|
||||
)
|
||||
.icon(IconId::new("numbering"))
|
||||
.icon(crate::icons::spec("numbering"))
|
||||
.selected(lists.numbering)
|
||||
.tooltip(tl!("Numbering").to_string())
|
||||
.show(ui);
|
||||
@@ -342,20 +342,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())
|
||||
@@ -371,7 +371,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())
|
||||
@@ -425,7 +425,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, _| {
|
||||
@@ -471,7 +471,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);
|
||||
@@ -492,7 +492,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);
|
||||
|
||||
@@ -10,7 +10,7 @@ use craft::ui::display::Divider;
|
||||
use craft::ui::layout_components::Stack;
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::primitives::{HAlign, IconSpec, TextRun};
|
||||
use craft::ui::primitives::{HAlign, TextRun};
|
||||
use craft::ui::tile_grid::{CaptionPlace, Tile, TileGrid};
|
||||
use egui::Ui;
|
||||
|
||||
@@ -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),
|
||||
@@ -263,18 +263,18 @@ pub(super) fn insert(row: &mut RibbonRow<'_>, app: &mut WordApp) {
|
||||
("dateTime", "Date & Time", "ui.dialog", json!({"name": "dateTime"})),
|
||||
("object", "Object", "insert.object", json!({})),
|
||||
] {
|
||||
IconButton::command(IconSpec::from(crate::icons::id(key)), CommandRef::with_params(id, params))
|
||||
IconButton::command(crate::icons::spec(key), CommandRef::with_params(id, params))
|
||||
.label(crate::tl!(tip))
|
||||
.tooltip(crate::tl!(tip))
|
||||
.show(ui);
|
||||
}
|
||||
});
|
||||
});
|
||||
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| {
|
||||
|
||||
@@ -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 +7,6 @@ use craft::ui::buttons::{Arrangement, Button, IconButton};
|
||||
use craft::ui::contract::{Bind, Gap, Props as _, Show as _, ShowContainer as _};
|
||||
use craft::ui::layout_components::{Row, Stack};
|
||||
use craft::ui::menu::MenuItem;
|
||||
use craft::ui::primitives::IconSpec;
|
||||
use craft::ui::text::NumberField;
|
||||
|
||||
pub(super) fn mailings(row: &mut RibbonRow<'_>, app: &mut WordApp) {
|
||||
@@ -15,7 +14,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 +69,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 +78,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 +86,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,20 +99,20 @@ 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, _| {
|
||||
Row::new().show(ui, |ui, _| {
|
||||
let nav = |ui: &mut egui::Ui, key: &'static str, tip: &'static str, id: &'static str| {
|
||||
IconButton::command(IconSpec::from(crate::icons::id(key)), CommandRef::with_params(id, json!({})))
|
||||
IconButton::command(crate::icons::spec(key), CommandRef::with_params(id, json!({})))
|
||||
.label(crate::tl!(tip))
|
||||
.tooltip(crate::tl!(tip))
|
||||
.show(ui);
|
||||
|
||||
@@ -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", ¤t)]);
|
||||
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");
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
use craft::behavior::{ColumnWidth, IconId};
|
||||
use craft::keymap::CommandRef;
|
||||
use craft::menu::ribbon::{RibbonGroup, RibbonRow};
|
||||
use craft::theme::ControlSize;
|
||||
use craft::ui::buttons::{Arrangement, Button, IconButton, ToggleButton};
|
||||
use craft::ui::choice::Checkbox;
|
||||
use craft::ui::contract::{Bind, Gap, Props as _, Show as _, ShowContainer as _};
|
||||
use craft::ui::display::Text;
|
||||
use craft::ui::layout::{GridFit, empty_cell};
|
||||
use craft::ui::layout_components::{Grid, Row, Stack};
|
||||
use craft::ui::menu::MenuItem;
|
||||
use craft::ui::style::TypeRole;
|
||||
use craft::ui::text::NumberField;
|
||||
|
||||
use super::common::menu_button;
|
||||
@@ -68,7 +71,7 @@ pub(super) fn table_design(row: &mut RibbonRow<'_>, app: &mut WordApp) {
|
||||
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
|
||||
let _ = menu_button(
|
||||
ui,
|
||||
Button::new(tl!("Styles").to_string()).icon(IconId::new("styles")),
|
||||
Button::new(tl!("Styles").to_string()).icon(crate::icons::spec("styles")),
|
||||
tl!("Styles").to_string(),
|
||||
Some("table.style"),
|
||||
|ui, _| {
|
||||
@@ -142,14 +145,20 @@ fn cell_size_boxes(ui: &mut Ui, app: &mut WordApp) {
|
||||
let w0 = laid.map(|x| x.w).or(stored_w).unwrap_or(0.0);
|
||||
let exact = row.height_rule == wordcraft_doc::props::HeightRule::Exact;
|
||||
let (height_units, width_units) = (crate::options::lengths(app.session.units()), crate::options::lengths(app.session.units()));
|
||||
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
|
||||
let out = NumberField::length(tl!("Height:").to_string(), Bind::given(Some(f64::from(h0))), height_units).range(CELL_SIZE_RANGE).show(ui);
|
||||
// As the old ribbon and Layout › Paragraph: a visible label beside each field, two decimals ("0.20").
|
||||
let caption = |label: &'static str| Text::new(tl!(label)).role(TypeRole::Caption);
|
||||
Grid::new(&[ColumnWidth::Content; 2]).gap(Gap::Tight).show(ui, |ui, _| {
|
||||
caption("Height:").show(ui);
|
||||
let field = NumberField::length(tl!("Height:").to_string(), Bind::given(Some(f64::from(h0))), height_units).range(CELL_SIZE_RANGE);
|
||||
let out = field.fixed_decimals(2).size(ControlSize::Sm).show(ui);
|
||||
apply_edits(app, out.edit.events, |app, v| {
|
||||
if let Some(h) = v {
|
||||
let _ = app.run("table.rowHeight", json!({"height": h, "rule": if exact { "exact" } else { "atLeast" }}));
|
||||
}
|
||||
});
|
||||
let out = NumberField::length(tl!("Width:").to_string(), Bind::given(Some(f64::from(w0))), width_units).range(CELL_SIZE_RANGE).show(ui);
|
||||
caption("Width:").show(ui);
|
||||
let field = NumberField::length(tl!("Width:").to_string(), Bind::given(Some(f64::from(w0))), width_units).range(CELL_SIZE_RANGE);
|
||||
let out = field.fixed_decimals(2).size(ControlSize::Sm).show(ui);
|
||||
apply_edits(app, out.edit.events, |app, v| {
|
||||
if let Some(w) = v {
|
||||
let _ = app.run("table.columnWidth", json!({"width": w}));
|
||||
@@ -270,7 +279,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"))
|
||||
@@ -279,10 +288,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, _| {
|
||||
@@ -291,7 +300,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);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -471,9 +471,8 @@ mod tests {
|
||||
a.run("caret.docEnd", json!({})).unwrap();
|
||||
assert!(a.session.sel.is_collapsed());
|
||||
|
||||
let ctx = a.ctx.clone().unwrap();
|
||||
let empty_r = a.run("edit.copy", json!({})).unwrap();
|
||||
put_result(&mut a, &ctx, &empty_r);
|
||||
// Copy is greyed with nothing selected (#7675), so the command is refused before it reaches the clipboard.
|
||||
assert!(a.run("edit.copy", json!({})).is_err(), "Copy with nothing selected is refused");
|
||||
|
||||
assert!(a.clipboard_published, "empty copy must not change published-copy state");
|
||||
let clip = handle(&a).unwrap();
|
||||
@@ -482,9 +481,7 @@ mod tests {
|
||||
|
||||
let mut a2 = app_holding(&[]);
|
||||
assert!(!a2.clipboard_published);
|
||||
let ctx2 = a2.ctx.clone().unwrap();
|
||||
let empty_r2 = a2.run("edit.copy", json!({})).unwrap();
|
||||
put_result(&mut a2, &ctx2, &empty_r2);
|
||||
assert!(a2.run("edit.copy", json!({})).is_err(), "Copy with nothing selected is refused");
|
||||
assert!(!a2.clipboard_published, "empty copy must not change published-copy state when false");
|
||||
}
|
||||
}
|
||||
@@ -3943,6 +3943,29 @@ fn shift_f10_opens_the_context_menu_at_the_caret() {
|
||||
assert_eq!(h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body), "Kilns fire");
|
||||
}
|
||||
|
||||
/// #7673: with nothing selected the text menu greys Cut and Copy, as production did; a selection enables them.
|
||||
#[test]
|
||||
fn the_context_menu_greys_cut_and_copy_without_a_selection() {
|
||||
use egui_kittest::kittest::{NodeT, Queryable};
|
||||
let row = |h: &Rig, name: &str| {
|
||||
let node = h.query_all_by_label(name).find(|node| node.accesskit_node().role() == egui::accesskit::Role::MenuItem);
|
||||
node.expect("the menu row").accesskit_node().is_disabled()
|
||||
};
|
||||
let mut h = harness(app());
|
||||
h.run_steps(4);
|
||||
h.event(egui::Event::Text("Kilns fire".into()));
|
||||
h.run_steps(2);
|
||||
h.state_mut().run("ui.contextMenu", json!({})).unwrap();
|
||||
h.run_steps(4);
|
||||
assert!(row(&h, "Cut") && row(&h, "Copy"), "nothing is selected");
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.run_steps(2);
|
||||
h.state_mut().run("select.all", json!({})).unwrap();
|
||||
h.state_mut().run("ui.contextMenu", json!({})).unwrap();
|
||||
h.run_steps(4);
|
||||
assert!(!row(&h, "Cut") && !row(&h, "Copy"), "the text is selected");
|
||||
}
|
||||
|
||||
/// A file dropped in the first two font-warm-up passes is taken before the early return;
|
||||
/// eframe does not preserve dropped files for a later frame.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
|
||||