Skip to content

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

Smart Filters: one command builder for OK, mask thumbnails keyed by size

abc2cb17f149e73c3e
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index bac2d588e..7297dde8f 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -2475,7 +2475,7 @@ impl PhotocraftApp {
self.mask_thumb_kind(ctx, doc, id, mask, mask_thumbs_ui::THUMB_MASK)
}
- /// The thumbnail of `mask` under cache `kind`, re-rendered only when the mask's pixels or the document width change; Smart Filter and layer masks are cached apart.
+ /// The thumbnail of `mask` under cache `kind`, re-rendered only when the mask's pixels or the document size change; Smart Filter and layer masks are cached apart.
pub(crate) fn mask_thumb_kind(
&mut self,
ctx: &egui::Context,
@@ -2484,7 +2484,7 @@ impl PhotocraftApp {
mask: &photocraft_doc::LayerMask,
kind: u8,
) -> egui::TextureId {
- let rev = surface_fingerprint(&mask.surface) ^ (doc.size.width as u64) << 40;
+ let rev = surface_fingerprint(&mask.surface) ^ (doc.size.width as u64) << 40 ^ (doc.size.height as u64) << 16;
let key = (id, kind);
if let Some((r, tex)) = self.thumbs.get(&key)
&& *r == rev
diff --git a/crates/ui-egui/src/smart_ui.rs b/crates/ui-egui/src/smart_ui.rs
index f924323b7..65dbc45b7 100644
--- a/crates/ui-egui/src/smart_ui.rs
+++ b/crates/ui-egui/src/smart_ui.rs
@@ -396,16 +396,11 @@ pub fn preview_command<'a>(fields: &serde_json::Map<String, Value>, command: &'a
/// The command a confirmed filter dialog runs: smart-filter edits update the recorded filter.
pub fn confirm_command(app: &PhotocraftApp, fields: &serde_json::Map<String, Value>, command: String, params: Value) -> Result<(String, Value), String> {
- if crate::smart_filter_dialog::owns(fields) {
+ // One builder for the preview and for OK, so the two cannot differ.
+ if fields.contains_key("__smartFilter") {
return crate::smart_filter_dialog::edit_command(app, fields);
}
- match fields.get("__smartFilter") {
- Some(sf) => {
- let (layer, index) = crate::smart_filter_dialog::validate_target(app, sf)?;
- Ok(("layer.smartFilter.setParams".into(), json!({"layer": layer.0, "index": index, "params": params})))
- }
- None => Ok((command, params)),
- }
+ Ok((command, params))
}
#[cfg(test)]