yoga-layout-python 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. yoga/YGConfig.py +92 -0
  2. yoga/YGEnums.py +404 -0
  3. yoga/YGMacros.py +9 -0
  4. yoga/YGNode.py +367 -0
  5. yoga/YGNodeLayout.py +81 -0
  6. yoga/YGNodeStyle.py +876 -0
  7. yoga/YGPixelGrid.py +42 -0
  8. yoga/YGValue.py +49 -0
  9. yoga/__init__.py +16 -0
  10. yoga/algorithm/AbsoluteLayout.py +417 -0
  11. yoga/algorithm/Align.py +34 -0
  12. yoga/algorithm/Baseline.py +54 -0
  13. yoga/algorithm/BoundAxis.py +55 -0
  14. yoga/algorithm/Cache.py +93 -0
  15. yoga/algorithm/CalculateLayout.py +1651 -0
  16. yoga/algorithm/FlexDirection.py +76 -0
  17. yoga/algorithm/FlexLine.py +130 -0
  18. yoga/algorithm/PixelGrid.py +56 -0
  19. yoga/algorithm/SizingMode.py +39 -0
  20. yoga/algorithm/TrailingPosition.py +34 -0
  21. yoga/algorithm/__init__.py +18 -0
  22. yoga/config/Config.py +137 -0
  23. yoga/config/__init__.py +9 -0
  24. yoga/debug/AssertFatal.py +24 -0
  25. yoga/debug/Log.py +49 -0
  26. yoga/debug/__init__.py +10 -0
  27. yoga/event/__init__.py +9 -0
  28. yoga/event/event.py +123 -0
  29. yoga/node/CachedMeasurement.py +51 -0
  30. yoga/node/LayoutResults.py +225 -0
  31. yoga/node/LayoutableChildren.py +79 -0
  32. yoga/node/Node.py +566 -0
  33. yoga/node/__init__.py +11 -0
  34. yoga/numeric/Comparison.py +46 -0
  35. yoga/numeric/FloatMath.py +24 -0
  36. yoga/numeric/FloatOptional.py +65 -0
  37. yoga/numeric/__init__.py +10 -0
  38. yoga/style/GridLine.py +44 -0
  39. yoga/style/GridTrack.py +47 -0
  40. yoga/style/SmallValueBuffer.py +133 -0
  41. yoga/style/Style.py +763 -0
  42. yoga/style/StyleLength.py +88 -0
  43. yoga/style/StyleSizeLength.py +117 -0
  44. yoga/style/StyleValueHandle.py +98 -0
  45. yoga/style/StyleValuePool.py +191 -0
  46. yoga/style/__init__.py +16 -0
  47. yoga_layout_python-0.1.0.dist-info/METADATA +158 -0
  48. yoga_layout_python-0.1.0.dist-info/RECORD +51 -0
  49. yoga_layout_python-0.1.0.dist-info/WHEEL +5 -0
  50. yoga_layout_python-0.1.0.dist-info/licenses/LICENSE +21 -0
  51. yoga_layout_python-0.1.0.dist-info/top_level.txt +1 -0
