iced_element: Use HashMap to track Outputs
This commit is contained in:
parent
c145b3c35a
commit
13efd32e23
1 changed files with 5 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::{HashMap, HashSet},
|
||||||
fmt,
|
fmt,
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
sync::{mpsc::Receiver, Arc, Mutex},
|
sync::{mpsc::Receiver, Arc, Mutex},
|
||||||
|
|
@ -124,7 +124,7 @@ impl<P: Program> IcedProgram for ProgramWrapper<P> {
|
||||||
|
|
||||||
struct IcedElementInternal<P: Program + Send + 'static> {
|
struct IcedElementInternal<P: Program + Send + 'static> {
|
||||||
// draw buffer
|
// draw buffer
|
||||||
outputs: Vec<Output>,
|
outputs: HashSet<Output>,
|
||||||
buffers: HashMap<OrderedFloat<f64>, (MemoryRenderBuffer, Option<(Vec<Primitive>, Color)>)>,
|
buffers: HashMap<OrderedFloat<f64>, (MemoryRenderBuffer, Option<(Vec<Primitive>, Color)>)>,
|
||||||
|
|
||||||
// state
|
// state
|
||||||
|
|
@ -238,7 +238,7 @@ impl<P: Program + Send + 'static> IcedElement<P> {
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
let mut internal = IcedElementInternal {
|
let mut internal = IcedElementInternal {
|
||||||
outputs: Vec::new(),
|
outputs: HashSet::new(),
|
||||||
buffers: HashMap::new(),
|
buffers: HashMap::new(),
|
||||||
size,
|
size,
|
||||||
cursor_pos: None,
|
cursor_pos: None,
|
||||||
|
|
@ -569,11 +569,11 @@ impl<P: Program + Send + 'static> SpaceElement for IcedElement<P> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
internal.outputs.push(output.clone());
|
internal.outputs.insert(output.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn output_leave(&self, output: &Output) {
|
fn output_leave(&self, output: &Output) {
|
||||||
self.0.lock().unwrap().outputs.retain(|o| o != output);
|
self.0.lock().unwrap().outputs.remove(output);
|
||||||
self.refresh();
|
self.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue