Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Merge remote-tracking branch 'upstream/main' into type-recent-fonts

Reynold Hudbd9a389b8ea
diff --cc crates/ui-egui/src/state.rs
index 0d7862090,42997fe62..9884ec681
--- a/crates/ui-egui/src/state.rs
+++ b/crates/ui-egui/src/state.rs
@@@ -1240,8 -1271,8 +1275,9 @@@ impl Default for UiState
Self {
tool: Tool::Brush,
group_tools: Vec::new(),
+ spring: None,
recent_files: Vec::new(),
+ recent_fonts: Vec::new(),
text_edit: None,
type_transform: None,
type_transform_pivot: None,
diff --cc crates/ui-egui/src/type_font_picker_tests.rs
index 0ba91455e,f17032523..8649f439a
--- a/crates/ui-egui/src/type_font_picker_tests.rs
+++ b/crates/ui-egui/src/type_font_picker_tests.rs
@@@ -472,24 -464,29 +472,51 @@@ fn font_menu_rows_search_both_names_and
assert!(rows(Some(&labels), "nothing").is_empty());
}
+/// Preferences ▸ Type ▸ Recent Fonts: recently used families move to the top (most recent first,
+/// once each); a query drops the hoisting so the list stays alphabetical while searching.
+#[test]
+fn recent_fonts_are_hoisted_to_the_top() {
+ let families: Vec<String> = ["Arial", "Baskerville", "Courier", "Zeta Sans"].iter().map(|s| s.to_string()).collect();
+ let recents: Vec<String> = vec!["Zeta Sans".into(), "Courier".into()];
+ let rows = |q: &str| -> Vec<String> { super::font_menu_rows(&families, None, q, &recents).into_iter().map(|(f, _)| f.clone()).collect() };
+ assert_eq!(rows(""), ["Zeta Sans", "Courier", "Arial", "Baskerville"], "recents hoist, most recent first, once each");
+ assert_eq!(rows("a"), ["Arial", "Baskerville", "Zeta Sans"], "a query drops the hoisting");
+}
+
+/// The menu itself draws the hoisted recents first.
+#[test]
+fn recent_fonts_appear_first_in_the_menu() {
+ let mut h = harness_with_recents(FontPreview::Medium, vec!["Zeta Sans".into(), "Family 05".into()]);
+ open(&mut h);
+ let zeta = h.get_by_label("Zeta Sans").rect().top();
+ let five = h.get_by_label("Family 05").rect().top();
+ let six = h.get_by_label("Family 06").rect().top();
+ assert!(zeta < five && five < six, "recents come first, in order: {zeta} {five} {six}");
+}
++
+ #[test]
+ fn wheel_over_the_closed_font_button_steps_through_the_families() {
+ let mut h = harness();
+ let button = h.query_all_by_role(Role::ComboBox).next().unwrap().rect().center();
+ h.hover_at(button);
+ h.run();
+ let wheel = |h: &mut Harness<'static, State>, y: f32| {
+ h.event(egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Line, delta: vec2(0.0, y), phase: egui::TouchPhase::Move, modifiers: Modifiers::NONE });
+ h.run();
+ };
+ wheel(&mut h, -2.0);
+ assert_eq!(h.state().current, "Family 02", "two notches down pick the second next family");
+ assert!(popup_rect(&h).is_none(), "the list stays closed");
+ wheel(&mut h, 1.0);
+ assert_eq!(h.state().current, "Family 01");
+ wheel(&mut h, 5.0);
+ assert_eq!(h.state().current, "Family 00", "stops at the first family");
+ }
+
+ #[test]
+ fn wheel_family_index_clamps_to_the_ends() {
+ assert_eq!(super::wheel_family_index(0, 3, -5.0), Some(2));
+ assert_eq!(super::wheel_family_index(1, 3, 1.0), Some(0));
+ assert_eq!(super::wheel_family_index(1, 3, 0.0), None);
+ assert_eq!(super::wheel_family_index(0, 0, -1.0), None);
+ }
diff --cc crates/ui-egui/src/type_tool.rs
index 53147cf11,f00fb5715..c2225a9d7
--- a/crates/ui-egui/src/type_tool.rs
+++ b/crates/ui-egui/src/type_tool.rs
@@@ -1380,6 -1529,26 +1549,26 @@@ pub(crate) fn family_picker_in
press.after(&response.response);
let hovered_font = response.inner.unwrap_or_default();
+ // The wheel over the closed button steps through the families, a notch each, like Photoshop's
+ // options-bar font menu: no need to open the list (#3350).
+ if !egui::ComboBox::is_open(ui.ctx(), response.response.id) && ui.is_enabled() {
+ let hovered = response.response.hovered();
+ if hovered {
+ ui.input_mut(|i| i.smooth_scroll_delta = egui::Vec2::ZERO);
+ }
+ let notches = crate::widgets::wheel_notches_of(ui, response.response.id.with("family-wheel"), hovered, 1.0);
- let rows = font_menu_rows(families, labels, "");
++ let rows = font_menu_rows(families, labels, "", recents);
+ if let Some(i) = rows.iter().position(|(f, _)| *f == current)
+ && let Some(n) = wheel_family_index(i, rows.len(), notches)
+ && let Some((f, _)) = rows.get(n)
+ && **f != *current
+ {
+ current.clone_from(f);
+ photocraft_text::served::request(f);
+ changed = true;
+ }
+ }
+
if salt == "type-font" {
let hover_id = egui::Id::new("type-font-hover");
if let Some(f) = hovered_font {
diff --cc docs/scorecard.md
index ec458233f,56a16654b..ab4c98be9
--- a/docs/scorecard.md
+++ b/docs/scorecard.md
@@@ -7,11 -7,11 +7,11 @@@ Generated by `cargo xtask scorecard` fr
| Area | Done | Partial | Missing | Key numbers |
|---|---:|---:|---:|---|
| [Performance](#performance) | 3 | 22 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 17 not run, 5 not measurable yet (baseline 2026-10-05) |
- | [File compatibility](#file-compatibility) | 6 | 13 | 8 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 |
- | [Tools](#tools) | 28 | 14 | 1 | |
- | [Workspace and UI](#workspace-and-ui) | 13 | 5 | 5 | settings that do nothing: 28 of 156 (target 0) |
- | [Type](#type) | 4 | 2 | 3 | |
- | [Automation](#automation) | 4 | 2 | 5 | 631 of 631 menu items live (100.0%) |
+ | [File compatibility](#file-compatibility) | 7 | 13 | 7 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 145/256, round trip ≥ 258/256 |
+ | [Tools](#tools) | 29 | 13 | 1 | |
-| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 157 (target 0) |
++| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 25 of 157 (target 0) |
+ | [Type](#type) | 4 | 3 | 2 | |
+ | [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) |
| [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present |
| [Distribution](#distribution) | 5 | 4 | 2 | |
| [Open bugs](#open-bugs) | 29 | 2 | 1 | |
@@@ -176,9 -176,9 +176,9 @@@ Corpus floors (`crates/io/tests/corpus.
## Workspace and UI
- **Settings that do nothing: 28 of 156** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.
-**Settings that do nothing: 26 of 157** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.
++**Settings that do nothing: 25 of 157** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.
- Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_collapse_icon_panels`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `workspace.enable_narrow_options_bar`, `file_handling.save_in_background`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.
-Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.
++Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.
| Id | Target | Status | Issue | Note |
|---|---|---|---|---|