PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Hide the Hyphenate checkbox until layout hyphenates (#6710) (#6869)
Vikram Bhaskarane1c209eadb58
diff --git a/crates/ui-egui/src/type_panels_ui.rs b/crates/ui-egui/src/type_panels_ui.rsindex d97a649fb..86ef66320 100644--- a/crates/ui-egui/src/type_panels_ui.rs+++ b/crates/ui-egui/src/type_panels_ui.rs@@ -443,7 +443,7 @@ fn options_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, paragraph: bool, s(tl!("Indent Right"), "end_indent_pt", "pt"),(tl!("Space Before"), "space_before_pt", "pt"),(tl!("Space After"), "space_after_pt", "pt"),- (tl!("Hyphenate"), "hyphenate", "bool"),+ // Hyphenate is stored and round-trips to PSD, but layout never hyphenates (#6710).];for &(label, key, kind) in rows {let mut on = defined(¶_attrs, key);@@ -969,4 +969,25 @@ mod tests {assert!(h.state().ui.type_panels.spell.is_none(), "the × closed Check Spelling");assert_eq!(h.state().session.active().unwrap().revision, revision, "and changed nothing");}++ #[test]+ fn hyphenate_is_not_shown_in_paragraph_style_options() {+ // #6710: layout never hyphenates; the style editor must not advertise it.+ use egui_kittest::kittest::Queryable;+ let mut app = app_with_text("Hi");+ app.ui.type_panels.styles = true;+ app.ui.type_panels.styles_tab = 1;+ app.ui.type_panels.options = Some((true, 0));+ let mut h = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state(+ |ui, app| {+ if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {+ windows(app, ui.ctx());+ }+ },+ app,+ );+ PhotocraftApp::setup_context(&h.ctx, Default::default());+ h.run_steps(4);+ assert!(h.query_by_label("Hyphenate").is_none());+ }}diff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rsindex ef021438f..ee29a9e1d 100644--- a/crates/ui-egui/src/type_tool.rs+++ b/crates/ui-egui/src/type_tool.rs@@ -2398,10 +2398,7 @@ fn type_sections(app: &mut PhotocraftApp, ui: &mut egui::Ui, character: bool, paapply(app, ui.ctx(), json!({"spaceAfter": v / u}));}});- let mut hy = para.hyphenate;- if crate::widgets::checkbox(ui, &mut hy, "Hyphenate").changed() {- apply(app, ui.ctx(), json!({"hyphenate": hy}));- }+ // Hyphenate is stored (⌥⇧⌘H / PSD AutoHyphenate) but layout never breaks words (#6710).ui.add_space(ROW_GAP);}}diff --git a/crates/ui-egui/src/type_tool_tests.rs b/crates/ui-egui/src/type_tool_tests.rsindex 9b840236f..5cbca3e2b 100644--- a/crates/ui-egui/src/type_tool_tests.rs+++ b/crates/ui-egui/src/type_tool_tests.rs@@ -1578,6 +1578,14 @@ mod multi_layer_formatting {h.run();}+ #[test]+ fn hyphenate_is_not_shown_while_layout_does_not_hyphenate() {+ // #6710: layout never hyphenates; the control must stay hidden until it does.+ let (app, _) = fixture();+ let h = controls(app, true);+ assert!(h.query_by_label("Hyphenate").is_none());+ }+#[test]fn properties_edit_shown_metrics_and_paragraphs_with_a_non_type_primary() {let (mut app, ids) = fixture();@@ -1595,8 +1603,6 @@ mod multi_layer_formatting {h.run();h.get_by_label("Center text").click();h.run();- h.get_by_label("Hyphenate").click();- h.run();number(&mut h, "Indent left margin", "9");for (id, scale) in [(ids[0], 2.0), (ids[1], 4.0)] {let c = style(h.state(), id, 0);@@ -1605,7 +1611,6 @@ mod multi_layer_formatting {assert!(c.faux_bold);let p = text(h.state(), id).paragraph_runs()[0].style.clone();assert_eq!(p.align, TextAlign::Center);- assert!(p.hyphenate);assert_eq!(p.start_indent_pt, 9.0);}assert_eq!(style(h.state(), ids[2], 0), untouched);