Back to godoc.org
gioui.org / widget

package widget

v0.0.0 (40141e2)
Latest Go to latest
Published: 3 hours ago | Licenses: MIT, Unlicense | Module: gioui.org

Overview

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

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

func (*Bool) Changed

func (b *Bool) Changed() bool

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

func (*Bool) History

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

func (*Bool) Layout

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

type Border

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

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

func (Border) Layout

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

type ChangeEvent

type ChangeEvent struct{}

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

type Click

type Click struct {
	Modifiers key.Modifiers
	NumClicks int
}

Click represents a click.

type Clickable

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

Clickable represents a clickable area.

func (*Clickable) Clicked

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

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

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

func (*Clickable) History

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

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

type Editor

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

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

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

func (*Editor) CaretPos

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

CaretPos returns the line & column numbers of the caret.

func (*Editor) Delete

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

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

Events returns available editor events.

func (*Editor) Focus

func (e *Editor) Focus()

Focus requests the input focus for the Editor.

func (*Editor) Focused

func (e *Editor) Focused() bool

Focused returns whether the editor is focused or not.

func (*Editor) Insert

func (e *Editor) Insert(s string)

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

func (*Editor) Layout

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

func (e *Editor) Len() int

Len is the length of the editor contents.

func (*Editor) Move

func (e *Editor) Move(distance int)

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

func (*Editor) NumLines

func (e *Editor) NumLines() int

NumLines returns the number of lines in the editor.

func (*Editor) PaintCaret

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

func (*Editor) PaintText

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

func (*Editor) SetText

func (e *Editor) SetText(s string)

SetText replaces the contents of the editor.

func (*Editor) Text

func (e *Editor) Text() string

Text returns the contents of the editor.

type EditorEvent

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

type Enum

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

func (*Enum) Changed

func (e *Enum) Changed() bool

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

func (*Enum) Layout

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

Layout adds the event handler for key.

type Float

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

Float is for selecting a value in a range.

func (*Float) Changed

func (f *Float) Changed() bool

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

func (*Float) Layout

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

Layout processes events.

func (*Float) Pos

func (f *Float) Pos() float32

Pos reports the selected position.

type Icon

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

func NewIcon

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

NewIcon returns a new Icon from IconVG data.

func (*Icon) Layout

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

type Image

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

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

type Label

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

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

type Press

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

type SubmitEvent struct {
	Text string
}

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

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier