Skip to main content

nominal_api_conjure/conjure/objects/scout/layout/api/
canvas_layout.rs

1/// A layout of node elements freely placed on a canvas. CanvasPanel entries represent panel
2/// nodes and HMI widgets; other CanvasObject variants may have different behavior.
3#[derive(
4    Debug,
5    Clone,
6    conjure_object::serde::Serialize,
7    conjure_object::serde::Deserialize,
8    conjure_object::private::DeriveWith
9)]
10#[serde(crate = "conjure_object::serde")]
11#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[conjure_object::private::staged_builder::staged_builder]
13#[builder(crate = conjure_object::private::staged_builder, update, inline)]
14pub struct CanvasLayout {
15    #[serde(rename = "id")]
16    id: conjure_object::Uuid,
17    #[builder(
18        default,
19        map(key(type = conjure_object::Uuid), value(type = super::CanvasObject))
20    )]
21    #[serde(
22        rename = "objects",
23        serialize_with = "conjure_object::private::serialize_map_keys_as_strings",
24        skip_serializing_if = "std::collections::BTreeMap::is_empty",
25        default
26    )]
27    objects: std::collections::BTreeMap<conjure_object::Uuid, super::CanvasObject>,
28}
29impl CanvasLayout {
30    /// Constructs a new instance of the type.
31    #[inline]
32    pub fn new(id: conjure_object::Uuid) -> Self {
33        Self::builder().id(id).build()
34    }
35    #[inline]
36    pub fn id(&self) -> conjure_object::Uuid {
37        self.id
38    }
39    #[inline]
40    pub fn objects(
41        &self,
42    ) -> &std::collections::BTreeMap<conjure_object::Uuid, super::CanvasObject> {
43        &self.objects
44    }
45}