about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-10-14 14:46:47 +0200
committerbptato <nincsnevem662@gmail.com>2023-10-14 14:47:22 +0200
commit15461c544e9718fde1e2627c082e91e848fe8d42 (patch)
treeff0d6c8035e119de8425364acd4df92a7580a808
parentd518a0dfa52ca3fc857eeb117147422f5f9ebdfc (diff)
downloadchawan-15461c544e9718fde1e2627c082e91e848fe8d42.tar.gz
layout: move Strut from box -> engine
-rw-r--r--src/layout/box.nim13
-rw-r--r--src/layout/engine.nim14
2 files changed, 14 insertions, 13 deletions
diff --git a/src/layout/box.nim b/src/layout/box.nim
index 82791103..7c764203 100644
--- a/src/layout/box.nim
+++ b/src/layout/box.nim
@@ -29,10 +29,6 @@ type
     t*: SizeConstraintType
     u*: LayoutUnit
 
-  Strut* = object
-    pos*: LayoutUnit
-    neg*: LayoutUnit
-
   Viewport* = ref object
     window*: WindowAttributes
     positioned*: seq[BlockBox]
@@ -204,15 +200,6 @@ type
     margin_top*: LayoutUnit
     margin_bottom*: LayoutUnit
 
-proc append*(a: var Strut, b: LayoutUnit) =
-  if b < 0:
-    a.neg = min(b, a.neg)
-  else:
-    a.pos = max(b, a.pos)
-
-func sum*(a: Strut): LayoutUnit =
-  return a.pos + a.neg
-
 func minContent*(): SizeConstraint =
   return SizeConstraint(t: MIN_CONTENT)
 
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index 99d98455..9cf45515 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -1058,6 +1058,20 @@ proc positionRelative(parent, box: BlockBox) =
   elif not top.auto:
     box.offset.y -= parent.height - bottom.px(parent.viewport) - box.height
 
+
+type Strut = object
+  pos: LayoutUnit
+  neg: LayoutUnit
+
+proc append(a: var Strut, b: LayoutUnit) =
+  if b < 0:
+    a.neg = min(b, a.neg)
+  else:
+    a.pos = max(b, a.pos)
+
+func sum(a: Strut): LayoutUnit =
+  return a.pos + a.neg
+
 proc applyChildPosition(parent, child: BlockBox, x, y: var LayoutUnit,
     margin_todo: var Strut, maxChildWidth, childHeight: var LayoutUnit) =
   if child.computed{"position"} == POSITION_ABSOLUTE: #TODO sticky, fixed