use renamite_animation::Frame;
use renamite_history::EditorCommand;
use renamite_model::{Document, NodeId, PropPath};
pub fn path_edit_target(
doc: &Document,
id: NodeId,
playhead: Frame,
record: bool,
) -> Option<(Option<Frame>, Option<EditorCommand>)> {
let prop = PropPath::new("shape.path");
let animated = doc.property_is_animated(id, &prop);
if !record && !animated {
return Some((None, None));
}
if doc.keyframe_data(id, &prop, playhead).is_some() {
return Some((Some(playhead), None));
}
let value = doc.value_at(id, &prop, playhead.0 as f64).ok()?;
Some((
Some(playhead),
Some(EditorCommand::AddKeyframe {
id,
prop,
frame: playhead,
value,
}),
))
}