figma_api/models/
layout_constraint.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/// LayoutConstraint : Layout constraint relative to containing Frame
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct LayoutConstraint {
17    /// Vertical constraint (relative to containing frame) as an enum:  - `TOP`: Node is laid out relative to top of the containing frame - `BOTTOM`: Node is laid out relative to bottom of the containing frame - `CENTER`: Node is vertically centered relative to containing frame - `TOP_BOTTOM`: Both top and bottom of node are constrained relative to containing frame (node stretches with frame) - `SCALE`: Node scales vertically with containing frame
18    #[serde(rename = "vertical")]
19    pub vertical: Vertical,
20    /// Horizontal constraint (relative to containing frame) as an enum:  - `LEFT`: Node is laid out relative to left of the containing frame - `RIGHT`: Node is laid out relative to right of the containing frame - `CENTER`: Node is horizontally centered relative to containing frame - `LEFT_RIGHT`: Both left and right of node are constrained relative to containing frame (node stretches with frame) - `SCALE`: Node scales horizontally with containing frame
21    #[serde(rename = "horizontal")]
22    pub horizontal: Horizontal,
23}
24
25impl LayoutConstraint {
26    /// Layout constraint relative to containing Frame
27    pub fn new(vertical: Vertical, horizontal: Horizontal) -> LayoutConstraint {
28        LayoutConstraint {
29            vertical,
30            horizontal,
31        }
32    }
33}
34/// Vertical constraint (relative to containing frame) as an enum:  - `TOP`: Node is laid out relative to top of the containing frame - `BOTTOM`: Node is laid out relative to bottom of the containing frame - `CENTER`: Node is vertically centered relative to containing frame - `TOP_BOTTOM`: Both top and bottom of node are constrained relative to containing frame (node stretches with frame) - `SCALE`: Node scales vertically with containing frame
35#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
36pub enum Vertical {
37    #[serde(rename = "TOP")]
38    Top,
39    #[serde(rename = "BOTTOM")]
40    Bottom,
41    #[serde(rename = "CENTER")]
42    Center,
43    #[serde(rename = "TOP_BOTTOM")]
44    TopBottom,
45    #[serde(rename = "SCALE")]
46    Scale,
47}
48
49impl Default for Vertical {
50    fn default() -> Vertical {
51        Self::Top
52    }
53}
54/// Horizontal constraint (relative to containing frame) as an enum:  - `LEFT`: Node is laid out relative to left of the containing frame - `RIGHT`: Node is laid out relative to right of the containing frame - `CENTER`: Node is horizontally centered relative to containing frame - `LEFT_RIGHT`: Both left and right of node are constrained relative to containing frame (node stretches with frame) - `SCALE`: Node scales horizontally with containing frame
55#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
56pub enum Horizontal {
57    #[serde(rename = "LEFT")]
58    Left,
59    #[serde(rename = "RIGHT")]
60    Right,
61    #[serde(rename = "CENTER")]
62    Center,
63    #[serde(rename = "LEFT_RIGHT")]
64    LeftRight,
65    #[serde(rename = "SCALE")]
66    Scale,
67}
68
69impl Default for Horizontal {
70    fn default() -> Horizontal {
71        Self::Left
72    }
73}
74