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
@@ -0,0 +1,93 @@
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 ..YGPixelGrid import YGRoundValueToPixelGrid
11
+ from ..algorithm.SizingMode import SizingMode
12
+ from ..numeric.Comparison import inexactEquals, isDefined
13
+
14
+
15
+ def sizeIsExactAndMatchesOldMeasuredSize(sizeMode: SizingMode, size: float, lastComputedSize: float) -> bool:
16
+ return sizeMode == SizingMode.StretchFit and inexactEquals(size, lastComputedSize)
17
+
18
+
19
+ def oldSizeIsMaxContentAndStillFits(
20
+ sizeMode: SizingMode,
21
+ size: float,
22
+ lastSizeMode: SizingMode,
23
+ lastComputedSize: float,
24
+ ) -> bool:
25
+ return sizeMode == SizingMode.FitContent and lastSizeMode == SizingMode.MaxContent and (
26
+ size >= lastComputedSize or inexactEquals(size, lastComputedSize)
27
+ )
28
+
29
+
30
+ def newSizeIsStricterAndStillValid(
31
+ sizeMode: SizingMode,
32
+ size: float,
33
+ lastSizeMode: SizingMode,
34
+ lastSize: float,
35
+ lastComputedSize: float,
36
+ ) -> bool:
37
+ return (
38
+ lastSizeMode == SizingMode.FitContent
39
+ and sizeMode == SizingMode.FitContent
40
+ and isDefined(lastSize)
41
+ and isDefined(size)
42
+ and isDefined(lastComputedSize)
43
+ and lastSize > size
44
+ and (lastComputedSize <= size or inexactEquals(size, lastComputedSize))
45
+ )
46
+
47
+
48
+ def canUseCachedMeasurement(
49
+ widthMode: SizingMode,
50
+ availableWidth: float,
51
+ heightMode: SizingMode,
52
+ availableHeight: float,
53
+ lastWidthMode: SizingMode,
54
+ lastAvailableWidth: float,
55
+ lastHeightMode: SizingMode,
56
+ lastAvailableHeight: float,
57
+ lastComputedWidth: float,
58
+ lastComputedHeight: float,
59
+ marginRow: float,
60
+ marginColumn: float,
61
+ config,
62
+ ) -> bool:
63
+ if (isDefined(lastComputedHeight) and lastComputedHeight < 0) or (isDefined(lastComputedWidth) and lastComputedWidth < 0):
64
+ return False
65
+
66
+ pointScaleFactor = config.getPointScaleFactor() if config is not None else 0.0
67
+ useRoundedComparison = config is not None and pointScaleFactor != 0
68
+ effectiveWidth = YGRoundValueToPixelGrid(availableWidth, pointScaleFactor, False, False) if useRoundedComparison else availableWidth
69
+ effectiveHeight = YGRoundValueToPixelGrid(availableHeight, pointScaleFactor, False, False) if useRoundedComparison else availableHeight
70
+ effectiveLastWidth = YGRoundValueToPixelGrid(lastAvailableWidth, pointScaleFactor, False, False) if useRoundedComparison else lastAvailableWidth
71
+ effectiveLastHeight = YGRoundValueToPixelGrid(lastAvailableHeight, pointScaleFactor, False, False) if useRoundedComparison else lastAvailableHeight
72
+
73
+ hasSameWidthSpec = lastWidthMode == widthMode and inexactEquals(effectiveLastWidth, effectiveWidth)
74
+ hasSameHeightSpec = lastHeightMode == heightMode and inexactEquals(effectiveLastHeight, effectiveHeight)
75
+
76
+ widthIsCompatible = hasSameWidthSpec or sizeIsExactAndMatchesOldMeasuredSize(
77
+ widthMode, availableWidth - marginRow, lastComputedWidth
78
+ ) or oldSizeIsMaxContentAndStillFits(
79
+ widthMode, availableWidth - marginRow, lastWidthMode, lastComputedWidth
80
+ ) or newSizeIsStricterAndStillValid(
81
+ widthMode, availableWidth - marginRow, lastWidthMode, lastAvailableWidth, lastComputedWidth
82
+ )
83
+
84
+ heightIsCompatible = hasSameHeightSpec or sizeIsExactAndMatchesOldMeasuredSize(
85
+ heightMode, availableHeight - marginColumn, lastComputedHeight
86
+ ) or oldSizeIsMaxContentAndStillFits(
87
+ heightMode, availableHeight - marginColumn, lastHeightMode, lastComputedHeight
88
+ ) or newSizeIsStricterAndStillValid(
89
+ heightMode, availableHeight - marginColumn, lastHeightMode, lastAvailableHeight, lastComputedHeight
90
+ )
91
+
92
+ return widthIsCompatible and heightIsCompatible
93
+