figma_api/models/table_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 TableNode {
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 nodes that are direct children of this node
50 #[serde(rename = "children")]
51 pub children: Vec<models::SubcanvasNode>,
52 /// Keep height and width constrained to same ratio.
53 #[serde(rename = "preserveRatio", skip_serializing_if = "Option::is_none")]
54 pub preserve_ratio: Option<bool>,
55 /// Horizontal and vertical layout constraints for node.
56 #[serde(rename = "constraints", skip_serializing_if = "Option::is_none")]
57 pub constraints: Option<Box<models::LayoutConstraint>>,
58 /// 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.
59 #[serde(rename = "relativeTransform", skip_serializing_if = "Option::is_none")]
60 pub relative_transform: Option<Vec<Vec<f64>>>,
61 /// 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.
62 #[serde(rename = "size", skip_serializing_if = "Option::is_none")]
63 pub size: Option<Box<models::Vector>>,
64 /// 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\".
65 #[serde(rename = "layoutAlign", skip_serializing_if = "Option::is_none")]
66 pub layout_align: Option<LayoutAlign>,
67 /// 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.
68 #[serde(rename = "layoutGrow", skip_serializing_if = "Option::is_none")]
69 pub layout_grow: Option<f64>,
70 /// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
71 #[serde(rename = "layoutPositioning", skip_serializing_if = "Option::is_none")]
72 pub layout_positioning: Option<LayoutPositioning>,
73 /// The minimum width of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
74 #[serde(rename = "minWidth", skip_serializing_if = "Option::is_none")]
75 pub min_width: Option<f64>,
76 /// The maximum width of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
77 #[serde(rename = "maxWidth", skip_serializing_if = "Option::is_none")]
78 pub max_width: Option<f64>,
79 /// The minimum height of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
80 #[serde(rename = "minHeight", skip_serializing_if = "Option::is_none")]
81 pub min_height: Option<f64>,
82 /// The maximum height of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
83 #[serde(rename = "maxHeight", skip_serializing_if = "Option::is_none")]
84 pub max_height: Option<f64>,
85 /// 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
86 #[serde(rename = "layoutSizingHorizontal", skip_serializing_if = "Option::is_none")]
87 pub layout_sizing_horizontal: Option<LayoutSizingHorizontal>,
88 /// 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
89 #[serde(rename = "layoutSizingVertical", skip_serializing_if = "Option::is_none")]
90 pub layout_sizing_vertical: Option<LayoutSizingVertical>,
91 /// An array of stroke paints applied to the node.
92 #[serde(rename = "strokes", skip_serializing_if = "Option::is_none")]
93 pub strokes: Option<Vec<models::Paint>>,
94 /// The weight of strokes on the node.
95 #[serde(rename = "strokeWeight", skip_serializing_if = "Option::is_none")]
96 pub stroke_weight: Option<f64>,
97 /// 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
98 #[serde(rename = "strokeAlign", skip_serializing_if = "Option::is_none")]
99 pub stroke_align: Option<StrokeAlign>,
100 /// A string enum with value of \"MITER\", \"BEVEL\", or \"ROUND\", describing how corners in vector paths are rendered.
101 #[serde(rename = "strokeJoin", skip_serializing_if = "Option::is_none")]
102 pub stroke_join: Option<StrokeJoin>,
103 /// 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.
104 #[serde(rename = "strokeDashes", skip_serializing_if = "Option::is_none")]
105 pub stroke_dashes: Option<Vec<f64>>,
106 /// An array of effects attached to this node (see effects section for more details)
107 #[serde(rename = "effects")]
108 pub effects: Vec<models::Effect>,
109 /// How this node blends with nodes behind it in the scene (see blend mode section for more details)
110 #[serde(rename = "blendMode")]
111 pub blend_mode: models::BlendMode,
112 /// Opacity of the node
113 #[serde(rename = "opacity", skip_serializing_if = "Option::is_none")]
114 pub opacity: Option<f64>,
115 /// An array of export settings representing images to export from the node.
116 #[serde(rename = "exportSettings", skip_serializing_if = "Option::is_none")]
117 pub export_settings: Option<Vec<models::ExportSetting>>,
118}
119
120impl TableNode {
121 pub fn new(id: String, name: String, scroll_behavior: ScrollBehavior, children: Vec<models::SubcanvasNode>, effects: Vec<models::Effect>, blend_mode: models::BlendMode) -> TableNode {
122 TableNode {
123 id,
124 name,
125 visible: None,
126 locked: None,
127 is_fixed: None,
128 scroll_behavior,
129 rotation: None,
130 component_property_references: None,
131 plugin_data: None,
132 shared_plugin_data: None,
133 bound_variables: None,
134 explicit_variable_modes: None,
135 children,
136 preserve_ratio: None,
137 constraints: None,
138 relative_transform: None,
139 size: None,
140 layout_align: None,
141 layout_grow: None,
142 layout_positioning: None,
143 min_width: None,
144 max_width: None,
145 min_height: None,
146 max_height: None,
147 layout_sizing_horizontal: None,
148 layout_sizing_vertical: None,
149 strokes: None,
150 stroke_weight: None,
151 stroke_align: None,
152 stroke_join: None,
153 stroke_dashes: None,
154 effects,
155 blend_mode,
156 opacity: None,
157 export_settings: None,
158 }
159 }
160}
161/// How layer should be treated when the frame is resized
162#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
163pub enum ScrollBehavior {
164 #[serde(rename = "SCROLLS")]
165 Scrolls,
166 #[serde(rename = "FIXED")]
167 Fixed,
168 #[serde(rename = "STICKY_SCROLLS")]
169 StickyScrolls,
170}
171
172impl Default for ScrollBehavior {
173 fn default() -> ScrollBehavior {
174 Self::Scrolls
175 }
176}
177/// 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\".
178#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
179pub enum LayoutAlign {
180 #[serde(rename = "INHERIT")]
181 Inherit,
182 #[serde(rename = "STRETCH")]
183 Stretch,
184 #[serde(rename = "MIN")]
185 Min,
186 #[serde(rename = "CENTER")]
187 Center,
188 #[serde(rename = "MAX")]
189 Max,
190}
191
192impl Default for LayoutAlign {
193 fn default() -> LayoutAlign {
194 Self::Inherit
195 }
196}
197/// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
198#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
199pub enum LayoutPositioning {
200 #[serde(rename = "AUTO")]
201 Auto,
202 #[serde(rename = "ABSOLUTE")]
203 Absolute,
204}
205
206impl Default for LayoutPositioning {
207 fn default() -> LayoutPositioning {
208 Self::Auto
209 }
210}
211/// 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
212#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
213pub enum LayoutSizingHorizontal {
214 #[serde(rename = "FIXED")]
215 Fixed,
216 #[serde(rename = "HUG")]
217 Hug,
218 #[serde(rename = "FILL")]
219 Fill,
220}
221
222impl Default for LayoutSizingHorizontal {
223 fn default() -> LayoutSizingHorizontal {
224 Self::Fixed
225 }
226}
227/// 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
228#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
229pub enum LayoutSizingVertical {
230 #[serde(rename = "FIXED")]
231 Fixed,
232 #[serde(rename = "HUG")]
233 Hug,
234 #[serde(rename = "FILL")]
235 Fill,
236}
237
238impl Default for LayoutSizingVertical {
239 fn default() -> LayoutSizingVertical {
240 Self::Fixed
241 }
242}
243/// 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
244#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
245pub enum StrokeAlign {
246 #[serde(rename = "INSIDE")]
247 Inside,
248 #[serde(rename = "OUTSIDE")]
249 Outside,
250 #[serde(rename = "CENTER")]
251 Center,
252}
253
254impl Default for StrokeAlign {
255 fn default() -> StrokeAlign {
256 Self::Inside
257 }
258}
259/// A string enum with value of \"MITER\", \"BEVEL\", or \"ROUND\", describing how corners in vector paths are rendered.
260#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
261pub enum StrokeJoin {
262 #[serde(rename = "MITER")]
263 Miter,
264 #[serde(rename = "BEVEL")]
265 Bevel,
266 #[serde(rename = "ROUND")]
267 Round,
268}
269
270impl Default for StrokeJoin {
271 fn default() -> StrokeJoin {
272 Self::Miter
273 }
274}
275