figma_api/models/table_cell_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 TableCellNode {
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 /// Keep height and width constrained to same ratio.
56 #[serde(rename = "preserveRatio", skip_serializing_if = "Option::is_none")]
57 pub preserve_ratio: Option<bool>,
58 /// Horizontal and vertical layout constraints for node.
59 #[serde(rename = "constraints", skip_serializing_if = "Option::is_none")]
60 pub constraints: Option<Box<models::LayoutConstraint>>,
61 /// 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.
62 #[serde(rename = "relativeTransform", skip_serializing_if = "Option::is_none")]
63 pub relative_transform: Option<Vec<Vec<f64>>>,
64 /// 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.
65 #[serde(rename = "size", skip_serializing_if = "Option::is_none")]
66 pub size: Option<Box<models::Vector>>,
67 /// 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\".
68 #[serde(rename = "layoutAlign", skip_serializing_if = "Option::is_none")]
69 pub layout_align: Option<LayoutAlign>,
70 /// 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.
71 #[serde(rename = "layoutGrow", skip_serializing_if = "Option::is_none")]
72 pub layout_grow: Option<f64>,
73 /// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
74 #[serde(rename = "layoutPositioning", skip_serializing_if = "Option::is_none")]
75 pub layout_positioning: Option<LayoutPositioning>,
76 /// The minimum width of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
77 #[serde(rename = "minWidth", skip_serializing_if = "Option::is_none")]
78 pub min_width: Option<f64>,
79 /// The maximum width of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
80 #[serde(rename = "maxWidth", skip_serializing_if = "Option::is_none")]
81 pub max_width: Option<f64>,
82 /// The minimum height of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
83 #[serde(rename = "minHeight", skip_serializing_if = "Option::is_none")]
84 pub min_height: Option<f64>,
85 /// The maximum height of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
86 #[serde(rename = "maxHeight", skip_serializing_if = "Option::is_none")]
87 pub max_height: Option<f64>,
88 /// 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
89 #[serde(rename = "layoutSizingHorizontal", skip_serializing_if = "Option::is_none")]
90 pub layout_sizing_horizontal: Option<LayoutSizingHorizontal>,
91 /// 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
92 #[serde(rename = "layoutSizingVertical", skip_serializing_if = "Option::is_none")]
93 pub layout_sizing_vertical: Option<LayoutSizingVertical>,
94 /// Text contained within a text box.
95 #[serde(rename = "characters")]
96 pub characters: String,
97}
98
99impl TableCellNode {
100 pub fn new(id: String, name: String, scroll_behavior: ScrollBehavior, fills: Vec<models::Paint>, characters: String) -> TableCellNode {
101 TableCellNode {
102 id,
103 name,
104 visible: None,
105 locked: None,
106 is_fixed: None,
107 scroll_behavior,
108 rotation: None,
109 component_property_references: None,
110 plugin_data: None,
111 shared_plugin_data: None,
112 bound_variables: None,
113 explicit_variable_modes: None,
114 fills,
115 styles: None,
116 preserve_ratio: None,
117 constraints: None,
118 relative_transform: None,
119 size: None,
120 layout_align: None,
121 layout_grow: None,
122 layout_positioning: None,
123 min_width: None,
124 max_width: None,
125 min_height: None,
126 max_height: None,
127 layout_sizing_horizontal: None,
128 layout_sizing_vertical: None,
129 characters,
130 }
131 }
132}
133/// How layer should be treated when the frame is resized
134#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
135pub enum ScrollBehavior {
136 #[serde(rename = "SCROLLS")]
137 Scrolls,
138 #[serde(rename = "FIXED")]
139 Fixed,
140 #[serde(rename = "STICKY_SCROLLS")]
141 StickyScrolls,
142}
143
144impl Default for ScrollBehavior {
145 fn default() -> ScrollBehavior {
146 Self::Scrolls
147 }
148}
149/// 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\".
150#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
151pub enum LayoutAlign {
152 #[serde(rename = "INHERIT")]
153 Inherit,
154 #[serde(rename = "STRETCH")]
155 Stretch,
156 #[serde(rename = "MIN")]
157 Min,
158 #[serde(rename = "CENTER")]
159 Center,
160 #[serde(rename = "MAX")]
161 Max,
162}
163
164impl Default for LayoutAlign {
165 fn default() -> LayoutAlign {
166 Self::Inherit
167 }
168}
169/// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
170#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
171pub enum LayoutPositioning {
172 #[serde(rename = "AUTO")]
173 Auto,
174 #[serde(rename = "ABSOLUTE")]
175 Absolute,
176}
177
178impl Default for LayoutPositioning {
179 fn default() -> LayoutPositioning {
180 Self::Auto
181 }
182}
183/// 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
184#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
185pub enum LayoutSizingHorizontal {
186 #[serde(rename = "FIXED")]
187 Fixed,
188 #[serde(rename = "HUG")]
189 Hug,
190 #[serde(rename = "FILL")]
191 Fill,
192}
193
194impl Default for LayoutSizingHorizontal {
195 fn default() -> LayoutSizingHorizontal {
196 Self::Fixed
197 }
198}
199/// 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
200#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
201pub enum LayoutSizingVertical {
202 #[serde(rename = "FIXED")]
203 Fixed,
204 #[serde(rename = "HUG")]
205 Hug,
206 #[serde(rename = "FILL")]
207 Fill,
208}
209
210impl Default for LayoutSizingVertical {
211 fn default() -> LayoutSizingVertical {
212 Self::Fixed
213 }
214}
215