-
Notifications
You must be signed in to change notification settings - Fork 0
/
body.go
62 lines (47 loc) · 2.63 KB
/
body.go
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
package pdflexgo
import "github.com/kjk/flex"
type Body struct {
delegated *BlockElement
pageNumber int
}
type BodyBuilder = func(body *Body)
func body() *Body {
body := &Body{}
body.delegated = Block()
return body
}
func (body *Body) PageNumber() int {
return body.pageNumber
}
func (_body *Body) copyBodyWithoutChildren(newBody *Body) {
layoutNode := _body.delegated.getFlexNode()
newLayoutNode := newBody.delegated.getFlexNode()
for _, edge := range []flex.Edge{flex.EdgeTop, flex.EdgeRight, flex.EdgeBottom, flex.EdgeLeft} {
margin := layoutNode.StyleGetMargin(edge)
if margin.Unit == flex.UnitPercent {
newLayoutNode.StyleSetMarginPercent(edge, margin.Value)
} else if margin.Unit == flex.UnitPoint {
newLayoutNode.StyleSetMargin(edge, margin.Value)
} else if margin.Unit == flex.UnitAuto {
newLayoutNode.StyleSetMarginAuto(edge)
}
padding := layoutNode.StyleGetPadding(edge)
if padding.Unit == flex.UnitPercent {
newLayoutNode.StyleSetPaddingPercent(edge, padding.Value)
} else if padding.Unit == flex.UnitPoint {
newLayoutNode.StyleSetPadding(edge, padding.Value)
}
newLayoutNode.StyleSetBorder(edge, layoutNode.StyleGetBorder(edge))
}
newBody.BackgroundColor(_body.delegated.backgroundColor.red, _body.delegated.backgroundColor.green, _body.delegated.backgroundColor.blue, _body.delegated.backgroundColor.alpha)
newBody.BorderColorTop(_body.delegated.borderColor[EdgeTop].red, _body.delegated.borderColor[EdgeTop].green, _body.delegated.borderColor[EdgeTop].blue, _body.delegated.borderColor[EdgeTop].alpha)
newBody.BorderColorRight(_body.delegated.borderColor[EdgeRight].red, _body.delegated.borderColor[EdgeRight].green, _body.delegated.borderColor[EdgeRight].blue, _body.delegated.borderColor[EdgeRight].alpha)
newBody.BorderColorBottom(_body.delegated.borderColor[EdgeBottom].red, _body.delegated.borderColor[EdgeBottom].green, _body.delegated.borderColor[EdgeBottom].blue, _body.delegated.borderColor[EdgeBottom].alpha)
newBody.BorderColorLeft(_body.delegated.borderColor[EdgeLeft].red, _body.delegated.borderColor[EdgeLeft].green, _body.delegated.borderColor[EdgeLeft].blue, _body.delegated.borderColor[EdgeLeft].alpha)
newBody.Direction(Direction(_body.delegated.getFlexNode().Layout.Direction))
newBody.FlexDirection(FlexDirection(_body.delegated.getFlexNode().Style.FlexDirection))
newBody.JustifyContent(Justify(_body.delegated.getFlexNode().Style.JustifyContent))
newBody.AlignContentType(Align(_body.delegated.getFlexNode().Style.AlignContent))
newBody.AlignItemsType(Align(_body.delegated.getFlexNode().Style.AlignItems))
newBody.FlexWrapValue(Wrap(_body.delegated.getFlexNode().Style.FlexWrap))
}