gioui.org: gioui.org/widget Index | Files | Directories

package widget

import "gioui.org/widget"

Package widget implements state tracking and event handling of common user interface controls. To draw widgets, use a theme packages such as package gioui.org/widget/material.

Index

Package Files

bool.go border.go buffer.go button.go doc.go editor.go enum.go float.go icon.go image.go label.go

type Bool Uses

type Bool struct {
    Value bool
    // contains filtered or unexported fields
}

func (*Bool) Changed Uses

func (b *Bool) Changed() bool

Changed reports whether Value has changed since the last call to Changed.

func (*Bool) History Uses

func (b *Bool) History() []Press

func (*Bool) Layout Uses

func (b *Bool) Layout(gtx layout.Context) layout.Dimensions

type Border Uses

type Border struct {
    Color        color.NRGBA
    CornerRadius unit.Value
    Width        unit.Value
}

Border lays out a widget and draws a border inside it.

func (Border) Layout Uses

func (b Border) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions

type ChangeEvent Uses

type ChangeEvent struct{}

A ChangeEvent is generated for every user change to the text.

type Click Uses

type Click struct {
    Modifiers key.Modifiers
    NumClicks int
}

Click represents a click.

type Clickable Uses

type Clickable struct {
    // contains filtered or unexported fields
}

Clickable represents a clickable area.

func (*Clickable) Clicked Uses

func (b *Clickable) Clicked() bool

Clicked reports whether there are pending clicks as would be reported by Clicks. If so, Clicked removes the earliest click.

func (*Clickable) Clicks Uses

func (b *Clickable) Clicks() []Click

Clicks returns and clear the clicks since the last call to Clicks.

func (*Clickable) History Uses

func (b *Clickable) History() []Press

History is the past pointer presses useful for drawing markers. History is retained for a short duration (about a second).

func (*Clickable) Layout Uses

func (b *Clickable) Layout(gtx layout.Context) layout.Dimensions

type Editor Uses

type Editor struct {
    Alignment text.Alignment
    // SingleLine force the text to stay on a single line.
    // SingleLine also sets the scrolling direction to
    // horizontal.
    SingleLine bool
    // Submit enabled translation of carriage return keys to SubmitEvents.
    // If not enabled, carriage returns are inserted as newlines in the text.
    Submit bool
    // Mask replaces the visual display of each rune in the contents with the given rune.
    // Newline characters are not masked. When non-zero, the unmasked contents
    // are accessed by Len, Text, and SetText.
    Mask rune
    // contains filtered or unexported fields
}

Editor implements an editable and scrollable text area.

func (*Editor) CaretCoords Uses

func (e *Editor) CaretCoords() f32.Point

CaretCoords returns the coordinates of the caret, relative to the editor itself.

func (*Editor) CaretPos Uses

func (e *Editor) CaretPos() (line, col int)

CaretPos returns the line & column numbers of the caret.

func (*Editor) Delete Uses

func (e *Editor) Delete(runes int)

Delete runes from the caret position. The sign of runes specifies the direction to delete: positive is forward, negative is backward.

func (*Editor) Events Uses

func (e *Editor) Events() []EditorEvent

Events returns available editor events.

func (*Editor) Focus Uses

func (e *Editor) Focus()

Focus requests the input focus for the Editor.

func (*Editor) Focused Uses

func (e *Editor) Focused() bool

Focused returns whether the editor is focused or not.

func (*Editor) Insert Uses

func (e *Editor) Insert(s string)

Insert inserts text at the caret, moving the caret forward.

func (*Editor) Layout Uses

func (e *Editor) Layout(gtx layout.Context, sh text.Shaper, font text.Font, size unit.Value) layout.Dimensions

Layout lays out the editor.

func (*Editor) Len Uses

func (e *Editor) Len() int

Len is the length of the editor contents.

func (*Editor) Move Uses

func (e *Editor) Move(distance int)

Move the caret: positive distance moves forward, negative distance moves backward.

func (*Editor) NumLines Uses

func (e *Editor) NumLines() int

NumLines returns the number of lines in the editor.

func (*Editor) PaintCaret Uses

func (e *Editor) PaintCaret(gtx layout.Context)

func (*Editor) PaintText Uses

func (e *Editor) PaintText(gtx layout.Context)

func (*Editor) SetText Uses

func (e *Editor) SetText(s string)

SetText replaces the contents of the editor.

func (*Editor) Text Uses

func (e *Editor) Text() string

Text returns the contents of the editor.

type EditorEvent Uses

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

type Enum Uses

type Enum struct {
    Value string
    // contains filtered or unexported fields
}

func (*Enum) Changed Uses

func (e *Enum) Changed() bool

Changed reports whether Value has changed by user interactino since the last call to Changed.

func (*Enum) Layout Uses

func (e *Enum) Layout(gtx layout.Context, key string) layout.Dimensions

Layout adds the event handler for key.

type Float Uses

type Float struct {
    Value float32
    // contains filtered or unexported fields
}

Float is for selecting a value in a range.

func (*Float) Changed Uses

func (f *Float) Changed() bool

Changed reports whether the value has changed since the last call to Changed.

func (*Float) Layout Uses

func (f *Float) Layout(gtx layout.Context, pointerMargin int, min, max float32) layout.Dimensions

Layout processes events.

func (*Float) Pos Uses

func (f *Float) Pos() float32

Pos reports the selected position.

type Icon Uses

type Icon struct {
    Color color.NRGBA
    // contains filtered or unexported fields
}

func NewIcon Uses

func NewIcon(data []byte) (*Icon, error)

NewIcon returns a new Icon from IconVG data.

func (*Icon) Layout Uses

func (ic *Icon) Layout(gtx layout.Context, sz unit.Value) layout.Dimensions

type Image Uses

type Image struct {
    // Src is the image to display.
    Src paint.ImageOp
    // Scale is the ratio of image pixels to
    // dps. If Scale is zero Image falls back to
    // a scale that match a standard 72 DPI.
    Scale float32
}

Image is a widget that displays an image.

func (Image) Layout Uses

func (im Image) Layout(gtx layout.Context) layout.Dimensions

type Label Uses

type Label struct {
    // Alignment specify the text alignment.
    Alignment text.Alignment
    // MaxLines limits the number of lines. Zero means no limit.
    MaxLines int
}

Label is a widget for laying out and drawing text.

func (Label) Layout Uses

func (l Label) Layout(gtx layout.Context, s text.Shaper, font text.Font, size unit.Value, txt string) layout.Dimensions

type Press Uses

type Press struct {
    // Position of the press.
    Position f32.Point
    // Start is when the press began.
    Start time.Time
    // End is when the press was ended by a release or cancel.
    // A zero End means it hasn't ended yet.
    End time.Time
    // Cancelled is true for cancelled presses.
    Cancelled bool
}

Press represents a past pointer press.

type SubmitEvent Uses

type SubmitEvent struct {
    Text string
}

A SubmitEvent is generated when Submit is set and a carriage return key is pressed.

Directories

PathSynopsis
materialPackage material implements the Material design.

Package widget imports 26 packages (graph) and is imported by 31 packages. Updated 2020-11-27. Refresh now. Tools for package owners.