figma_api/models/has_layout_trait.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 HasLayoutTrait {
16 /// Keep height and width constrained to same ratio.
17 #[serde(rename = "preserveRatio", skip_serializing_if = "Option::is_none")]
18 pub preserve_ratio: Option<bool>,
19 /// Horizontal and vertical layout constraints for node.
20 #[serde(rename = "constraints", skip_serializing_if = "Option::is_none")]
21 pub constraints: Option<Box<models::LayoutConstraint>>,
22 /// 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.
23 #[serde(rename = "relativeTransform", skip_serializing_if = "Option::is_none")]
24 pub relative_transform: Option<Vec<Vec<f64>>>,
25 /// 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.
26 #[serde(rename = "size", skip_serializing_if = "Option::is_none")]
27 pub size: Option<Box<models::Vector>>,
28 /// 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\".
29 #[serde(rename = "layoutAlign", skip_serializing_if = "Option::is_none")]
30 pub layout_align: Option<LayoutAlign>,
31 /// 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.
32 #[serde(rename = "layoutGrow", skip_serializing_if = "Option::is_none")]
33 pub layout_grow: Option<f64>,
34 /// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
35 #[serde(rename = "layoutPositioning", skip_serializing_if = "Option::is_none")]
36 pub layout_positioning: Option<LayoutPositioning>,
37 /// The minimum width of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
38 #[serde(rename = "minWidth", skip_serializing_if = "Option::is_none")]
39 pub min_width: Option<f64>,
40 /// The maximum width of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
41 #[serde(rename = "maxWidth", skip_serializing_if = "Option::is_none")]
42 pub max_width: Option<f64>,
43 /// The minimum height of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
44 #[serde(rename = "minHeight", skip_serializing_if = "Option::is_none")]
45 pub min_height: Option<f64>,
46 /// The maximum height of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
47 #[serde(rename = "maxHeight", skip_serializing_if = "Option::is_none")]
48 pub max_height: Option<f64>,
49 /// 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
50 #[serde(rename = "layoutSizingHorizontal", skip_serializing_if = "Option::is_none")]
51 pub layout_sizing_horizontal: Option<LayoutSizingHorizontal>,
52 /// 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
53 #[serde(rename = "layoutSizingVertical", skip_serializing_if = "Option::is_none")]
54 pub layout_sizing_vertical: Option<LayoutSizingVertical>,
55}
56
57impl HasLayoutTrait {
58 pub fn new() -> HasLayoutTrait {
59 HasLayoutTrait {
60 preserve_ratio: None,
61 constraints: None,
62 relative_transform: None,
63 size: None,
64 layout_align: None,
65 layout_grow: None,
66 layout_positioning: None,
67 min_width: None,
68 max_width: None,
69 min_height: None,
70 max_height: None,
71 layout_sizing_horizontal: None,
72 layout_sizing_vertical: None,
73 }
74 }
75}
76/// 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\".
77#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
78pub enum LayoutAlign {
79 #[serde(rename = "INHERIT")]
80 Inherit,
81 #[serde(rename = "STRETCH")]
82 Stretch,
83 #[serde(rename = "MIN")]
84 Min,
85 #[serde(rename = "CENTER")]
86 Center,
87 #[serde(rename = "MAX")]
88 Max,
89}
90
91impl Default for LayoutAlign {
92 fn default() -> LayoutAlign {
93 Self::Inherit
94 }
95}
96/// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
97#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
98pub enum LayoutPositioning {
99 #[serde(rename = "AUTO")]
100 Auto,
101 #[serde(rename = "ABSOLUTE")]
102 Absolute,
103}
104
105impl Default for LayoutPositioning {
106 fn default() -> LayoutPositioning {
107 Self::Auto
108 }
109}
110/// 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
111#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
112pub enum LayoutSizingHorizontal {
113 #[serde(rename = "FIXED")]
114 Fixed,
115 #[serde(rename = "HUG")]
116 Hug,
117 #[serde(rename = "FILL")]
118 Fill,
119}
120
121impl Default for LayoutSizingHorizontal {
122 fn default() -> LayoutSizingHorizontal {
123 Self::Fixed
124 }
125}
126/// 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
127#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
128pub enum LayoutSizingVertical {
129 #[serde(rename = "FIXED")]
130 Fixed,
131 #[serde(rename = "HUG")]
132 Hug,
133 #[serde(rename = "FILL")]
134 Fill,
135}
136
137impl Default for LayoutSizingVertical {
138 fn default() -> LayoutSizingVertical {
139 Self::Fixed
140 }
141}
142