layout

package
v0.0.0-...-1210f28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2017 License: ISC Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Dimensions

	Children []BlockBox
	// contains filtered or unexported fields
}

func NewBlock

func NewBlock(s *style.Style) *Block

func (*Block) Layout

func (b *Block) Layout(contBlock Dimensions)

func (*Block) Node

func (b *Block) Node() dom.Node

func (*Block) Render

func (b *Block) Render(l *paint.List)

func (*Block) Size

func (b *Block) Size() Dimensions

func (*Block) Style

func (b *Block) Style() *style.Style

type BlockBox

type BlockBox interface {
	Box
	Layout(contBlock Dimensions)
	// contains filtered or unexported methods
}

type Box

type Box interface {
	Size() Dimensions
	Style() *style.Style
	Node() dom.Node
	Render(l *paint.List)
}

func MakeBoxes

func MakeBoxes(s *style.Style) (result []Box)

func MakeInlines

func MakeInlines(s *style.Style) []Box

func MakeTextBoxes

func MakeTextBoxes(s *style.Style) []Box

TODO deal with spaces properly!

type Dimensions

type Dimensions struct {
	Rect

	Margin, Border, Padding Edges

	Ascender int
}

func (Dimensions) BorderRect

func (d Dimensions) BorderRect() Rect

func (Dimensions) MarginRect

func (d Dimensions) MarginRect() Rect

func (Dimensions) PaddingRect

func (d Dimensions) PaddingRect() Rect

type Edges

type Edges struct {
	Top, Right, Bottom, Left int
}

type Inline

type Inline struct {
	Dimensions

	Children            []InlineBox
	Font                font.Font
	LeftOpen, RightOpen bool
	// contains filtered or unexported fields
}

Inline is an inline box

func (*Inline) AlignBottom

func (box *Inline) AlignBottom(ybottom int)

AlignBottom moves all bottom children down to the specified ybottom. AlignTop needs to be run before!

func (*Inline) AlignTop

func (box *Inline) AlignTop(y int) int

AlignTop aligns all children with vertical-layout set to top or bottom to the specified y position. bottom boxes will be moved down in a later step. it returns the height of the highest top/bottom subtree.

func (*Inline) CalcHeight

func (box *Inline) CalcHeight(contBlock Dimensions) (maxHeight, maxAsc, maxDesc int)

func (*Inline) CalcWidth

func (box *Inline) CalcWidth(contBlock Dimensions) int

func (*Inline) IsEmpty

func (i *Inline) IsEmpty() bool

func (*Inline) LayoutX

func (i *Inline) LayoutX(x int)

func (*Inline) Move

func (i *Inline) Move(dx, dy int)

func (*Inline) MoveBaseline

func (box *Inline) MoveBaseline(dy int)

func (*Inline) Node

func (i *Inline) Node() dom.Node

func (*Inline) Render

func (b *Inline) Render(l *paint.List)

func (*Inline) Size

func (box *Inline) Size() Dimensions

func (*Inline) Style

func (box *Inline) Style() *style.Style

func (*Inline) SubtreeMinMax

func (box *Inline) SubtreeMinMax() (min int, max int)

func (*Inline) VerticalAlignNormalChildren

func (box *Inline) VerticalAlignNormalChildren(baseline int)

type InlineBox

type InlineBox interface {
	Box
	CalcWidth(contBlock Dimensions) int
	CalcHeight(contBlock Dimensions) (maxHeight, maxAsc, maxDesc int)

	// Testing!
	LayoutX(x int)
	Move(dx, dy int)
	VerticalAlignNormalChildren(baseline int)
	SubtreeMinMax() (min int, max int)
	AlignTop(y int) int
	AlignBottom(ybottom int)
	MoveBaseline(dy int)
	// contains filtered or unexported methods
}

type IntrinsicSizer

type IntrinsicSizer interface {
	IntrinsicHeight() (h int, ok bool)
	IntrinsicWidth() (w int, ok bool)
	IntrinsicRatio() (w int, h int, ok bool) // ratio = w/h
}

type Line

type Line struct {
	Dimensions // rect+asc, rest should be 0

	Inline    *Inline
	HardBreak bool
	// contains filtered or unexported fields
}

func (*Line) Layout

