mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-06-02 13:29:23 +00:00
0851f0545b
The graph object stores information about the graphical representation of a gst pipeline including the element box, the pads and the connections.
37 lines
745 B
Rust
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);
|
|
}
|
|
}
|