Documentation ¶
Index ¶
- Variables
- func BuildTree(engine *callisto.RenderEngine, sourceFilePath string) (err error)
- func GetChildAlignWithString(rawChildAlign string) callisto.ChildAlign
- func GetLayoutManagerWithString(rawLayoutManager string) callisto.LayoutManager
- func GetPaddingFromRaw(rawString string) callisto.ElementPadding
- func ParseBorder(rawString string) (callisto.ElementBorder, error)
- func ParseBorderWithPosition(rawString string) (width int, color string, err error)
- func ParseBoxSizing(rawString string) callisto.BoxSizing
- func ParseFont(rawString string) string
- func ParseImageFit(rawString string) (callisto.ImageFit, error)
- type Body
- type BoxDocElement
- type BuildContext
- type Doc
- type ElementHandler
- type ImageDocElement
- type Meta
- type ParagraphDocElement
- type TextDocElement
- type Unit
Constants ¶
This section is empty.
Variables ¶
View Source
var ChildAlignMapping map[string]callisto.ChildAlign = map[string]callisto.ChildAlign{ "mainAxisTop": callisto.MainAxisTop, "mainAxisCenter": callisto.MainAxisCenter, "mainAxisBottom": callisto.MainAxisBottom, "crossAxisLeft": callisto.CrossAxisLeft, "crossAxisCenter": callisto.CrossAxisCenter, "crossAxisRight": callisto.CrossAxisRight, "crossMainAxisCenter": callisto.MainCrossAxisCenter, }
View Source
var ImageFitMapping map[string]callisto.ImageFit = map[string]callisto.ImageFit{ "width": callisto.FitWidth, "height": callisto.FitHeight, "both": callisto.Both, "none": callisto.NoFit, }
View Source
var UnitSymbolMapping map[Unit]string = map[Unit]string{ ParentDeltaRelative: "rd", ParentScaleRelative: "%", Pixel: "px", }
Functions ¶
func GetChildAlignWithString ¶
func GetChildAlignWithString(rawChildAlign string) callisto.ChildAlign
func GetLayoutManagerWithString ¶
func GetLayoutManagerWithString(rawLayoutManager string) callisto.LayoutManager
func GetPaddingFromRaw ¶
func GetPaddingFromRaw(rawString string) callisto.ElementPadding
func ParseBorder ¶
func ParseBorder(rawString string) (callisto.ElementBorder, error)
func ParseBorderWithPosition ¶
func ParseBoxSizing ¶
Types ¶
type BoxDocElement ¶
type BoxDocElement struct { Width string `json:"width"` Height string `json:"height"` LayoutManager string `json:"layoutManager"` ChildAlign string `json:"childAlign"` Background string `json:"background"` Children []map[string]interface{} `json:"children"` Padding string `json:"padding"` BoxSizing string `json:"boxSizing"` Border string `json:"border"` BorderTop string `json:"borderTop"` BorderRight string `json:"borderRight"` BorderBottom string `json:"borderBottom"` BorderLeft string `json:"borderLeft"` }
type BuildContext ¶
type BuildContext struct {
// contains filtered or unexported fields
}
type Doc ¶
func ReadJsonDoc ¶
type ElementHandler ¶
type ElementHandler func(context BuildContext) (callisto.Element, error)
var BoxHandler ElementHandler = func(context BuildContext) (callisto.Element, error) { var docElm BoxDocElement err := mapstructure.Decode(context.content, &docElm) if err != nil { return nil, err } node := &callisto.Box{ Color: docElm.Background, LayoutManager: GetLayoutManagerWithString(docElm.LayoutManager), ChildrenAlign: GetChildAlignWithString(docElm.ChildAlign), ElementPosition: callisto.ElementPosition{ UseParentDelta: true, }, } dimension := callisto.ElementDimension{} width, widthUnit, err := ParseValueAndUnit(docElm.Width) switch widthUnit { case ParentScaleRelative: dimension.UserParentRelative = true dimension.ParentRelativeScaleWidth = width / 100 case Pixel: dimension.Width = width case ParentDeltaRelative: dimension.UserParentRelative = true dimension.ParentRelativeDeltaWidth = width } height, heightUnit, err := ParseValueAndUnit(docElm.Height) switch heightUnit { case ParentScaleRelative: dimension.UserParentRelative = true dimension.ParentRelativeScaleHeight = height / 100 case Pixel: dimension.Height = height case ParentDeltaRelative: dimension.UserParentRelative = true dimension.ParentRelativeDeltaWidth = height } node.ElementDimension = dimension node.Padding = GetPaddingFromRaw(docElm.Padding) node.BoxSizing = ParseBoxSizing(docElm.BoxSizing) border, err := ParseBorder(docElm.Border) if err != nil { return nil, err } node.Border = border topWidth, topColor, err := ParseBorderWithPosition(docElm.BorderTop) if err != nil { return nil, err } node.Border.Top = callisto.Border{ Width: topWidth, Color: topColor, } rightWidth, rightColor, err := ParseBorderWithPosition(docElm.BorderRight) if err != nil { return nil, err } node.Border.Right = callisto.Border{ Width: rightWidth, Color: rightColor, } bottomWidth, bottomColor, err := ParseBorderWithPosition(docElm.BorderBottom) if err != nil { return nil, err } node.Border.Bottom = callisto.Border{ Width: bottomWidth, Color: bottomColor, } leftWidth, leftColor, err := ParseBorderWithPosition(docElm.BorderLeft) if err != nil { return nil, err } node.Border.Left = callisto.Border{ Width: leftWidth, Color: leftColor, } return node, nil }
var ImageElementHandler ElementHandler = func(context BuildContext) (callisto.Element, error) { boxElement, err := BoxHandler(context) if err != nil { return nil, err } box := boxElement.(*callisto.Box) var docElm ImageDocElement err = mapstructure.Decode(&context.content, &docElm) if err != nil { return nil, err } node := callisto.ImageBox{ Box: *box, Src: docElm.Src, OriginDimension: docElm.OriginDimension, Fit: callisto.FitHeight, } imageFit, err := ParseImageFit(docElm.Fit) if err != nil { return nil, err } node.Fit = imageFit return &node, nil }
var ParagraphHandler ElementHandler = func(context BuildContext) (callisto.Element, error) { boxElement, err := BoxHandler(context) if err != nil { return nil, err } box := boxElement.(*callisto.Box) var docElm ParagraphDocElement err = mapstructure.Decode(&context.content, &docElm) if err != nil { return nil, err } node := callisto.ParagraphBox{ Box: *box, } err = copier.Copy(&node, &docElm) if err != nil { return nil, err } node.FontPath = ParseFont(docElm.Font) return &node, nil }
var TextHandler ElementHandler = func(context BuildContext) (callisto.Element, error) { boxElement, err := BoxHandler(context) if err != nil { return nil, err } box := boxElement.(*callisto.Box) var docElm TextDocElement err = mapstructure.Decode(&context.content, &docElm) if err != nil { return nil, err } node := callisto.TextBox{ Box: *box, } err = copier.Copy(&node, &docElm) if err != nil { return nil, err } node.FontPath = ParseFont(docElm.Font) return &node, nil }
func Dispatch ¶
func Dispatch(elementType string) ElementHandler
type ImageDocElement ¶
type ParagraphDocElement ¶
type TextDocElement ¶
Click to show internal directories.
Click to hide internal directories.