From 9b39fe56b810d576f41fc43237f7cd85590e6f6d Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Thu, 26 Sep 2024 19:10:34 -0700 Subject: [PATCH] Outline: include constraints in element diff key This tells Sycamore that the outline view of an element should update when the element's constraint set has changed. To make the constraint set hashable, so we can include it in the diff key, we store it as a `BTreeSet` instead of an `FxHashSet`. --- app-proto/full-interface/src/assembly.rs | 4 ++-- app-proto/full-interface/src/main.rs | 7 ++++--- app-proto/full-interface/src/outline.rs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app-proto/full-interface/src/assembly.rs b/app-proto/full-interface/src/assembly.rs index 6fac59f..1d0a6f8 100644 --- a/app-proto/full-interface/src/assembly.rs +++ b/app-proto/full-interface/src/assembly.rs @@ -1,6 +1,6 @@ use nalgebra::DVector; -use rustc_hash::FxHashSet; use slab::Slab; +use std::collections::BTreeSet; use sycamore::prelude::*; #[derive(Clone, PartialEq)] @@ -9,7 +9,7 @@ pub struct Element { pub label: String, pub color: [f32; 3], pub rep: DVector, - pub constraints: FxHashSet + pub constraints: BTreeSet } #[derive(Clone)] diff --git a/app-proto/full-interface/src/main.rs b/app-proto/full-interface/src/main.rs index 2f31ada..e867ad3 100644 --- a/app-proto/full-interface/src/main.rs +++ b/app-proto/full-interface/src/main.rs @@ -5,6 +5,7 @@ mod outline; use nalgebra::DVector; use rustc_hash::FxHashSet; +use std::collections::BTreeSet; use sycamore::prelude::*; use add_remove::AddRemove; @@ -37,7 +38,7 @@ fn main() { label: String::from("Wing A"), color: [1.00_f32, 0.25_f32, 0.00_f32], rep: DVector::::from_column_slice(&[0.5, 0.5, 0.0, 0.5, -0.25]), - constraints: FxHashSet::default() + constraints: BTreeSet::default() } ) ); @@ -48,7 +49,7 @@ fn main() { label: String::from("Wing B"), color: [0.00_f32, 0.25_f32, 1.00_f32], rep: DVector::::from_column_slice(&[-0.5, -0.5, 0.0, 0.5, -0.25]), - constraints: FxHashSet::default() + constraints: BTreeSet::default() }, ) ); @@ -59,7 +60,7 @@ fn main() { label: String::from("Central"), color: [0.75_f32, 0.75_f32, 0.75_f32], rep: DVector::::from_column_slice(&[0.0, 0.0, 0.0, 0.4, -0.625]), - constraints: FxHashSet::default() + constraints: BTreeSet::default() } ) ); diff --git a/app-proto/full-interface/src/outline.rs b/app-proto/full-interface/src/outline.rs index be5a9b1..8a0a3fb 100644 --- a/app-proto/full-interface/src/outline.rs +++ b/app-proto/full-interface/src/outline.rs @@ -148,7 +148,7 @@ pub fn Outline() -> View { } } }, - key=|(key, _)| key.clone() + key=|(key, elt)| (key.clone(), elt.constraints.clone()) ) } }