PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Type options: drag the "T" icon to change the font size, as in Photoshop (#6437)
Marco Arnulfoef46343f6b8a
diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex 449f741e2..9c7b28b6f 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -1081,6 +1081,7 @@# Paragraph and character panelsFont Size: Кегль:+ Font size КегльType: Текст:Style СтильStyle: Normal Стиль: Обычныйdiff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rsindex d73bb2e2c..ed530fb2d 100644--- a/crates/ui-egui/src/type_tool.rs+++ b/crates/ui-egui/src/type_tool.rs@@ -1742,8 +1742,12 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {apply(app, ui.ctx(), json!({"fontStyle": style}));}}- let (r, _) = ui.allocate_exact_size(egui::vec2(18.0, 22.0), egui::Sense::hover());+ let (r, icon) = ui.allocate_exact_size(egui::vec2(18.0, 22.0), egui::Sense::hover());crate::icons::paint(ui, r, "type", 13.0, t.icon);+ let icon = icon.on_hover_text(tl!("Font size"));+ icon.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, true, tl!("Font size")));+ // Photoshop's "T" scrubs the size field beside it, like the Character panel's icons (#6437).+ crate::widgets::scrub_option_label(ui, &icon);let (unit, label) = type_unit(app);let mut display = size * unit;if crate::widgets::value_field(ui, &mut display, unit..=1296.0 * unit, label, 66.0).changed() {diff --git a/crates/ui-egui/src/type_tool_tests.rs b/crates/ui-egui/src/type_tool_tests.rsindex c7b54c887..b14cd16cf 100644--- a/crates/ui-egui/src/type_tool_tests.rs+++ b/crates/ui-egui/src/type_tool_tests.rs@@ -410,6 +410,87 @@ fn size_drag_is_live_and_one_history_step_per_drag() {assert_eq!(size_at(h.state(), id, 0), 20.0);}+fn options_harness(app: PhotocraftApp) -> Harness<'static, PhotocraftApp> {+ let mut h = Harness::builder().with_size(vec2(900.0, 60.0)).build_ui_state(+ |ui, app: &mut PhotocraftApp| {+ ui.horizontal(|ui| super::options_bar(app, ui));+ },+ app,+ );+ PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::ALL[0]);+ h.run_steps(3);+ h+}++/// Drags the options bar's "T" icon `dx` points to the right with `mods` held.+fn scrub_size_icon(h: &mut Harness<'static, PhotocraftApp>, dx: f32, mods: Modifiers) {+ let icon = h.get_by_label("Font size").rect().center();+ h.hover_at(icon);+ h.run_steps(1);+ press(h, icon, true);+ for k in 1..=5 {+ h.event(egui::Event::ModifiersChanged(mods));+ h.hover_at(icon + vec2(dx * k as f32 / 5.0, 0.0));+ h.run_steps(1);+ }+ press(h, icon + vec2(dx, 0.0), false);+ h.event(egui::Event::ModifiersChanged(Modifiers::NONE));+ h.run_steps(2);+}++fn history_len(h: &Harness<'static, PhotocraftApp>) -> usize {+ h.state().session.active().unwrap().history.entries().len()+}++/// Photoshop's options bar "T" icon is a scrubby slider for the size beside it, like the+/// Character panel's icons (#6437): a point per point dragged, the whole drag one undo step.+#[test]+fn options_bar_t_icon_scrubs_the_size_in_one_history_step() {+ let mut app = new_app();+ let id = LayerId(app.run("type.create", json!({"text": "Hello", "size": 20, "x": 300, "y": 420})).unwrap()["layer"].as_u64().unwrap());+ let mut h = options_harness(app);+ let steps = history_len(&h);+ scrub_size_icon(&mut h, 30.0, Modifiers::NONE);+ assert_eq!(size_at(h.state(), id, 0), 50.0, "30 points to the right: 20 pt → 50 pt");+ assert_eq!(history_len(&h), steps + 1, "one history step for the whole drag");+ assert!(h.state_mut().session.undo());+ assert_eq!(size_at(h.state(), id, 0), 20.0);+}++/// While editing with characters selected, scrubbing the "T" icon sizes only the selection.+#[test]+fn options_bar_t_icon_scrubs_the_selected_characters_only() {+ let mut app = new_app();+ let id = LayerId(app.run("type.create", json!({"text": "Hello world", "size": 20, "x": 300, "y": 420})).unwrap()["layer"].as_u64().unwrap());+ app.ui.text_edit = Some(crate::state::TextEdit {+ layer: id.0,+ caret: 11,+ anchor: 6,+ session: "s".into(),+ created: false,+ mask: false,+ dragging: false,+ resize: None,+ preedit: None,+ });+ let mut h = options_harness(app);+ scrub_size_icon(&mut h, -8.0, Modifiers::NONE);+ let sizes = [0, 5, 6, 10].map(|ci| size_at(h.state(), id, ci));+ assert_eq!(sizes, [20.0, 20.0, 12.0, 12.0], "\"world\" goes 20 pt → 12 pt, \"Hello \" stays");+}++/// Scrubbing the "T" icon stops at the size field's limits: 1 pt and 1296 pt.+#[test]+fn options_bar_t_icon_scrub_stops_at_the_size_limits() {+ let mut app = new_app();+ let id = LayerId(app.run("type.create", json!({"text": "Hello", "size": 20, "x": 300, "y": 420})).unwrap()["layer"].as_u64().unwrap());+ let mut h = options_harness(app);+ scrub_size_icon(&mut h, -60.0, Modifiers::NONE);+ assert_eq!(size_at(h.state(), id, 0), 1.0, "60 points left of 20 pt stops at the minimum");+ scrub_size_icon(&mut h, 200.0, Modifiers::SHIFT);+ assert_eq!(size_at(h.state(), id, 0), 1296.0, "Shift (10 pt per point) past the top stops at the maximum");+}+/// A point inside glyph `i` of vertical type: `f` of the way down its advance, right of the/// column's centre line.fn vglyph(h: &mut Harness<'static, PhotocraftApp>, id: LayerId, i: usize, f: f32) -> Pos2 {diff --git a/docs/ui-parity.md b/docs/ui-parity.mdindex 793f09840..95f2041f5 100644--- a/docs/ui-parity.md+++ b/docs/ui-parity.md@@ -1,6 +1,6 @@# UI parity: tools, handles, modifiers and feel-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-16 · **Change:** minor (Type options bar "T" icon scrubs the font size, #6437; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, thehandles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,@@ -161,6 +161,7 @@ Triangle and Curvature Pen (minus legacy Rounded Rectangle and Targeted Adjustme| Guides stored as f64 | missing | `Vec<f32>` (UI-217-20) || Geometry precision | partial | `geom::Point` f64, paths f64; paint internals mostly f32 || Numeric fields: arithmetic, scrubby labels | partial | units in expressions and double-click reset missing (UI-217-13) |+| Type options bar: drag the "T" icon to change the font size | done | `type_tool.rs` `options_bar`: the icon scrubs the size field like the Character panel's icons (Shift x10, Alt fine), at layer or selection scope, one history step per drag, within 1–1296 pt (#6437) |## Navigation@@ -227,6 +228,7 @@ Paragraph; the rest open as in-app floating windows.| Date | Change | Summary ||---|---|---|+| 2026-10-16 | minor | Type options bar: dragging the "T" icon scrubs the font size, as the Character panel's icons do (#6437) || 2026-10-13 | minor | Menu bar from the keyboard: Alt / F10 focus, Alt+letter, underlined mnemonics (#4988) || 2026-10-13 | minor | Layers panel filter row: Kind is a real dropdown with Kind, Name and Mode filters, drivable by `ui.set {layerFilter}` (#5048); row added as partial || 2026-10-13 | minor | Stale "missing tool" rows corrected against main: Color Replacement (`paint.colorReplacement`), Red Eye (`paint.redEye`) and Add/Delete Anchor Point (the P flyout cycle) are live toolbar tools, so only Art History Brush is missing; no percentage or estimate changed |