render

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package render is the wire protocol between the ui runtime (Go) and a host's native renderer. Its generated Swift and Java ship inside the host kits: regenerate with `go test ./ui/render -update` after changing it.

Lengths are points (iOS) / dp (Android). Colors are 0xRRGGBBAA; 0 means unset (transparent background, default text color).

Index

Constants

View Source
const (
	PanAny uint8 = iota + 1
	PanX
	PanY
)

Which drags a view reports (Box.Pan).

View Source
const (
	GestureBegan uint8 = iota
	GestureChanged
	GestureEnded
	GestureCancelled
)

The phases of a gesture (Panned, Pinched).

View Source
const (
	CornerTopLeft     = 1
	CornerTopRight    = 2
	CornerBottomRight = 4
	CornerBottomLeft  = 8
)

The corners in Box.Corners.

View Source
const (
	DrawMoveTo uint8 = iota
	DrawLineTo
	DrawQuadTo
	DrawCubicTo
	DrawClose
	DrawCircle
	DrawRect
	DrawFill
	DrawStroke
	DrawFillGradient
	DrawArc
	DrawOval
	DrawEvenOdd
	DrawStrokeGradient
	DrawClip
	DrawSave
	DrawRestore
	DrawLayer
	DrawTranslate
	DrawRotate
	DrawScale
	DrawBlend
	DrawShadow
	DrawDash
	DrawLineStyle
	DrawTrim
	DrawImage
	DrawText
	DrawBind
	DrawTag
	DrawFillShader
)

The commands in Draw.Cmds.

View Source
const AnimSize = 12

AnimSize is how many numbers each animation takes in Draw.Anims.

View Source
const SchemaHash uint64 = 0x454dac12204004c4

SchemaHash identifies this schema's wire layout. Hosts pass it (combined with any other schemas) to nn_start, which refuses a mismatch.

Variables

This section is empty.

Functions

func AppendMessage

func AppendMessage(b []byte, v Message) []byte

AppendMessage appends a Message: its variant index (0 for nil), then the variant.

func AppendOp

func AppendOp(b []byte, v Op) []byte

AppendOp appends a Op: its variant index (0 for nil), then the variant.

func Encode

func Encode(m Message) []byte

Encode returns m's wire encoding: its message id, then its fields.

Types

type Align

type Align uint8

Align is horizontal text alignment.

const (
	AlignStart Align = iota
	AlignCenter
	AlignEnd
)

type BackgroundRun added in v0.0.13

type BackgroundRun struct{ Name string }

BackgroundRun asks Go to run a background task (plugins/backgroundtasks).

func (*BackgroundRun) AppendWire added in v0.0.13

func (m *BackgroundRun) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*BackgroundRun) ReadWire added in v0.0.13

func (m *BackgroundRun) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Blur added in v0.0.13

type Blur uint8

Blur is how strongly what is behind a view is blurred: the platform's materials on iOS, a blur radius elsewhere.

const (
	BlurNone Blur = iota
	BlurUltraThin
	BlurThin
	BlurRegular
	BlurThick
	// BlurGlass is Liquid Glass on iOS 26+ (the tint is left out: glass
	// takes its color from behind); elsewhere, BlurUltraThin with the tint.
	BlurGlass
)

type Box

