LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge fixes: close the test functions the #307/#325 and #325/#346 merges ran together
Claude7f386aa25800
diff --git a/crates/engine/src/presets.rs b/crates/engine/src/presets.rsindex f77b435d7..ec63cc239 100644--- a/crates/engine/src/presets.rs+++ b/crates/engine/src/presets.rs@@ -451,10 +451,7 @@ impl Session {if let Some(p) = profile(id) {return Some((p.name, p.group));}- self.lut_profiles- .iter()- .find(|p| p.id == id)- .map(|p| (p.name.as_str(), p.group.as_str()))+ self.lut_profiles.iter().find(|p| p.id == id).map(|p| (p.name.as_str(), p.group.as_str()))}/// Remember `id` as the most recently applied profile.diff --git a/crates/ui-egui/src/headless.rs b/crates/ui-egui/src/headless.rsindex a60051bb0..e6e790000 100644--- a/crates/ui-egui/src/headless.rs+++ b/crates/ui-egui/src/headless.rs@@ -1421,6 +1421,8 @@ mod tests {}let _ = std::fs::remove_dir_all(&dir);}+ }+/// The import review opens bigger than the old fixed 6 × 2.5 grid and can be resized by its/// corner: the photo grid takes the new height, and the window then keeps its size (issue #337).#[test]diff --git a/crates/ui-egui/src/import.rs b/crates/ui-egui/src/import.rsindex 2122aa8d5..f5ac3c636 100644--- a/crates/ui-egui/src/import.rs+++ b/crates/ui-egui/src/import.rs@@ -831,18 +831,19 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDialog) {y(CONTENT_BOTTOM).zip(y(GRID_BOTTOM)).map(|(content, grid)| content - grid)});let grid_h = grid_height(ui.available_height(), below.unwrap_or(DEFAULT_BELOW_GRID), cell + 26.0);- let grid = egui::ScrollArea::vertical().id_salt("import-grid").max_height(grid_h).auto_shrink([false, false]).show_viewport(ui, |ui, viewport| {- let (area, _) = ui.allocate_exact_size(vec2(avail, rows as f32 * (cell + 26.0)), Sense::hover());- for i in 0..n {- let (c, r) = (i % cols, i / cols);- let local = Rect::from_min_size(pos2(c as f32 * (cell + 6.0), r as f32 * (cell + 26.0)), vec2(cell, cell + 20.0));- if !local.intersects(viewport.expand(cell)) {- continue;+ let grid =+ egui::ScrollArea::vertical().id_salt("import-grid").max_height(grid_h).auto_shrink([false, false]).show_viewport(ui, |ui, viewport| {+ let (area, _) = ui.allocate_exact_size(vec2(avail, rows as f32 * (cell + 26.0)), Sense::hover());+ for i in 0..n {+ let (c, r) = (i % cols, i / cols);+ let local = Rect::from_min_size(pos2(c as f32 * (cell + 6.0), r as f32 * (cell + 26.0)), vec2(cell, cell + 20.0));+ if !local.intersects(viewport.expand(cell)) {+ continue;+ }+ let rect = local.translate(area.min.to_vec2());+ candidate_cell(app, ui, d, i, rect);}- let rect = local.translate(area.min.to_vec2());- candidate_cell(app, ui, d, i, rect);- }- });+ });if !ui.is_sizing_pass() {ui.ctx().data_mut(|m| m.insert_temp(egui::Id::new(GRID_BOTTOM), grid.inner_rect.bottom()));}diff --git a/crates/ui-egui/src/panels/edit.rs b/crates/ui-egui/src/panels/edit.rsindex 163ae6fb8..cd2aae461 100644--- a/crates/ui-egui/src/panels/edit.rs+++ b/crates/ui-egui/src/panels/edit.rs@@ -351,11 +351,7 @@ fn profile_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettings)let cur = d.profile.id.as_str();// (clicked, hovered)let mut pick: (Option<String>, Option<String>) = (None, None);- let mut item = |ui: &mut egui::Ui,- key: &str,- id: &str,- name: &str,- pick: &mut (Option<String>, Option<String>)| {+ let mut item = |ui: &mut egui::Ui, key: &str, id: &str, name: &str, pick: &mut (Option<String>, Option<String>)| {let r = ui.selectable_label(id == cur, crate::i18n::profile_label(id, name));register(ui.ctx(), format!("profileMenu:{key}:{id}"), r.rect);if r.clicked() {@@ -429,7 +425,8 @@ fn profile_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettings)let mut s = d.clone();s.profile.id = hovered_id.clone();s.profile.amount = 100.0;- app.hover_preview = Some(crate::HoverPreview { label: crate::i18n::tr_format!("Profile: {}", crate::i18n::profile_label(hovered_id, name)), settings: s });+ app.hover_preview =+ Some(crate::HoverPreview { label: crate::i18n::tr_format!("Profile: {}", crate::i18n::profile_label(hovered_id, name)), settings: s });}if let Some(id) = pick.0 {let _ = app.run("develop.profile", json!({"id": id}));diff --git a/crates/ui-egui/src/panels/profiles.rs b/crates/ui-egui/src/panels/profiles.rsindex 03a62451d..c5045b740 100644--- a/crates/ui-egui/src/panels/profiles.rs+++ b/crates/ui-egui/src/panels/profiles.rs@@ -35,7 +35,13 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {let (cr, _) = ui.allocate_exact_size(vec2(ui.available_width(), 34.0), Sense::hover());let name = app.session.profile_info(&d.profile.id).map(|(name, _)| name).unwrap_or("Color");ui.painter().text(pos2(cr.left() + 24.0, cr.center().y), Align2::LEFT_CENTER, crate::i18n::tr("Profile"), t.font(13.0), t.text_dim);- ui.painter().text(pos2(cr.left() + 84.0, cr.center().y), Align2::LEFT_CENTER, crate::i18n::profile_label(&d.profile.id, name), t.font(14.0), t.text_label);+ ui.painter().text(+ pos2(cr.left() + 84.0, cr.center().y),+ Align2::LEFT_CENTER,+ crate::i18n::profile_label(&d.profile.id, name),+ t.font(14.0),+ t.text_label,+ );if d.profile.id != "lc.color" {super::edit::control(app, ui, &d, "profile.amount", true);ui.add_space(6.0);@@ -53,20 +59,19 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {sections.push(("Favorites", "fav", false, favs));}for g in profile_groups() {- sections.push((g, "", false, PROFILES.iter().filter(|p| p.group == g).map(|p| (p.id.to_string(), p.name.to_string(), p.group.to_string())).collect()));+ sections.push((+ g,+ "",+ false,+ PROFILES.iter().filter(|p| p.group == g).map(|p| (p.id.to_string(), p.name.to_string(), p.group.to_string())).collect(),+ ));}// imported LUT profile groupslet mut lut_groups: Vec<String> = app.session.lut_profiles.iter().map(|p| p.group.clone()).collect();lut_groups.sort_unstable();lut_groups.dedup();for g in &lut_groups {- let profiles = app- .session- .lut_profiles- .iter()- .filter(|p| &p.group == g)- .map(|p| (p.id.clone(), p.name.clone(), p.group.clone()))- .collect();+ let profiles = app.session.lut_profiles.iter().filter(|p| &p.group == g).map(|p| (p.id.clone(), p.name.clone(), p.group.clone())).collect();sections.push((g.as_str(), "", true, profiles));}for (title, tag, imported, list) in sections {@@ -81,7 +86,13 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {if open { Icon::ChevronDown } else { Icon::ChevronRight },t.text_label,);- ui.painter().text(pos2(r.left() + 36.0, r.center().y), Align2::LEFT_CENTER, crate::i18n::builtin_label(title, !imported), t.semibold(13.0), t.text_label);+ ui.painter().text(+ pos2(r.left() + 36.0, r.center().y),+ Align2::LEFT_CENTER,+ crate::i18n::builtin_label(title, !imported),+ t.semibold(13.0),+ t.text_label,+ );ui.painter().text(pos2(r.right() - 22.0, r.center().y), Align2::RIGHT_CENTER, list.len().to_string(), t.font(12.0), t.text_dim);if resp.clicked() {ui.data_mut(|m| m.insert_temp(open_id, !open));@@ -111,7 +122,8 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {&& let Some((p_name, _)) = app.session.profile_info(&saved_profile_id){let s = with_profile_id(&d, &saved_profile_id);- app.hover_preview = Some(HoverPreview { label: crate::i18n::tr_format!("Profile: {}", crate::i18n::profile_label(p_id, p_name)), settings: s });+ app.hover_preview =+ Some(HoverPreview { label: crate::i18n::tr_format!("Profile: {}", crate::i18n::profile_label(p_id, p_name)), settings: s });}} else {ui.data_mut(|m| m.remove::<(PhotoId, String)>(last_hover_id));@@ -160,7 +172,13 @@ fn cell_ui(painter.rect_stroke(thumb, 3.0, Stroke::new(1.0, t.text_dim), egui::StrokeKind::Outside);}let name_color = if applied { t.text } else { t.text_label };- painter.text(pos2(cell.left() + 2.0, thumb.bottom() + 12.0), Align2::LEFT_CENTER, crate::i18n::profile_label(p_id, p_name), t.font(12.0), name_color);+ painter.text(+ pos2(cell.left() + 2.0, thumb.bottom() + 12.0),+ Align2::LEFT_CENTER,+ crate::i18n::profile_label(p_id, p_name),+ t.font(12.0),+ name_color,+ );// favourite star (always shown when set, on hover otherwise)let fav = app.session.profile_favorites.iter().any(|f| f == p_id);let star = Rect::from_center_size(pos2(thumb.right() - 13.0, thumb.top() + 13.0), vec2(20.0, 20.0));@@ -171,10 +189,15 @@ fn cell_ui(paint(painter, star.shrink(4.0), if fav { Icon::StarFilled } else { Icon::Star }, if fav || over_star { t.star } else { Color32::WHITE });}if resp.hovered() && !applied && !over_star {- app.hover_preview = Some(HoverPreview { label: crate::i18n::tr_format!("Profile: {}", crate::i18n::profile_label(p_id, p_name)), settings: s.clone() });+ app.hover_preview =+ Some(HoverPreview { label: crate::i18n::tr_format!("Profile: {}", crate::i18n::profile_label(p_id, p_name)), settings: s.clone() });ui.data_mut(|m| m.insert_temp(egui::Id::new("last-profile-hover"), (id, p_id.to_string())));}- let resp = resp.on_hover_text(format!("{} ({})", crate::i18n::profile_label(p_id, p_name), crate::i18n::builtin_label(p_group, lightcraft_engine::presets::profile(p_id).is_some())));+ let resp = resp.on_hover_text(format!(+ "{} ({})",+ crate::i18n::profile_label(p_id, p_name),+ crate::i18n::builtin_label(p_group, lightcraft_engine::presets::profile(p_id).is_some())+ ));if resp.clicked() {if resp.interact_pointer_pos().is_some_and(|q| star.contains(q)) {let _ = app.run("profile.favorite", json!({"id": p_id}));diff --git a/crates/ui-egui/src/tests_panels.rs b/crates/ui-egui/src/tests_panels.rsindex 46b2cb6c4..37d051311 100644--- a/crates/ui-egui/src/tests_panels.rs+++ b/crates/ui-egui/src/tests_panels.rs@@ -534,6 +534,8 @@ fn the_selection_bar_stays_inside_the_panel() {let panel = widget(&h, "panel:left_panel");let bar = widget(&h, "highlight:libfolder:/a/b/c/d/e/f/g/h/i/j/k/l");assert!(bar.right() <= panel.right(), "the bar {bar:?} ends inside the panel {panel:?}");+}+/// Select All in the loupe: every filmstrip cell of a selected photo is drawn selected, not just/// the active one (issue #298).#[test]