fyrox_ui/alignment.rs
1// Copyright (c) 2019-present Dmitry Stepanov and Fyrox Engine contributors.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in all
11// copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19// SOFTWARE.
20
21//! Alignment defines relative location of the widget to its parent widget. There are two kinds of alignment:
22//! [`HorizontalAlignment`] and [`VerticalAlignment`]. Check the docs for them for more info.
23
24use crate::core::{reflect::prelude::*, visitor::prelude::*};
25use fyrox_core::uuid_provider;
26use strum_macros::{AsRefStr, EnumString, VariantNames};
27
28/// Horizontal alignment defines relative location and size of the widget to its parent widget along horizontal
29/// (X) axis.
30#[derive(
31 Copy, Clone, PartialEq, Debug, Eq, Default, Reflect, Visit, AsRefStr, EnumString, VariantNames,
32)]
33pub enum HorizontalAlignment {
34 /// Tells the widget to take all available space along horizontal axis and stay at left side of the
35 /// parent widget. This is default horizontal alignment for all widgets.
36 #[default]
37 Stretch,
38 /// Tells the widget to stay at the left side of the parent widget and take as less space as
39 /// possible (shrink-to-fit).
40 Left,
41 /// Tells the widget to stay at the center of the parent widget and take as less space as possible
42 /// (shrink-to-fit).
43 Center,
44 /// Tells the widget to stay at the right side of the parent widget and take as less space as
45 /// possible (shrink-to-fit).
46 Right,
47}
48
49uuid_provider!(HorizontalAlignment = "ef571515-ec16-47ad-bfe3-ddc259e2c7d3");
50
51/// Horizontal alignment defines relative location and size of the widget to its parent widget along vertical
52/// (Y) axis.
53#[derive(
54 Copy, Clone, PartialEq, Debug, Eq, Default, Reflect, Visit, AsRefStr, EnumString, VariantNames,
55)]
56pub enum VerticalAlignment {
57 /// Tells the widget to take all available space along vertical axis and stay at top side of the
58 /// parent widget. This is default vertical alignment for all widgets.
59 #[default]
60 Stretch,
61 /// Tells the widget to stay at the top side of the parent widget and take as less space as
62 /// possible (shrink-to-fit).
63 Top,
64 /// Tells the widget to stay at the center of the parent widget and take as less space as possible
65 /// (shrink-to-fit).
66 Center,
67 /// Tells the widget to stay at the bottom side of the parent widget and take as less space as
68 /// possible (shrink-to-fit).
69 Bottom,
70}
71
72uuid_provider!(VerticalAlignment = "8555dc0d-c9b7-4c49-816a-a7f610a6886d");