type Box struct {
	Tag         uint32
	Background  uint32
	Radius      float32
	BorderWidth float32
	BorderColor uint32
	Opacity     float32 // 0..1
	Clip        bool
	Label       string // accessibility label
	TestID      string // accessibilityIdentifier / view tag, for tests
	Href        string // where a pressable leads (the web host makes it a link)
	Copy        string // text a tap on a pressable copies (the web host copies it inside the tap)
	// Transition animates changes to this view's frame, opacity and
	// background over this many milliseconds; 0 changes them at once.
	Transition uint32
	LongPress  bool // a pressable that reports long presses

	// Blur shows what is behind the view, blurred; Background tints it.
	Blur Blur
	// A gradient painted over Background: colors at stops (0..1; evenly
	// spaced when there are none), from (GradientX0, GradientY0) to
	// (GradientX1, GradientY1) in the view's unit square. A radial one
	// spreads from the first point out to the distance to the second.
	GradientColors                                 []uint32
	GradientStops                                  []float32
	GradientRadial                                 bool
	GradientX0, GradientY0, GradientX1, GradientY1 float32
	// A shadow under the view: its color (0 for none), blur radius and offset.
	ShadowColor                    uint32
	ShadowRadius, ShadowX, ShadowY float32
	// Corners are the corners Radius rounds: a mask of Corner*; 0 is all four.
	Corners uint8
	// Hidden takes the view off the screen (Style.Hidden): not drawn, not tapped.
	Hidden bool
	// Scale (1 when 0) and Rotate (degrees) transform the view about its
	// centre, after layout: its place among its siblings doesn't change.
	Scale, Rotate float32
	// Pan is the drags the view reports (PanAny, PanX, PanY; 0 for none):
	// a one-way drag leaves the other way to whatever scrolls around it.
	Pan uint8
	// Pinch makes the view report two-finger pinches.
	Pinch bool
	// Back makes a pressable take the system's back button: the host presses
	// the newest one before anything else goes back.
	Back bool
}

Box is the visual style every view kind shares.

func (*Box) AppendWire

func (m *Box) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Box) ReadWire

func (m *Box) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Changed

type Changed struct {
	Tag  uint32
	Text string
}

Changed reports an input's new text.

func (*Changed) AppendWire

func (m *Changed) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Changed) ReadWire

func (m *Changed) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Children

type Children struct {
	Tag      uint32
	Children []uint32
}

Children sets a view's child views, in order. Views of Tag not listed are removed. For a scroll view the children go in its content.

func (*Children) AppendWire

func (m *Children) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Children) ReadWire

func (m *Children) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Chrome

type Chrome struct {
	Dark       bool
	Background uint32 // screens, modals, the root
	Text       uint32
	TextMuted  uint32 // unselected tabs
	Accent     uint32 // back buttons, selected tabs
	Bar        uint32 // navigation and tab bar backgrounds
	BarText    uint32 // titles on bars
	Border     uint32 // bar separators
}

Chrome is the theme for what the host draws itself: navigation and tab bars, screen and modal backgrounds, the status bar. Sent when it changes.

func (*Chrome) AppendWire

func (m *Chrome) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Chrome) ReadWire

func (m *Chrome) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Commit

type Commit struct {
	Seq  uint64
	Root uint32 // the root view's tag, when it changes; 0 otherwise
	Ops  []Op

	// Where the time went in Go, for diagnostics.
	BuildNs  uint64 // components and reconciliation
	LayoutNs uint64 // flexbox, including text measurement
	Measures uint32 // text measurements that reached the host
}

Commit is one render: apply its ops in order, in one UI-thread pass.

func (*Commit) AppendWire

func (m *Commit) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Commit) ReadWire

func (m *Commit) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Create

type Create struct {
	Tag  uint32
	Kind Kind
}

Create makes a view for Tag. It is not shown until a Children op places it.

func (*Create) AppendWire

func (m *Create) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Create) ReadWire

func (m *Create) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Destroy

type Destroy struct{ Tags []uint32 }

Destroy forgets views (and removes them from their parents).

func (*Destroy) AppendWire

func (m *Destroy) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Destroy) ReadWire

func (m *Destroy) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Dismissed

type Dismissed struct{ Tag uint32 }

Dismissed reports that the user closed a modal (swipe down, back button).

func (*Dismissed) AppendWire

func (m *Dismissed) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Dismissed) ReadWire

func (m *Dismissed) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Draw added in v0.0.13

type Draw struct {
	Tag    uint32
	W, H   float32
	Cmds   []uint8
	Nums   []float32
	Colors []uint32
	Strs   []string
	Anims  []float32
	Touch  bool
}

Draw sets what a canvas draws: commands in a W×H space fitted to the view (centred, keeping its aspect, like an SVG viewBox). Each command takes its numbers from Nums, its colors from Colors and its strings from Strs, in order:

