Compare commits

..
Author SHA1 Message Date
Martin BallandClaude Opus 5.5 3dcef087dd fix(docx): a text box in a hyperlinked nested group survives an edit (repin regression)
craft-libs 6a46b44449 keeps a hyperlinked nested group as a nested
InlineObject::Group. WordCraft looks one level deep, so prune_text_boxes
dropped the nested box's story on the first edit. The bridge now lifts nested
members into the parent group, offsets composed, as the reader does for
unlinked groups.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FypgCWNarDG3QfXK2YMzdx
2026-11-29 02:42:58 +00:00
15 changed files with 24 additions and 343 deletions
+1 -9
View File
@@ -95,15 +95,7 @@
"unsigned_artifact_name": "nightly-unsigned-linux-x86_64",
"trust": {
"fingerprint": "2B76741B414AAD6CD33E631213A005C0B9D7C3ED"
},
"package_formats": [
"appimage",
"arch",
"deb",
"flatpak",
"oci",
"rpm"
]
}
},
"macos-aarch64": {
"unsigned_artifact_name": "nightly-unsigned-macos-aarch64",
-5
View File
@@ -506,11 +506,6 @@ pub struct ParaProps {
/// file (not laid out yet); Word sizes a line by it, so dropping it changes Word's pages.
#[serde(skip_serializing_if = "Option::is_none")]
pub text_alignment: Option<TextAlignment>,
/// A list item's paragraph after its first (or a list header's), with no number of its own,
/// at this list level (0..=8): formats with list items (ODT, HTML, Markdown) keep it in the
/// item. Set only directly, never by a style.
#[serde(skip_serializing_if = "Option::is_none")]
pub list_item: Option<u8>,
}
impl ParaProps {
-1
View File
@@ -229,7 +229,6 @@ fn every_para_prop_round_trips() {
fmt_change: None,
snap_to_grid: Some(false),
text_alignment: Some(TextAlignment::Top),
list_item: None, // not a DOCX property
};
let variants = [
ParaProps { line_spacing: Some(LineSpacing::AtLeast(14.0)), indent_first: Some(24.0), align: Some(Align::Center), ..Default::default() },
-1
View File
@@ -906,7 +906,6 @@ pub fn state(s: &Session) -> Value {
"italic": all.iter().all(shown_italic),
"underline": all.iter().all(|r| r.underline != Underline::None),
"underlineColor": same(&|r| json!(r.underline_color.map_or_else(|| "auto".to_string(), |c| c.hex()))),
"shading": same(&|r| json!(r.shading.map(|c| c.hex()))),
"strike": all.iter().all(|r| r.strike),
"border": all.iter().all(|r| r.border.is_some()),
"subscript": all.iter().all(|r| r.vert_align == VertAlign::Subscript),
+1 -1
View File
@@ -304,7 +304,7 @@ pub fn specs() -> Vec<CommandSpec> {
/// start, so all of a paragraph's text is still text, except in the last paragraph of its story,
/// cell or box, where it stands for the paragraph with its mark. A selected picture, shape or text
/// box is its object character, not text (a field's object character is).
pub fn shades_text(s: &Session) -> bool {
fn shades_text(s: &Session) -> bool {
let (a, b) = s.sel.ordered();
if a == b || a.story != b.story || a.path != b.path {
return false;
-13
View File
@@ -1258,16 +1258,3 @@ fn html_container_shading_is_paragraph_shading_while_inline_highlight_stays_on_r
assert_eq!(p2.runs.first().and_then(|r| r.props.shading), Some(wordcraft_doc::Rgb(0xff, 0xff, 0x00)), "{exported}");
}
}
#[test]
fn odt_list_item_later_paragraphs_stay_in_the_item() {
// "One" has two paragraphs. The second must stay inside item 1, so HTML's "Two" is item 2.
let fodt = r#"<?xml version="1.0" encoding="UTF-8"?>
<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"><office:automatic-styles><text:list-style style:name="L1"><text:list-level-style-number text:level="1" style:num-format="1"/></text:list-style></office:automatic-styles><office:body><office:text><text:list text:style-name="L1"><text:list-item><text:p>One</text:p><text:p>Still one</text:p></text:list-item><text:list-item><text:p>Two</text:p></text:list-item></text:list></office:text></office:body></office:document>"#;
let doc = crate::odt::import_flat(fodt.as_bytes()).unwrap();
let html = crate::html::export(&doc);
assert_eq!(html.matches("<ol").count(), 1, "one list, not restarted: {html}");
let (one, still, two) = (html.find("One").unwrap(), html.find("Still one").unwrap(), html.find("Two").unwrap());
assert!(one < still && still < two, "{html}");
assert!(html[one..still].matches("</li>").count() == 0, "later paragraph left item 1: {html}");
}
-11
View File
@@ -147,12 +147,6 @@ const LINKED_EDIT: [craft::ui::runtime::commands::EditCommands; 5] = {
[Cut, Copy, Paste, Undo, Redo]
};
/// The English parts of a registry `location` (`Home › Font`, split as `i18n::location` does); `None` for no place.
pub(crate) fn location_path(location: &str) -> Option<Vec<&str>> {
let path: Vec<&str> = location.split(" › ").filter(|part| !part.is_empty()).collect();
(!path.is_empty()).then_some(path)
}
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
@@ -189,11 +183,6 @@ impl WordApp {
// 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());
// Its ribbon place is its menu path, in English: Customize Keyboard files it under the tab by name,
// and the framework translates each segment where it shows it.
if let Some(path) = location_path(spec.location) {
def = def.with_path(path.into_iter().map(str::to_owned).collect());
}
for binding in default_bindings(spec.shortcut) {
def = def.with_default(binding);
}
+1 -19
View File
@@ -25,11 +25,7 @@ pub(crate) fn help_entries(app: &WordApp) -> Vec<HelpEntry> {
.map(|c| {
let command =
if c.id == "view.paperColor" { CommandRef::with_params("file.options", json!({"pane": "general"})) } else { CommandRef::new(c.id) };
let entry = HelpEntry::new(command, tl!(c.label).to_string()).with_english(c.label.to_string());
match crate::app::command_board::location_path(c.location) {
Some(path) => entry.with_path(path.into_iter().map(|part| tl!(part).to_string())),
None => entry,
}
HelpEntry::new(command, tl!(c.label).to_string()).with_english(c.label.to_string())
})
.collect()
}
@@ -85,17 +81,3 @@ pub(super) fn show(app: &mut WordApp, ui: &mut Ui, compact: bool) -> egui::Rect
}
rect
}
#[cfg(test)]
mod tests {
use crate::{Services, WordApp};
/// #7983: a search result names the ribbon place of its command.
#[test]
fn search_entries_show_the_ribbon_location() {
let app = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Services::default());
let entries = super::help_entries(&app);
let bold = entries.iter().find(|e| e.command().id == "format.bold").expect("format.bold is searchable");
assert!(!bold.path().is_empty(), "the entry has a path");
}
}
+8 -120
View File
@@ -241,67 +241,14 @@ pub fn apply(app: &mut WordApp, target: &Target, hex: &str) {
}
}
/// The colour every item has, `None` for no items, no colour, or items that differ.
fn agree(mut colors: impl Iterator<Item = Option<Rgb>>) -> Option<Rgb> {
let first = colors.next()??;
colors.all(|c| c == Some(first)).then_some(first)
}
/// The shading the given cells share; cells a ragged table lacks are skipped, not read as unshaded.
fn cell_shading(table: &wordcraft_doc::Table, cells: impl IntoIterator<Item = (usize, usize)>) -> Option<Rgb> {
agree(cells.into_iter().filter_map(|(r, c)| table.rows.get(r)?.cells.get(c).map(|cell| cell.props.shading)))
}
/// The colour a target has now (the dialog's Current swatch), read from what its command changes:
/// `para.shading` reads the selected text's shading when the selection is text within one paragraph,
/// else the paragraphs'; `shape.effects` reads shapes only. `None` when it has none, is Automatic,
/// differs across the selection, or cannot be read (a picture's icon colour is not stored).
/// The colour a target has now (the dialog's Current swatch).
fn current_of(app: &mut WordApp, target: &Target) -> Option<Rgb> {
use wordcraft_doc::InlineObject;
let Target::Run { cmd, .. } = target else { return None };
let s = &app.session;
let shapes = |o: &InlineObject| matches!(o, InlineObject::Shape { .. }) || o.is_canvas();
let objects = || wordcraft_engine::cmd::objects::target_objects(s, shapes).into_iter().map(|(_, o)| o);
match cmd.as_str() {
"format.color" | "format.underlineColor" => {
let st = wordcraft_engine::cmd::format::state(s);
let key = if cmd == "format.color" { "color" } else { "underlineColor" };
st.get(key).and_then(Value::as_str).and_then(parse)
"format.color" => {
let st = wordcraft_engine::cmd::format::state(&app.session);
st.get("color").and_then(Value::as_str).and_then(parse)
}
// The command shades the selected text, not its paragraph, when the selection is text within one.
"para.shading" if wordcraft_engine::cmd::para::shades_text(s) => {
wordcraft_engine::cmd::format::state(s).get("shading").and_then(Value::as_str).and_then(parse)
}
"para.shading" => agree(
wordcraft_engine::cmd::selected_paths(s)
.iter()
.map(|path| s.doc.para(s.sel.focus.story, path).and_then(|p| s.doc.styles.resolve_para(&p.props).shading)),
),
"table.shading" => {
let (tp, _, _) = s.sel.focus.path.cell()?;
let table = s.doc.table(s.sel.focus.story, &tp)?;
cell_shading(table, wordcraft_engine::cmd::table::selected_cells(s))
}
"design.pageColor" => s.doc.settings.page_color,
"shape.fill" => agree(objects().map(|o| {
let fill = match &o {
InlineObject::Shape { fill, .. } => fill.as_ref(),
o => o.canvas_style().and_then(|c| c.fill.as_ref()),
};
match fill {
Some(wordcraft_doc::fill::Fill::Solid { color, .. }) => Some(*color),
_ => None,
}
})),
"shape.outline" => agree(objects().map(|o| match &o {
InlineObject::Shape { stroke, .. } => *stroke,
o => o.canvas_style().and_then(|c| c.stroke),
})),
// Glow is applied to shapes only, so a canvas in the selection is not read.
"shape.effects" => agree(objects().filter(|o| matches!(o, InlineObject::Shape { .. })).map(|o| match &o {
InlineObject::Shape { effects, .. } => effects.glow.as_ref().map(|g| g.color),
_ => None,
})),
_ => None,
}
}
@@ -582,15 +529,14 @@ pub fn highlight_split(ui: &mut Ui, app: &mut WordApp, label: impl Into<Label>)
// More Colors…
/// The Colors dialog: Standard honeycomb and greys, Custom compact picker. `current` is the colour
/// the target has now, `None` when it has none: Current then shows no colour (as in v0.19.1) and
/// Restore does nothing, while New starts on black. `key` comes back in the result.
/// the target has now; `key` comes back in the result.
pub fn more_colors(current: Option<Rgb>, key: String, tab: ColorPickerTab) -> ColorPickerDialog {
let (cells, greys) = standard_cells();
let dialog = ColorPickerDialog::new(key, tl!("Colors").to_string(), current.map_or(Srgba::rgb(0.0, 0.0, 0.0), srgba))
ColorPickerDialog::new(key, tl!("Colors").to_string(), current.map_or(Srgba::rgb(0.0, 0.0, 0.0), srgba))
.layout(ColorPickerDialogLayout::Tabbed)
.standard(cells, greys)
.tab(tab);
if current.is_some() { dialog } else { dialog.no_current() }
.compare(current.is_some())
.tab(tab)
}
/// Opens the Colors dialog for `target`, remembering where its answer goes.
@@ -820,62 +766,4 @@ mod tests {
assert_eq!(app.ui.recent_colors.first().map(String::as_str), Some("7A3EC8"));
assert!(app.more_colors.is_empty(), "no entry outlives its dialog");
}
/// The Current swatch reads what the selection has, and says "no colour" where there is none or it
/// differs (#7984).
#[test]
fn current_reads_the_selection_and_is_none_when_unset_or_mixed() {
let c = |hex: u8| Rgb(hex, hex, hex);
assert_eq!(agree([Some(c(1)), Some(c(1))].into_iter()), Some(c(1)), "all alike");
assert_eq!(agree([Some(c(1)), Some(c(2))].into_iter()), None, "mixed");
assert_eq!(agree([Some(c(1)), None].into_iter()), None, "one has none");
assert_eq!(agree(std::iter::empty()), None, "nothing selected");
// Set on the caret's paragraph directly: the commands lay the page out, which costs ~0.7 s.
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
let shading = Target::cmd("para.shading");
assert_eq!(current_of(&mut app, &shading), None, "no shading yet");
assert_eq!(current_of(&mut app, &Target::cmd("table.shading")), None, "no table, no colour");
assert_eq!(current_of(&mut app, &Target::cmd("shape.fill")), None, "no shape selected");
let at = app.session.sel.focus.clone();
app.session.doc.para_mut(at.story, &at.path).unwrap().props.shading = Some(c(0xAA));
assert_eq!(current_of(&mut app, &shading), Some(c(0xAA)), "a collapsed caret reads its paragraph");
}
/// Text selected inside a paragraph is what Shading changes, so Current must not report the
/// paragraph's shading for it (#7984).
#[test]
fn partial_selection_reads_the_text_shading_not_the_paragraph() {
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::from_text("hello world")), crate::Services::default());
let at = app.session.sel.focus.clone();
app.session.doc.para_mut(at.story, &at.path).unwrap().props.shading = Some(Rgb(0xAA, 0xAA, 0xAA));
let mut end = at.clone();
end.off = 5;
app.session.sel = wordcraft_engine::Selection { anchor: at, focus: end };
let shading = Target::cmd("para.shading");
assert_eq!(current_of(&mut app, &shading), None, "the text has no shading, whatever its paragraph has");
let _ = app.session.run("format.shading", &json!({"color": "112233"}));
assert_eq!(current_of(&mut app, &shading), Some(Rgb(0x11, 0x22, 0x33)), "the selected run's shading");
}
/// A ragged table's missing cells do not blank Current when the real cells agree (#7984).
#[test]
fn table_shading_skips_missing_cells() {
let mut t = wordcraft_doc::Table::new(2, 2, 100.0);
t.rows[1].cells.pop();
for cell in t.rows.iter_mut().flat_map(|r| r.cells.iter_mut()) {
cell.props.shading = Some(Rgb(1, 2, 3));
}
let all = [(0, 0), (0, 1), (1, 0), (1, 1)];
assert_eq!(cell_shading(&t, all), Some(Rgb(1, 2, 3)), "the missing (1,1) is skipped");
t.rows[0].cells[1].props.shading = None;
assert_eq!(cell_shading(&t, all), None, "a real unshaded cell still blanks it");
}
/// A target with no colour opens with no Current colour, not black (#7984).
#[test]
fn no_current_colour_is_not_black() {
assert!(more_colors(None, "k".into(), ColorPickerTab::Standard).has_no_current());
assert!(!more_colors(Some(Rgb(0, 0, 0)), "k".into(), ColorPickerTab::Standard).has_no_current(), "a real black stays a current colour");
}
}
@@ -5,11 +5,10 @@
//! through `tools.customizeKeyboard`, so agents get the same result without the dialog.
use craft::keymap::{Binding, CommandDef, Keymap, Overrides};
use craft::menu::shortcuts::{Area, DialogState, Layout, Options, Outcome, ShortcutsDialog};
use craft::menu::shortcuts::{DialogState, Layout, Options, Outcome, ShortcutsDialog};
use craft::ui::dialog::{DialogId, DialogResult, DialogStack, FieldRefusal, StackDialog, dialog_id};
use egui::{Context, Ui};
use serde_json::{Value, json};
use wordcraft_engine::ribbon::{CONTEXTUAL_TABS, TABS};
use super::host::{DialogHooks, Settle, open_with};
use crate::WordApp;
@@ -50,61 +49,11 @@ fn assignable(binding: &Binding) -> bool {
chord.mods.cmd || chord.mods.ctrl || chord.mods.alt || chord.is_function_key()
}
/// The ribbon tab a command lives on, in English (the first part of its path).
fn tab(def: &CommandDef) -> &str {
def.paths.first().and_then(|path| path.first()).map_or("", String::as_str)
}
/// Tabs that come up with the selection or a view, besides the engine's contextual ones; they share one Categories entry.
const EXTRA_CONTEXT_TABS: [&str; 3] = ["Header & Footer", "Outlining", "Reading"];
fn in_tab<const N: usize>(def: &CommandDef) -> bool {
tab(def) == TABS[N]
}
fn in_context_tab(def: &CommandDef) -> bool {
CONTEXTUAL_TABS.contains(&tab(def)) || EXTRA_CONTEXT_TABS.contains(&tab(def))
}
fn in_no_tab(def: &CommandDef) -> bool {
!TABS.contains(&tab(def)) && !in_context_tab(def)
}
/// One filter per entry of `TABS` (the array's length makes the compiler check it).
const TAB_FILTERS: [fn(&CommandDef) -> bool; TABS.len()] = [
in_tab::<0>,
in_tab::<1>,
in_tab::<2>,
in_tab::<3>,
in_tab::<4>,
in_tab::<5>,
in_tab::<6>,
in_tab::<7>,
in_tab::<8>,
in_tab::<9>,
in_tab::<10>,
in_tab::<11>,
in_tab::<12>,
];
/// Categories as Word lists them: the ribbon tabs (not the framework's menu and panel ids), the contextual tabs, the
/// rest, then All Commands.
fn areas() -> Vec<Area> {
let mut areas: Vec<Area> = TABS.iter().copied().zip(TAB_FILTERS).map(|(name, rows)| Area::new(name, tl!(name), rows)).collect();
areas.push(Area::new("Contextual Tabs", tl!("Contextual Tabs"), in_context_tab));
areas.push(Area::new("Other", tl!("Other"), in_no_tab));
areas.push(Area::new("All Commands", tl!("All Commands"), |_| true));
areas
}
/// The framework dialog's options: the command-list layout, sorted by label, with the assign rule above.
fn options() -> Options {
Options::default().with(|o| {
o.layout = Layout::CommandLists;
o.sort_by_label = true;
o.own_areas = true;
o.size = Some(egui::vec2(720.0, 700.0));
o.areas = areas();
o.title = Some(tl!("Customize Keyboard").to_string());
o.accept = Some(Box::new(|_: &CommandDef, binding: &Binding| {
if assignable(binding) { Ok(()) } else { Err(tl!("Use a key combination with Ctrl, Alt or a function key.").to_string()) }
@@ -298,53 +247,4 @@ mod tests {
let unbound_labels = keys_list_labels(&h);
assert!(unbound_labels.iter().any(|t| t == "None"), "empty keys list says None: {unbound_labels:?}");
}
/// #7971: Categories are the ribbon tabs a command is on, not menu or panel ids; a command with no tab is under Other,
/// and every command is under All Commands.
#[test]
fn categories_are_ribbon_tabs() {
use craft::keymap::{CommandDef, Scope};
let on = |path: &[&str]| {
let mut def = CommandDef::new(CommandRef::new("x"), "X", Scope::app());
if !path.is_empty() {
def = def.with_path(path.iter().map(|part| part.to_string()).collect());
}
def
};
let areas = super::areas();
let listing = |def: &CommandDef| areas.iter().filter(|a| (a.rows)(def)).map(|a| a.id).collect::<Vec<_>>();
assert_eq!(listing(&on(&["Home", "Font"])), ["Home", "All Commands"]);
assert_eq!(listing(&on(&["Help", "Support"])), ["Help", "All Commands"], "every ribbon tab has its entry");
assert_eq!(listing(&on(&["Table Design", "Styles"])), ["Contextual Tabs", "All Commands"]);
assert_eq!(listing(&on(&[])), ["Other", "All Commands"]);
assert_eq!(areas.last().map(|a| a.id), Some("All Commands"), "All Commands comes last");
}
/// #7971: under another language, and for the SmartArt tab that shows as "Diagram Design", commands still land
/// under their tab (the catalog keeps English paths; only the display is translated).
#[test]
fn commands_stay_under_their_tab_in_another_language() {
let ctx = egui::Context::default();
crate::i18n::fixture_host(&ctx, "x-fixture", "\tHome\tHome-FX\n\tFont\tFont-FX\n\tDiagram Design\tDiagram-FX\n");
let mut a = app();
let catalog = a.catalog().expect("catalog");
let areas = super::areas();
let under = |id: &str, area: &str| {
let def = catalog.defs().iter().find(|def| def.command == CommandRef::new(id)).unwrap_or_else(|| panic!("{id} in catalog"));
areas.iter().any(|a| a.id == area && (a.rows)(def))
};
assert!(under("format.bold", "Home"), "Bold is under Home in a translated interface");
assert!(!under("format.bold", "Other"));
let smart = a.session.registry.all().iter().find(|spec| spec.location.starts_with("SmartArt Design")).expect("a SmartArt command");
assert!(under(smart.id, "Contextual Tabs") && !under(smart.id, "Other"), "{} is under the contextual tabs", smart.id);
}
/// #7971: the board's catalog files each engine command under its ribbon tab.
#[test]
fn catalog_paths_follow_the_ribbon_location() {
let mut a = app();
let catalog = a.catalog().expect("catalog");
let bold = catalog.defs().iter().find(|def| def.command == CommandRef::new("format.bold")).expect("format.bold");
assert_eq!(bold.paths.first().and_then(|p| p.first()).map(String::as_str), Some("Home"));
}
}
+3 -3
View File
@@ -6,7 +6,7 @@ use std::borrow::Cow;
use craft::behavior::{Mixed, SelectionChange, keyed};
use craft::color_ui::ui::ColorPickerTab;
use craft::pages::ui::table::{BorderEdges, EdgeKey, EdgeLook, EdgePicker, EdgeSize, SampleArea};
use craft::pages::ui::table::{BorderEdges, EdgeKey, EdgeLook, EdgePicker, SampleArea};
use craft::text::ui::DocUnit;
use craft::text::ui::ruler::{TabAlign as UiAlign, TabLeader as UiLeader, TabStop as UiStop};
use craft::text::ui::tabs_dialog::{MAX_STOPS, TabStopsDialog, TabStopsResult};
@@ -518,7 +518,7 @@ fn lines(ui: &mut Ui, key: &'static str, l: &mut LineForm, area: SampleArea, fil
Stack::new().show(ui, |ui, _| {
let mut edges = l.edges(between);
let sample = EdgeLook::sample(area, fill.map(srgba));
let picker = EdgePicker::new(word(tl!("Preview")), Bind::bound(&mut edges)).look(sample).preview(EdgeSize::Sample);
let picker = EdgePicker::new(word(tl!("Preview")), Bind::bound(&mut edges)).look(sample);
let picker = if between { picker.paragraph() } else { picker };
picker.show(ui);
l.take_edges(edges, between);
@@ -572,7 +572,7 @@ impl WordForm for BordersForm {
let mut none = BorderEdges::default();
let area = if self.fill_to_text { SampleArea::Text } else { SampleArea::Paragraph };
let sample = EdgeLook::sample(area, Rgb::parse(&self.fill).map(srgba));
EdgePicker::new(word(tl!("Preview")), Bind::bound(&mut none)).look(sample).preview(EdgeSize::Sample).enabled(false).show(ui);
EdgePicker::new(word(tl!("Preview")), Bind::bound(&mut none)).look(sample).enabled(false).show(ui);
Self::apply_to(ui, &mut self.fill_to_text, word(tl!("Paragraph")), word(tl!("Text")));
}
}
+8 -10
View File
@@ -20,7 +20,7 @@ use craft::ui::contract::{
};
use craft::ui::dialog::{Dialog, DialogId, DialogResult, DialogStack, FieldRefusal, PromptChoice, StackDialog, StandardPrompt, dialog_id};
use craft::ui::display::Text;
use craft::ui::layout_components::{Grid, Row, Stack};
use craft::ui::layout_components::{Row, Stack};
use craft::ui::list::{List, ListRow, ToggleCell, ToggleState};
use craft::ui::notices::Notice;
use craft::ui::runtime::env::Label;
@@ -52,8 +52,6 @@ pub struct TreeItem {
pub command: Option<String>,
}
/// The body's panes: the command pickers, the Add and Remove buttons, then the ribbon or toolbar list.
const PANES: [ColumnWidth; 3] = [ColumnWidth::fill(1.0), ColumnWidth::Content, ColumnWidth::fill(1.0)];
/// The column of show boxes in the ribbon tree.
const SHOWN: ColumnKey = ColumnKey::new("shown");
@@ -146,10 +144,10 @@ impl RibbonDialog {
fn body(&mut self, ui: &mut Ui) {
self.page_tabs(ui);
search(ui, &mut self.filter);
Grid::new(&PANES).fill_width().show(ui, |ui, _| {
Stack::new().fill_width().show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
Stack::new().show(ui, |ui, _| {
Text::new(word("Choose a command")).show(ui);
Row::new().fill_width().show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
if let Some(category) = pick(ui, "rb_categories", "Categories:", &self.categories, &self.category) {
self.category = category;
self.filter.clear();
@@ -222,9 +220,9 @@ impl RibbonDialog {
self.file("remove", Value::Object(address(&sel)));
}
});
Stack::new().fill_width().show(ui, |ui, _| {
Stack::new().show(ui, |ui, _| {
Text::new(word("Ribbon tabs")).show(ui);
Row::new().fill_width().show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
self.tree(ui);
Stack::new().show(ui, |ui, _| {
for (text, by) in [("Up", -1), ("Down", 1)] {
@@ -313,9 +311,9 @@ impl RibbonDialog {
self.file("qatRemove", json!(self.qat_selected));
}
});
Stack::new().fill_width().show(ui, |ui, _| {
Stack::new().show(ui, |ui, _| {
Text::new(word("Quick Access Toolbar")).show(ui);
Row::new().fill_width().show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
if let Some(id) = pick(ui, "rb_qat", "Quick Access Toolbar", &self.qat, &self.qat_selected) {
self.qat_selected = id;
}
-12
View File
@@ -2340,18 +2340,6 @@ fn dialog_previews_are_drawn_larger_than_a_control() {
);
}
}
/// #7977: Borders and Shading draws its edge preview at sample size, not as a thumbnail.
#[test]
fn borders_preview_is_larger_than_a_thumbnail() {
use egui::accesskit::Role;
let mut h = app_harness(app_with("Lanterns"));
h.state_mut().run("ui.dialog", json!({"name": "borders"})).unwrap();
h.run_steps(6);
let preview = h.get_by_role_and_label(Role::Group, "Preview").rect();
let button = h.get_by_role_and_label(Role::Button, "Cancel").rect();
assert!(preview.height() > 2.0 * button.height(), "the preview is {}pt high beside a {}pt button", preview.height(), button.height());
}
/// #7982: Custom Properties' hint wraps inside the dialog instead of running under the Cancel button.
#[test]
fn custom_properties_hint_does_not_run_under_the_buttons() {
+1 -4
View File
@@ -129,8 +129,6 @@ struct Strings {
numeral_id: String,
proofing_language: String,
autosave_reason: String,
/// The Initials box's placeholder: the initials an empty box falls back to (#8018).
initials_hint: String,
}
impl Strings {
@@ -201,7 +199,6 @@ impl Strings {
numeral_id,
proofing_language,
autosave_reason: crate::AutoSaveBlock::Browser.reason().to_string(),
initials_hint: app.session.user_initials(),
}
}
}
@@ -360,7 +357,7 @@ impl PreferencesModel for OptionsModel<'_> {
Some(tl!("Personalize")),
vec![
RowSpec::new("general.userName", tl!("User name:"), RowKind::Text(&app.session.author)).enabled(!protected),
RowSpec::new("general.initials", tl!("Initials:"), RowKind::Text(&app.session.initials)).placeholder(&s.initials_hint),
RowSpec::new("general.initials", tl!("Initials:"), RowKind::Text(&app.session.initials)),
],
),
],
-33
View File
@@ -539,36 +539,3 @@ fn folder_settings_have_apply_and_clear() {
}
let _ = std::fs::remove_dir_all(&dir);
}
/// #8018: an empty Initials box paints the initials it falls back to.
#[test]
fn empty_initials_box_paints_the_default_initials() {
fn painted(shapes: &[egui::epaint::ClippedShape], out: &mut Vec<String>) {
fn walk(shape: &egui::Shape, out: &mut Vec<String>) {
match shape {
egui::Shape::Text(t) => out.push(t.galley.text().to_string()),
egui::Shape::Vec(v) => v.iter().for_each(|c| walk(c, out)),
_ => {}
}
}
shapes.iter().for_each(|c| walk(&c.shape, out));
}
let shown = || {
let mut a = app();
a.session.author = "Zora Quentin".into();
a.run("ui.backstage", json!({"value": true, "page": "options", "pane": "general"})).unwrap();
let mut h = crate::test_harness::builder().build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
options_frames(&mut h, 3);
let mut texts = Vec::new();
painted(&h.output().shapes, &mut texts);
texts
};
assert!(shown().iter().any(|t| t == "ZQ"), "empty box paints the default initials");
}