func (l *Line) Layout(contBlock Dimensions)

func (*Line) Node

func (l *Line) Node() dom.Node

func (*Line) Render

func (b *Line) Render(l *paint.List)

func (*Line) Size

func (l *Line) Size() Dimensions

func (*Line) Style

func (l *Line) Style() *style.Style

type LineBlock

type LineBlock struct {
	Block
}

This will replace LineBlock when it's ready

func NewLineBlock

func NewLineBlock(s *style.Style) *LineBlock

NewLineBlock creates a LineBlock The argument is its parent's node (the block container)

func (*LineBlock) IsEmpty

func (b *LineBlock) IsEmpty() bool

func (*LineBlock) Layout

func (b *LineBlock) Layout(contBlock Dimensions)

func (*LineBlock) Render

func (b *LineBlock) Render(l *paint.List)

type Rect

type Rect struct {
	X, Y, Width, Height int
}

func (Rect) MaxX

func (r Rect) MaxX() int

func (Rect) MaxY

func (r Rect) MaxY() int

func (Rect) Rectangle

func (r Rect) Rectangle() image.Rectangle

type Replaced

type Replaced struct {
	Dimensions
	// contains filtered or unexported fields
}

func (*Replaced) AlignBottom

func (r *Replaced) AlignBottom(y int)

func (*Replaced) AlignTop

func (r *Replaced) AlignTop(y int) int

func (*Replaced) CalcHeight

func (r *Replaced) CalcHeight(contBlock Dimensions) (maxHeight, maxAsc, maxDesc int)

TODO Padding? Border? Margin? see above ...

func (*Replaced) CalcWidth

func (r *Replaced) CalcWidth(contBlock Dimensions) int

CalcWidth calculates the width of the replaced element. Uses the algorithm from http://www.w3.org/TR/2011/REC-CSS2-20110607/visudet.html#inline-replaced-width TODO Padding? Border? Margin? TODO deal with the undefined case TODO respect min-width and max-width The correct algorithm is in http://www.w3.org/TR/2011/REC-CSS2-20110607/visudet.html#min-max-widths It includes a complex table ...

func (*Replaced) LayoutX

func (r *Replaced) LayoutX(x int)

func (*Replaced) Move

func (r *Replaced) Move(dx, dy int)

func (*Replaced) MoveBaseline

func (r *Replaced) MoveBaseline(dy int)

func (*Replaced) Node

func (r *Replaced) Node() dom.Node

func (*Replaced) Render

func (r *Replaced) Render(l *paint.List)

func (*Replaced) Size

func (r *Replaced) Size() Dimensions

func (*Replaced) Style

func (r *Replaced) Style() *style.Style

func (*Replaced) SubtreeMinMax

func (r *Replaced) SubtreeMinMax() (min int, max int)

func (*Replaced) VerticalAlignNormalChildren

func (r *Replaced) VerticalAlignNormalChildren(baseline int)

type Text

type Text struct {
	Rect

	Text        string
	Font        font.Font
	LineHeight  int
	Collapsible bool
	ForcesBreak bool
	AllowsBreak bool
	// contains filtered or unexported fields
}

func (*Text) AlignBottom

func (_ *Text) AlignBottom(ybottom int)

func (*Text) AlignTop

func (t *Text) AlignTop(y int) int

func (*Text) CalcHeight

func (t *Text) CalcHeight(_ Dimensions) (maxHeight, maxAsc, maxDesc int)

func (*Text) CalcWidth

func (t *Text) CalcWidth(_ Dimensions) int

func (*Text) LayoutX

func (t *Text) LayoutX(x int)

func (*Text) Move

func (t *Text) Move(dx, dy int)

func (*Text) MoveBaseline

func (t *Text) MoveBaseline(dy int)

func (*Text) Node

func (t *Text) Node() dom.Node

func (*Text) Render

func (t *Text) Render(l *paint.List)

func (*Text) Size

func (t *Text) Size() Dimensions

func (*Text) Style

func (t *Text) Style() *style.Style

func (*Text) SubtreeMinMax

func (t *Text) SubtreeMinMax() (min int, max int)

func (*Text) VerticalAlignNormalChildren

func (t *Text) VerticalAlignNormalChildren(baseline int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL