Smart Filters: document the functions next to the ones the PR changes

CodeRabbit counts the functions around the lines a PR changes, not only the
changed ones, so the PR's docstring coverage stays low (59.49%, threshold 80%)
unless the untouched neighbours are documented too. Comments only; no code
changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
abc2cb
2026-10-18 17:54:43 +03:00
co-authored by Claude Opus 5.5
parent 79793acefe
commit 25b79243f1
5 changed files with 10 additions and 0 deletions
+6
View File
@@ -10,10 +10,12 @@ use crate::{EngineError, Result, Session};
const ID: &str = "layer.setEffectsExpanded";
/// A `layer.setEffectsExpanded` parameter error.
fn bad(msg: impl Into<String>) -> EngineError {
EngineError::BadParams { cmd: ID.into(), msg: msg.into() }
}
/// The command is available while some layer has effects or Smart Filters to disclose.
fn has_effects(s: &Session) -> std::result::Result<(), String> {
let d = s.active().ok_or("no document open")?;
if d.doc.walk().iter().any(|(_, _, l)| has_children(l)) { Ok(()) } else { Err("no layer has effects or smart filters".into()) }
@@ -24,6 +26,7 @@ fn has_children(l: &Layer) -> bool {
!l.effects.items.is_empty() || matches!(&l.content, LayerContent::Smart(sm) if !sm.smart_filters.is_empty())
}
/// An optional boolean param: `None` when absent or null, an error when it is anything but true or false.
fn opt_bool(p: &Value, key: &str) -> Result<Option<bool>> {
match p.get(key) {
None | Some(Value::Null) => Ok(None),
@@ -64,6 +67,7 @@ fn set_expanded(s: &mut Session, p: &Value) -> Result<Value> {
Ok(json!({"expanded": expanded, "layers": targets.len()}))
}
/// Register `layer.setEffectsExpanded`: view state, so it is not journaled and adds no undo step.
pub fn specs() -> Vec<CommandSpec> {
vec![CommandSpec {
id: ID,
@@ -93,6 +97,7 @@ mod tests {
(s, a, b)
}
/// Whether the layer's effects list is shown, i.e. it is not in the document's collapsed set.
fn open(s: &Session, id: u64) -> bool {
!s.active().unwrap().fx_collapsed.contains(&LayerId(id))
}
@@ -120,6 +125,7 @@ mod tests {
assert!(s.active().unwrap().fx_collapsed.is_empty());
}
/// Toggling one layer or all of them flips only the disclosure state: no history step, no duplicates, and the document stays clean.
#[test]
fn toggles_one_layer_or_all_without_history() {
let (mut s, a, b) = session();
+1
View File
@@ -77,6 +77,7 @@ fn non_normal_coverage_changes_retain_source_over_semantics() {
}
}
/// A `depth`-bit document with one empty layer.
fn session(depth: u64) -> Session {
let mut s = Session::new();
s.execute("file.new", json!({"width": W, "height": H, "depth": depth})).unwrap();
+1
View File
@@ -93,6 +93,7 @@ fn screen_motion_blur_retains_input_coverage() {
assert!(error <= PASS_TOL, "Screen/Motion Blur error {error}, {bad}% pixels exceed 2/255");
}
/// Re-render every Photoshop oracle in the corpus with PhotoCraft's filters and compare it with Photoshop's own merged composite.
#[test]
fn photoshop_oracles_rerendered() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../corpus/photoshop");
+1
View File
@@ -2330,6 +2330,7 @@ impl PhotocraftApp {
id
}
/// The cached thumbnail of `mask`, the layer mask of layer `id`.
pub fn mask_thumb(&mut self, ctx: &egui::Context, doc: &Document, id: photocraft_doc::LayerId, mask: &photocraft_doc::LayerMask) -> egui::TextureId {
self.mask_thumb_kind(ctx, doc, id, mask, mask_thumbs_ui::THUMB_MASK)
}
+1
View File
@@ -206,6 +206,7 @@ pub fn filter_rows(app: &mut PhotocraftApp, ui: &mut egui::Ui, doc: &Document, l
/// Filters row, all of them). Also what a click selects.
pub(crate) type FilterDrag = (u64, Option<usize>);
/// Memory key of the smart filter row being dragged.
pub(crate) fn drag_key() -> egui::Id {
egui::Id::new("smart-filter-drag")
}