UI: view-mode tooltips, SmartArt labels and TOC style names follow the interface language (#1272)

* UI: view-mode tooltips, SmartArt labels and TOC style names follow the interface language

Found while translating the interface:
- The status bar's Web/Print/Read view buttons showed their internal ids (`readMode`) as tooltips;
  they now show the translated names ("Web Layout", "Print Layout", "Read Mode").
- SmartArt layout tiles drew each label on one line, so long labels (and long translations) ran out
  of the 96 px tile. A label wider than the tile now breaks at the space nearest its middle; the tile
  is 96 px high to make room for the second line.
- Table of Contents › Options listed built-in styles (Normal, Title, Caption …) in English in every
  language; they now use the same display names as the Styles pane. The document keeps its names.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* TOC options: the style list's scroll bar takes its own room

A floating scroll bar was drawn over the level boxes and hid their right edge. The list now uses a
solid scroll bar, so the list is as wide as its widest label and level box plus the bar.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-10-14 18:58:07 -04:00
1 parent 2ffe707b03
commit f47cd975ae
2 files changed
+29 -11

No files matched your search

+6 -2
View File
@@ -820,14 +820,18 @@ fn toc_ui(app: &mut WordApp, ui: &mut Ui, f: &mut TocForm) -> Next {
if ok || cancel { Next::Close } else { Next::Stay }
}
fn toc_options_ui(_app: &mut WordApp, ui: &mut Ui, f: &mut TocForm, was: &TocForm) -> Next {
fn toc_options_ui(app: &mut WordApp, ui: &mut Ui, f: &mut TocForm, was: &TocForm) -> Next {
heading(ui, "Collect entries from:");
ui.checkbox(&mut f.heading_styles, crate::i18n::fmt(tl!("Heading styles (levels 1–{n})"), &[("n", &f.levels.to_string())]));
ui.label(tl!("Other styles and their TOC level:"));
// A solid scroll bar takes its own room beside the list instead of floating over the level boxes.
ui.spacing_mut().scroll = egui::style::ScrollStyle::solid();
egui::ScrollArea::vertical().max_height(180.0).show(ui, |ui| {
egui::Grid::new("toc_styles").num_columns(2).spacing(vec2(10.0, 3.0)).show(ui, |ui| {
for (name, level) in f.style_levels.iter_mut() {
ui.label(name.as_str());
// Built-in styles read in the interface language; the document keeps the English name.
let shown = app.session.doc.styles.styles.iter().find(|st| st.name == *name).map_or_else(|| name.clone(), crate::i18n::style_name);
ui.label(shown);
ui.add(egui::DragValue::new(level).range(0..=9).custom_formatter(|v, _| if v < 0.5 { String::new() } else { format!("{v:.0}") }));
ui.end_row();
}
+23 -9
View File
@@ -176,7 +176,7 @@ pub fn picker_ui(app: &mut WordApp, ui: &mut Ui, f: &mut SmartArtForm) -> bool {
ui.set_min_height(2.0 * 96.0 + 8.0);
egui::Grid::new("smart_art_layouts").spacing(vec2(8.0, 8.0)).show(ui, |ui| {
for (k, layout) in f.shown().into_iter().enumerate() {
let (rect, resp) = ui.allocate_exact_size(vec2(96.0, 88.0), Sense::click());
let (rect, resp) = ui.allocate_exact_size(vec2(96.0, 96.0), Sense::click());
let on = f.layout == layout;
let fill = if on {
t.checked
@@ -194,14 +194,28 @@ pub fn picker_ui(app: &mut WordApp, ui: &mut Ui, f: &mut SmartArtForm) -> bool {
&theme,
t.text_dim,
);
ui.painter().text(
pos2(rect.center().x, rect.bottom() - 11.0),
egui::Align2::CENTER_CENTER,
tl!(layout.label()),
regular(10.5),
t.text,
);
let resp = resp.on_hover_text(tl!(layout.label()));
// A label wider than the tile (a long translation) breaks at its middle space.
let label = tl!(layout.label());
let width = |text: &str| ui.ctx().fonts_mut(|f| f.layout_no_wrap(text.to_string(), regular(10.5), t.text).size().x);
let lines = if width(label) <= rect.width() - 6.0 {
vec![label.to_string()]
} else {
let split = label
.match_indices(' ')
.map(|(i, _)| (label[..i].to_string(), label[i + 1..].to_string()))
.min_by(|a, b| width(&a.0).max(width(&a.1)).total_cmp(&width(&b.0).max(width(&b.1))));
split.map_or_else(|| vec![label.to_string()], |(a, b)| vec![a, b])
};
for (n, line) in lines.iter().rev().enumerate() {
ui.painter().text(
pos2(rect.center().x, rect.bottom() - 11.0 - 12.5 * n as f32),
egui::Align2::CENTER_CENTER,
line,
regular(10.5),
t.text,
);
}
let resp = resp.on_hover_text(label);
if resp.clicked() {
f.layout = layout;
}