widgetx

package
v0.0.0-...-c164e21 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT, Unlicense Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadIcon

func LoadIcon(data []byte) widget.Icon

LoadIcon loads an icon from its data.

func LoadIcons

func LoadIcons(data ...[]byte) []widget.Icon

LoadIcons returns a slice of icons from their data.

Types

type Anim

type Anim struct {
	// Next is the interpolator function.
	Next func(float32) (float32, time.Duration)
	// contains filtered or unexported fields
}

Anim manages Frame refreshes based on an interpolator function.

func (*Anim) Animate

func (a *Anim) Animate(gtx layout.Context) (done bool)

Animate moves the animation forward if possible and returns whether or not the animation is complete.

func (*Anim) Animating

func (a *Anim) Animating() bool

func (*Anim) Start

func (a *Anim) Start(start, end float32)

Start starts the animation, ending when the value crosses the end value.

func (*Anim) Value

func (a *Anim) Value() float32

Value returns the current value, without animating.

type ClickElement

type ClickElement func(layout.Context, int, *widget.Clickable) layout.Dimensions

ClickElement displays the ith element.

type ClickIcon

type ClickIcon struct {
	Hover Hover
	// Color is the icon color when not hovered.
	Color color.NRGBA
	Size  unit.Value
	Icon  widget.Icon
	// contains filtered or unexported fields
}

ClickIcon provides a clickable icon with hover shadow.

func (*ClickIcon) Bind

func (cl *ClickIcon) Bind(bar *Icons, idx int)

func (*ClickIcon) Changed

func (cl *ClickIcon) Changed() bool

func (*ClickIcon) Hovered

func (cl *ClickIcon) Hovered() bool

func (*ClickIcon) Layout

func (cl *ClickIcon) Layout(gtx layout.Context) layout.Dimensions

func (*ClickIcon) Status

func (cl *ClickIcon) Status() bool

type ClickList

type ClickList struct {
	Hover Hover
	List  layout.List
	// contains filtered or unexported fields
}

ClickList manages a list of clickable items.

func (*ClickList) Clicked

func (cl *ClickList) Clicked() (pos int, click widget.Click)

func (*ClickList) Hovered

func (cl *ClickList) Hovered(idx int) bool

func (*ClickList) Layout

func (cl *ClickList) Layout(gtx layout.Context, n int, el ClickElement) layout.Dimensions

type ClickListWrap

type ClickListWrap struct {
	Hover     Hover
	Separator color.NRGBA
	List      layoutx.ListWrap
	// contains filtered or unexported fields
}

func (*ClickListWrap) Clicked

func (cl *ClickListWrap) Clicked() (pos int, click widget.Click)

func (*ClickListWrap) Layout

func (cl *ClickListWrap) Layout(gtx layout.Context, n int, el ClickElement) layout.Dimensions

type Draggable

type Draggable struct {
	Axis gesture.Axis
	// Ratio is calculated after each layout from gtx.Constraints.Min.
	// Ratio is always in [0, 1].
	Ratio f32.Point
	// contains filtered or unexported fields
}

Draggable makes an area draggable and reports its position in Pos.

func (*Draggable) Layout

func (d *Draggable) Layout(gtx layout.Context) layout.Dimensions

type Error

type Error struct {
	// Error is the error to be displayed.
	Error error
	// Show is the duration for which the error is displayed.
	// If zero, it is displayed until Error is nil.
	Show       time.Duration
	Text       themex.Text
	Background color.NRGBA
	// contains filtered or unexported fields
}

Error is used to display transient or not transient error message.

func (*Error) Layout

func (e *Error) Layout(gtx layout.Context) layout.Dimensions

type File

