1
1
use crate :: {
2
- AlignContent , AlignItems , AlignSelf , Direction , Display , FlexDirection , FlexWrap ,
3
- JustifyContent , PositionType , Size , Style , UiRect , Val ,
2
+ AlignContent , AlignItems , AlignSelf , Display , FlexDirection , FlexWrap , JustifyContent ,
3
+ PositionType , Size , Style , UiRect , Val ,
4
4
} ;
5
5
6
6
pub fn from_rect (
7
7
scale_factor : f64 ,
8
8
rect : UiRect < Val > ,
9
- ) -> stretch :: geometry:: Rect < stretch :: style:: Dimension > {
10
- stretch :: geometry:: Rect {
9
+ ) -> taffy :: geometry:: Rect < taffy :: style:: Dimension > {
10
+ taffy :: geometry:: Rect {
11
11
start : from_val ( scale_factor, rect. left ) ,
12
12
end : from_val ( scale_factor, rect. right ) ,
13
13
// NOTE: top and bottom are intentionally flipped. stretch has a flipped y-axis
@@ -16,8 +16,8 @@ pub fn from_rect(
16
16
}
17
17
}
18
18
19
- pub fn from_f32_size ( scale_factor : f64 , size : Size < f32 > ) -> stretch :: geometry:: Size < f32 > {
20
- stretch :: geometry:: Size {
19
+ pub fn from_f32_size ( scale_factor : f64 , size : Size < f32 > ) -> taffy :: geometry:: Size < f32 > {
20
+ taffy :: geometry:: Size {
21
21
width : ( scale_factor * size. width as f64 ) as f32 ,
22
22
height : ( scale_factor * size. height as f64 ) as f32 ,
23
23
}
@@ -26,19 +26,17 @@ pub fn from_f32_size(scale_factor: f64, size: Size<f32>) -> stretch::geometry::S
26
26
pub fn from_val_size (
27
27
scale_factor : f64 ,
28
28
size : Size < Val > ,
29
- ) -> stretch :: geometry:: Size < stretch :: style:: Dimension > {
30
- stretch :: geometry:: Size {
29
+ ) -> taffy :: geometry:: Size < taffy :: style:: Dimension > {
30
+ taffy :: geometry:: Size {
31
31
width : from_val ( scale_factor, size. width ) ,
32
32
height : from_val ( scale_factor, size. height ) ,
33
33
}
34
34
}
35
35
36
- pub fn from_style ( scale_factor : f64 , value : & Style ) -> stretch:: style:: Style {
37
- stretch:: style:: Style {
38
- overflow : stretch:: style:: Overflow :: Visible ,
36
+ pub fn from_style ( scale_factor : f64 , value : & Style ) -> taffy:: style:: Style {
37
+ taffy:: style:: Style {
39
38
display : value. display . into ( ) ,
40
39
position_type : value. position_type . into ( ) ,
41
- direction : value. direction . into ( ) ,
42
40
flex_direction : value. flex_direction . into ( ) ,
43
41
flex_wrap : value. flex_wrap . into ( ) ,
44
42
align_items : value. align_items . into ( ) ,
@@ -56,117 +54,107 @@ pub fn from_style(scale_factor: f64, value: &Style) -> stretch::style::Style {
56
54
min_size : from_val_size ( scale_factor, value. min_size ) ,
57
55
max_size : from_val_size ( scale_factor, value. max_size ) ,
58
56
aspect_ratio : match value. aspect_ratio {
59
- Some ( value) => stretch :: number:: Number :: Defined ( value) ,
60
- None => stretch :: number:: Number :: Undefined ,
57
+ Some ( value) => taffy :: number:: Number :: Defined ( value) ,
58
+ None => taffy :: number:: Number :: Undefined ,
61
59
} ,
62
60
}
63
61
}
64
62
65
- pub fn from_val ( scale_factor : f64 , val : Val ) -> stretch :: style:: Dimension {
63
+ pub fn from_val ( scale_factor : f64 , val : Val ) -> taffy :: style:: Dimension {
66
64
match val {
67
- Val :: Auto => stretch :: style:: Dimension :: Auto ,
68
- Val :: Percent ( value) => stretch :: style:: Dimension :: Percent ( value / 100.0 ) ,
69
- Val :: Px ( value) => stretch :: style:: Dimension :: Points ( ( scale_factor * value as f64 ) as f32 ) ,
70
- Val :: Undefined => stretch :: style:: Dimension :: Undefined ,
65
+ Val :: Auto => taffy :: style:: Dimension :: Auto ,
66
+ Val :: Percent ( value) => taffy :: style:: Dimension :: Percent ( value / 100.0 ) ,
67
+ Val :: Px ( value) => taffy :: style:: Dimension :: Points ( ( scale_factor * value as f64 ) as f32 ) ,
68
+ Val :: Undefined => taffy :: style:: Dimension :: Undefined ,
71
69
}
72
70
}
73
71
74
- impl From < AlignItems > for stretch :: style:: AlignItems {
72
+ impl From < AlignItems > for taffy :: style:: AlignItems {
75
73
fn from ( value : AlignItems ) -> Self {
76
74
match value {
77
- AlignItems :: FlexStart => stretch :: style:: AlignItems :: FlexStart ,
78
- AlignItems :: FlexEnd => stretch :: style:: AlignItems :: FlexEnd ,
79
- AlignItems :: Center => stretch :: style:: AlignItems :: Center ,
80
- AlignItems :: Baseline => stretch :: style:: AlignItems :: Baseline ,
81
- AlignItems :: Stretch => stretch :: style:: AlignItems :: Stretch ,
75
+ AlignItems :: FlexStart => taffy :: style:: AlignItems :: FlexStart ,
76
+ AlignItems :: FlexEnd => taffy :: style:: AlignItems :: FlexEnd ,
77
+ AlignItems :: Center => taffy :: style:: AlignItems :: Center ,
78
+ AlignItems :: Baseline => taffy :: style:: AlignItems :: Baseline ,
79
+ AlignItems :: Stretch => taffy :: style:: AlignItems :: Stretch ,
82
80
}
83
81
}
84
82
}
85
83
86
- impl From < AlignSelf > for stretch :: style:: AlignSelf {
84
+ impl From < AlignSelf > for taffy :: style:: AlignSelf {
87
85
fn from ( value : AlignSelf ) -> Self {
88
86
match value {
89
- AlignSelf :: Auto => stretch :: style:: AlignSelf :: Auto ,
90
- AlignSelf :: FlexStart => stretch :: style:: AlignSelf :: FlexStart ,
91
- AlignSelf :: FlexEnd => stretch :: style:: AlignSelf :: FlexEnd ,
92
- AlignSelf :: Center => stretch :: style:: AlignSelf :: Center ,
93
- AlignSelf :: Baseline => stretch :: style:: AlignSelf :: Baseline ,
94
- AlignSelf :: Stretch => stretch :: style:: AlignSelf :: Stretch ,
87
+ AlignSelf :: Auto => taffy :: style:: AlignSelf :: Auto ,
88
+ AlignSelf :: FlexStart => taffy :: style:: AlignSelf :: FlexStart ,
89
+ AlignSelf :: FlexEnd => taffy :: style:: AlignSelf :: FlexEnd ,
90
+ AlignSelf :: Center => taffy :: style:: AlignSelf :: Center ,
91
+ AlignSelf :: Baseline => taffy :: style:: AlignSelf :: Baseline ,
92
+ AlignSelf :: Stretch => taffy :: style:: AlignSelf :: Stretch ,
95
93
}
96
94
}
97
95
}
98
96
99
- impl From < AlignContent > for stretch :: style:: AlignContent {
97
+ impl From < AlignContent > for taffy :: style:: AlignContent {
100
98
fn from ( value : AlignContent ) -> Self {
101
99
match value {
102
- AlignContent :: FlexStart => stretch :: style:: AlignContent :: FlexStart ,
103
- AlignContent :: FlexEnd => stretch :: style:: AlignContent :: FlexEnd ,
104
- AlignContent :: Center => stretch :: style:: AlignContent :: Center ,
105
- AlignContent :: Stretch => stretch :: style:: AlignContent :: Stretch ,
106
- AlignContent :: SpaceBetween => stretch :: style:: AlignContent :: SpaceBetween ,
107
- AlignContent :: SpaceAround => stretch :: style:: AlignContent :: SpaceAround ,
100
+ AlignContent :: FlexStart => taffy :: style:: AlignContent :: FlexStart ,
101
+ AlignContent :: FlexEnd => taffy :: style:: AlignContent :: FlexEnd ,
102
+ AlignContent :: Center => taffy :: style:: AlignContent :: Center ,
103
+ AlignContent :: Stretch => taffy :: style:: AlignContent :: Stretch ,
104
+ AlignContent :: SpaceBetween => taffy :: style:: AlignContent :: SpaceBetween ,
105
+ AlignContent :: SpaceAround => taffy :: style:: AlignContent :: SpaceAround ,
108
106
}
109
107
}
110
108
}
111
109
112
- impl From < Direction > for stretch:: style:: Direction {
113
- fn from ( value : Direction ) -> Self {
114
- match value {
115
- Direction :: Inherit => stretch:: style:: Direction :: Inherit ,
116
- Direction :: LeftToRight => stretch:: style:: Direction :: LTR ,
117
- Direction :: RightToLeft => stretch:: style:: Direction :: RTL ,
118
- }
119
- }
120
- }
121
-
122
- impl From < Display > for stretch:: style:: Display {
110
+ impl From < Display > for taffy:: style:: Display {
123
111
fn from ( value : Display ) -> Self {
124
112
match value {
125
- Display :: Flex => stretch :: style:: Display :: Flex ,
126
- Display :: None => stretch :: style:: Display :: None ,
113
+ Display :: Flex => taffy :: style:: Display :: Flex ,
114
+ Display :: None => taffy :: style:: Display :: None ,
127
115
}
128
116
}
129
117
}
130
118
131
- impl From < FlexDirection > for stretch :: style:: FlexDirection {
119
+ impl From < FlexDirection > for taffy :: style:: FlexDirection {
132
120
fn from ( value : FlexDirection ) -> Self {
133
121
match value {
134
- FlexDirection :: Row => stretch :: style:: FlexDirection :: Row ,
135
- FlexDirection :: Column => stretch :: style:: FlexDirection :: Column ,
136
- FlexDirection :: RowReverse => stretch :: style:: FlexDirection :: RowReverse ,
137
- FlexDirection :: ColumnReverse => stretch :: style:: FlexDirection :: ColumnReverse ,
122
+ FlexDirection :: Row => taffy :: style:: FlexDirection :: Row ,
123
+ FlexDirection :: Column => taffy :: style:: FlexDirection :: Column ,
124
+ FlexDirection :: RowReverse => taffy :: style:: FlexDirection :: RowReverse ,
125
+ FlexDirection :: ColumnReverse => taffy :: style:: FlexDirection :: ColumnReverse ,
138
126
}
139
127
}
140
128
}
141
129
142
- impl From < JustifyContent > for stretch :: style:: JustifyContent {
130
+ impl From < JustifyContent > for taffy :: style:: JustifyContent {
143
131
fn from ( value : JustifyContent ) -> Self {
144
132
match value {
145
- JustifyContent :: FlexStart => stretch :: style:: JustifyContent :: FlexStart ,
146
- JustifyContent :: FlexEnd => stretch :: style:: JustifyContent :: FlexEnd ,
147
- JustifyContent :: Center => stretch :: style:: JustifyContent :: Center ,
148
- JustifyContent :: SpaceBetween => stretch :: style:: JustifyContent :: SpaceBetween ,
149
- JustifyContent :: SpaceAround => stretch :: style:: JustifyContent :: SpaceAround ,
150
- JustifyContent :: SpaceEvenly => stretch :: style:: JustifyContent :: SpaceEvenly ,
133
+ JustifyContent :: FlexStart => taffy :: style:: JustifyContent :: FlexStart ,
134
+ JustifyContent :: FlexEnd => taffy :: style:: JustifyContent :: FlexEnd ,
135
+ JustifyContent :: Center => taffy :: style:: JustifyContent :: Center ,
136
+ JustifyContent :: SpaceBetween => taffy :: style:: JustifyContent :: SpaceBetween ,
137
+ JustifyContent :: SpaceAround => taffy :: style:: JustifyContent :: SpaceAround ,
138
+ JustifyContent :: SpaceEvenly => taffy :: style:: JustifyContent :: SpaceEvenly ,
151
139
}
152
140
}
153
141
}
154
142
155
- impl From < PositionType > for stretch :: style:: PositionType {
143
+ impl From < PositionType > for taffy :: style:: PositionType {
156
144
fn from ( value : PositionType ) -> Self {
157
145
match value {
158
- PositionType :: Relative => stretch :: style:: PositionType :: Relative ,
159
- PositionType :: Absolute => stretch :: style:: PositionType :: Absolute ,
146
+ PositionType :: Relative => taffy :: style:: PositionType :: Relative ,
147
+ PositionType :: Absolute => taffy :: style:: PositionType :: Absolute ,
160
148
}
161
149
}
162
150
}
163
151
164
- impl From < FlexWrap > for stretch :: style:: FlexWrap {
152
+ impl From < FlexWrap > for taffy :: style:: FlexWrap {
165
153
fn from ( value : FlexWrap ) -> Self {
166
154
match value {
167
- FlexWrap :: NoWrap => stretch :: style:: FlexWrap :: NoWrap ,
168
- FlexWrap :: Wrap => stretch :: style:: FlexWrap :: Wrap ,
169
- FlexWrap :: WrapReverse => stretch :: style:: FlexWrap :: WrapReverse ,
155
+ FlexWrap :: NoWrap => taffy :: style:: FlexWrap :: NoWrap ,
156
+ FlexWrap :: Wrap => taffy :: style:: FlexWrap :: Wrap ,
157
+ FlexWrap :: WrapReverse => taffy :: style:: FlexWrap :: WrapReverse ,
170
158
}
171
159
}
172
160
}
0 commit comments