figma_api/models/
widget_node.rs

1/*
2 * Figma API
3 *
4 * This is the OpenAPI specification for the [Figma REST API](https://www.figma.com/developers/api).  Note: we are releasing the OpenAPI specification as a beta given the large surface area and complexity of the REST API. If you notice any inaccuracies with the specification, please [file an issue](https://github.com/figma/rest-api-spec/issues).
5 *
6 * The version of the OpenAPI document: 0.31.0
7 * Contact: support@figma.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct WidgetNode {
16    /// A string uniquely identifying this node within the document.
17    #[serde(rename = "id")]
18    pub id: String,
19    /// The name given to the node by the user in the tool.
20    #[serde(rename = "name")]
21    pub name: String,
22    /// Whether or not the node is visible on the canvas.
23    #[serde(rename = "visible", skip_serializing_if = "Option::is_none")]
24    pub visible: Option<bool>,
25    /// If true, layer is locked and cannot be edited
26    #[serde(rename = "locked", skip_serializing_if = "Option::is_none")]
27    pub locked: Option<bool>,
28    /// Whether the layer is fixed while the parent is scrolling
29    #[serde(rename = "isFixed", skip_serializing_if = "Option::is_none")]
30    pub is_fixed: Option<bool>,
31    /// How layer should be treated when the frame is resized
32    #[serde(rename = "scrollBehavior")]
33    pub scroll_behavior: ScrollBehavior,
34    /// The rotation of the node, if not 0.
35    #[serde(rename = "rotation", skip_serializing_if = "Option::is_none")]
36    pub rotation: Option<f64>,
37    /// A mapping of a layer's property to component property name of component properties attached to this node. The component property name can be used to look up more information on the corresponding component's or component set's componentPropertyDefinitions.
38    #[serde(rename = "componentPropertyReferences", skip_serializing_if = "Option::is_none")]
39    pub component_property_references: Option<std::collections::HashMap<String, String>>,
40    #[serde(rename = "pluginData", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
41    pub plugin_data: Option<Option<serde_json::Value>>,
42    #[serde(rename = "sharedPluginData", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
43    pub shared_plugin_data: Option<Option<serde_json::Value>>,
44    #[serde(rename = "boundVariables", skip_serializing_if = "Option::is_none")]
45    pub bound_variables: Option<Box<models::IsLayerTraitBoundVariables>>,
46    /// A mapping of variable collection ID to mode ID representing the explicitly set modes for this node.
47    #[serde(rename = "explicitVariableModes", skip_serializing_if = "Option::is_none")]
48    pub explicit_variable_modes: Option<std::collections::HashMap<String, String>>,
49    /// An array of export settings representing images to export from the node.
50    #[serde(rename = "exportSettings", skip_serializing_if = "Option::is_none")]
51    pub export_settings: Option<Vec<models::ExportSetting>>,
52    /// An array of nodes that are direct children of this node
53    #[serde(rename = "children")]
54    pub children: Vec<models::SubcanvasNode>,
55}
56
57impl WidgetNode {
58    pub fn new(id: String, name: String, scroll_behavior: ScrollBehavior, children: Vec<models::SubcanvasNode>) -> WidgetNode {
59        WidgetNode {
60            id,
61            name,
62            visible: None,
63            locked: None,
64            is_fixed: None,
65            scroll_behavior,
66            rotation: None,
67            component_property_references: None,
68            plugin_data: None,
69            shared_plugin_data: None,
70            bound_variables: None,
71            explicit_variable_modes: None,
72            export_settings: None,
73            children,
74        }
75    }
76}
77/// How layer should be treated when the frame is resized
78#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
79pub enum ScrollBehavior {
80    #[serde(rename = "SCROLLS")]
81    Scrolls,
82    #[serde(rename = "FIXED")]
83    Fixed,
84    #[serde(rename = "STICKY_SCROLLS")]
85    StickyScrolls,
86}
87
88impl Default for ScrollBehavior {
89    fn default() -> ScrollBehavior {
90        Self::Scrolls
91    }
92}
93