type File struct {
	Palettes struct {
		// Main is applied to the overall window.
		Main material.Palette
		// Area is applied to the individual windows.
		Area material.Palette
		// Error is applied to displayed error messages.
		Error material.Palette
	}
	Text struct {
		Label  Label
		Editor func(layout.Context, *Input) layout.Dimensions
	}
	Icons struct {
		Partitions      widget.Icon
		File            widget.Icon
		Folder          widget.Icon
		Favorite        widget.Icon
		History         widget.Icon
		Selection       widget.Icon
		FavoriteHistory widget.Icon
		Refresh         widget.Icon
		Expand          widget.Icon
		Collapse        widget.Icon
		Search          widget.Icon
		Close           widget.Icon
		ShowHidden      widget.Icon
		ShowDetails     widget.Icon
		SortAsc         widget.Icon
		SortDesc        widget.Icon
		NewFolder       widget.Icon
	}
	Hover Hover
	// Path is the current path.
	Path string
	// Selection determines the number and kind of files or directories to be selected.
	Selection FileSelection
	// contains filtered or unexported fields
}

File provides a way to select a set of files or directories.

func (*File) Layout

func (f *File) Layout(gtx layout.Context) layout.Dimensions

func (*File) Selected

func (f *File) Selected() []string

Selected returns the slice of selected files or directories.

type FilePalettes

type FilePalettes struct {
	Main  material.Palette
	Area  material.Palette
	Error material.Palette
}

FilePalettes defines the color palettes for File.

type FileSelection

type FileSelection uint8

FileSelection is the type and number of files to be selected by a File.

const (
	SelectFile        FileSelection = iota // Single file
	SelectDirectory                        // Single directory
	SelectFiles                            // SelectFiles
	SelectDirectories                      // SelectDirectories
)

type Hover

type Hover struct {
	// Background is the filling color when hovered.
	Background color.NRGBA
	// Foreground is the icon color when hovered.
	Foreground color.NRGBA
	// Radius is the filling radius.
	Radius unit.Value
}

Hover fills its min area with Background when hovered.

Typical use is with layout.Expanded.

func (Hover) Layout

func (h Hover) Layout(gtx layout.Context, hovered bool) layout.Dimensions

type Icons

type Icons struct {
	Hover Hover
	// Color is the icon color when not hovered.
	Color color.NRGBA
	Size  unit.Value
	Icons []widget.Icon

	List layout.List
	// contains filtered or unexported fields
}

Icons represents a toolbar made of icons.

func (*Icons) Click

func (s *Icons) Click(idx int)

func (*Icons) Hidden

func (s *Icons) Hidden(idx int) bool

func (*Icons) Hide

func (s *Icons) Hide(indexes ...int)

Hide temporarily removes the icon at indexes from the menu.

func (*Icons) Hovered

func (s *Icons) Hovered(idx int) bool

func (*Icons) Layout

func (s *Icons) Layout(gtx layout.Context, onClick, onPress func(gtx layout.Context, idx int)) layout.Dimensions

func (*Icons) SetStatus

func (s *Icons) SetStatus(idx int, status bool)

func (*Icons) Show

func (s *Icons) Show(indexes ...int)

Show restores the icon at indexes in the menu.

func (*Icons) Status

func (s *Icons) Status(idx int) bool

type Input

type Input struct {
	Padding   unit.Value
	Leading   layout.Widget
	Trailing  layout.Widget
	Editor    *widget.Editor
	NoUnfocus bool // disables ESC to unfocus
	// contains filtered or unexported fields
}

func (*Input) Changed

func (in *Input) Changed() bool

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

func (*Input) Clear

func (in *Input) Clear()

Clear clears the input text. It does not change the active state.

func (*Input) Focus

func (in *Input) Focus()

func (*Input) Focused

func (in *Input) Focused() bool

func (*Input) Layout

func (in *Input) Layout(gtx layout.Context, ed layout.Widget) layout.Dimensions

func (*Input) Submitted

func (in *Input) Submitted() bool

func (*Input) Text

func (in *Input) Text() string

Text returns the current input text.

type Label

type Label struct {
	themex.Text
	widget.Label
}

func (Label) Layout

func (l Label) Layout(gtx layout.Context, ratio float32, txt string) layout.Dimensions

type ListCue

type ListCue struct {
	Color1 color.NRGBA
	Color2 color.NRGBA
	Width  unit.Value
}