yoga/YGConfig.py ADDED
@@ -0,0 +1,92 @@
1
+ """
2
+ Copyright (c) Meta Platforms, Inc. and affiliates.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file in the root directory of this source tree.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from typing import Any
11
+
12
+ from .YGEnums import YGErrata, YGExperimentalFeature
13
+ from .config.Config import Config, _default_logger, getDefaultConfig, resolveRef
14
+
15
+
16
+ YGConfigRef = Config
17
+ YGConfigConstRef = Config
18
+ YGNodeRef = Any
19
+ YGNodeConstRef = Any
20
+ YGLogger = Any
21
+ YGCloneNodeFunc = Any
22
+
23
+
24
+ def YGConfigNew() -> YGConfigRef:
25
+ return Config(logger_=_default_logger)
26
+
27
+
28
+ def YGConfigFree(config: YGConfigRef) -> None:
29
+ del config
30
+
31
+
32
+ def YGConfigGetDefault() -> YGConfigConstRef:
33
+ return getDefaultConfig()
34
+
35
+
36
+ def YGConfigSetUseWebDefaults(config: YGConfigRef, enabled: bool) -> None:
37
+ resolveRef(config).setUseWebDefaults(enabled)
38
+
39
+
40
+ def YGConfigGetUseWebDefaults(config: YGConfigConstRef) -> bool:
41
+ return resolveRef(config).useWebDefaults()
42
+
43
+
44
+ def YGConfigSetPointScaleFactor(config: YGConfigRef, pixelsInPoint: float) -> None:
45
+ configRef = resolveRef(config)
46
+ if pixelsInPoint < 0.0:
47
+ raise ValueError("Scale factor should not be less than zero")
48
+ configRef.setPointScaleFactor(pixelsInPoint)
49
+
50
+
51
+ def YGConfigGetPointScaleFactor(config: YGConfigConstRef) -> float:
52
+ return resolveRef(config).getPointScaleFactor()
53
+
54
+
55
+ def YGConfigSetErrata(config: YGConfigRef, errata: YGErrata) -> None:
56
+ resolveRef(config).setErrata(errata)
57
+
58
+
59
+ def YGConfigGetErrata(config: YGConfigConstRef) -> YGErrata:
60
+ return resolveRef(config).getErrata()
61
+
62
+
63
+ def YGConfigSetLogger(config: YGConfigRef, logger: YGLogger) -> None:
64
+ configRef = resolveRef(config)
65
+ if logger is not None:
66
+ configRef.setLogger(logger)
67
+ else:
68
+ configRef.setLogger(_default_logger)
69
+
70
+
71
+ def YGConfigSetContext(config: YGConfigRef, context: object) -> None:
72
+ resolveRef(config).setContext(context)
73
+
74
+
75
+ def YGConfigGetContext(config: YGConfigConstRef) -> object:
76
+ return resolveRef(config).getContext()
77
+
78
+
79
+ def YGConfigSetExperimentalFeatureEnabled(
80
+ config: YGConfigRef, feature: YGExperimentalFeature, enabled: bool
81
+ ) -> None:
82
+ resolveRef(config).setExperimentalFeatureEnabled(feature, enabled)
83
+
84
+
85
+ def YGConfigIsExperimentalFeatureEnabled(
86
+ config: YGConfigConstRef, feature: YGExperimentalFeature
87
+ ) -> bool:
88
+ return resolveRef(config).isExperimentalFeatureEnabled(feature)
89
+
90
+
91
+ def YGConfigSetCloneNodeFunc(config: YGConfigRef, callback: YGCloneNodeFunc) -> None:
92
+ resolveRef(config).setCloneNodeCallback(callback)
yoga/YGEnums.py ADDED
@@ -0,0 +1,404 @@
1
+ """
2
+ Copyright (c) Meta Platforms, Inc. and affiliates.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file in the root directory of this source tree.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from enum import IntEnum, IntFlag
11
+
12
+
13
+ class YGAlign(IntEnum):
14
+ YGAlignAuto = 0
15
+ YGAlignFlexStart = 1
16
+ YGAlignCenter = 2
17
+ YGAlignFlexEnd = 3
18
+ YGAlignStretch = 4
19
+ YGAlignBaseline = 5
20
+ YGAlignSpaceBetween = 6
21
+ YGAlignSpaceAround = 7
22
+ YGAlignSpaceEvenly = 8
23
+ YGAlignStart = 9
24
+ YGAlignEnd = 10
25
+
26
+
27
+ class YGBoxSizing(IntEnum):
28
+ YGBoxSizingBorderBox = 0
29
+ YGBoxSizingContentBox = 1
30
+
31
+
32
+ class YGDimension(IntEnum):
33
+ YGDimensionWidth = 0
34
+ YGDimensionHeight = 1
35
+
36
+
37
+ class YGDirection(IntEnum):
38
+ YGDirectionInherit = 0
39
+ YGDirectionLTR = 1
40
+ YGDirectionRTL = 2
41
+
42
+
43
+ class YGDisplay(IntEnum):
44
+ YGDisplayFlex = 0
45
+ YGDisplayNone = 1
46
+ YGDisplayContents = 2
47
+ YGDisplayGrid = 3
48
+
49
+
50
+ class YGEdge(IntEnum):
51
+ YGEdgeLeft = 0
52
+ YGEdgeTop = 1
53
+ YGEdgeRight = 2
54
+ YGEdgeBottom = 3
55
+ YGEdgeStart = 4
56
+ YGEdgeEnd = 5
57
+ YGEdgeHorizontal = 6
58
+ YGEdgeVertical = 7
59
+ YGEdgeAll = 8
60
+
61
+
62
+ class YGErrata(IntFlag):
63
+ YGErrataNone = 0
64
+ YGErrataStretchFlexBasis = 1
65
+ YGErrataAbsolutePositionWithoutInsetsExcludesPadding = 2
66
+ YGErrataAbsolutePercentAgainstInnerSize = 4
67
+ YGErrataAll = 2147483647
68
+ YGErrataClassic = 2147483646
69
+
70
+
71
+ class YGExperimentalFeature(IntEnum):
72
+ YGExperimentalFeatureWebFlexBasis = 0
73
+
74
+
75
+ class YGFlexDirection(IntEnum):
76
+ YGFlexDirectionColumn = 0
77
+ YGFlexDirectionColumnReverse = 1
78
+ YGFlexDirectionRow = 2
79
+ YGFlexDirectionRowReverse = 3
80
+
81
+
82
+ class YGGridTrackType(IntEnum):
83
+ YGGridTrackTypeAuto = 0
84
+ YGGridTrackTypePoints = 1
85
+ YGGridTrackTypePercent = 2
86
+ YGGridTrackTypeFr = 3
87
+ YGGridTrackTypeMinmax = 4
88
+
89
+
90
+ class YGGutter(IntEnum):
91
+ YGGutterColumn = 0
92
+ YGGutterRow = 1
93
+ YGGutterAll = 2
94
+
95
+
96
+ class YGJustify(IntEnum):
97
+ YGJustifyAuto = 0
98
+ YGJustifyFlexStart = 1
99
+ YGJustifyCenter = 2
100
+ YGJustifyFlexEnd = 3
101
+ YGJustifySpaceBetween = 4
102
+ YGJustifySpaceAround = 5
103
+ YGJustifySpaceEvenly = 6
104
+ YGJustifyStretch = 7
105
+ YGJustifyStart = 8
106
+ YGJustifyEnd = 9
107
+
108
+
109
+ class YGLogLevel(IntEnum):
110
+ YGLogLevelError = 0
111
+ YGLogLevelWarn = 1
112
+ YGLogLevelInfo = 2
113
+ YGLogLevelDebug = 3
114
+ YGLogLevelVerbose = 4
115
+ YGLogLevelFatal = 5
116
+
117
+
118
+ class YGMeasureMode(IntEnum):
119
+ YGMeasureModeUndefined = 0
120
+ YGMeasureModeExactly = 1
121
+ YGMeasureModeAtMost = 2
122
+
123
+
124
+ class YGNodeType(IntEnum):
125
+ YGNodeTypeDefault = 0
126
+ YGNodeTypeText = 1
127
+
128
+
129
+ class YGOverflow(IntEnum):
130
+ YGOverflowVisible = 0
131
+ YGOverflowHidden = 1
132
+ YGOverflowScroll = 2
133
+
134
+
135
+ class YGPositionType(IntEnum):
136
+ YGPositionTypeStatic = 0
137
+ YGPositionTypeRelative = 1
138
+ YGPositionTypeAbsolute = 2
139
+
140
+
141
+ class YGUnit(IntEnum):
142
+ YGUnitUndefined = 0
143
+ YGUnitPoint = 1
144
+ YGUnitPercent = 2
145
+ YGUnitAuto = 3
146
+ YGUnitMaxContent = 4
147
+ YGUnitFitContent = 5
148
+ YGUnitStretch = 6
149
+
150
+
151
+ class YGWrap(IntEnum):
152
+ YGWrapNoWrap = 0
153
+ YGWrapWrap = 1
154
+ YGWrapWrapReverse = 2
155
+
156
+
157
+ def YGAlignToString(value: YGAlign) -> str:
158
+ if value == YGAlign.YGAlignAuto:
159
+ return "auto"
160
+ if value == YGAlign.YGAlignFlexStart:
161
+ return "flex-start"
162
+ if value == YGAlign.YGAlignCenter:
163
+ return "center"
164
+ if value == YGAlign.YGAlignFlexEnd:
165
+ return "flex-end"
166
+ if value == YGAlign.YGAlignStretch:
167
+ return "stretch"
168
+ if value == YGAlign.YGAlignBaseline:
169
+ return "baseline"
170
+ if value == YGAlign.YGAlignSpaceBetween:
171
+ return "space-between"
172
+ if value == YGAlign.YGAlignSpaceAround:
173
+ return "space-around"
174
+ if value == YGAlign.YGAlignSpaceEvenly:
175
+ return "space-evenly"
176
+ if value == YGAlign.YGAlignStart:
177
+ return "start"
178
+ if value == YGAlign.YGAlignEnd:
179
+ return "end"
180
+ return "unknown"
181
+
182
+
183
+ def YGBoxSizingToString(value: YGBoxSizing) -> str:
184
+ if value == YGBoxSizing.YGBoxSizingBorderBox:
185
+ return "border-box"
186
+ if value == YGBoxSizing.YGBoxSizingContentBox:
187
+ return "content-box"
188
+ return "unknown"
189
+
190
+
191
+ def YGDimensionToString(value: YGDimension) -> str:
192
+ if value == YGDimension.YGDimensionWidth:
193
+ return "width"
194
+ if value == YGDimension.YGDimensionHeight:
195
+ return "height"
196
+ return "unknown"
197
+
198
+
199
+ def YGDirectionToString(value: YGDirection) -> str:
200
+ if value == YGDirection.YGDirectionInherit:
201
+ return "inherit"
202
+ if value == YGDirection.YGDirectionLTR:
203
+ return "ltr"
204
+ if value == YGDirection.YGDirectionRTL:
205
+ return "rtl"
206
+ return "unknown"
207
+
208
+
209
+ def YGDisplayToString(value: YGDisplay) -> str:
210
+ if value == YGDisplay.YGDisplayFlex:
211
+ return "flex"
212
+ if value == YGDisplay.YGDisplayNone:
213
+ return "none"
214
+ if value == YGDisplay.YGDisplayContents:
215
+ return "contents"
216
+ if value == YGDisplay.YGDisplayGrid:
217
+ return "grid"
218
+ return "unknown"
219
+
220
+
221
+ def YGEdgeToString(value: YGEdge) -> str:
222
+ if value == YGEdge.YGEdgeLeft:
223
+ return "left"
224
+ if value == YGEdge.YGEdgeTop:
225
+ return "top"
226
+ if value == YGEdge.YGEdgeRight:
227
+ return "right"
228
+ if value == YGEdge.YGEdgeBottom:
229
+ return "bottom"
230
+ if value == YGEdge.YGEdgeStart:
231
+ return "start"
232
+ if value == YGEdge.YGEdgeEnd:
233
+ return "end"
234
+ if value == YGEdge.YGEdgeHorizontal:
235
+ return "horizontal"
236
+ if value == YGEdge.YGEdgeVertical:
237
+ return "vertical"
238
+ if value == YGEdge.YGEdgeAll:
239
+ return "all"
240
+ return "unknown"
241
+
242
+
243
+ def YGErrataToString(value: YGErrata) -> str:
244
+ if value == YGErrata.YGErrataNone:
245
+ return "none"
246
+ if value == YGErrata.YGErrataStretchFlexBasis:
247
+ return "stretch-flex-basis"
248
+ if value == YGErrata.YGErrataAbsolutePositionWithoutInsetsExcludesPadding:
249
+ return "absolute-position-without-insets-excludes-padding"
250
+ if value == YGErrata.YGErrataAbsolutePercentAgainstInnerSize:
251
+ return "absolute-percent-against-inner-size"
252
+ if value == YGErrata.YGErrataAll:
253
+ return "all"
254
+ if value == YGErrata.YGErrataClassic:
255
+ return "classic"
256
+ return "unknown"
257
+
258
+
259
+ def YGExperimentalFeatureToString(value: YGExperimentalFeature) -> str:
260
+ if value == YGExperimentalFeature.YGExperimentalFeatureWebFlexBasis:
261
+ return "web-flex-basis"
262
+ return "unknown"
263
+
264
+
265
+ def YGFlexDirectionToString(value: YGFlexDirection) -> str:
266
+ if value == YGFlexDirection.YGFlexDirectionColumn:
267
+ return "column"
268
+ if value == YGFlexDirection.YGFlexDirectionColumnReverse:
269
+ return "column-reverse"
270
+ if value == YGFlexDirection.YGFlexDirectionRow:
271
+ return "row"
272
+ if value == YGFlexDirection.YGFlexDirectionRowReverse:
273
+ return "row-reverse"
274
+ return "unknown"
275
+
276
+
277
+ def YGGridTrackTypeToString(value: YGGridTrackType) -> str:
278
+ if value == YGGridTrackType.YGGridTrackTypeAuto:
279
+ return "auto"
280
+ if value == YGGridTrackType.YGGridTrackTypePoints:
281
+ return "points"
282
+ if value == YGGridTrackType.YGGridTrackTypePercent:
283
+ return "percent"
284
+ if value == YGGridTrackType.YGGridTrackTypeFr:
285
+ return "fr"
286
+ if value == YGGridTrackType.YGGridTrackTypeMinmax:
287
+ return "minmax"
288
+ return "unknown"
289
+
290
+
291
+ def YGGutterToString(value: YGGutter) -> str:
292
+ if value == YGGutter.YGGutterColumn:
293
+ return "column"
294
+ if value == YGGutter.YGGutterRow:
295
+ return "row"
296
+ if value == YGGutter.YGGutterAll:
297
+ return "all"
298
+ return "unknown"
299
+
300
+
301
+ def YGJustifyToString(value: YGJustify) -> str:
302
+ if value == YGJustify.YGJustifyAuto:
303
+ return "auto"
304
+ if value == YGJustify.YGJustifyFlexStart:
305
+ return "flex-start"
306
+ if value == YGJustify.YGJustifyCenter:
307
+ return "center"
308
+ if value == YGJustify.YGJustifyFlexEnd:
309
+ return "flex-end"
310
+ if value == YGJustify.YGJustifySpaceBetween:
311
+ return "space-between"
312
+ if value == YGJustify.YGJustifySpaceAround:
313
+ return "space-around"
314
+ if value == YGJustify.YGJustifySpaceEvenly:
315
+ return "space-evenly"
316
+ if value == YGJustify.YGJustifyStretch:
317
+ return "stretch"
318
+ if value == YGJustify.YGJustifyStart:
319
+ return "start"
320
+ if value == YGJustify.YGJustifyEnd:
321
+ return "end"
322
+ return "unknown"
323
+
324
+
325
+ def YGLogLevelToString(value: YGLogLevel) -> str:
326
+ if value == YGLogLevel.YGLogLevelError:
327
+ return "error"
328
+ if value == YGLogLevel.YGLogLevelWarn:
329
+ return "warn"
330
+ if value == YGLogLevel.YGLogLevelInfo:
331
+ return "info"
332
+ if value == YGLogLevel.YGLogLevelDebug:
333
+ return "debug"
334
+ if value == YGLogLevel.YGLogLevelVerbose:
335
+ return "verbose"
336
+ if value == YGLogLevel.YGLogLevelFatal:
337
+ return "fatal"
338
+ return "unknown"
339
+
340
+
341
+ def YGMeasureModeToString(value: YGMeasureMode) -> str:
342
+ if value == YGMeasureMode.YGMeasureModeUndefined:
343
+ return "undefined"
344
+ if value == YGMeasureMode.YGMeasureModeExactly:
345
+ return "exactly"
346
+ if value == YGMeasureMode.YGMeasureModeAtMost:
347
+ return "at-most"
348
+ return "unknown"
349
+
350
+
351
+ def YGNodeTypeToString(value: YGNodeType) -> str:
352
+ if value == YGNodeType.YGNodeTypeDefault:
353
+ return "default"
354
+ if value == YGNodeType.YGNodeTypeText:
355
+ return "text"
356
+ return "unknown"
357
+
358
+
359
+ def YGOverflowToString(value: YGOverflow) -> str:
360
+ if value == YGOverflow.YGOverflowVisible:
361
+ return "visible"
362
+ if value == YGOverflow.YGOverflowHidden:
363
+ return "hidden"
364
+ if value == YGOverflow.YGOverflowScroll:
365
+ return "scroll"
366
+ return "unknown"
367
+
368
+
369
+ def YGPositionTypeToString(value: YGPositionType) -> str:
370
+ if value == YGPositionType.YGPositionTypeStatic:
371
+ return "static"
372
+ if value == YGPositionType.YGPositionTypeRelative:
373
+ return "relative"
374
+ if value == YGPositionType.YGPositionTypeAbsolute:
375
+ return "absolute"
376
+ return "unknown"
377
+
378
+
379
+ def YGUnitToString(value: YGUnit) -> str:
380
+ if value == YGUnit.YGUnitUndefined:
381
+ return "undefined"
382
+ if value == YGUnit.YGUnitPoint:
383
+ return "point"
384
+ if value == YGUnit.YGUnitPercent:
385
+ return "percent"
386
+ if value == YGUnit.YGUnitAuto:
387
+ return "auto"
388
+ if value == YGUnit.YGUnitMaxContent:
389
+ return "max-content"
390
+ if value == YGUnit.YGUnitFitContent:
391
+ return "fit-content"
392
+ if value == YGUnit.YGUnitStretch:
393
+ return "stretch"
394
+ return "unknown"
395
+
396
+
397
+ def YGWrapToString(value: YGWrap) -> str:
398
+ if value == YGWrap.YGWrapNoWrap:
399
+ return "no-wrap"
400
+ if value == YGWrap.YGWrapWrap:
401
+ return "wrap"
402
+ if value == YGWrap.YGWrapWrapReverse:
403
+ return "wrap-reverse"
404
+ return "unknown"
yoga/YGMacros.py ADDED
@@ -0,0 +1,9 @@
1
+ """
2
+ Copyright (c) Meta Platforms, Inc. and affiliates.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file in the root directory of this source tree.
6
+ """
7
+
8
+ # Yoga's C/C++ macro layer has no runtime meaning in Python.
9
+