DrawMoveTo x y · DrawLineTo x y · DrawQuadTo cx cy x y
DrawCubicTo c1x c1y c2x c2y x y · DrawClose
DrawCircle cx cy r · DrawRect x y w h radius   (add to the path)
DrawArc cx cy r start sweep · DrawOval x y w h (add to the path: a new subpath;
                                               degrees, clockwise from 3 o'clock)
DrawEvenOdd                                    (the path fills by the even-odd rule)
DrawFill color · DrawStroke width color        (paint the path, then start a new one)
DrawFillGradient kind x0 y0 x1 y1 n stop×n colors×n
                                               (kind 0: from (x0, y0) to (x1, y1);
                                               1: from (x0, y0) out to the distance to (x1, y1);
                                               2: around (x0, y0), starting toward (x1, y1))
DrawStrokeGradient width kind x0 y0 x1 y1 n stop×n colors×n
DrawClip                                       (later drawing stays inside the path; a new path)
DrawSave · DrawRestore                         (the state below, and the clip)
DrawLayer opacity                              (a Save whose drawing is blended in at Restore)
DrawTranslate x y · DrawRotate degrees · DrawScale sx sy
DrawBlend mode · DrawShadow dx dy blur color   (blur: a CSS blur radius; color 0 for none)
DrawDash n len×n                               (strokes dashed; n 0 for solid)
DrawLineStyle cap join                         (cap 0 round, 1 butt, 2 square;
                                               join 0 round, 1 miter, 2 bevel)
DrawTrim length start end                      (the next stroke shows start..end of
                                               its length, as fractions)
DrawImage url x y w h fit                      (url a string; Fit)
DrawText text family x y width size weight align lines color
                                               (text and family strings; (x, y) its top left,
                                               wrapped at width when over 0; color 0 the default)
DrawBind arg anim from to                      (the next command's arg-th number is
                                               from + (to - from) × anim's value)
DrawTag n                                      (the next Fill, Stroke or gradient paints
                                               shape n, from 1, for taps and drag handles)
DrawFillShader x y w h n u×n fallback source   (fill with a shader, run over the box
                                               (x, y, w, h) that holds the path; its
                                               uniforms; a color where it can't run; the
                                               platform's source, its main taking a point
                                               in the canvas's units)

Anims holds the animations DrawBind uses, AnimSize numbers each: id, run, kind (0: a clock from 0 to 1; 1: follows to, from where it is; 2: a drag, which also follows to), ms, delay, ease, bounce, repeat (-1 forever; a drag's axis, 0 across, 1 down), reverse (0 or 1; a drag's handle, the shape it starts on, 0 for anywhere), to, min, max (a drag's range). The host runs them itself, from when it first sees each id or run, and sends a NativeEvent named "anim" with "id:run" when one ends.

With Touch, the canvas takes touches: a tap sends a NativeEvent named "tap" with "shape,x,y" (the topmost tagged shape under it, 0 for none, and where, in the canvas's units), and a drag moves its number with the finger, in the canvas's units, sending "drag" with "id:value" when it's let go.

func (*Draw) AppendWire added in v0.0.13

func (m *Draw) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Draw) ReadWire added in v0.0.13

func (m *Draw) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Fit

type Fit uint8

Fit is how an image fills its frame.

const (
	FitCover Fit = iota
	FitContain
	FitStretch
)

type Font

type Font struct {
	Size   float32
	Weight uint16 // 100..900; 0 means 400
	Family string // a font the app bundles (nimbus native font add); "" is the system font
	// Tracking is extra space between letters, in points (negative tightens).
	Tracking float32
	// LineHeight is the distance between lines, in points; 0 is the font's own.
	LineHeight float32
	// Tabular gives every digit the same width, so figures line up and
	// don't jiggle as they change.
	Tabular bool
}

Font is shared by text, inputs and measurement.

func (*Font) AppendWire

func (m *Font) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Font) ReadWire

func (m *Font) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Frame

type Frame struct {
	Tag        uint32
	X, Y, W, H float32
}

Frame places a view relative to its parent (scroll views: their content).

func (*Frame) AppendWire

func (m *Frame) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Frame) ReadWire

func (m *Frame) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Image

type Image struct {
	Tag uint32
	URL string
	Fit Fit
}

func (*Image) AppendWire

func (m *Image) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Image) ReadWire

func (m *Image) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Input

type Input struct {
	Tag         uint32
	Value       string
	Placeholder string
	Font        Font
	Color       uint32
	Secure      bool
	Keyboard    Keyboard
	Multiline   bool // wraps and grows with Return making new lines
	// Submit makes Return send (Submitted) instead of a new line; the key
	// says Send.
	Submit bool
	// AutoFocus focuses the input when it appears, keyboard up.
	AutoFocus bool
}

Input sets a text field. The host replaces the field's text only when it differs, so typing is never interrupted.

func (*Input) AppendWire

func (m *Input) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Input) ReadWire

