Compare commits
2 Commits
main
...
outline-up
Author | SHA1 | Date | |
---|---|---|---|
|
b479e57446 | ||
|
8daef5f71e |
@ -148,6 +148,9 @@ pub fn AddRemove() -> View {
|
|||||||
assembly.elements_by_id.update(|elts_by_id| elts_by_id.clear());
|
assembly.elements_by_id.update(|elts_by_id| elts_by_id.clear());
|
||||||
state.selection.update(|sel| sel.clear());
|
state.selection.update(|sel| sel.clear());
|
||||||
|
|
||||||
|
// increment assembly serial number
|
||||||
|
state.assembly_serial.set_fn_silent(|serial| serial.wrapping_add(1));
|
||||||
|
|
||||||
// load assembly
|
// load assembly
|
||||||
match name.as_str() {
|
match name.as_str() {
|
||||||
"general" => load_gen_assemb(assembly),
|
"general" => load_gen_assemb(assembly),
|
||||||
|
@ -15,6 +15,7 @@ use outline::Outline;
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct AppState {
|
struct AppState {
|
||||||
assembly: Assembly,
|
assembly: Assembly,
|
||||||
|
assembly_serial: Signal<u32>,
|
||||||
selection: Signal<FxHashSet<ElementKey>>
|
selection: Signal<FxHashSet<ElementKey>>
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ impl AppState {
|
|||||||
fn new() -> AppState {
|
fn new() -> AppState {
|
||||||
AppState {
|
AppState {
|
||||||
assembly: Assembly::new(),
|
assembly: Assembly::new(),
|
||||||
|
assembly_serial: create_signal(0),
|
||||||
selection: create_signal(FxHashSet::default())
|
selection: create_signal(FxHashSet::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,11 +180,15 @@ pub fn Outline() -> View {
|
|||||||
|
|
||||||
// list the elements alphabetically by ID
|
// list the elements alphabetically by ID
|
||||||
let element_list = state.assembly.elements.map(
|
let element_list = state.assembly.elements.map(
|
||||||
|elts| elts
|
move |elts| {
|
||||||
.clone()
|
let asm_serial = state.assembly_serial.get_untracked();
|
||||||
.into_iter()
|
elts
|
||||||
.sorted_by_key(|(_, elt)| elt.id.clone())
|
.clone()
|
||||||
.collect()
|
.into_iter()
|
||||||
|
.sorted_by_key(|(_, elt)| elt.id.clone())
|
||||||
|
.map(|(key, elt)| (asm_serial, key, elt))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
@ -197,10 +201,10 @@ pub fn Outline() -> View {
|
|||||||
) {
|
) {
|
||||||
Keyed(
|
Keyed(
|
||||||
list=element_list,
|
list=element_list,
|
||||||
view=|(key, elt)| view! {
|
view=|(_, key, elt)| view! {
|
||||||
ElementOutlineItem(key=key, element=elt)
|
ElementOutlineItem(key=key, element=elt)
|
||||||
},
|
},
|
||||||
key=|(key, _)| key.clone()
|
key=|(asm_serial, key, _)| (asm_serial.clone(), key.clone())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user