figma_api/models/
section_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 SectionNode {
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 fill paints applied to the node.
50    #[serde(rename = "fills")]
51    pub fills: Vec<models::Paint>,
52    /// A mapping of a StyleType to style ID (see Style) of styles present on this node. The style ID can be used to look up more information about the style in the top-level styles field.
53    #[serde(rename = "styles", skip_serializing_if = "Option::is_none")]
54    pub styles: Option<std::collections::HashMap<String, String>>,
55    /// An array of stroke paints applied to the node.
56    #[serde(rename = "strokes", skip_serializing_if = "Option::is_none")]
57    pub strokes: Option<Vec<models::Paint>>,
58    /// The weight of strokes on the node.
59    #[serde(rename = "strokeWeight", skip_serializing_if = "Option::is_none")]
60    pub stroke_weight: Option<f64>,
61    /// Position of stroke relative to vector outline, as a string enum  - `INSIDE`: stroke drawn inside the shape boundary - `OUTSIDE`: stroke drawn outside the shape boundary - `CENTER`: stroke drawn centered along the shape boundary
62    #[serde(rename = "strokeAlign", skip_serializing_if = "Option::is_none")]
63    pub stroke_align: Option<StrokeAlign>,
64    /// A string enum with value of \"MITER\", \"BEVEL\", or \"ROUND\", describing how corners in vector paths are rendered.
65    #[serde(rename = "strokeJoin", skip_serializing_if = "Option::is_none")]
66    pub stroke_join: Option<StrokeJoin>,
67    /// An array of floating point numbers describing the pattern of dash length and gap lengths that the vector stroke will use when drawn.  For example a value of [1, 2] indicates that the stroke will be drawn with a dash of length 1 followed by a gap of length 2, repeated.
68    #[serde(rename = "strokeDashes", skip_serializing_if = "Option::is_none")]
69    pub stroke_dashes: Option<Vec<f64>>,
70    /// Only specified if parameter `geometry=paths` is used. An array of paths representing the object fill.
71    #[serde(rename = "fillGeometry", skip_serializing_if = "Option::is_none")]
72    pub fill_geometry: Option<Vec<models::Path>>,
73    /// Only specified if parameter `geometry=paths` is used. An array of paths representing the object stroke.
74    #[serde(rename = "strokeGeometry", skip_serializing_if = "Option::is_none")]
75    pub stroke_geometry: Option<Vec<models::Path>>,
76    /// A string enum describing the end caps of vector paths.
77    #[serde(rename = "strokeCap", skip_serializing_if = "Option::is_none")]
78    pub stroke_cap: Option<StrokeCap>,
79    /// Only valid if `strokeJoin` is \"MITER\". The corner angle, in degrees, below which `strokeJoin` will be set to \"BEVEL\" to avoid super sharp corners. By default this is 28.96 degrees.
80    #[serde(rename = "strokeMiterAngle", skip_serializing_if = "Option::is_none")]
81    pub stroke_miter_angle: Option<f64>,
82    /// An array of nodes that are direct children of this node
83    #[serde(rename = "children")]
84    pub children: Vec<models::SubcanvasNode>,
85    /// Keep height and width constrained to same ratio.
86    #[serde(rename = "preserveRatio", skip_serializing_if = "Option::is_none")]
87    pub preserve_ratio: Option<bool>,
88    /// Horizontal and vertical layout constraints for node.
89    #[serde(rename = "constraints", skip_serializing_if = "Option::is_none")]
90    pub constraints: Option<Box<models::LayoutConstraint>>,
91    /// A transformation matrix is standard way in computer graphics to represent translation and rotation. These are the top two rows of a 3x3 matrix. The bottom row of the matrix is assumed to be [0, 0, 1]. This is known as an affine transform and is enough to represent translation, rotation, and skew.  The identity transform is [[1, 0, 0], [0, 1, 0]].  A translation matrix will typically look like:  ``` [[1, 0, tx],   [0, 1, ty]] ```  and a rotation matrix will typically look like:  ``` [[cos(angle), sin(angle), 0],   [-sin(angle), cos(angle), 0]] ```  Another way to think about this transform is as three vectors:  - The x axis (t[0][0], t[1][0]) - The y axis (t[0][1], t[1][1]) - The translation offset (t[0][2], t[1][2])  The most common usage of the Transform matrix is the `relativeTransform property`. This particular usage of the matrix has a few additional restrictions. The translation offset can take on any value but we do enforce that the axis vectors are unit vectors (i.e. have length 1). The axes are not required to be at 90° angles to each other.
92    #[serde(rename = "relativeTransform", skip_serializing_if = "Option::is_none")]
93    pub relative_transform: Option<Vec<Vec<f64>>>,
94    /// Width and height of element. This is different from the width and height of the bounding box in that the absolute bounding box represents the element after scaling and rotation. Only present if `geometry=paths` is passed.
95    #[serde(rename = "size", skip_serializing_if = "Option::is_none")]
96    pub size: Option<Box<models::Vector>>,
97    ///  Determines if the layer should stretch along the parent's counter axis. This property is only provided for direct children of auto-layout frames.  - `INHERIT` - `STRETCH`  In previous versions of auto layout, determined how the layer is aligned inside an auto-layout frame. This property is only provided for direct children of auto-layout frames.  - `MIN` - `CENTER` - `MAX` - `STRETCH`  In horizontal auto-layout frames, \"MIN\" and \"MAX\" correspond to \"TOP\" and \"BOTTOM\". In vertical auto-layout frames, \"MIN\" and \"MAX\" correspond to \"LEFT\" and \"RIGHT\".
98    #[serde(rename = "layoutAlign", skip_serializing_if = "Option::is_none")]
99    pub layout_align: Option<LayoutAlign>,
100    /// This property is applicable only for direct children of auto-layout frames, ignored otherwise. Determines whether a layer should stretch along the parent's primary axis. A `0` corresponds to a fixed size and `1` corresponds to stretch.
101    #[serde(rename = "layoutGrow", skip_serializing_if = "Option::is_none")]
102    pub layout_grow: Option<f64>,
103    /// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
104    #[serde(rename = "layoutPositioning", skip_serializing_if = "Option::is_none")]
105    pub layout_positioning: Option<LayoutPositioning>,
106    /// The minimum width of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
107    #[serde(rename = "minWidth", skip_serializing_if = "Option::is_none")]
108    pub min_width: Option<f64>,
109    /// The maximum width of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
110    #[serde(rename = "maxWidth", skip_serializing_if = "Option::is_none")]
111    pub max_width: Option<f64>,
112    /// The minimum height of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
113    #[serde(rename = "minHeight", skip_serializing_if = "Option::is_none")]
114    pub min_height: Option<f64>,
115    /// The maximum height of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
116    #[serde(rename = "maxHeight", skip_serializing_if = "Option::is_none")]
117    pub max_height: Option<f64>,
118    /// The horizontal sizing setting on this auto-layout frame or frame child. - `FIXED` - `HUG`: only valid on auto-layout frames and text nodes - `FILL`: only valid on auto-layout frame children
119    #[serde(rename = "layoutSizingHorizontal", skip_serializing_if = "Option::is_none")]
120    pub layout_sizing_horizontal: Option<LayoutSizingHorizontal>,
121    /// The vertical sizing setting on this auto-layout frame or frame child. - `FIXED` - `HUG`: only valid on auto-layout frames and text nodes - `FILL`: only valid on auto-layout frame children
122    #[serde(rename = "layoutSizingVertical", skip_serializing_if = "Option::is_none")]
123    pub layout_sizing_vertical: Option<LayoutSizingVertical>,
124    /// Whether the contents of the section are visible
125    #[serde(rename = "sectionContentsHidden")]
126    pub section_contents_hidden: bool,
127}
128
129impl SectionNode {
130    pub fn new(id: String, name: String, scroll_behavior: ScrollBehavior, fills: Vec<models::Paint>, children: Vec<models::SubcanvasNode>, section_contents_hidden: bool) -> SectionNode {
131        SectionNode {
132            id,
133            name,
134            visible: None,
135            locked: None,
136            is_fixed: None,
137            scroll_behavior,
138            rotation: None,
139            component_property_references: None,
140            plugin_data: None,
141            shared_plugin_data: None,
142            bound_variables: None,
143            explicit_variable_modes: None,
144            fills,
145            styles: None,
146            strokes: None,
147            stroke_weight: None,
148            stroke_align: None,
149            stroke_join: None,
150            stroke_dashes: None,
151            fill_geometry: None,
152            stroke_geometry: None,
153            stroke_cap: None,
154            stroke_miter_angle: None,
155            children,
156            preserve_ratio: None,
157            constraints: None,
158            relative_transform: None,
159            size: None,
160            layout_align: None,
161            layout_grow: None,
162            layout_positioning: None,
163            min_width: None,
164            max_width: None,
165            min_height: None,
166            max_height: None,
167            layout_sizing_horizontal: None,
168            layout_sizing_vertical: None,
169            section_contents_hidden,
170        }
171    }
172}
173/// How layer should be treated when the frame is resized
174#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
175pub enum ScrollBehavior {
176    #[serde(rename = "SCROLLS")]
177    Scrolls,
178    #[serde(rename = "FIXED")]
179    Fixed,
180    #[serde(rename = "STICKY_SCROLLS")]
181    StickyScrolls,
182}
183
184impl Default for ScrollBehavior {
185    fn default() -> ScrollBehavior {
186        Self::Scrolls
187    }
188}
189/// Position of stroke relative to vector outline, as a string enum  - `INSIDE`: stroke drawn inside the shape boundary - `OUTSIDE`: stroke drawn outside the shape boundary - `CENTER`: stroke drawn centered along the shape boundary
190#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
191pub enum StrokeAlign {
192    #[serde(rename = "INSIDE")]
193    Inside,
194    #[serde(rename = "OUTSIDE")]
195    Outside,
196    #[serde(rename = "CENTER")]
197    Center,
198}
199
200impl Default for StrokeAlign {
201    fn default() -> StrokeAlign {
202        Self::Inside
203    }
204}
205/// A string enum with value of \"MITER\", \"BEVEL\", or \"ROUND\", describing how corners in vector paths are rendered.
206#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
207pub enum StrokeJoin {
208    #[serde(rename = "MITER")]
209    Miter,
210    #[serde(rename = "BEVEL")]
211    Bevel,
212    #[serde(rename = "ROUND")]
213    Round,
214}
215
216impl Default for StrokeJoin {
217    fn default() -> StrokeJoin {
218        Self::Miter
219    }
220}
221/// A string enum describing the end caps of vector paths.
222#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
223pub enum StrokeCap {
224    #[serde(rename = "NONE")]
225    None,
226    #[serde(rename = "ROUND")]
227    Round,
228    #[serde(rename = "SQUARE")]
229    Square,
230    #[serde(rename = "LINE_ARROW")]
231    LineArrow,
232    #[serde(rename = "TRIANGLE_ARROW")]
233    TriangleArrow,
234    #[serde(rename = "DIAMOND_FILLED")]
235    DiamondFilled,
236    #[serde(rename = "CIRCLE_FILLED")]
237    CircleFilled,
238    #[serde(rename = "TRIANGLE_FILLED")]
239    TriangleFilled,
240    #[serde(rename = "WASHI_TAPE_1")]
241    WashiTape1,
242    #[serde(rename = "WASHI_TAPE_2")]
243    WashiTape2,
244    #[serde(rename = "WASHI_TAPE_3")]
245    WashiTape3,
246    #[serde(rename = "WASHI_TAPE_4")]
247    WashiTape4,
248    #[serde(rename = "WASHI_TAPE_5")]
249    WashiTape5,
250    #[serde(rename = "WASHI_TAPE_6")]
251    WashiTape6,
252}
253
254impl Default for StrokeCap {
255    fn default() -> StrokeCap {
256        Self::None
257    }
258}
259///  Determines if the layer should stretch along the parent's counter axis. This property is only provided for direct children of auto-layout frames.  - `INHERIT` - `STRETCH`  In previous versions of auto layout, determined how the layer is aligned inside an auto-layout frame. This property is only provided for direct children of auto-layout frames.  - `MIN` - `CENTER` - `MAX` - `STRETCH`  In horizontal auto-layout frames, \"MIN\" and \"MAX\" correspond to \"TOP\" and \"BOTTOM\". In vertical auto-layout frames, \"MIN\" and \"MAX\" correspond to \"LEFT\" and \"RIGHT\".
260#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
261pub enum LayoutAlign {
262    #[serde(rename = "INHERIT")]
263    Inherit,
264    #[serde(rename = "STRETCH")]
265    Stretch,
266    #[serde(rename = "MIN")]
267    Min,
268    #[serde(rename = "CENTER")]
269    Center,
270    #[serde(rename = "MAX")]
271    Max,
272}
273
274impl Default for LayoutAlign {
275    fn default() -> LayoutAlign {
276        Self::Inherit
277    }
278}
279/// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
280#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
281pub enum LayoutPositioning {
282    #[serde(rename = "AUTO")]
283    Auto,
284    #[serde(rename = "ABSOLUTE")]
285    Absolute,
286}
287
288impl Default for LayoutPositioning {
289    fn default() -> LayoutPositioning {
290        Self::Auto
291    }
292}
293/// The horizontal sizing setting on this auto-layout frame or frame child. - `FIXED` - `HUG`: only valid on auto-layout frames and text nodes - `FILL`: only valid on auto-layout frame children
294#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
295pub enum LayoutSizingHorizontal {
296    #[serde(rename = "FIXED")]
297    Fixed,
298    #[serde(rename = "HUG")]
299    Hug,
300    #[serde(rename = "FILL")]
301    Fill,
302}
303
304impl Default for LayoutSizingHorizontal {
305    fn default() -> LayoutSizingHorizontal {
306        Self::Fixed
307    }
308}
309/// The vertical sizing setting on this auto-layout frame or frame child. - `FIXED` - `HUG`: only valid on auto-layout frames and text nodes - `FILL`: only valid on auto-layout frame children
310#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
311pub enum LayoutSizingVertical {
312    #[serde(rename = "FIXED")]
313    Fixed,
314    #[serde(rename = "HUG")]
315    Hug,
316    #[serde(rename = "FILL")]
317    Fill,
318}
319
320impl Default for LayoutSizingVertical {
321    fn default() -> LayoutSizingVertical {
322        Self::Fixed
323    }
324}
325