ListCue provides a shaded bar on the top/bottom or left/right part of a widget based on the Position offsets.

func (ListCue) Layout

func (lc ListCue) Layout(gtx layout.Context, axis layout.Axis, pos layout.Position) layout.Dimensions
type MenuPopup struct {
	List       ClickList
	Background color.NRGBA
	Padding    unit.Value
	Border     widget.Border
	// contains filtered or unexported fields
}

MenuPopup provides a popup menu.

func (pl *MenuPopup) Layout(gtx layout.Context, num int, el layout.ListElement) layout.Dimensions
type Modal struct {
	Background   color.NRGBA
	Keys         []string
	ReleaseMouse bool
	// contains filtered or unexported fields
}

Modal displays a widget and deactivates its background by grabbing keyboard and mouse events as specified by the Release fields.

func (*Modal) Changed

func (m *Modal) Changed() bool

Changed returns whether or not the area was clicked or ESC was pressed.

func (*Modal) Layout

func (m *Modal) Layout(gtx layout.Context) layout.Dimensions

Layout displays the modal as a defer operation.

type Resizable

type Resizable struct {
	Axis layout.Axis
	// Ratio defines the ratio between the current position
	// of the handle and the widget main axis. Ratio is in [0, 1].
	Ratio float32
	// contains filtered or unexported fields
}

Resizable represents an area that can be resized by dragging a handle.

func (*Resizable) Layout

func (rs *Resizable) Layout(gtx layout.Context, handle layout.Widget) layout.Dimensions

Layout the handle and make it draggable. Dragging actions update the Ratio value.

type Select

type Select struct {
	// Above displays the list above the selected item.
	// By default it is displayed below.
	Above bool
	// contains filtered or unexported fields
}

Select displays a single value that can be selected from a set of values.

func (*Select) Layout

func (s *Select) Layout(gtx layout.Context, n int, el ClickElement) layout.Dimensions

Layout displays the currently selected element within the minimum constraints and the list of elements within the maximum constraints if opened.

func (*Select) Opened

func (s *Select) Opened() bool

func (*Select) Selected

func (s *Select) Selected() int

Selected returns the index of the selected entry.

type Tabs

type Tabs struct {
	List layout.List
	// contains filtered or unexported fields
}

Tabs allows switching content from a list of label widgets.

func (*Tabs) Active

func (ts *Tabs) Active() int

Active returns the index of the active tab.

func (*Tabs) Layout

func (ts *Tabs) Layout(gtx layout.Context, n int, label, content layout.ListElement) layout.Dimensions

Layout lays out the content and list of labels. content may be called with a negative index if there is no tab at all.

func (*Tabs) Remove

func (ts *Tabs) Remove(idx int)

Remove removes the tab at index idx.

func (*Tabs) SetActive

func (ts *Tabs) SetActive(idx int)

SetActive sets the active tab to the one at index idx.

type Tree

type Tree struct {
	Root     func() []int
	Children func(id int) []int
	Axis     layout.Axis
	// contains filtered or unexported fields
}

Tree is a simple tree data structure that can lay itself out. Tree items are referenced by a unique id. Clicking on an item toggles the visibility of its children.

func (*Tree) Close

func (t *Tree) Close(id int)

func (*Tree) Closed

func (t *Tree) Closed(id int) bool

func (*Tree) Layout

func (t *Tree) Layout(gtx layout.Context, el TreeElement) layout.Dimensions

func (*Tree) Open

func (t *Tree) Open(id int)

func (*Tree) Reset

func (t *Tree) Reset()

Reset is to be called when the layout of the tree has changed or its number of elements.

Must be called before any of its element is to be laid out.

type TreeElement

type TreeElement func(layout.Context, *widget.Bool, TreeNode) layout.Dimensions

TreeElement lays out the TreeNode element.

type TreeNode

type TreeNode struct {
	ID          int
	ChildrenNum int
	Depth       int
}

TreeNode contains information about a node.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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