GstPipelineStudio/src/graph.rs
Stéphane Cerveau 0851f0545b GPS: introduce the graph object
The graph object stores information about the graphical
representation of a gst pipeline including
the element box, the pads and the connections.
2022-01-11 20:48:53 +01:00

37 lines
745 B
Rust

#[derive(Debug, Clone, Default)]
pub struct Element {
pub name: String,
pub position: (f64, f64),
pub size: (f64, f64),
}
#[derive(Debug)]
pub struct Graph {
elements: Vec<Element>,
last_x_position: u32,
}
impl Default for Graph {
fn default() -> Graph {
Graph {
elements: vec![],
last_x_position: 0,
}
}
}
impl Graph {
pub fn elements(&mut self) -> &Vec<Element> {
&self.elements
}
pub fn add_element(&mut self, element: Element) {
self.elements.push(element);
}
pub fn remove_element(&mut self, name: &str) {
let index = self.elements.iter().position(|x| x.name == name).unwrap();
self.elements.remove(index);
}
}