about summary refs log blame commit diff stats
path: root/src/layout/box.nim
blob: d7ae34008ac34a180b3ec41a8235445e13656125 (plain) (tree)
1
2
3
4
5
6
7
8
9

              
                 
               
              

    

                         


                     
                                 
                  
                          

                                  
               
                     
 


                                     
                
 


                                           
                                        
                



                                      
               
 


                           

               
                
 
                             




                         
 
                     
                  
                       
               
 
                                          
                          

                                  
                       
              

                       
 

                            
               
 
                                   
                      

                        
 
                                  
                       
 

                                          
 
                                       
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

  InlineSpacing* = ref object of InlineAtom
    word*: InlineWord

  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