about summary refs log tree commit diff stats
path: root/src/layout/box.nim
blob: d461f0f55d25c4d237b3bbcb4e200020f962c7c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import options

import css/values
import html/dom
import io/term

type
  Viewport* = ref object
    term*: TermAttributes
    root*: BlockBox
    map*: seq[CSSBox]

  CSSBox* = ref object of RootObj
    t*: CSSDisplay
    children*: seq[CSSBox]
    inlinelayout*: bool
    specified*: CSSSpecifiedValues
    node*: Node
    element*: Element

  InlineAtom* = ref object of RootObj
    relx*: int
    width*: int
    height*: int

  InlineWord* = ref object of InlineAtom
    str*: string
    fontstyle*: CSSFontStyle
    fontweight*: int
    textdecoration*: CSSTextDecoration
    color*: CSSColor
    node*: Node

  InlineRow* = ref object
    atoms*: seq[InlineAtom]
    relx*: int
    rely*: int
    width*: int
    height*: int

  InlineContext* = ref object
    relx*: int
    width*: int
    height*: int
    rows*: seq[InlineRow]
    thisrow*: InlineRow

    whitespace*: bool
    maxwidth*: int
    viewport*: Viewport
    node*: Node

  BlockContext* = ref object of InlineAtom
    inline*: InlineContext
    nested*: seq[BlockContext]
    specified*: CSSSpecifiedValues
    viewport*: Viewport
    rely*: int
    margin_top*: int
    margin_bottom*: int

    compwidth*: int
    compheight*: Option[int]
    done*: bool

  InlineBox* = ref object of CSSBox
    text*: seq[string]
    ictx*: InlineContext
    newline*: bool

  BlockBox* = ref object of CSSBox
    bctx*: BlockContext

  InlineBlockBox* = ref object of BlockBox
    ictx*: InlineContext

  ListItemBox* = ref object of BlockBox