Documentation ¶
Overview ¶
package pubdata intended for exporting data structure for other platforms such as mobile, wasm and so on. All of type of exported struct field and function signature should be restricted by the restriction of platform conversion. e.g. mobile type restrinction is found at https://pkg.go.dev/golang.org/x/mobile/cmd/gobind?utm_source=godoc#hdr-Type_restrictions
Index ¶
Constants ¶
const ( ContentTypeText = "text" ContentTypeTextButton = "text_button" ContentTypeImage = "image" )
const ( AlignmentNone = "none" AlignmentLeft = "left" AlignmentCenter = "center" AlignmentRight = "right" )
Variables ¶
This section is empty.
Functions ¶
func AlignmentString ¶
Types ¶
type Box ¶
type Box interface { RuneWidth() int // return box's width in runewidth. ContentType() string // return box's content type BoxDataUnion // BoxDataUnion is interface for getting data depending on box type. }
Box is abstract content. It holds nomal text, unsplitable text and images and so on. The Box is the smallest element for whole content. The whole content consist with multiple Paragraph-s, which is divided by the hard return (\n). Paragraph consist with multiple Line-s, which is divided by rune width in the maximum width in the view window. The Line consists with multiple Box-s, which is divided by its attributes.
The Box type can be validated by type assertion or ContentType().
type BoxCommon ¶
type BoxCommon struct { CommonRuneWidth int `json:"rune_width"` CommonLineCountHint int `json:"line_count_hint"` CommonContentType string `json:"content_type"` // Implement BoxDataUnion interface. BoxDataUnionImpl }
BoxCommon implements Box interface. Data() should be implemented by the derived types.
func (*BoxCommon) ContentType ¶
func (*BoxCommon) LineCountHint ¶
type BoxDataUnion ¶
type BoxDataUnion interface { TextData() *TextData TextButtonData() *TextButtonData ImageData() *ImageData }
BoxDataUnion is a union data structure for Box implementers.
type BoxDataUnionImpl ¶
type BoxDataUnionImpl struct{}
BoxDataUnionImpl implements BoxDataUnion interface.
func (BoxDataUnionImpl) ImageData ¶
func (BoxDataUnionImpl) ImageData() *ImageData
func (BoxDataUnionImpl) TextButtonData ¶
func (BoxDataUnionImpl) TextButtonData() *TextButtonData
func (BoxDataUnionImpl) TextData ¶
func (BoxDataUnionImpl) TextData() *TextData
type Boxes ¶
type Boxes struct {
// contains filtered or unexported fields
}
Boxes is intermediation for []Box, used for gomobile export.
func (Boxes) MarshalJSON ¶
Implement json.Mashaller interface. Unmarshal is not considered.
func (*Boxes) UnmarshalJSON ¶
Implement json.Unmarshller interface.
type ImageData ¶
type ImageData struct { Source string `json:"source"` WidthPx int `json:"width_px"` HeightPx int `json:"height_px"` WidthTextScale int `json:"width_text_scale"` HeightTextScale int `json:"height_text_scale"` Data []byte `json:"data"` DataFetchType ImageFetchType `json:"data_fetch_type"` }
ImageData is data for ContentTypeImage.
type ImageFetchType ¶
type ImageFetchType = int
ImageFetchType indicates how image pixels to be included in ImageData.Data. This type is aliases for int since it may be encoded to the json format.
const ( // ImageFetchNone indicates no image pixel data in ImageData. // Client use URI of image to fetch pixels manually. ImageFetchNone ImageFetchType = iota // ImageFetchRawRGBA indicates image pixels stored in raw RGBA bytes in // ImageData. ImageFetchRawRGBA // ImageFetchEncodedPNG indicates image pixels stored in png encoded bytes in // ImageData. ImageFetchEncodedPNG )
type Line ¶
type Line struct { Boxes Boxes `json:"boxes"` RuneWidth int `json:"rune_width"` // rune width for this line, that is sum of one in boxes. }
Line is a line in view window.
type Lines ¶
type Lines struct {
// contains filtered or unexported fields
}
Lines is intermediation for []Line, used for gomobile export.
func (Lines) MarshalJSON ¶
Implement json.Mashaller interface. Unmarshal is not considered.
func (*Lines) UnmarshalJSON ¶
Implement json.Unmarshller interface.
type Paragraph ¶
type Paragraph struct { ID int `json:"id"` Lines Lines `json:"lines"` Alignment string `json:"alignment"` Fixed bool `json:"fixed"` }
Paragraph is a block of content divided by hard return (\n).
type TextButtonBox ¶
type TextButtonBox struct { BoxCommon BoxData TextButtonData `json:"data"` }
TextBottonBox holds normal text and emits input command when this box is tapped/clicked on UI.
func (*TextButtonBox) TextButtonData ¶
func (t *TextButtonBox) TextButtonData() *TextButtonData
TextButtonData returns *TextButtonData.
type TextButtonData ¶
TextButtonData is data for ContentTypeTextButton.
type TextData ¶
type TextData struct { // text content should not contain hard return. Text string `json:"text"` // Foreground color represents 32bit RGB used to font face color FgColor int `json:"fgcolor"` // Background color represents 32bit RGB used to background on text. BgColor int `json:"bgcolor"` }
TextData is data for ContentTypeText.