widget

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type C

type C = layout.Context

type D

type D = layout.Dimensions

type Editable added in v0.6.0

type Editable struct {
	Text      string
	TextSize  unit.Sp
	Color     color.NRGBA
	OnChanged func(text string)
	// contains filtered or unexported fields
}

Editable is an editable label that layouts an editor in responds to clicking.

func EditableLabel added in v0.6.0

func EditableLabel(text string, onChanged func(text string)) *Editable

func (*Editable) Layout added in v0.6.0

func (e *Editable) Layout(gtx C, th *theme.Theme) D

func (*Editable) SetEditing added in v0.6.0

func (e *Editable) SetEditing(editing bool)

func (*Editable) Update added in v0.6.0

func (e *Editable) Update(gtx C)

type LabelAlignment

type LabelAlignment uint8
const (
	Top LabelAlignment = iota
	Left
	Right
	Hidden
)

type LabelOption

type LabelOption struct {
	Alignment LabelAlignment
	Ratio     float32
	// Space between laben and input box
	Padding unit.Dp
}
type Link[T LinkSrc] struct {
	Title  string
	Src    T
	Params map[string]interface{}
	// Open in new tab. Valid only if the link is a native gioview View.
	OpenInNewTab bool
	// Click handler for the link.
	OnClicked func(intent any) error
	// contains filtered or unexported fields
}

A link is a clickable widget used to jump between views, or open a web URL, as anchor in HTML.

func (*Link[T]) Clicked added in v0.6.0

func (link *Link[T]) Clicked() bool

func (*Link[T]) Layout added in v0.6.0

func (link *Link[T]) Layout(gtx C, lt *text.Shaper, font font.Font, size unit.Sp, textMaterial op.CallOp) D

func (*Link[T]) OnClick added in v0.6.0

func (link *Link[T]) OnClick() error

OnClick handles the click event by calling the provided OnClicked callback. If no OnClicked callback is provided, it does nothing.

func (*Link[T]) Update added in v0.6.0

func (link *Link[T]) Update(gtx C) bool

Update handles link events and reports if the link was clicked.

type LinkSrc added in v0.6.0

type LinkSrc interface {
	~string | view.ViewID
}

LinkSrc defines a generic type constraint. String type is for web url. And ViewID indicates a Gioview View.

type LinkStyle added in v0.6.0

type LinkStyle[T LinkSrc] struct {

	// Face defines the text style.
	Font         font.Font
	Color        color.NRGBA
	ClickedColor color.NRGBA
	// show as button or normal text?
	Style string
	// contains filtered or unexported fields
}
func NewLink[T LinkSrc](link *Link[T], style string) *LinkStyle[T]

func (*LinkStyle[T]) Layout added in v0.6.0

func (ls *LinkStyle[T]) Layout(gtx C, th *theme.Theme) D

type ModalLayer added in v0.5.0

type ModalLayer struct {
	component.VisibilityAnimation
	Widget func(gtx layout.Context, th *material.Theme, anim *component.VisibilityAnimation) layout.Dimensions
}

ModalLayer is a widget drawn on top of the normal UI that can be populated by other components with dismissble modal dialogs.

func NewModal added in v0.5.0

func NewModal() *ModalLayer

NewModal creates an initializes a modal layer.

func (*ModalLayer) Layout added in v0.5.0

func (m *ModalLayer) Layout(gtx layout.Context, th *material.Theme) layout.Dimensions

Layout renders the modal layer. Unless a modal widget has been triggered, this will do nothing.

type Tag added in v0.6.0

type Tag struct {
	Text     string
	TextSize unit.Sp
	Font     font.Font
	// Text color the of label. For outine variant, this is also the border of the tag.
	TextColor color.NRGBA
	// Background color of the label. Only valid in the case of Solid variant.
	Background color.NRGBA
	Radius     unit.Dp
	Inset      layout.Inset
	Variant    TagVariant
}

Tag is used for items that need to be labeled using keywords that describe them.

func (Tag) Layout added in v0.6.0

func (t Tag) Layout(gtx C, th *theme.Theme) D

type TagVariant added in v0.6.0

type TagVariant uint8
const (
	Solid TagVariant = iota
	Outline
)

type TextField

type TextField struct {
	// padding between the text and border.
	Padding unit.Dp
	// border radius of the input box.
	Radius     unit.Dp
	SingleLine bool
	// Text alignment in the box.
	Alignment text.Alignment
	// Label alignment option
	LabelOption LabelOption

	// Helper text to give additional context to a field.
	HelperText string
	// The maximum number of characters the text input will allow.
	// Zero means no limit.
	MaxChars int
	// Mask replaces the visual display of each rune in the contents with the given rune.
	Mask rune

	// Leading appears before the content of the text input.
	Leading layout.Widget
	// Trailing appears after the content of the text input.
	Trailing layout.Widget
	// contains filtered or unexported fields
}

Another TextField implementation with the following features: * configurable padding and border radius * more compact design by put character counters inline. * subscribe ESC key events to defocus the text field. * configurable label alignment.

func (*TextField) Changed

func (in *TextField) Changed() bool

Changed returns whether or not the text input has changed since last call.

func (*TextField) Clear

func (in *TextField) Clear()

Clear clears the input text.

func (*TextField) ClearError

func (in *TextField) ClearError()

func (*TextField) Focused

func (in *TextField) Focused(gtx layout.Context) bool

func (*TextField) Layout

func (in *TextField) Layout(gtx layout.Context, th *theme.Theme, hint string) layout.Dimensions

func (*TextField) SetError

func (in *TextField) SetError(err string)

func (*TextField) SetFocus added in v0.8.0

func (in *TextField) SetFocus(gtx layout.Context)

func (*TextField) SetText

func (in *TextField) SetText(text string)

func (*TextField) State added in v0.8.0

func (in *TextField) State() *widget.Editor

func (*TextField) Submitted

func (in *TextField) Submitted() bool

func (*TextField) Text

func (in *TextField) Text() string

Text returns the current input text.

type TransferTarget added in v0.6.0

type TransferTarget interface {
	// data to copy to clipboard.
	Data() string
	// read data from clipboard.
	OnPaste(data string, removeOld bool) error
}

type Transferable added in v0.6.0

type Transferable struct {
	Target TransferTarget
	// contains filtered or unexported fields
}

func (*Transferable) Layout added in v0.6.0

func (t *Transferable) Layout(gtx C, th *theme.Theme, w layout.Widget) D

func (*Transferable) Update added in v0.6.0

func (t *Transferable) Update(gtx C) error

type WrapList

type WrapList struct {
	widget.Scrollbar
	gvlayout.ListWrap
}

WrapList holds the persistent state for a wrappable layout.List that has a scrollbar attached.

type WrapListStyle

type WrapListStyle struct {
	material.ScrollbarStyle
	material.AnchorStrategy
	// contains filtered or unexported fields
}

WrapListStyle configures the presentation of a wrappable layout.List with a scrollbar.

func List

func List(th *theme.Theme, state *WrapList) *WrapListStyle

func (WrapListStyle) Layout

Layout the list and its scrollbar.

Jump to

Keyboard shortcuts

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