func (m *Input) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Keyboard

type Keyboard uint8

Keyboard is the soft keyboard an input asks for.

const (
	KeyboardText Keyboard = iota
	KeyboardNumber
	KeyboardEmail
	KeyboardURL
)

type Kind

type Kind uint8

Kind is the native view a tag stands for.

const (
	KindView Kind = iota
	KindText
	KindImage
	KindPressable
	KindScroll
	KindInput
	KindSpinner
	// KindStack is a navigation stack: its children are screens, shown one
	// at a time under a native bar, with native push / pop transitions.
	KindStack
	// KindTabs is a tab bar: its children are the tabs' root views, one
	// shown at a time above the native tab bar.
	KindTabs
	// KindModal is a view presented over everything (a sheet on iOS). It is
	// not placed by a Children op: Present shows it, Destroy dismisses it.
	KindModal
	// KindSwitch is an on/off toggle: UISwitch, Android's Switch.
	KindSwitch
	// KindSlider picks a number in a range: UISlider, Android's SeekBar.
	KindSlider
	// KindCanvas draws shapes Go describes (Draw).
	KindCanvas
	// KindNative holds a view the host makes itself, such as a map (Native).
	KindNative
)

type LongPressed added in v0.0.9

type LongPressed struct{ Tag uint32 }

LongPressed reports a long press on a pressable that asked for them.

func (*LongPressed) AppendWire added in v0.0.9

func (m *LongPressed) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*LongPressed) ReadWire added in v0.0.9

func (m *LongPressed) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type MeasureText

type MeasureText struct {
	Text     string
	Font     Font
	MaxWidth float32 // < 0: no limit
	Lines    uint32
	Spans    []Span // a rich text's runs (Text is them joined)
}

MeasureText asks the host for a text's size (synchronous host call).

func (*MeasureText) AppendWire

func (m *MeasureText) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*MeasureText) ReadWire

func (m *MeasureText) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Message

type Message interface {
	// contains filtered or unexported methods
}

Message is any top-level message in this schema.

func Decode

func Decode(b []byte) (Message, error)

Decode reads exactly one message.

func ReadMessage

func ReadMessage(r *wire.Reader) Message

ReadMessage decodes a Message (nil for index 0).

type Native added in v0.0.13

type Native struct {
	Tag   uint32
	Type  string
	Props string
}

Native sets a KindNative view's kind, once, and its props, as JSON.

func (*Native) AppendWire added in v0.0.13

func (m *Native) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Native) ReadWire added in v0.0.13

func (m *Native) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type NativeEvent added in v0.0.13

type NativeEvent struct {
	Tag  uint32
	Name string
	Data string
}

NativeEvent is what a native view has to say (ui.Native): a name, and JSON.

func (*NativeEvent) AppendWire added in v0.0.13

func (m *NativeEvent) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*NativeEvent) ReadWire added in v0.0.13

func (m *NativeEvent) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Op

type Op interface {
	// contains filtered or unexported methods
}

Op changes one native view.

func ReadOp

func ReadOp(r *wire.Reader) Op

ReadOp decodes a Op (nil for index 0).

type Open added in v0.0.9

type Open struct{ URL string }

Open reports a link that opened the app (myapp://orders/42, or a web link the app handles), at launch or while it runs.

func (*Open) AppendWire added in v0.0.9

func (m *Open) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Open) ReadWire added in v0.0.9

func (m *Open) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Panned added in v0.0.13

type Panned struct {
	Tag          uint32
	Phase        uint8
	X, Y, VX, VY float32
}

Panned reports a drag on a view that asked for them: how far it has come from where it began (X, Y) and how fast it's going (VX, VY, per second), in points. A view that moves with the finger doesn't change these.

func (*Panned) AppendWire added in v0.0.13

func (m *Panned) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Panned) ReadWire added in v0.0.13

