Make constraints editable

This commit is contained in:
Aaron Fenyes 2024-10-29 22:32:00 -07:00
parent e5f4d523f9
commit e0880d2ad2
5 changed files with 49 additions and 13 deletions

View file

@ -214,11 +214,14 @@ pub fn AddRemove() -> View {
(arg_vec[0].clone(), arg_vec[1].clone())
}
);
let rep = create_signal(0.0);
let active = create_signal(true);
state.assembly.insert_constraint(Constraint {
args: args,
rep: 0.0,
active: active
rep: rep,
rep_text: create_signal(String::new()),
rep_valid: create_signal(false),
active: active,
});
state.assembly.realize();
state.selection.update(|sel| sel.clear());
@ -233,13 +236,19 @@ pub fn AddRemove() -> View {
&JsValue::from(cst.args.0),
&JsValue::from(cst.args.1),
&JsValue::from(":"),
&JsValue::from(cst.rep)
&JsValue::from(cst.rep.get_untracked())
);
}
});
// make constraint activation trigger a realization update
// update the realization when the constraint activated, or
// edited while active
create_effect(move || {
rep.track();
console::log_2(
&JsValue::from("Constraint rep updated to"),
&JsValue::from(rep.get_untracked())
);
if active.get() {
state.assembly.realize();
}