Assembly: mark constraints as active or not

This commit is contained in:
Aaron Fenyes 2024-10-16 23:16:29 -07:00
parent f1690b62e1
commit 517fd327fa
4 changed files with 11 additions and 3 deletions

View File

@ -104,6 +104,10 @@ details[open]:has(li) .elt-switch::after {
font-style: italic; font-style: italic;
} }
.cst > input {
margin: 0px 8px 0px 0px;
}
/* display */ /* display */
canvas { canvas {

View File

@ -66,7 +66,8 @@ fn load_gen_assemb(assembly: &Assembly) {
assembly.elements_by_id.with_untracked(|elts_by_id| elts_by_id["gemini_a"]), assembly.elements_by_id.with_untracked(|elts_by_id| elts_by_id["gemini_a"]),
assembly.elements_by_id.with_untracked(|elts_by_id| elts_by_id["gemini_b"]) assembly.elements_by_id.with_untracked(|elts_by_id| elts_by_id["gemini_b"])
), ),
rep: 0.5 rep: 0.5,
active: create_signal(true)
} }
); );
} }
@ -211,7 +212,8 @@ pub fn AddRemove() -> View {
); );
state.assembly.insert_constraint(Constraint { state.assembly.insert_constraint(Constraint {
args: args, args: args,
rep: 0.0 rep: 0.0,
active: create_signal(true)
}); });
state.selection.update(|sel| sel.clear()); state.selection.update(|sel| sel.clear());

View File

@ -16,7 +16,8 @@ pub struct Element {
#[derive(Clone)] #[derive(Clone)]
pub struct Constraint { pub struct Constraint {
pub args: (usize, usize), pub args: (usize, usize),
pub rep: f64 pub rep: f64,
pub active: Signal<bool>
} }
// a complete, view-independent description of an assembly // a complete, view-independent description of an assembly

View File

@ -136,6 +136,7 @@ pub fn Outline() -> View {
let other_arg_label = assembly.elements.with(|elts| elts[other_arg].label.clone()); let other_arg_label = assembly.elements.with(|elts| elts[other_arg].label.clone());
view! { view! {
li(class="cst") { li(class="cst") {
input(r#type="checkbox", bind:checked=cst.active)
div(class="cst-label") { (other_arg_label) } div(class="cst-label") { (other_arg_label) }
div(class="cst-rep") { (cst.rep) } div(class="cst-rep") { (cst.rep) }
} }