figma_api/models/layout_grid.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/// LayoutGrid : Guides to align and place objects within a frames.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct LayoutGrid {
17 /// Orientation of the grid as a string enum - `COLUMNS`: Vertical grid - `ROWS`: Horizontal grid - `GRID`: Square grid
18 #[serde(rename = "pattern")]
19 pub pattern: Pattern,
20 /// Width of column grid or height of row grid or square grid spacing.
21 #[serde(rename = "sectionSize")]
22 pub section_size: f64,
23 /// Is the grid currently visible?
24 #[serde(rename = "visible")]
25 pub visible: bool,
26 /// Color of the grid
27 #[serde(rename = "color")]
28 pub color: Box<models::Rgba>,
29 /// Positioning of grid as a string enum - `MIN`: Grid starts at the left or top of the frame - `MAX`: Grid starts at the right or bottom of the frame - `STRETCH`: Grid is stretched to fit the frame - `CENTER`: Grid is center aligned
30 #[serde(rename = "alignment")]
31 pub alignment: Alignment,
32 /// Spacing in between columns and rows
33 #[serde(rename = "gutterSize")]
34 pub gutter_size: f64,
35 /// Spacing before the first column or row
36 #[serde(rename = "offset")]
37 pub offset: f64,
38 /// Number of columns or rows
39 #[serde(rename = "count")]
40 pub count: f64,
41 #[serde(rename = "boundVariables", skip_serializing_if = "Option::is_none")]
42 pub bound_variables: Option<Box<models::LayoutGridBoundVariables>>,
43}
44
45impl LayoutGrid {
46 /// Guides to align and place objects within a frames.
47 pub fn new(pattern: Pattern, section_size: f64, visible: bool, color: models::Rgba, alignment: Alignment, gutter_size: f64, offset: f64, count: f64) -> LayoutGrid {
48 LayoutGrid {
49 pattern,
50 section_size,
51 visible,
52 color: Box::new(color),
53 alignment,
54 gutter_size,
55 offset,
56 count,
57 bound_variables: None,
58 }
59 }
60}
61/// Orientation of the grid as a string enum - `COLUMNS`: Vertical grid - `ROWS`: Horizontal grid - `GRID`: Square grid
62#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
63pub enum Pattern {
64 #[serde(rename = "COLUMNS")]
65 Columns,
66 #[serde(rename = "ROWS")]
67 Rows,
68 #[serde(rename = "GRID")]
69 Grid,
70}
71
72impl Default for Pattern {
73 fn default() -> Pattern {
74 Self::Columns
75 }
76}
77/// Positioning of grid as a string enum - `MIN`: Grid starts at the left or top of the frame - `MAX`: Grid starts at the right or bottom of the frame - `STRETCH`: Grid is stretched to fit the frame - `CENTER`: Grid is center aligned
78#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
79pub enum Alignment {
80 #[serde(rename = "MIN")]
81 Min,
82 #[serde(rename = "MAX")]
83 Max,
84 #[serde(rename = "STRETCH")]
85 Stretch,
86 #[serde(rename = "CENTER")]
87 Center,
88}
89
90impl Default for Alignment {
91 fn default() -> Alignment {
92 Self::Min
93 }
94}
95