DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge feat/style-sections-cjk: CJK sections in Paragraph and Character Style Options
aiongg65a6a0ba7e67
diff --cc crates/engine/src/cmd/style.rsindex f7ec64f1c,6c44357ca..9b603165b--- a/crates/engine/src/cmd/style.rs+++ b/crates/engine/src/cmd/style.rs@@@ -95,7 -95,7 +95,7 @@@ pub fn specs() -> Vec<CommandSpec>"Paragraph Style Options…",[],None,- "{name, rename?, basedOn?, nextStyle?, para?: {… ruleAbove?/ruleBelow?: only the named rule fields change; startAt?: null = continue numbering}, chars?: {…}}",- "{name, rename?, basedOn?, nextStyle?, para?: {… ruleAbove?/ruleBelow?: only the named rule fields change, kinsoku?: set | null (default rules)}, chars?: {…}}",++ "{name, rename?, basedOn?, nextStyle?, para?: {… ruleAbove?/ruleBelow?: only the named rule fields change; startAt?: null = continue numbering; kinsoku?: set | null (default rules)}, chars?: {…}}",has_doc,edit_para),@@@ -426,20 -425,10 +426,21 @@@ fn apply_char(s: &mut Session, p: &Valu})}+/// In a style, `startAt: null` is Continue from Previous Number: it is stored as an explicit+/// "continue" so it also overrides a Start At the style would inherit.+fn continue_numbering(p: Option<&Value>, para: &mut ParaAttrs) {+ let explicit =+ p.and_then(Value::as_object).is_some_and(|o| o.iter().any(|(k, v)| v.is_null() && k.replace('_', "").eq_ignore_ascii_case("startAt")));+ if explicit {+ para.start_at = Some(None);+ }+}+fn create_para(s: &mut Session, p: &Value) -> Result<Value> {let base = str_param(p, "name").unwrap_or("Paragraph Style 1").to_string();- let mut para: ParaAttrs = attrs(p.get("para"), |a: &mut ParaAttrs, k, v| a.set_json(k, v))?;+ let mut para: ParaAttrs = attrs(p.get("para"), |a: &mut ParaAttrs, k, v| a.set_json_over(k, v, &designcraft_doc::ParaProps::default()))?;+ continue_numbering(p.get("para"), &mut para);+ explicit_default_kinsoku(&mut para, p.get("para"));let mut chars: CharAttrs = attrs(p.get("chars"), |a: &mut CharAttrs, k, v| a.set_json(k, v))?;if p.get("fromSelection").and_then(Value::as_bool).unwrap_or(false)&& let Ok(cur) = s.execute("type.selectionAttrs", &json!({}))@@@ -493,7 -490,7 +502,8 @@@ fn edit_para(s: &mut Session, p: &Value// A rule object changes only the rule fields it names, over the style's resolved rule.let (current, _) = d.styles.resolve_para_style(&name);let mut para: ParaAttrs = attrs(p.get("para"), |a: &mut ParaAttrs, k, v| a.set_json_over(k, v, ¤t))?;+ continue_numbering(p.get("para"), &mut para);+ explicit_default_kinsoku(&mut para, p.get("para"));let st = d.styles_mut().para_mut(&name).ok_or_else(|| bad("style.paragraph.edit", format!("no style `{name}`")))?;st.para.merge(¶);st.chars.merge(&chars);@@@ -1198,24 -1128,22 +1208,40 @@@ mod color_testsassert!(s.doc().unwrap().doc.styles.char_style("[None]").unwrap().chars.is_empty());}+ #[test]+ fn continue_numbering_in_a_style_overrides_an_inherited_start_at() {+ let mut s = Session::new();+ s.execute("file.new", &json!({})).unwrap();+ s.execute("style.paragraph.create", &json!({"name": "Steps", "para": {"listType": "numbers", "startAt": 5}})).unwrap();+ s.execute("style.paragraph.create", &json!({"name": "More Steps", "basedOn": "Steps"})).unwrap();+ let start = |s: &Session, name: &str| s.doc().unwrap().doc.styles.resolve_para_style(name).0.start_at;+ assert_eq!(start(&s, "More Steps"), Some(5), "inherited");+ s.execute("style.paragraph.edit", &json!({"name": "More Steps", "para": {"startAt": null}})).unwrap();+ assert_eq!(s.doc().unwrap().doc.styles.para("More Steps").unwrap().para.start_at, Some(None));+ assert_eq!(start(&s, "More Steps"), None, "continues");+ assert_eq!(start(&s, "Steps"), Some(5), "the parent keeps its Start At");+ s.execute("style.paragraph.edit", &json!({"name": "Steps", "para": {"startAt": null}})).unwrap();+ assert_eq!(start(&s, "Steps"), None);+ s.execute("style.paragraph.create", &json!({"name": "Fresh", "basedOn": "More Steps", "para": {"start_at": null}})).unwrap();+ assert_eq!(s.doc().unwrap().doc.styles.para("Fresh").unwrap().para.start_at, Some(None));+ }++ #[test]+ fn null_kinsoku_sets_the_default_rules_over_a_based_on_set() {+ let mut s = Session::new();+ s.execute("file.new", &json!({})).unwrap();+ let hard = serde_json::to_value(designcraft_doc::cjk::Kinsoku::named("HardKinsoku").unwrap()).unwrap();+ s.execute("style.paragraph.create", &json!({"name": "Base", "para": {"kinsoku": hard}})).unwrap();+ s.execute("style.paragraph.create", &json!({"name": "Body", "basedOn": "Base", "para": {"kinsoku": hard}})).unwrap();+ s.execute("style.paragraph.edit", &json!({"name": "Body", "para": {"kinsoku": null}})).unwrap();+ let styles = s.doc().unwrap().doc.styles.clone();+ assert_eq!(styles.para("Body").unwrap().para.kinsoku, Some(None));+ assert_eq!(styles.resolve_para_style("Body").0.kinsoku, None, "Base's set no longer applies");+ // An edit without the attribute keeps it.+ s.execute("style.paragraph.edit", &json!({"name": "Body", "para": {"rensuuji": false}})).unwrap();+ assert_eq!(s.doc().unwrap().doc.styles.para("Body").unwrap().para.kinsoku, Some(None));+ }+#[test]fn new_character_style_checks_its_based_on() {let mut s = Session::new();diff --cc crates/ui-egui/src/dialogs.rsindex 74b65673a,ddbced490..3c4af97fb--- a/crates/ui-egui/src/dialogs.rs+++ b/crates/ui-egui/src/dialogs.rs@@@ -2694,20 -2609,9 +2697,23 @@@ fn paragraph_style_options(app: &mut De});}"color" => character_color(&app.ui.language, ui, d, &CharFields { base: &cv, sparse: false }, &doc),+ "advanced" => advanced_character_formats(&app.ui.language, ui, d, &CharFields { base: &cv, sparse: false }),+ "openType" => open_type_features(&app.ui.language, ui, d, &CharFields { base: &cv, sparse: false }),+ "underline" => line_options(&app.ui.language, ui, d, &CharFields { base: &cv, sparse: false }, &doc, "underline"),+ "strikethrough" => line_options(&app.ui.language, ui, d, &CharFields { base: &cv, sparse: false }, &doc, "strikethrough"),+ "border" => border_shading(&app.ui.language, ui, d, &pv, &doc, true),+ "shading" => border_shading(&app.ui.language, ui, d, &pv, &doc, false),+ "keep" => keep_options(&app.ui.language, ui, d, &pv),+ "span" => span_columns(&app.ui.language, ui, d, &pv, &doc),+ "bullets" => {+ let (char_styles, families, fonts, scope) = ListUi::new_parts(app);+ let lu =+ ListUi { char_styles: &char_styles, families: &families, fonts: &fonts, scope, family: &cp.font_family, style: &cp.font_style };+ bullets_and_numbering(&app.ui.language, ui, d, &pv, &doc, &lu);+ }+ s if style_cjk::is_section(s) => {+ style_cjk::section(&app.ui.language, ui, d, s, &CharFields { base: &cv, sparse: false }, Some(&pv), &doc)+ }_ => {egui::Grid::new("psg").num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Style Name:"));@@@ -2928,797 -2888,11 +2934,803 @@@ fn para_choice(lang: &str, ui: &mut egu});}-/// An attribute's name as Style Settings shows it: the field's label where the name reads poorly.-fn setting_label(lang: &str, key: &str) -> String {- match key {- "hScale" => crate::i18n::tr(lang, "Horizontal Scale:").trim_end_matches([':', ':']).to_string(),- "vScale" => crate::i18n::tr(lang, "Vertical Scale:").trim_end_matches([':', ':']).to_string(),+/// Four per-side values in the order the attribute holds them: top, left, bottom, right. An+/// edited side stores the whole array.+fn para_sides(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, key: &str, field: &dyn Fn(&mut egui::Ui, &str, Option<f64>) -> Option<f64>) {+ let mut sides: [f64; 4] = serde_json::from_value(para_value(d, pv, key)).unwrap_or_default();+ let mut changed = false;+ egui::Grid::new(("pssides", key)).num_columns(4).spacing([8.0, 6.0]).show(ui, |ui| {+ for (i, label) in ["Top:", "Left:", "Bottom:", "Right:"].into_iter().enumerate() {+ crate::rtl::label(ui, crate::i18n::tr(lang, label));+ if let Some(side) = sides.get_mut(i)+ && let Some(v) = field(ui, &format!("ps{key}{i}"), Some(*side))+ {+ *side = v;+ changed = true;+ }+ if i % 2 == 1 {+ ui.end_row();+ }+ }+ });+ if changed {+ para_set(d, key, json!(sides));+ }+}++/// A swatch menu with a colour chip per swatch (hidden swatches left out); returns the swatch+/// picked.+fn swatch_menu(ui: &mut egui::Ui, doc: &designcraft_doc::Document, id: impl egui::AsIdSalt, current: &str, width: f32) -> Option<String> {+ let mut picked = None;+ egui::ComboBox::from_id_salt(id).selected_text(current).width(width).show_ui(ui, |ui| {+ for w in doc.swatches.iter().filter(|w| !w.hidden) {+ let (c, g) = crate::widgets::swatch_colors(doc, &w.name, 1.0);+ ui.horizontal(|ui| {+ let (r, _) = ui.allocate_exact_size(egui::vec2(12.0, 12.0), egui::Sense::hover());+ crate::widgets::paint_chip(ui.painter(), r, c, g);+ if ui.selectable_label(w.name == current, &w.name).clicked() {+ picked = Some(w.name.clone());+ }+ });+ }+ });+ picked+}++/// Built-in stroke types of the paragraph border's Type menu (serialized `StrokeType`s).+const BORDER_TYPES: [&str; 11] =+ ["solid", "dashed", "dotted", "thickThin", "thinThick", "thinThin", "thickThick", "thinThickThin", "thickThinThick", "wavy", "hashed"];++/// The border's stroke type: a built-in type or one of the document's stroke styles.+fn border_type_menu(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, doc: &designcraft_doc::Document) {+ use designcraft_doc::StrokeType;+ let cur: StrokeType = serde_json::from_value(para_value(d, pv, "borderType")).unwrap_or_default();+ let shown = match &cur {+ StrokeType::Style { name } => name.clone(),+ k => crate::i18n::tr(lang, k.label()).to_string(),+ };+ egui::ComboBox::from_id_salt("psbordertype").selected_text(crate::rtl::widget(ui, shown)).width(160.0).show_ui(ui, |ui| {+ for k in BORDER_TYPES {+ let ty = if k == "dashed" { json!({"kind": k, "pattern": []}) } else { json!({"kind": k}) };+ let Ok(t) = serde_json::from_value::<StrokeType>(ty.clone()) else { continue };+ let on = std::mem::discriminant(&t) == std::mem::discriminant(&cur);+ if ui.selectable_label(on, crate::rtl::widget(ui, crate::i18n::tr(lang, t.label()))).clicked() && !on {+ para_set(d, "borderType", ty);+ }+ }+ for st in &doc.stroke_styles {+ let on = matches!(&cur, StrokeType::Style { name } if *name == st.name);+ if ui.selectable_label(on, &st.name).clicked() {+ para_set(d, "borderType", json!({"kind": "style", "name": st.name}));+ }+ }+ });+}++/// Corner size and shape of a border or shading (`key` holds top left, top right, bottom right,+/// bottom left); an edited corner stores all four.+fn para_corners(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, key: &str, units: Unit) {+ use designcraft_geom::corners::{Corner, CornerShape};+ let mut corners: [Corner; 4] = serde_json::from_value(para_value(d, pv, key)).unwrap_or_default();+ let mut changed = false;+ egui::Grid::new(("pscorners", key)).num_columns(3).spacing([8.0, 6.0]).show(ui, |ui| {+ for (i, label) in ["Top Left:", "Top Right:", "Bottom Right:", "Bottom Left:"].into_iter().enumerate() {+ let Some(c) = corners.get_mut(i) else { continue };+ crate::rtl::label(ui, crate::i18n::tr(lang, label));+ if let Some(v) = crate::widgets::measure(ui, &format!("ps{key}{i}"), Some(c.size), units, 70.0) {+ c.size = if v.is_finite() { v.clamp(0.0, 10_000.0) } else { 0.0 };+ changed = true;+ }+ egui::ComboBox::from_id_salt(("pscornershape", key, i))+ .selected_text(crate::rtl::widget(ui, crate::i18n::tr(lang, c.shape.label())))+ .width(130.0)+ .show_ui(ui, |ui| {+ for shape in CornerShape::ALL {+ if ui.selectable_label(c.shape == shape, crate::rtl::widget(ui, crate::i18n::tr(lang, shape.label()))).clicked() {+ c.shape = shape;+ changed = true;+ }+ }+ });+ ui.end_row();+ }+ });+ if changed {+ para_set(d, key, serde_json::to_value(corners).unwrap_or_default());+ }+}++/// The colour and tint rows of a border, its gap or shading (`keys`: colour, tint), in a grid.+fn para_color_tint(+ ui: &mut egui::Ui,+ d: &mut Dialog,+ pv: &Value,+ doc: &designcraft_doc::Document,+ keys: (&str, &str),+ labels: (&str, &str),+ enabled: bool,+) {+ let (color_key, tint_key) = keys;+ crate::rtl::label(ui, labels.0);+ let color = para_value(d, pv, color_key).as_str().unwrap_or("").to_string();+ if let Some(w) = ui.add_enabled_ui(enabled, |ui| swatch_menu(ui, doc, ("pscolor", color_key), &color, 160.0)).inner {+ para_set(d, color_key, json!(w));+ }+ ui.end_row();+ crate::rtl::label(ui, labels.1);+ let tint = para_value(d, pv, tint_key).as_f64().map(|t| t * 100.0);+ if let Some(v) = ui.add_enabled_ui(enabled, |ui| crate::widgets::number(ui, &format!("ps{tint_key}"), tint, "%", 60.0, 0)).inner {+ para_set(d, tint_key, json!(if v.is_finite() { (v / 100.0).clamp(0.0, 1.0) } else { 1.0 }));+ }+ ui.end_row();+}++/// Paragraph Style Options › Paragraph Border / Paragraph Shading (and the Paragraph Borders and+/// Shading dialog): on or off, the stroke (border) or colour (shading), corners, offsets, the+/// edges and width the box follows, and the options for split and consecutive paragraphs.+fn border_shading(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, doc: &designcraft_doc::Document, border: bool) {+ let key = |field: &str| format!("{}{field}", if border { "border" } else { "shading" });+ let on_key = key("On");+ para_check(ui, d, pv, &on_key, crate::i18n::tr(lang, if border { "Border" } else { "Shading" }));+ let on = para_value(d, pv, &on_key).as_bool().unwrap_or(false);+ let units = doc.settings.horizontal_units;+ let head = |ui: &mut egui::Ui, t: &str| {+ ui.add_space(4.0);+ crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(lang, t)).font(semibold(12.0)));+ };+ ui.add_space(4.0);+ egui::ScrollArea::vertical().id_salt(("psbsscroll", border)).max_height(330.0).show(ui, |ui| {+ ui.add_enabled_ui(on, |ui| {+ if border {+ head(ui, "Stroke");+ para_sides(lang, ui, d, pv, &key("Weights"), &|ui: &mut egui::Ui, id: &str, v: Option<f64>| {+ crate::widgets::number(ui, id, v, " pt", 60.0, 2).map(|w| if w.is_finite() { w.clamp(0.0, 1000.0) } else { 0.0 })+ });+ ui.add_space(4.0);+ } else {+ head(ui, "Color");+ }+ egui::Grid::new(("psbs", border)).num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {+ if border {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Type:"));+ border_type_menu(lang, ui, d, pv, doc);+ ui.end_row();+ }+ let (color, tint) = (crate::i18n::tr(lang, "Color:"), crate::i18n::tr(lang, "Tint:"));+ para_color_tint(ui, d, pv, doc, (&key("Color"), &key("Tint")), (color, tint), true);+ if border {+ // The gap colour shows between the dashes, dots or stripes.+ let solid = para_value(d, pv, "borderType").get("kind").and_then(Value::as_str).is_none_or(|k| k == "solid");+ let (gap, gap_tint) = (crate::i18n::tr(lang, "Gap Color:"), crate::i18n::tr(lang, "Gap Tint:"));+ para_color_tint(ui, d, pv, doc, ("borderGapColor", "borderGapTint"), (gap, gap_tint), !solid);+ crate::rtl::label(ui, crate::i18n::tr(lang, "Cap:"));+ para_choice(lang, ui, d, pv, "borderCap", &[("butt", "Butt"), ("round", "Round"), ("projecting", "Projecting")]);+ ui.end_row();+ crate::rtl::label(ui, crate::i18n::tr(lang, "Join:"));+ para_choice(lang, ui, d, pv, "borderJoin", &[("miter", "Miter"), ("round", "Round"), ("bevel", "Bevel")]);+ ui.end_row();+ }+ });+ head(ui, "Corner Size and Shape");+ para_corners(lang, ui, d, pv, &key("Corners"), units);+ head(ui, "Offsets");+ para_sides(lang, ui, d, pv, &key("Offsets"), &|ui: &mut egui::Ui, id: &str, v: Option<f64>| {+ crate::widgets::measure(ui, id, v, units, 60.0)+ });+ ui.add_space(4.0);+ egui::Grid::new(("psbsedges", border)).num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Top Edge:"));+ para_choice(+ lang,+ ui,+ d,+ pv,+ &key("Top"),+ &[("ascent", "Ascent"), ("baseline", "Baseline"), ("emBox", "Em Box Top"), ("leading", "Leading")],+ );+ ui.end_row();+ crate::rtl::label(ui, crate::i18n::tr(lang, "Bottom Edge:"));+ para_choice(lang, ui, d, pv, &key("Bottom"), &[("descent", "Descent"), ("baseline", "Baseline"), ("emBox", "Em Box Bottom")]);+ ui.end_row();+ crate::rtl::label(ui, crate::i18n::tr(lang, "Width:"));+ para_choice(lang, ui, d, pv, &key("Width"), &[("column", "Column"), ("text", "Text")]);+ ui.end_row();+ });+ ui.add_space(4.0);+ if border {+ para_check(ui, d, pv, "borderDisplayIfSplits", crate::i18n::tr(lang, "Display Border if Paragraph Splits Across Frames/Columns"));+ para_check(ui, d, pv, "borderMerge", crate::i18n::tr(lang, "Merge Consecutive Borders and Shading"));+ } else {+ para_check(ui, d, pv, "shadingClip", crate::i18n::tr(lang, "Clip to Frame"));+ para_check(ui, d, pv, "shadingNonprinting", crate::i18n::tr(lang, "Do not Print or Export"));+ }+ });+ });+}++/// Paragraph Style Options › Keep Options: lines kept with the next paragraph, the paragraph's+/// lines kept together (all of them, or its first and last lines), and where it starts.+fn keep_options(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value) {+ ui.horizontal(|ui| {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Keep with Next:"));+ para_count(ui, d, pv, "keepWithNext", (0, 5));+ crate::rtl::label(ui, crate::i18n::tr(lang, "lines"));+ });+ ui.add_space(4.0);+ para_check(ui, d, pv, "keepLinesTogether", crate::i18n::tr(lang, "Keep Lines Together"));+ let together = para_value(d, pv, "keepLinesTogether").as_bool().unwrap_or(false);+ ui.add_enabled_ui(together, |ui| {+ ui.indent("pskeepall", |ui| {+ let all = para_value(d, pv, "keepAllLines").as_bool().unwrap_or(true);+ if ui.radio(all, crate::rtl::widget(ui, crate::i18n::tr(lang, "All Lines in Paragraph"))).clicked() {+ para_set(d, "keepAllLines", json!(true));+ }+ if ui.radio(!all, crate::rtl::widget(ui, crate::i18n::tr(lang, "At Start/End of Paragraph"))).clicked() {+ para_set(d, "keepAllLines", json!(false));+ }+ ui.add_enabled_ui(!all, |ui| {+ egui::Grid::new("pskeepends").num_columns(3).spacing([8.0, 6.0]).show(ui, |ui| {+ for (label, key) in [("Start:", "keepFirst"), ("End:", "keepLast")] {+ crate::rtl::label(ui, crate::i18n::tr(lang, label));+ para_count(ui, d, pv, key, (1, 50));+ crate::rtl::label(ui, crate::i18n::tr(lang, "lines"));+ ui.end_row();+ }+ });+ });+ });+ });+ ui.add_space(6.0);+ ui.horizontal(|ui| {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Start Paragraph:"));+ para_choice(+ lang,+ ui,+ d,+ pv,+ "startParagraph",+ &[+ ("anywhere", "Anywhere"),+ ("nextColumn", "In Next Column"),+ ("nextFrame", "In Next Frame"),+ ("nextPage", "On Next Page"),+ ("nextOddPage", "On Next Odd Page"),+ ("nextEvenPage", "On Next Even Page"),+ ],+ );+ });+}++/// Paragraph Style Options › Span Columns (and the Span Columns dialog): one column, spanning+/// columns (0 = all), or split into sub-columns with inside and outside gutters; the least space+/// before and after a spanning or split paragraph.+fn span_columns(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, doc: &designcraft_doc::Document) {+ use designcraft_doc::SpanColumns;+ let cur: SpanColumns = serde_json::from_value(para_value(d, pv, "spanColumns")).unwrap_or_default();+ let same = |a: &SpanColumns, b: &SpanColumns| std::mem::discriminant(a) == std::mem::discriminant(b);+ let units = doc.settings.horizontal_units;+ let mut next = None;+ egui::Grid::new("psspan").num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Paragraph Layout:"));+ let kinds = [("Single Column", SpanColumns::Single), ("Span Columns", SpanColumns::Span(0)), ("Split Column", SpanColumns::Split(2))];+ // "Span Columns" names both the section and this option, which some languages word differently.+ let kind_label = |k: &'static str| -> &'static str { crate::i18n::tr_context(lang, k, "paragraphLayout") };+ let shown = kinds.iter().find(|k| same(&k.1, &cur)).map_or("", |k| kind_label(k.0));+ egui::ComboBox::from_id_salt("psspankind").selected_text(crate::rtl::widget(ui, shown)).width(200.0).show_ui(ui, |ui| {+ for (label, v) in kinds {+ if ui.selectable_label(same(&v, &cur), crate::rtl::widget(ui, kind_label(label))).clicked() && !same(&v, &cur) {+ next = Some(v);+ }+ }+ });+ ui.end_row();+ match cur {+ SpanColumns::Single => {}+ SpanColumns::Span(n) => {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Columns:"));+ let shown = if n == 0 { crate::i18n::tr(lang, "All").to_string() } else { n.to_string() };+ egui::ComboBox::from_id_salt("psspann").selected_text(crate::rtl::widget(ui, shown)).width(80.0).show_ui(ui, |ui| {+ if ui.selectable_label(n == 0, crate::rtl::widget(ui, crate::i18n::tr(lang, "All"))).clicked() {+ next = Some(SpanColumns::Span(0));+ }+ for c in 2..=20u32 {+ if ui.selectable_label(n == c, c.to_string()).clicked() {+ next = Some(SpanColumns::Span(c));+ }+ }+ });+ ui.end_row();+ }+ SpanColumns::Split(n) => {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Columns:"));+ if let Some(c) = crate::widgets::number(ui, "pssplitn", Some(f64::from(n)), "", 50.0, 0) {+ next = Some(SpanColumns::Split(if c.is_finite() { c.round().clamp(2.0, 20.0) as u32 } else { 2 }));+ }+ ui.end_row();+ }+ }+ let v_units = doc.settings.vertical_units;+ let spaces = match cur {+ SpanColumns::Single => None,+ SpanColumns::Span(_) => Some(("Space Before Span:", "Space After Span:")),+ SpanColumns::Split(_) => Some(("Space Before Split:", "Space After Split:")),+ };+ if let Some((before, after)) = spaces {+ for (label, key) in [(before, "spanSpaceBefore"), (after, "spanSpaceAfter")] {+ crate::rtl::label(ui, crate::i18n::tr(lang, label));+ para_measure(ui, d, pv, key, v_units);+ ui.end_row();+ }+ }+ if matches!(cur, SpanColumns::Split(_)) {+ for (label, key) in [("Inside Gutter:", "splitInsideGutter"), ("Outside Gutter:", "splitOutsideGutter")] {+ crate::rtl::label(ui, crate::i18n::tr(lang, label));+ para_measure(ui, d, pv, key, units);+ ui.end_row();+ }+ }+ });+ if let Some(v) = next {+ para_set(d, "spanColumns", serde_json::to_value(v).unwrap_or_default());+ }+}++/// Number styles as the list's Format menu shows them (`NumberStyle` values).+const NUMBER_STYLES: [(&str, &str); 9] = [+ ("arabic", "1, 2, 3, 4..."),+ ("upperRoman", "I, II, III, IV..."),+ ("lowerRoman", "i, ii, iii, iv..."),+ ("upperLetters", "A, B, C, D..."),+ ("lowerLetters", "a, b, c, d..."),+ ("arabicLeadingZero", "01, 02, 03..."),+ ("arabicThreeDigits", "001, 002, 003..."),+ ("arabicFourDigits", "0001, 0002, 0003..."),+ ("symbols", "*, †, ‡, §..."),+];++/// A list label text (Text After, Number), shown with its tab as `^t`; labels expand+/// metacharacters, so the typed text is stored as it is.+fn list_text(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, label: &str, key: &str) {+ crate::rtl::label(ui, crate::i18n::tr(lang, label));+ let mut s = para_value(d, pv, key).as_str().unwrap_or("").replace('\t', "^t");+ if ui.add(egui::TextEdit::singleline(&mut s).desired_width(160.0)).changed() {+ para_set(d, key, json!(s));+ }+ ui.end_row();+}++/// What the Bullets and Numbering section offers besides the paragraph's attributes: the+/// document's character styles, the font families for the bullet, the fonts, and the paragraph's+/// font (the bullet's when it has none of its own).+struct ListUi<'a> {+ char_styles: &'a [String],+ families: &'a [String],+ fonts: &'a designcraft_fonts::ScopedFonts<'static>,+ scope: u32,+ family: &'a str,+ style: &'a str,+}++impl ListUi<'_> {+ fn new_parts(app: &DesignApp) -> (Vec<String>, Vec<String>, designcraft_fonts::ScopedFonts<'static>, u32) {+ let styles = app.session.active().map(|s| s.doc.styles.character.iter().map(|c| c.name.clone()).collect()).unwrap_or_default();+ let families = crate::panels::font_menu(app).into_iter().map(|f| f.family).collect();+ (styles, families, crate::panels::fonts(app), crate::panels::font_scope(app))+ }+}++/// A character style for a bullet or number (`key`), [None] first.+fn list_char_style(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, key: &str, styles: &[String]) {+ let cur = para_value(d, pv, key).as_str().unwrap_or(designcraft_doc::NO_CHAR_STYLE).to_string();+ egui::ComboBox::from_id_salt(("pslistcs", key)).selected_text(crate::rtl::widget(ui, crate::i18n::style_name(lang, &cur))).width(200.0).show_ui(+ ui,+ |ui| {+ for n in std::iter::once(designcraft_doc::NO_CHAR_STYLE)+ .chain(styles.iter().map(String::as_str).filter(|n| *n != designcraft_doc::NO_CHAR_STYLE))+ {+ if ui.selectable_label(n == cur, crate::rtl::widget(ui, crate::i18n::style_name(lang, n))).clicked() {+ para_set(d, key, json!(n));+ }+ }+ },+ );+}++/// The bullet character: common bullets, a field, and the font's glyphs in a grid to pick from.+fn bullet_char(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, lu: &ListUi<'_>) {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Bullet Character:"));+ ui.horizontal(|ui| {+ let cur = para_value(d, pv, "bulletChar").as_str().unwrap_or("").to_string();+ for b in ["\u{2022}", "\u{2013}", "\u{2014}", "\u{00BB}", "*"] {+ if ui.add_sized([24.0, 20.0], egui::Button::selectable(cur == b, b)).clicked() {+ para_set(d, "bulletChar", json!(b));+ }+ }+ let mut s = cur;+ if ui.add(egui::TextEdit::singleline(&mut s).desired_width(36.0)).changed() {+ para_set(d, "bulletChar", json!(s));+ }+ let open = d.b("bulletGlyphs");+ if ui.selectable_label(open, crate::rtl::widget(ui, crate::i18n::tr(lang, "Glyphs…"))).clicked() {+ d.fields.insert("bulletGlyphs".into(), json!(!open));+ }+ });+ ui.end_row();+ if d.b("bulletGlyphs") {+ ui.label("");+ ui.vertical(|ui| {+ ui.set_width(300.0);+ let font = para_value(d, pv, "bulletFont").as_str().unwrap_or("").to_string();+ let (family, style) = if font.is_empty() {+ (lu.family.to_string(), lu.style.to_string())+ } else {+ let st = para_value(d, pv, "bulletFontStyle").as_str().unwrap_or("").to_string();+ let st = if st.is_empty() { lu.fonts.styles(&font).into_iter().next().unwrap_or_else(|| "Regular".into()) } else { st };+ (font, st)+ };+ let mut q = d.s("bulletGlyphQuery");+ if ui+ .add(+ egui::TextEdit::singleline(&mut q)+ .hint_text(crate::rtl::widget(ui, crate::i18n::tr(lang, "Search: character or U+code")))+ .desired_width(300.0),+ )+ .changed()+ {+ d.fields.insert("bulletGlyphQuery".into(), json!(q));+ }+ if let (Some(c), _) = crate::panels::glyphs::grid(ui, lu.fonts, lu.scope, &family, &style, &q, 160.0) {+ para_set(d, "bulletChar", json!(c.to_string()));+ }+ });+ ui.end_row();+ }+}++/// The bullet's font family and style ("" = the paragraph's).+fn bullet_font(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, lu: &ListUi<'_>) {+ let font = para_value(d, pv, "bulletFont").as_str().unwrap_or("").to_string();+ let inherit = crate::i18n::tr(lang, "(Paragraph Font)");+ crate::rtl::label(ui, crate::i18n::tr(lang, "Font Family:"));+ egui::ComboBox::from_id_salt("psbulletfont").selected_text(if font.is_empty() { inherit } else { font.as_str() }).width(200.0).show_ui(+ ui,+ |ui| {+ if ui.selectable_label(font.is_empty(), inherit).clicked() {+ para_set(d, "bulletFont", json!(""));+ para_set(d, "bulletFontStyle", json!(""));+ }+ for f in lu.families {+ if ui.selectable_label(*f == font, f).clicked() {+ para_set(d, "bulletFont", json!(f));+ para_set(d, "bulletFontStyle", json!(lu.fonts.styles(f).into_iter().next().unwrap_or_default()));+ }+ }+ },+ );+ ui.end_row();+ crate::rtl::label(ui, crate::i18n::tr(lang, "Font Style:"));+ let style = para_value(d, pv, "bulletFontStyle").as_str().unwrap_or("").to_string();+ ui.add_enabled_ui(!font.is_empty(), |ui| {+ egui::ComboBox::from_id_salt("psbulletstyle").selected_text(style.as_str()).width(200.0).show_ui(ui, |ui| {+ for st in lu.fonts.styles(&font) {+ if ui.selectable_label(st == style, &st).clicked() {+ para_set(d, "bulletFontStyle", json!(st));+ }+ }+ });+ });+ ui.end_row();+}++/// Paragraph Style Options › Bullets and Numbering (and the Bullets and Numbering dialog): the+/// list type and level; the bullet, its font and the text after it, or the list, number style,+/// number text and where numbering starts and restarts; the label's character style; then where+/// the label goes (alignment, indents and the tab position of the text after it).+fn bullets_and_numbering(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, doc: &designcraft_doc::Document, lu: &ListUi<'_>) {+ let units = doc.settings.horizontal_units;+ let kind = para_value(d, pv, "listType").as_str().unwrap_or("none").to_string();+ let level = para_value(d, pv, "listLevel").as_u64().unwrap_or(1).clamp(1, designcraft_doc::LIST_LEVELS as u64) as u32;+ egui::ScrollArea::vertical().id_salt("psbnscroll").max_height(340.0).show(ui, |ui| {+ egui::Grid::new("psbn").num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {+ crate::rtl::label(ui, crate::i18n::tr(lang, "List Type:"));+ para_choice(lang, ui, d, pv, "listType", &[("none", "None"), ("bullets", "Bullets"), ("numbers", "Numbers")]);+ ui.end_row();+ if kind != "none" {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Level:"));+ para_count(ui, d, pv, "listLevel", (1, designcraft_doc::LIST_LEVELS as u32));+ ui.end_row();+ }+ match kind.as_str() {+ "bullets" => {+ bullet_char(lang, ui, d, pv, lu);+ bullet_font(lang, ui, d, pv, lu);+ list_text(lang, ui, d, pv, "Text After:", "listSeparator");+ crate::rtl::label(ui, crate::i18n::tr(lang, "Character Style:"));+ list_char_style(lang, ui, d, pv, "bulletCharStyle", lu.char_styles);+ ui.end_row();+ }+ "numbers" => {+ crate::rtl::label(ui, crate::i18n::tr(lang, "List:"));+ let list = para_value(d, pv, "listName").as_str().unwrap_or("").to_string();+ // "" is the story's own list.+ let name = |n: &str| if n.is_empty() { crate::i18n::tr(lang, "[Default]").to_string() } else { n.to_string() };+ egui::ComboBox::from_id_salt("pslist").selected_text(name(&list)).width(200.0).show_ui(ui, |ui| {+ for n in std::iter::once("").chain(doc.settings.lists.iter().map(|l| l.name.as_str())) {+ if ui.selectable_label(n == list, name(n)).clicked() {+ para_set(d, "listName", json!(n));+ }+ }+ });+ ui.end_row();+ crate::rtl::label(ui, crate::i18n::tr(lang, "Format:"));+ para_choice(lang, ui, d, pv, "numberStyle", &NUMBER_STYLES);+ ui.end_row();+ list_text(lang, ui, d, pv, "Number:", "numberExpression");+ crate::rtl::label(ui, crate::i18n::tr(lang, "Character Style:"));+ list_char_style(lang, ui, d, pv, "numberCharStyle", lu.char_styles);+ ui.end_row();+ crate::rtl::label(ui, crate::i18n::tr(lang, "Mode:"));+ let start = para_value(d, pv, "startAt").as_u64();+ ui.horizontal(|ui| {+ let shown = crate::i18n::tr(lang, if start.is_some() { "Start At" } else { "Continue from Previous Number" });+ egui::ComboBox::from_id_salt("psmode").selected_text(crate::rtl::widget(ui, shown)).width(200.0).show_ui(ui, |ui| {+ if ui+ .selectable_label(start.is_none(), crate::rtl::widget(ui, crate::i18n::tr(lang, "Continue from Previous Number")))+ .clicked()+ {+ para_set(d, "startAt", Value::Null);+ }+ if ui.selectable_label(start.is_some(), crate::rtl::widget(ui, crate::i18n::tr(lang, "Start At"))).clicked()+ && start.is_none()+ {+ para_set(d, "startAt", json!(1));+ }+ });+ if let Some(n) = start+ && let Some(v) = crate::widgets::number(ui, "psstartat", Some(n as f64), "", 60.0, 0)+ {+ para_set(d, "startAt", json!(if v.is_finite() { v.round().clamp(0.0, 1_000_000.0) as u32 } else { 1 }));+ }+ });+ ui.end_row();+ // Restart Numbers at This Level After: a higher level (any, or one of them).+ ui.label("");+ ui.add_enabled_ui(level > 1, |ui| {+ ui.horizontal(|ui| {+ para_check(ui, d, pv, "restartNumbers", crate::i18n::tr(lang, "Restart Numbers at This Level After:"));+ let after = para_value(d, pv, "restartAfterLevel").as_u64().unwrap_or(0) as u32;+ let label = |n: u32| if n == 0 { crate::i18n::tr(lang, "Any Previous Level").to_string() } else { n.to_string() };+ egui::ComboBox::from_id_salt("psrestartafter").selected_text(crate::rtl::widget(ui, label(after))).width(140.0).show_ui(+ ui,+ |ui| {+ for n in 0..level {+ if ui.selectable_label(n == after, crate::rtl::widget(ui, label(n))).clicked() {+ para_set(d, "restartAfterLevel", json!(n));+ }+ }+ },+ );+ });+ });+ ui.end_row();+ }+ _ => {}+ }+ if kind != "none" {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Alignment:"));+ let key = if kind == "bullets" { "bulletAlign" } else { "numberAlign" };+ para_choice(lang, ui, d, pv, key, &[("left", "Left"), ("center", "Center"), ("right", "Right")]);+ ui.end_row();+ for (label, key) in [("Left Indent:", "leftIndent"), ("First Line Indent:", "firstLineIndent")] {+ crate::rtl::label(ui, crate::i18n::tr(lang, label));+ para_measure(ui, d, pv, key, units);+ ui.end_row();+ }+ // Tab Position: none, or a stop for the text after the label.+ crate::rtl::label(ui, crate::i18n::tr(lang, "Tab Position:"));+ ui.horizontal(|ui| {+ let tab = para_value(d, pv, "listTab").as_f64();+ let mut on = tab.is_some();+ if ui.checkbox(&mut on, "").changed() {+ let left = para_value(d, pv, "leftIndent").as_f64().filter(|v| v.is_finite() && *v > 0.0).unwrap_or(18.0);+ para_set(d, "listTab", if on { json!(left) } else { Value::Null });+ }+ if let Some(t) = tab+ && let Some(v) = crate::widgets::measure(ui, "pslisttab", Some(t), units, 80.0)+ {+ para_set(d, "listTab", json!(if v.is_finite() { v.max(0.0) } else { 0.0 }));+ }+ });+ ui.end_row();+ }+ });+ });+}++/// Paragraph Borders and Shading, Span Columns, and Bullets and Numbering for the selected+/// paragraphs: the Paragraph Style Options sections over the paragraphs' attributes (`current`);+/// OK applies the edits (`p.<key>`) as local formatting.+fn paragraph_local(app: &mut DesignApp, ui: &mut egui::Ui, d: &mut Dialog) {+ let Some(doc) = app.session.active().map(|s| s.doc.clone()) else { return };+ let pv = d.fields.get("current").cloned().unwrap_or_default();+ let lang = app.ui.language.clone();+ ui.set_min_width(480.0);+ match d.s("section").as_str() {+ "span" => span_columns(&lang, ui, d, &pv, &doc),+ "bullets" => {+ let (char_styles, families, fonts, scope) = ListUi::new_parts(app);+ let (family, style) = (d.s("family"), d.s("style"));+ let lu = ListUi { char_styles: &char_styles, families: &families, fonts: &fonts, scope, family: &family, style: &style };+ bullets_and_numbering(&lang, ui, d, &pv, &doc, &lu);+ }+ section => {+ let border = section != "shading";+ ui.horizontal(|ui| {+ for (tab, label) in [("border", "Border"), ("shading", "Shading")] {+ if ui.selectable_label(section == tab, crate::rtl::widget(ui, crate::i18n::tr(&lang, label))).clicked() {+ d.fields.insert("section".into(), json!(tab));+ }+ }+ });+ ui.separator();+ border_shading(&lang, ui, d, &pv, &doc, border);+ }+ }+}+- fn section_list(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, sections: &[(&str, &str)]) {++fn section_list(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, cjk: bool, sections: &[(&str, &str)]) {++ let sections = style_cjk::sections(cjk, d.id == "paragraphStyleOptions", sections);+ ui.vertical(|ui| {+ ui.set_width(170.0);- for (id, label) in sections {- if ui.selectable_label(d.s("section") == *id, crate::rtl::widget(ui, crate::i18n::tr(lang, label))).clicked() {- d.fields.insert("section".into(), json!(id));++ // The dialog has a fixed height; a long list scrolls.++ egui::ScrollArea::vertical().id_salt("style_sections").auto_shrink([false, true]).show(ui, |ui| {++ for (id, label) in §ions {++ if ui.selectable_label(d.s("section") == *id, crate::rtl::widget(ui, crate::i18n::tr(lang, label))).clicked() {++ d.fields.insert("section".into(), json!(id));++ }+ }- }++ });+ });+}++/// "Paragraph Style n" / "Character Style n": the first name no style has.+fn next_style_name(styles: &designcraft_doc::Styles, para: bool) -> String {+ let (base, count) = if para { ("Paragraph Style", styles.paragraph.len()) } else { ("Character Style", styles.character.len()) };+ let taken = |n: &str| if para { styles.para(n).is_some() } else { styles.char_style(n).is_some() };+ // Among count + 1 numbers at least one is free.+ (1..=count + 1).map(|i| format!("{base} {i}")).find(|n| !taken(n)).unwrap_or_else(|| format!("{base} {}", count + 1))+}++/// Paragraph or Character Style Options for an existing style (a double-click on it in the styles+/// panel, or Edit in its menu). [None] and [No Paragraph Style] have no options.+pub fn open_style_options(app: &mut DesignApp, para: bool, name: &str) {+ if name == if para { designcraft_doc::NO_PARA_STYLE } else { designcraft_doc::NO_CHAR_STYLE } {+ return;+ }+ let id = if para { "paragraphStyleOptions" } else { "characterStyleOptions" };+ app.ui.dialog = Some(Dialog::new(id, json!({"name": name})));+}++/// New Paragraph Style… / New Character Style…: the style options for a style made on OK, named+/// with the next free "Paragraph Style n" / "Character Style n".+pub fn open_new_style(app: &mut DesignApp, para: bool) {+ let Some(st) = app.session.active() else { return };+ let name = next_style_name(&st.doc.styles, para);+ let id = if para { "paragraphStyleOptions" } else { "characterStyleOptions" };+ app.ui.dialog = Some(Dialog::new(id, json!({"new": true, "rename": name})));+}++/// Character Style Options: General, then the character sections it shares with Paragraph Style+/// Options. A character style sets only some attributes: the fields show those it and its Based+/// On set and leave the rest blank. Edits are `c.<attr>` fields (`null` = no longer set), applied+/// on OK; `new` makes the style instead of editing `name`.+fn character_style_options(app: &mut DesignApp, ui: &mut egui::Ui, d: &mut Dialog) {+ let name = d.s("name");+ let new = d.b("new");+ let Some(doc) = app.session.active().map(|st| st.doc.clone()) else { return };+ let styles = &doc.styles;+ let style = match styles.char_style(&name) {+ _ if new => designcraft_doc::CharacterStyle { name: String::new(), based_on: None, chars: Default::default(), shortcut: String::new() },+ Some(s) if name != designcraft_doc::NO_CHAR_STYLE => s.clone(),+ _ => {+ crate::rtl::label(ui, format!("No style named {name}"));+ return;+ }+ };+ if !d.fields.contains_key("rename") {+ d.fields.insert("rename".into(), json!(if new { next_style_name(styles, false) } else { name.clone() }));+ }+ let based = d+ .fields+ .get("basedOn")+ .and_then(Value::as_str)+ .map(str::to_string)+ .or(style.based_on.clone())+ .unwrap_or_else(|| designcraft_doc::NO_CHAR_STYLE.into());+ // The fields show the style's own attributes over those its Based On gives it.+ let mut shown = styles.char_style_attrs(&based);+ shown.merge(&style.chars);+ let base = serde_json::to_value(&shown).unwrap_or_default();+ let cf = CharFields { base: &base, sparse: true };+ let lang = app.ui.language.clone();+ ui.set_min_width(560.0);+ ui.horizontal_top(|ui| {+ // A fixed height: the separator would otherwise stretch the dialog to the window.+ ui.set_min_height(380.0);+ ui.set_max_height(380.0);+ section_list(+ &lang,+ ui,+ d,++ crate::cjk_features(app),+ &[+ ("general", "General"),+ ("chars", "Basic Character Formats"),+ ("advanced", "Advanced Character Formats"),+ ("color", "Character Color"),+ ("openType", "OpenType Features"),+ ("underline", "Underline Options"),+ ("strikethrough", "Strikethrough Options"),+ ],+ );+ ui.separator();+ ui.vertical(|ui| match d.s("section").as_str() {+ "chars" => basic_character_formats(app, ui, d, &cf),+ "advanced" => advanced_character_formats(&lang, ui, d, &cf),+ "color" => character_color(&lang, ui, d, &cf, &doc),+ "openType" => open_type_features(&lang, ui, d, &cf),+ "underline" => line_options(&lang, ui, d, &cf, &doc, "underline"),+ "strikethrough" => line_options(&lang, ui, d, &cf, &doc, "strikethrough"),++ s if style_cjk::is_section(s) => style_cjk::section(&lang, ui, d, s, &cf, None, &doc),+ _ => {+ egui::Grid::new("csg").num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {+ crate::rtl::label(ui, crate::i18n::tr(&lang, "Style Name:"));+ text_field(ui, d, "rename", 220.0);+ ui.end_row();+ crate::rtl::label(ui, crate::i18n::tr(&lang, "Based On:"));+ egui::ComboBox::from_id_salt("csbased")+ .selected_text(crate::rtl::widget(ui, crate::i18n::style_name(&lang, &based)))+ .width(220.0)+ .show_ui(ui, |ui| {+ // Not itself, nor a style based on it.+ for s in styles.character.iter().filter(|s| new || !styles.char_based_on_cycles(&name, &s.name)) {+ if ui.selectable_label(s.name == based, crate::rtl::widget(ui, crate::i18n::style_name(&lang, &s.name))).clicked() {+ d.fields.insert("basedOn".into(), json!(s.name));+ }+ }+ });+ ui.end_row();+ });+ let status = d.s("status");+ if !status.is_empty() {+ crate::rtl::label(ui, egui::RichText::new(status).color(crate::theme::Tokens::get(ui.ctx()).text_strong));+ }+ ui.add_space(8.0);+ crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(&lang, "Style Settings:")).font(semibold(12.0)));+ // What OK would leave the style setting, after its Based On.+ let mut own = serde_json::to_value(&style.chars).unwrap_or_default();+ if let Some(o) = own.as_object_mut() {+ for (k, v) in d.fields.iter().filter_map(|(k, v)| Some((k.strip_prefix("c.")?, v))) {+ if v.is_null() {+ o.remove(k);+ } else {+ o.insert(k.to_string(), v.clone());+ }+ }+ }+ let mut parts = vec![crate::i18n::style_name(&lang, &based).to_string()];+ parts.extend(own.as_object().into_iter().flatten().map(|(k, v)| format!("{}: {}", setting_label(&lang, k), setting_text(v))));+ ui.add(egui::Label::new(egui::RichText::new(parts.join(" + ")).color(crate::theme::Tokens::get(ui.ctx()).text_dim)).wrap());+ }+ });+ });+}++/// An attribute's name as Style Settings shows it: the field's label where the name reads poorly.+fn setting_label(lang: &str, key: &str) -> String {+ match key {+ "hScale" => crate::i18n::tr(lang, "Horizontal Scale:").trim_end_matches([':', ':']).to_string(),+ "vScale" => crate::i18n::tr(lang, "Vertical Scale:").trim_end_matches([':', ':']).to_string(),"capitalization" => crate::i18n::tr(lang, "Case:").trim_end_matches([':', ':']).to_string(),"otfFeatures" => crate::i18n::tr(lang, "OpenType Features").to_string(),_ => crate::i18n::tr(lang, &humanize(key)).to_string(),diff --cc crates/ui-egui/src/i18n.rsindex c1afd8610,ed7c4f047..ec31be7a6--- a/crates/ui-egui/src/i18n.rs+++ b/crates/ui-egui/src/i18n.rs@@@ -90,6 -89,104 +90,103 @@@ const TABLE: &[(&str, [&str; 5])] = &("Ruby…", ["Ruby …", "Ruby…", "Ruby…", "ルビ…", "旁注…"]),("Kenten", ["Kenten", "Kenten", "Kenten", "圏点", "圈点"]),("Warichu", ["Warichu", "Warichu", "Warichu", "割り注", "割注"]),+ // Style Options: CJK sections.+ ("Tate-chu-yoko Settings", ["Tate-Chu-Yoko-Einstellungen", "Paramètres Tate-Chu-Yoko", "Ajustes de Tate-Chu-Yoko", "縦中横設定", "纵中横设置"]),+ ("Kenten Settings", ["Kenten-Einstellungen", "Paramètres Kenten", "Ajustes de Kenten", "圏点設定", "圈点设置"]),+ (+ "Japanese Composition Settings",+ ["Japanischer Satz", "Paramètres de composition japonaise", "Ajustes de composición japonesa", "日本語文字組版", "日文排版设置"],+ ),+ ("Grid Settings", ["Rastereinstellungen", "Paramètres de grille", "Ajustes de cuadrícula", "グリッド設定", "网格设置"]),+ ("Warichu Settings", ["Warichu-Einstellungen", "Paramètres Warichu", "Ajustes de Warichu", "割注設定", "割注设置"]),+ ("Up/Down Position:", ["Position oben/unten:", "Position haut/bas:", "Posición arriba/abajo:", "上下位置:", "上下位置:"]),+ ("Left/Right Position:", ["Position links/rechts:", "Position gauche/droite:", "Posición izquierda/derecha:", "左右位置:", "左右位置:"]),+ ("Kenten Type:", ["Kenten-Art:", "Type de kenten:", "Tipo de kenten:", "圏点種類:", "圈点类型:"]),+ ("Sesame Dot", ["Sesampunkt", "Point sésame", "Punto de sésamo", "ゴマ", "芝麻点"]),+ ("White Sesame Dot", ["Weißer Sesampunkt", "Point sésame blanc", "Punto de sésamo blanco", "白ゴマ", "空心芝麻点"]),+ ("Bullseye", ["Zielscheibe", "Cible", "Diana", "蛇の目", "靶心"]),+ ("Black Circle", ["Schwarzer Kreis", "Cercle noir", "Círculo negro", "黒丸", "实心圆"]),+ ("Small Black Circle", ["Kleiner schwarzer Kreis", "Petit cercle noir", "Círculo negro pequeño", "小さい黒丸", "小实心圆"]),+ ("Double Circle", ["Doppelkreis", "Double cercle", "Círculo doble", "二重丸", "双圆"]),+ ("Black Triangle", ["Schwarzes Dreieck", "Triangle noir", "Triángulo negro", "黒三角", "实心三角"]),+ ("White Triangle", ["Weißes Dreieck", "Triangle blanc", "Triángulo blanco", "白三角", "空心三角"]),+ ("White Circle", ["Weißer Kreis", "Cercle blanc", "Círculo blanco", "白丸", "空心圆"]),+ ("Small White Circle", ["Kleiner weißer Kreis", "Petit cercle blanc", "Círculo blanco pequeño", "小さい白丸", "小空心圆"]),+ ("Character:", ["Zeichen:", "Caractère:", "Carácter:", "文字:", "字符:"]),+ ("Kinsoku Set:", ["Kinsoku-Satz:", "Jeu kinsoku:", "Conjunto kinsoku:", "禁則処理セット:", "避头尾集:"]),+ ("Default Rules", ["Standardregeln", "Règles par défaut", "Reglas predeterminadas", "既定の規則", "默认规则"]),+ ("Hard Kinsoku", ["Hartes Kinsoku", "Kinsoku strict", "Kinsoku estricto", "強い禁則", "严格避头尾"]),+ ("Soft Kinsoku", ["Weiches Kinsoku", "Kinsoku souple", "Kinsoku flexible", "弱い禁則", "宽松避头尾"]),+ (+ "Simplified Chinese Kinsoku",+ ["Kinsoku für vereinfachtes Chinesisch", "Kinsoku chinois simplifié", "Kinsoku de chino simplificado", "簡体中国語禁則", "简体中文避头尾"],+ ),+ (+ "Traditional Chinese Kinsoku",+ ["Kinsoku für traditionelles Chinesisch", "Kinsoku chinois traditionnel", "Kinsoku de chino tradicional", "繁体中国語禁則", "繁体中文避头尾"],+ ),+ ("Korean Kinsoku", ["Koreanisches Kinsoku", "Kinsoku coréen", "Kinsoku coreano", "韓国語禁則", "韩文避头尾"]),+ ("Kinsoku Type:", ["Kinsoku-Methode:", "Type de kinsoku:", "Tipo de kinsoku:", "禁則調整方式:", "避头尾调整方式:"]),+ ("Push In First", ["Zuerst einziehen", "Rentrer d'abord", "Primero hacia dentro", "追い込み優先", "先推入"]),+ ("Push Out First", ["Zuerst hinausschieben", "Repousser d'abord", "Primero hacia fuera", "追い出し優先", "先推出"]),+ ("Push Out Only", ["Nur hinausschieben", "Repousser uniquement", "Solo hacia fuera", "追い出しのみ", "仅推出"]),+ (+ "Prioritize Adjustment Amount",+ ["Anpassungsbetrag bevorzugen", "Priorité à la valeur d'ajustement", "Priorizar la cantidad de ajuste", "調整量を優先", "优先调整量"],+ ),+ ("Hanging Type:", ["Hängende Interpunktion:", "Ponctuation suspendue:", "Puntuación colgante:", "ぶら下がり方法:", "悬挂方式:"]),+ ("Force", ["Erzwingen", "Forcer", "Forzar", "強制", "强制"]),+ ("Bunri-Kinshi", ["Bunri-Kinshi", "Bunri-Kinshi", "Bunri-Kinshi", "分離禁止処理", "分离禁止"]),+ ("Mojikumi Set:", ["Mojikumi-Satz:", "Jeu mojikumi:", "Conjunto mojikumi:", "文字組み:", "标点挤压集:"]),+ ("Leading Model:", ["Zeilenabstandsmodell:", "Modèle d'interlignage:", "Modelo de interlineado:", "行送りの基準位置:", "行距基准位置:"]),+ (+ "Em Box Top/Right",+ ["Geviert oben/rechts", "Haut/droite du cadratin", "Parte superior/derecha del cuadratín", "仮想ボディの上/右", "全角字框上/右"],+ ),+ ("Em Box Center", ["Geviert Mitte", "Centre du cadratin", "Centro del cuadratín", "仮想ボディの中央", "全角字框居中"]),+ (+ "Em Box Bottom/Left",+ ["Geviert unten/links", "Bas/gauche du cadratin", "Parte inferior/izquierda del cuadratín", "仮想ボディの下/左", "全角字框下/左"],+ ),+ (+ "Em Box Center (Down)",+ ["Geviert Mitte (unten)", "Centre du cadratin (bas)", "Centro del cuadratín (abajo)", "仮想ボディの中央(下)", "全角字框居中(下)"],+ ),+ ("Roman Baseline", ["Lateinische Grundlinie", "Ligne de base romaine", "Línea de base romana", "欧文ベースライン", "罗马字基线"]),+ ("Rensuuji", ["Rensuuji", "Rensuuji", "Rensuuji", "連数字処理", "连数字处理"]),+ (+ "Absorb Ideographic Space at Line End",+ [+ "Ideografisches Leerzeichen am Zeilenende absorbieren",+ "Absorber l'espace idéographique en fin de ligne",+ "Absorber el espacio ideográfico al final de línea",+ "全角スペースを行末吸収",+ "行尾吸收全角空格",+ ],+ ),+ ("Grid Alignment:", ["Am Raster ausrichten:", "Alignement sur la grille:", "Alineación con cuadrícula:", "グリッド揃え:", "网格对齐:"]),+ (+ "Align Only First Line to Grid",+ [+ "Nur erste Zeile am Raster ausrichten",+ "Aligner uniquement la première ligne sur la grille",+ "Alinear solo la primera línea con la cuadrícula",+ "1 行目のみグリッドに揃える",+ "仅首行对齐网格",+ ],+ ),- ("Lines:", ["Zeilen:", "Lignes:", "Líneas:", "行数:", "行数:"]),+ ("Warichu Size:", ["Warichu-Größe:", "Taille warichu:", "Tamaño de warichu:", "割注サイズ:", "割注大小:"]),+ ("Line Spacing:", ["Zeilenabstand:", "Interligne:", "Interlineado:", "行の間隔:", "行间距:"]),+ ("Auto", ["Auto", "Auto", "Automático", "自動", "自动"]),+ ("Line Break Options", ["Umbruchoptionen", "Options de saut de ligne", "Opciones de salto de línea", "改行オプション", "换行选项"]),+ (+ "Characters Before Break:",+ ["Zeichen vor dem Umbruch:", "Caractères avant le saut:", "Caracteres antes del salto:", "1 行目の最小文字数:", "换行前最少字符数:"],+ ),+ (+ "Characters After Break:",+ ["Zeichen nach dem Umbruch:", "Caractères après le saut:", "Caracteres después del salto:", "最終行の最小文字数:", "换行后最少字符数:"],+ ),("Font", ["Schriftart", "Police", "Fuente", "フォント", "字体"]),("Size", ["Schriftgrad", "Corps", "Tamaño", "サイズ", "大小"]),("Character", ["Zeichen", "Caractère", "Carácter", "文字", "字符"]),