mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Smart Filters: one command builder for OK, mask thumbnails keyed by size
- smart_ui.rs: confirm_command sends every Smart Filter edit through smart_filter_dialog::edit_command, the builder the canvas preview already uses, so preview and OK cannot build different payloads. - lib.rs: the mask thumbnail cache revision includes the document height as well as the width. Two documents that restore the same layer id and width no longer share a thumbnail framed for the other's height. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
6da0673cd1
commit
17f149e73c
2 files changed
+5
-10
No files matched your search
@@ -2475,7 +2475,7 @@ impl PhotocraftApp {
|
|||||||
self.mask_thumb_kind(ctx, doc, id, mask, mask_thumbs_ui::THUMB_MASK)
|
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(
|
pub(crate) fn mask_thumb_kind(
|
||||||
&mut self,
|
&mut self,
|
||||||
ctx: &egui::Context,
|
ctx: &egui::Context,
|
||||||
@@ -2484,7 +2484,7 @@ impl PhotocraftApp {
|
|||||||
mask: &photocraft_doc::LayerMask,
|
mask: &photocraft_doc::LayerMask,
|
||||||
kind: u8,
|
kind: u8,
|
||||||
) -> egui::TextureId {
|
) -> 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);
|
let key = (id, kind);
|
||||||
if let Some((r, tex)) = self.thumbs.get(&key)
|
if let Some((r, tex)) = self.thumbs.get(&key)
|
||||||
&& *r == rev
|
&& *r == rev
|
||||||
|
|||||||
@@ -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.
|
/// 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> {
|
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);
|
return crate::smart_filter_dialog::edit_command(app, fields);
|
||||||
}
|
}
|
||||||
match fields.get("__smartFilter") {
|
Ok((command, params))
|
||||||
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)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Reference in new issue
Block a user