func (m *Panned) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Pinched added in v0.0.13

type Pinched struct {
	Tag   uint32
	Phase uint8
	Scale float32
}

Pinched reports a two-finger pinch: Scale is the fingers' distance over what it was at the start.

func (*Pinched) AppendWire added in v0.0.13

func (m *Pinched) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Pinched) ReadWire added in v0.0.13

func (m *Pinched) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type PluginAck

type PluginAck struct{ Err string }

PluginAck answers PluginCall: Err is empty when the call started.

func (*PluginAck) AppendWire

func (m *PluginAck) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*PluginAck) ReadWire

func (m *PluginAck) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type PluginCall

type PluginCall struct {
	ID     uint64
	Plugin string
	Method string
	Args   string
}

PluginCall asks a native plugin to run a method (synchronous host call). The host answers at once with PluginAck and sends the outcome later as a PluginResult with the same ID. Args and results are JSON.

func (*PluginCall) AppendWire

func (m *PluginCall) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*PluginCall) ReadWire

func (m *PluginCall) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type PluginResult

type PluginResult struct {
	ID    uint64
	Value string
	Code  string
	Err   string
}

PluginResult is a plugin call's outcome. A failure has a Code ("unavailable", "cancelled", "denied", "not_found", "failed") and Err.

func (*PluginResult) AppendWire

func (m *PluginResult) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*PluginResult) ReadWire

func (m *PluginResult) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Popped

type Popped struct {
	Tag   uint32
	Depth uint32
}

Popped reports that the user went back in a stack (back button, swipe or system back), leaving Depth screens.

func (*Popped) AppendWire

func (m *Popped) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Popped) ReadWire

func (m *Popped) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Present

type Present struct{ Tag uint32 }

Present shows a KindModal view over the app, with the platform's transition.

func (*Present) AppendWire

func (m *Present) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Present) ReadWire

func (m *Present) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Press

type Press struct{ Tag uint32 }

Press reports a tap on a pressable.

func (*Press) AppendWire

func (m *Press) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Press) ReadWire

func (m *Press) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Reattach

type Reattach struct{ Reason string }

Reattach reports a new native view hierarchy for a runtime that is already running (an Android activity created again): Go sends every view again, and the UI carries on with its state.

func (*Reattach) AppendWire

func (m *Reattach) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Reattach) ReadWire

func (m *Reattach) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Refresh

type Refresh struct{ Tag uint32 }

Refresh reports that the user pulled a refreshable scroll view.

func (*Refresh) AppendWire

func (m *Refresh) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Refresh) ReadWire

func (m *Refresh) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Resized

type Resized struct {
	Tag    uint32
	W, H   float32
	Bottom float32
}

Resized reports the size a stack or tab bar gives its screens. Bottom is how much of that height a bar covers (iOS tabs run under the tab bar); content should keep clear of it.

func (*Resized) AppendWire

func (m *Resized) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Resized) ReadWire

func (m *Resized) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Screen

type Screen struct {
	Tag   uint32
	Title string
}

Screen sets a stack screen's title. Tag is the screen's root view, a child of a KindStack view.

func (*Screen) AppendWire

func (m *Screen) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Screen) ReadWire

func (m *Screen) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Scroll

type Scroll struct {
	Tag        uint32
	W, H       float32
	Horizontal bool
	Report     bool
	// Refreshable shows pull to refresh; pulling sends Refresh. Refreshing
	// keeps the indicator showing until Go clears it.
	Refreshable bool
	Refreshing  bool
	// StickToEnd keeps the end in view as the content grows (a chat): when
	// it gets longer, the view scrolls to show its end.
	StickToEnd bool
}

Scroll sets a scroll view's content size. With Report, the host sends Scrolled whenever the view scrolls (lists need it to know what to show).

func (*Scroll) AppendWire

func (m *Scroll) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Scroll) ReadWire

func (m *Scroll) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Scrolled

type Scrolled struct {
	Tag  uint32
	X, Y float32
	W, H float32
}

Scrolled reports a scroll view's offset and visible size (only for views whose Scroll op asked for it).

func (*Scrolled) AppendWire

func (m *Scrolled) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Scrolled) ReadWire

func (m *Scrolled) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Selected

