Implement custom shader for window-close anim

This commit is contained in:
Ivan Molodetskikh
2024-05-12 09:52:21 +04:00
parent 29c7552852
commit 9004c83954
14 changed files with 361 additions and 30 deletions
+30 -13
View File
@@ -552,18 +552,24 @@ impl Default for WindowOpenAnim {
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct WindowCloseAnim(pub Animation);
#[derive(Debug, Clone, PartialEq)]
pub struct WindowCloseAnim {
pub anim: Animation,
pub custom_shader: Option<String>,
}
impl Default for WindowCloseAnim {
fn default() -> Self {
Self(Animation {
off: false,
kind: AnimationKind::Easing(EasingParams {
duration_ms: 150,
curve: AnimationCurve::EaseOutQuad,
}),
})
Self {
anim: Animation {
off: false,
kind: AnimationKind::Easing(EasingParams {
duration_ms: 150,
curve: AnimationCurve::EaseOutQuad,
}),
},
custom_shader: None,
}
}
}
@@ -1420,10 +1426,21 @@ where
node: &knuffel::ast::SpannedNode<S>,
ctx: &mut knuffel::decode::Context<S>,
) -> Result<Self, DecodeError<S>> {
let default = Self::default().0;
Ok(Self(Animation::decode_node(node, ctx, default, |_, _| {
Ok(false)
})?))
let default = Self::default().anim;
let mut custom_shader = None;
let anim = Animation::decode_node(node, ctx, default, |child, ctx| {
if &**child.node_name == "custom-shader" {
custom_shader = parse_arg_node("custom-shader", child, ctx)?;
Ok(true)
} else {
Ok(false)
}
})?;
Ok(Self {
anim,
custom_shader,
})
}
}