PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Fix #1387: the Type tool's font, style and size controls show in every theme (#1414)
BFlatacb57c169f95
diff --git a/crates/ui-egui/src/move_auto_select_tests.rs b/crates/ui-egui/src/move_auto_select_tests.rsindex a71876230..d3bcd9704 100644--- a/crates/ui-egui/src/move_auto_select_tests.rs+++ b/crates/ui-egui/src/move_auto_select_tests.rs@@ -151,3 +151,32 @@ fn every_theme_shows_the_auto_select_toggle() {assert!(!h.state().ui.tool_options.move_auto_select, "{theme:?}: the toggle turns Auto-Select off");}}++#[test]+fn every_theme_shows_the_type_options() {+ // #1387: outside the Pro themes the Type tool's options bar was only the hint "Click to add+ // text", so there was no font, style or size control while typing.+ use egui_kittest::Harness;+ use egui_kittest::kittest::{NodeT, Queryable};+ for theme in crate::theme::ThemeKind::ALL {+ let (mut app, _, _) = app();+ app.ui.tool = Tool::Type;+ let mut h = Harness::builder().with_size(egui::vec2(1600.0, 60.0)).build_ui_state(+ |ui, app: &mut PhotocraftApp| {+ if !ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {+ return;+ }+ crate::panels::options_bar(app, ui);+ },+ app,+ );+ PhotocraftApp::setup_context(&h.ctx, theme);+ h.run_steps(4);+ let combos: Vec<String> = h+ .query_all_by_role(egui::accesskit::Role::ComboBox)+ .map(|n| format!("{:?} {:?}", n.accesskit_node().label(), n.accesskit_node().value()))+ .collect();+ let font = h.state().ui.tool_options.type_font.clone();+ assert!(combos.iter().any(|c| c.contains(&font)), "{theme:?}: the font picker shows {font:?}; combo boxes: {combos:?}");+ }+}diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rsindex e57f79052..71784c6c5 100644--- a/crates/ui-egui/src/panels.rs+++ b/crates/ui-egui/src/panels.rs@@ -789,7 +789,8 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {}});}- Tool::Type | Tool::VerticalType if t.pro => crate::type_tool::options_bar(app, ui),+ // Every theme gets the font, style and size controls (#1387), as with Auto-Select (#1275).+ Tool::Type | Tool::VerticalType => crate::type_tool::options_bar(app, ui),Tool::Move if t.pro => {let o = &mut app.ui.tool_options;widgets::checkbox(ui, &mut o.move_auto_select, tl!("Auto-Select:"));@@ -922,7 +923,6 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {),Tool::Gradient => hint(ui, tl!("Drag to draw a gradient")),Tool::PaintBucket => hint(ui, tl!("Click to fill similar colours")),- Tool::Type | Tool::VerticalType => hint(ui, tl!("Click to add text")),// Retouching and smart-selection tools draw their bar in `retouch_ui::options_bar`._ => {}}