about summary refs log tree commit diff stats
path: root/src/layout/box.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-06-04 19:03:23 +0200
committerbptato <nincsnevem662@gmail.com>2024-06-04 19:07:14 +0200
commitf081b787090045bb23c4de7bb4d866e963484b7f (patch)
tree882a708cc3192e841502f7c7efc8296402db9451 /src/layout/box.nim
parent3aa8f1e0694d1606c3f3795f8b83e8a82caacd3e (diff)
downloadchawan-f081b787090045bb23c4de7bb4d866e963484b7f.tar.gz
layout: track overflow size
Not very useful yet; partial layouting and/or a new renderer is probably
necessary to replace the current FormatCell-based node placement,
otherwise it will be unbearably slow.
Diffstat (limited to 'src/layout/box.nim')
-rw-r--r--src/layout/box.nim25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/layout/box.nim b/src/layout/box.nim
index 501cdc78..2c98aaed 100644
--- a/src/layout/box.nim
+++ b/src/layout/box.nim
@@ -11,6 +11,8 @@ type
 
   Size* = array[DimensionType, LayoutUnit]
 
+  Overflow* = array[DimensionType, Span]
+
   InlineAtomType* = enum
     iatSpacing, iatWord, iatInlineBlock, iatImage
 
@@ -30,13 +32,16 @@ type
   RootInlineFragmentState* = object
     # offset relative to parent
     offset*: Offset
+    # padding size
+    size*: Size
+    # overflow relative to offset
+    overflow*: Overflow
+    # minimum content width
+    xminwidth*: LayoutUnit
     # baseline of the first line box
     firstBaseline*: LayoutUnit
     # baseline of the last line box
     baseline*: LayoutUnit
-    # minimum content width
-    xminwidth*: LayoutUnit
-    size*: Size
 
   RootInlineFragment* = ref object
     fragment*: InlineFragment # root fragment
@@ -81,13 +86,15 @@ type
   RelativeRect* = array[DimensionType, Span]
 
   BlockBoxLayoutState* = object
+    # offset relative to parent
     offset*: Offset
-    size*: Size # padding size
+    # padding size
+    size*: Size
     margin*: RelativeRect #TODO get rid of this?
     positioned*: RelativeRect #TODO ditto
-    # very bad name. basically the minimum content width after the contents
-    # have been positioned (usually the width of the shortest word.) used
-    # in table cells.
+    # overflow relative to offset
+    overflow*: Overflow
+    # minimum content width (usually shortest word)
     xminwidth*: LayoutUnit
     # baseline of the first line box of all descendants
     firstBaseline*: LayoutUnit
@@ -164,3 +171,7 @@ func top*(s: RelativeRect): LayoutUnit =
 
 func bottom*(s: RelativeRect): LayoutUnit =
   return s[dtVertical].send
+
+proc `+=`*(span: var Span; u: LayoutUnit) =
+  span.start += u
+  span.send += u