type Selected struct {
	Tag   uint32
	Index uint32
}

Selected reports that the user picked the tab at Index.

func (*Selected) AppendWire

func (m *Selected) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Selected) ReadWire

func (m *Selected) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Slid added in v0.0.9

type Slid struct {
	Tag   uint32
	Value float32
}

Slid reports the value the user dragged a slider to.

func (*Slid) AppendWire added in v0.0.9

func (m *Slid) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Slid) ReadWire added in v0.0.9

func (m *Slid) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Slider added in v0.0.9

type Slider struct {
	Tag      uint32
	Value    float32
	Min, Max float32
	Enabled  bool
	Tint     uint32
}

Slider sets a slider.

func (*Slider) AppendWire added in v0.0.9

func (m *Slider) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Slider) ReadWire added in v0.0.9

func (m *Slider) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Span added in v0.0.13

type Span struct {
	Text  string
	Font  Font
	Color uint32
}

Span is a run of a text with its own font and color.

func (*Span) AppendWire added in v0.0.13

func (m *Span) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Span) ReadWire added in v0.0.13

func (m *Span) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Spinner

type Spinner struct {
	Tag   uint32
	Color uint32
}

func (*Spinner) AppendWire

func (m *Spinner) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Spinner) ReadWire

func (m *Spinner) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Submitted added in v0.0.13

type Submitted struct {
	Tag uint32
}

Submitted reports Return on an input that submits (Input.Submit).

func (*Submitted) AppendWire added in v0.0.13

func (m *Submitted) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Submitted) ReadWire added in v0.0.13

func (m *Submitted) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Switch

type Switch struct {
	Tag     uint32
	On      bool
	Enabled bool
	Tint    uint32 // the on color; 0 is the platform's
}

Switch sets a toggle's state.

func (*Switch) AppendWire

func (m *Switch) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Switch) ReadWire

func (m *Switch) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type TabItem

type TabItem struct {
	Tag   uint32
	Title string
	Icon  string
}

TabItem sets a tab's title and icon (an SF Symbol name on iOS). Tag is the tab's root view, a child of a KindTabs view.

func (*TabItem) AppendWire

func (m *TabItem) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*TabItem) ReadWire

func (m *TabItem) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type TabSelect

type TabSelect struct {
	Tag   uint32
	Index uint32
}

TabSelect shows the tab at Index.

func (*TabSelect) AppendWire

func (m *TabSelect) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*TabSelect) ReadWire

func (m *TabSelect) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Text

type Text struct {
	Tag   uint32
	Text  string
	Font  Font
	Color uint32
	Align Align
	Lines uint32 // 0 = unlimited; truncated with an ellipsis
	// MinScale lets a one-line text shrink to fit its width, down to this
	// share of its size (0.6: 60%); 0 truncates instead.
	MinScale float32
	// Spans, when there are any, are the text in runs of their own look
	// (Text is then all of them, joined).
	Spans []Span
	// Style.Padding: the text is drawn this far inside its frame.
	PadLeft, PadTop, PadRight, PadBottom float32
}

Text sets a text view's content and style.

func (*Text) AppendWire

func (m *Text) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Text) ReadWire

func (m *Text) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type TextSize

type TextSize struct{ W, H float32 }

TextSize answers MeasureText.

func (*TextSize) AppendWire

func (m *TextSize) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*TextSize) ReadWire

func (m *TextSize) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Toggled

type Toggled struct {
	Tag uint32
	On  bool
}

Toggled reports that the user flipped a switch.

func (*Toggled) AppendWire

func (m *Toggled) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Toggled) ReadWire

func (m *Toggled) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Viewport

type Viewport struct {
	W, H                float32
	Scale               float32 // pixels per point / dp
	SafeTop, SafeBottom float32
	SafeLeft, SafeRight float32
	Platform            string // "ios" | "android"
	Dark                bool
	// Keyboard is how far the on-screen keyboard covers the root view from
	// its bottom edge; 0 when hidden or when the window already shrank.
	Keyboard float32
}

Viewport is the space the root fills; hosts send it at start and whenever it changes.

func (*Viewport) AppendWire

func (m *Viewport) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Viewport) ReadWire

func (m *Viewport) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

Jump to

Keyboard shortcuts

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