gotoki

package module
Version: v0.0.0-...-051cd72 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: MIT, Unlicense Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFileWindow

func NewFileWindow(f *File, ms DialogStyle, onClose func(err error, clicked int), options ...app.Option)

NewFileWindow creates a new window for the File f with the applied modal.

The onClose callback gets one of the following values for clicked:

- -1: the window was destroyed
- 0: button1 was clicked
- 1: button2 was clicked

func NewWindow

func NewWindow(w layout.Widget, onClose func(error), options ...app.Option) *app.Window

Types

type Anim

type Anim struct {
	// Next defines the next value and how to long it takes to get to it.
	Next func(float32) (float32, time.Duration)
	// contains filtered or unexported fields
}

Anim provides frame refreshes for value transitions.

func (*Anim) Animate

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

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

func (*Anim) Animating

func (a *Anim) Animating() bool

func (*Anim) Prepare

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

Prepare prepares the animation, ending when the value crosses the end value.

The animation is NOT triggered until Animate is called.

func (*Anim) Stop

func (a *Anim) Stop()

Stop cancels the animation.

func (*Anim) Value

func (a *Anim) Value() float32

Value returns the current value, without animating.

type Background

type Background struct {
	Color          color.NRGBA
	NW, NE, SE, SW unit.Value
}

func UniformBackground

func UniformBackground(c color.NRGBA, radius unit.Value) Background

func (Background) Layout

func (b Background) Layout(gtx layout.Context) layout.Dimensions

func (Background) LayoutWidget

func (b Background) LayoutWidget(gtx layout.Context, w layout.Widget) layout.Dimensions

type Bar

type Bar struct {
	BarStyle
	Position layout.Direction
	Bar      []BarNode
	// contains filtered or unexported fields
}

Bar provides a way to organize widgets for menu actions. The widgets are usually icons, text or a mix of both.

func (*Bar) CrossAxis

func (b *Bar) CrossAxis() layout.Axis

CrossAxis returns the cross axis in use based on the bar position.

func (*Bar) Layout

func (b *Bar) Layout(gtx layout.Context, el BarElement, onClick func(*BarNode)) layout.Dimensions

func (*Bar) MainAxis

func (b *Bar) MainAxis() layout.Axis

MainAxis returns the main axis in use based on the bar position.

func (*Bar) Pressed

func (b *Bar) Pressed(idx int) bool

Pressed returns whether the button at index idx is pressed.

type BarElement

type BarElement func(layout.Context, *BarNode) layout.Dimensions

type BarIcon

type BarIcon struct {
	Bar
	Icons   []Icon // default icon
	Clicked []Icon // icon when BarBool is true or BarPopup has Popup
}

BarIcon is a Bar with icons only. The BarNode ids must match their index in the Icons slice.

func (*BarIcon) Layout

func (b *BarIcon) Layout(gtx layout.Context, onClick func(*BarNode)) layout.Dimensions

type BarNode

type BarNode struct {
	Kind BarNodeKind
	ID   int
	// Disabled disables clicking on the node.
	Disabled bool
	// Hidden hides the node. Its main purpose is to be able to filter
	// the content from another Tree's nodes.
	Hidden bool
	// State is the node's state for kind Stateful and the open/close
	// state for Popup.
	State bool
	// BarPopup defines the position of the popup widget relative to
	// the clicked area.
	Pos Popup
	// Popup is the widget to be displayed as a popup.
	// Its constraints are the same as the bar it belongs to.
	Popup layout.Widget
}

BarNode is a bar item.

type BarNodeKind

type BarNodeKind uint8

BarNodeKind defines the kind of node: stateless, stateful or popup

const (
	BarStateless BarNodeKind = iota // no state associated with the node
	BarBool                         // the node has a boolean state
	BarPopup                        // the node pops up a widget
)

type BarStyle

type BarStyle struct {
	Inset      layout.Inset
	Background Background
	Bar        ButtonStyle
	Alignment  layout.Alignment
}

BarStyle defines the stylistic elements of a Bar.

type Button

type Button struct {
	ButtonStyle
	// contains filtered or unexported fields
}

Button is a clickable area.

func (*Button) Clicked

func (b *Button) Clicked() bool

Clicked returns whether the button was clicked in the previous layout.

func (*Button) ClickedN

func (b *Button) ClickedN(n int) bool

ClickedN returns whether the button was clicked n times.

func (*Button) Hovered

func (b *Button) Hovered() bool

Hovered returns whether the button is hovered.

func (*Button) Layout

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

func (*Button) Pressed

func (b *Button) Pressed() bool

Pressed returns whether the button is pressed.

type ButtonBool

type ButtonBool struct {
	State bool
	Button
}

ButtonBool is a Button with a boolean state. The state is toggled by clicking on the button.

func (*ButtonBool) Layout

type ButtonStyle

type ButtonStyle struct {
	Inset    layout.Inset
	Default  Background
	Hover    Background
	Click    Background
	Disabled Background
	Start    Icon
	End      Icon
	// PressDelay make constant presses spaced out by a certain delay.
	PressDelay time.Duration
}

ButtonStyle defines the stylistic elements of a Button.

type ButtonText

type ButtonText struct {
	ButtonTextStyle
	Button
}

ButtonText is a Button displaying text.

func (*ButtonText) Layout

func (b *ButtonText) Layout(gtx layout.Context, txt string) layout.Dimensions

type ButtonTextStyle

type ButtonTextStyle struct {
	Default  Text
	Hover    Text
	Click    Text
	Disabled Text
}

ButtonTextStyle defines the stylistic elements of a ButtonText.

type Buttons

type Buttons []Button

Buttons is a slice of Buttons that can be resized with a given style.

func (Buttons) Pressed

func (b Buttons) Pressed(idx int) bool

Pressed returns whether the button at index idx is pressed.

func (*Buttons) Resize

func (b *Buttons) Resize(n int, style ButtonStyle)

Resize resizes the slice and applies the style to all buttons.

type ButtonsBool

type ButtonsBool struct {
	// Single only keeps the last clicked button with a true state.
	Single  bool
	Buttons []ButtonBool
}

ButtonsBool holds a slice of ButtonBools that can be laid out according to a Widgets.

func (*ButtonsBool) Clicked

func (b *ButtonsBool) Clicked() int

Clicked returns the button index that was clicked in the previous layout.

func (*ButtonsBool) ClickedN

func (b *ButtonsBool) ClickedN(n int) int

ClickedN returns whether the last clicked button was clicked n times.

func (*ButtonsBool) Hovered

func (b *ButtonsBool) Hovered() int

Hovered returns the index of the hovered button if any.

func (*ButtonsBool) Layout

func (*ButtonsBool) Resize

func (b *ButtonsBool) Resize(n int, style ButtonStyle)

Resize resizes the slice and applies the style to all buttons.

func (*ButtonsBool) Select

func (b *ButtonsBool) Select(idx int)

Select marks the button at the given index as selected. If in single mode, any current selection is discarded.

func (*ButtonsBool) Selected

func (b *ButtonsBool) Selected() int

Selected returns the index of the first button with a true state or -1 if none has it.

func (*ButtonsBool) Unselect

func (b *ButtonsBool) Unselect(idx int)

Unselect marks the button at the given index as unselected.

type CheckBoxState

type CheckBoxState uint8

CheckBoxState is the state of a Checkbox.

const (
	CheckboxOff CheckBoxState = iota
	CheckboxOn
	CheckboxBoth // only available in CheckboxTri
)

type Checkbox

type Checkbox struct {
	CheckboxStyle
	Axis layout.Axis
	// contains filtered or unexported fields
}

Checkbox provides a 2 states widget.

func (*Checkbox) Changed

func (b *Checkbox) Changed() bool

func (*Checkbox) Checked

func (b *Checkbox) Checked() bool

Checked returns the checkbox state.

func (*Checkbox) Layout

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

type CheckboxStyle

type CheckboxStyle struct {
	Default  Palette
	Hover    Palette
	Disabled Palette
	Radius   unit.Value
}

CheckboxStyle defines the stylistic elements of a Checkbox.

type CheckboxTri

type CheckboxTri struct {
	Checkbox
}

CheckboxTri provides a 3 states widget.

func (*CheckboxTri) Changed

func (b *CheckboxTri) Changed() bool

func (*CheckboxTri) Layout

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

func (*CheckboxTri) Value

func (b *CheckboxTri) Value() CheckBoxState

Value returns the checkbox state.

type ColorEditor

type ColorEditor struct {
	ColorEditorStyle
	// Color is the color to be edited.
	Color color.NRGBA
	// NoAlpha disables alpha channel changes.
	NoAlpha bool
	// contains filtered or unexported fields
}

ColorEditor is a simple NRGBA color editor.

func (*ColorEditor) Changed

func (b *ColorEditor) Changed() bool

func (*ColorEditor) Layout

func (ed *ColorEditor) Layout(gtx layout.Context) layout.Dimensions

func (*ColorEditor) Update

func (ed *ColorEditor) Update()

Update updates the ColorEditor widgets with its current color.

type ColorEditorStyle

type ColorEditorStyle struct {
	// Axis defines the sliders axis.
	Axis layout.Axis
	// Input is used to display RGBA values.
	Input  InputInt
	Slider Slider
}

ColorEditorStyle defines the stylistic elements of a ColorEditor.

type Dialog

type Dialog struct {
	DialogStyle
	// contains filtered or unexported fields
}

Dialog displays two buttons next to each other.

func (*Dialog) Clicked

func (d *Dialog) Clicked(b DialogButtonType) bool

Clicked returns whether the button was clicked.

func (*Dialog) Disable

func (d *Dialog) Disable(b DialogButtonType)

Disable disables the button.

func (*Dialog) Enable

func (d *Dialog) Enable(b DialogButtonType)

Enable enables the button.

func (*Dialog) Layout

func (d *Dialog) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions

type DialogButtonType

type DialogButtonType uint8

DialogButtonType is the button index for a Dialog.

Buttons are laid out from left to right in increasing index.

const (
	DialogButton1 DialogButtonType = iota
	DialogButton2
)

type DialogStyle

type DialogStyle struct {
	Inset      layout.Inset
	Background Background
	Text       ButtonText
	Button1    string
	Button2    string
}

DialogStyle defines the stylistic elements of a Dialog. Button1 and Button2 are placed next to each other at the SE of the modal window.

type Enum

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

Enum manages a set of int keys. Whenever a key is clicked, the Value is set with the corresponding key.

func (*Enum) Changed

func (b *Enum) Changed() bool

func (*Enum) Hovered

func (e *Enum) Hovered() (int, bool)

Hovered reports the key being hovered, if any.

func (*Enum) Layout

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

Layout registers the key.

func (*Enum) Reset

func (e *Enum) Reset()

Reset clears the enum.

type Error

type Error struct {
	ErrorStyle
	// Error is the error to be displayed.
	Error error
	// 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 ErrorStyle

type ErrorStyle struct {
	Inset layout.Inset
	// Show is the duration for which the error is displayed.
	// If zero, it is displayed until Error is nil.
	Show       time.Duration
	Text       Text
	Background Background
}

ErrorStyle defines the stylistic elements of an Error.

type File

type File struct {
	// Path is the path to display files from.
	Path string
	// Filter is applied to all entries within a directory.
	Filter func(fs.DirEntry) (keep bool)
	FileStyle
	// contains filtered or unexported fields
}

File is a simple file picker.

func (*File) Layout

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

func (*File) Refresh

func (f *File) Refresh()

Refresh reloads the content of the current directory, applying the filter if any.

func (*File) Reset

func (f *File) Reset()

Reset clears the file inputs and selection.

func (*File) SelectDir

func (f *File) SelectDir(ok bool)

SelectDir toggles directory or file selection.

func (*File) Selected

func (f *File) Selected() (fullpath string, clicks int)

Selected returns the selected file and the number of clicks it received (one of: 0, 1 or 2).

type FileStyle

type FileStyle struct {
	// Inset defines the padding main File window.
	Inset layout.Inset
	// Text is used to display the text items.
	Text Text
	// Error is used to display error messages.
	Error *Error
	// Input is the text input for the file name.
	Input InputText
	// Hover is the background and foreground colors used for list items being hovered.
	Hover Palette
	// ListBackground is the background used for lists.
	ListBackground Background
	// Background is the background color used for the widget.
	Background color.NRGBA
	// Size is the icons size.
	Size unit.Value
	// Resize defines the style for the directories/files separator.
	Resize      ResizeStyle
	Partitions  Icon
	NavBackward Icon
	NavForward  Icon
	Bar         BarStyle
	// Filter defines the style for file and directory filtering.
	Filter SelectStyle
}

FileStyle defines the stylistic elements of a File.

type Grid

type Grid struct {
	// Width is the cell width.
	Width unit.Value
	// Height is the cell height.
	Height unit.Value
	// contains filtered or unexported fields
}

Grid is a two dimensions List.

func (*Grid) First

func (g *Grid) First() (x, y int)

First returns the indices of the top left cell.

func (*Grid) Last

func (g *Grid) Last() (x, y int)

Last returns the indices of the bottom right cell.

func (*Grid) Layout

func (g *Grid) Layout(gtx layout.Context, xn, yn int, cell func(gtx layout.Context, x, y int) layout.Dimensions) layout.Dimensions

func (*Grid) Offset

func (g *Grid) Offset() (x, y int)

Offset returns the top left cell offset in pixels.

func (*Grid) StartAt

func (g *Grid) StartAt(x, y int)

StartAt positions the top left cell at (x, y) indices.

type Icon

type Icon struct {
	IconStyle
	Icon widget.Icon
	Size unit.Value
}

func (*Icon) Layout

func (ic *Icon) Layout(gtx layout.Context) layout.Dimensions

type IconStyle

type IconStyle struct {
	Enabled  color.NRGBA
	Disabled color.NRGBA
}

type Input

type Input struct {
	InputStyle
	// Hint is displayed when the input's content is empty.
	Hint string
	// Assist is displayed below the input box.
	Assist string
	// contains filtered or unexported fields
}

Input lays out an input box for single line text.

func (*Input) Changed

func (b *Input) Changed() bool

func (*Input) Editing

func (in *Input) Editing() bool

Editing returns whether the input is being edited.

func (*Input) Layout

func (in *Input) Layout(gtx layout.Context, ed *widget.Editor, onSubmit InputOnSubmit) layout.Dimensions

func (*Input) Reset

func (in *Input) Reset()

Reset clears the Input content.

func (*Input) String

func (in *Input) String() string

String returns the Input content (cached).

func (*Input) Submitted

func (in *Input) Submitted() bool

Submitted returns whether the editor submitted its value in the last frame.

func (*Input) Unfocused

func (in *Input) Unfocused() bool

Unfocused returns whether the input was unfocused by ESC.

type InputInt

type InputInt struct {
	InputIntStyle
	// Incr is the amount by which the value can be
	// increased or decreased.
	Incr int
	// AllowExpr enables simple arithmetic expressions as input.
	// The *, /, - and + operators are supported.
	AllowExpr bool
	Input
	// contains filtered or unexported fields
}

InputInt lays out an input field for integer values.

func (*InputInt) Changed

func (in *InputInt) Changed() bool

func (*InputInt) Int

func (in *InputInt) Int() int

Int returns the current value.

func (*InputInt) Layout

func (in *InputInt) Layout(gtx layout.Context, ed *widget.Editor, onSubmit InputIntOnSubmit) layout.Dimensions

func (*InputInt) SetInt

func (in *InputInt) SetInt(x int, ed *widget.Editor)

SetInt sets the input field to x and updates the editor.

type InputIntOnSubmit

type InputIntOnSubmit func(int, *file.Error)

InputIntOnSubmit is called when the editor is submitted.

type InputIntStyle

type InputIntStyle struct {
	Input     InputStyle
	InputIncr InputStyle
	MoreStyle ButtonStyle
	LessStyle ButtonStyle
	More      Icon
	Less      Icon
}

InputIntStyle defines the stylistic elements of an InputInt.

type InputOnSubmit

type InputOnSubmit func(string) (noFocus bool)

InputOnSubmit is called when the editor is submitted.

type InputRangeInt

type InputRangeInt struct {
	Min, Max int
	// AssistFmt defines the format string
	// to display the min and max values.
	// Empty means no display.
	AssistFmt string
	InputInt
}

InputRangeInt lays out an input field for integer values within a range.

func (*InputRangeInt) Layout

func (in *InputRangeInt) Layout(gtx layout.Context, ed *widget.Editor, onSubmit InputIntOnSubmit) layout.Dimensions

type InputStyle

type InputStyle struct {
	Inset      layout.Inset
	Background Background
	Editing    Background
	Selection  color.NRGBA
	Text       Text
	Disabled   Text
	Assist     Text
}

InputStyle defines the stylistic elements of an Input.

type InputText

type InputText struct {
	InputTextStyle
	Input
	// DoubleFocus defines the editor to be focused upon double click
	// instead of single click.
	DoubleFocus bool
	// NoClear disables the clear button.
	NoClear bool
	// contains filtered or unexported fields
}

InputText lays out an input field for text with a clear button.

func (*InputText) Changed

func (b *InputText) Changed() bool

func (*InputText) Clicked

func (in *InputText) Clicked() bool

Clicked returns whether or not the input was single clicked. Only valid when DoubleFocus is true.

func (*InputText) Layout

func (in *InputText) Layout(gtx layout.Context, ed *widget.Editor, onSubmit func(string) bool) (d layout.Dimensions)

type InputTextStyle

type InputTextStyle struct {
	Clear Icon
	// Button is used to display the clear icon.
	Button ButtonStyle
}

InputTextStyle defines the stylistic elements of an InputText.

type Menu struct {
	MenuStyle
	Position    layout.Direction
	ScrollToEnd bool
	Alignment   layout.Alignment
	Menu        []MenuNode
	// contains filtered or unexported fields
}

Menu provides a way to organize widgets for menu actions. The widgets are usually icons, text or a mix of both.

func (m *Menu) Layout(gtx layout.Context, el MenuElement, onClick func(*MenuNode)) layout.Dimensions
type MenuElement func(layout.Context, *MenuNode) layout.Dimensions
type MenuNode struct {
	ID int
	// Disabled disables clicking on the node.
	Disabled bool
	// Menu defines a submenu.
	Menu []MenuNode
	// MenuPos defines the position of the submenu relative to
	// the clicked area.
	MenuPos Popup
	// MenuOpen is the submenu open status.
	MenuOpen bool
	// contains filtered or unexported fields
}

MenuNode is a menu item. It acts as a submenu if len(Menu) > 0.

type MenuStyle struct {
	Inset         layout.Inset
	Background    Background
	Menu          ButtonStyle
	MenuHighlight Background
	Top           Icon
	Right         Icon
	Bottom        Icon
	Left          Icon
}

MenuStyle defines the stylistic elements of a Menu.

type Modal struct {
	ModalStyle
	Dialog
}

Modal deactivates its container and pops up a widget with a Cancel or OK button. Its Layout is performed as a Defer op.

func (*Modal) Popup

func (m *Modal) Popup(gtx layout.Context, w, dw layout.Widget)

Popup lays out the modal with w as its main content and dw, if non nil, as the content displayed before its Dialog.

type ModalStyle

type ModalStyle struct {
	Overlay color.NRGBA
}

ModalStyle defines the stylistic elements of a Modal.

type Palette

type Palette struct {
	Background color.NRGBA
	Foreground color.NRGBA
}

func (Palette) Layout

func (p Palette) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions

Layout fills the widget's size with the Background color and sets its color op to Foreground.

type Pan

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

Pan makes a widget pannable.

func (*Pan) Layout

func (p *Pan) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions

func (*Pan) Offset

func (p *Pan) Offset() (x, y int)

Offset returns the top left offset in pixels.

func (*Pan) OffsetAt

func (p *Pan) OffsetAt(x, y int)

OffsetAt offsets the widget by (x, y) pixels.

func (*Pan) OffsetLast

func (p *Pan) OffsetLast() (x, y int)

OffsetLast returns the bottom right offset in pixels.

type Popup uint8

Popup displays a widget relative to another one.

const (
	TopLeft Popup = iota
	Top
	TopRight
	Right
	BottomRight
	Bottom
	BottomLeft
	Left
)

func (Popup) Popup

func (p Popup) Popup(gtx layout.Context, src image.Point, popup layout.Widget)

Popup displays the popup widget around the src as follow.

TopLeft

XXX
XXX
XXX
 **
 **

Top

XXX
XXX
XXX
**
**

TopRight

  XXX
**XXX
**XXX

Right

**XXX
**XXX
  XXX

BottomRight

**
**
XXX
XXX
XXX

Bottom

 **
 **
XXX
XXX
XXX

BottomLeft

XXX**
XXX**
XXX

Left

XXX
XXX**
XXX**

type Resize

type Resize struct {
	ResizeStyle
	// Axis defines how the widgets and the handle are laid out.
	Axis layout.Axis
	// Ratio defines how much space is available to the first widget.
	Ratio float32
	// contains filtered or unexported fields
}

Resize provides a draggable handle in between two widgets for resizing their area. Any of the widgets can be nil in which case they are ignored.

func (*Resize) Layout

func (rs *Resize) Layout(gtx layout.Context, w1, w2 layout.Widget) layout.Dimensions

type ResizeCorner

type ResizeCorner struct {
	ResizeCornerStyle
	Position ResizeCorners
	Size     image.Point
	// contains filtered or unexported fields
}

ResizeCorner overlays a resize widget in one of the 4 corners. TODO wip

func (*ResizeCorner) Layout

type ResizeCorner2

type ResizeCorner2 struct {
	ResizeCornerStyle
	Position ResizeCorners
	RatioH   float32
	RatioV   float32
	// contains filtered or unexported fields
}

ResizeCorner2 overlays a resize widget in one of the 4 corners.

func (*ResizeCorner2) Layout

max contraint = container for the widget

type ResizeCornerStyle

type ResizeCornerStyle struct {
	Handle Background
	Width  unit.Value
	Height unit.Value
}

ResizeCornerStyle defines the stylistic elements of a ResizeCorner2.

type ResizeCorners

type ResizeCorners uint8
const (
	BottomRightCorner ResizeCorners = iota
	BottomLeftCorner
	TopLeftCorner
	TopRightCorner
)

type ResizeStyle

type ResizeStyle struct {
	Background Background
	Handle     Background
	Width      unit.Value
	Height     unit.Value
}

ResizeStyle defines the stylistic elements of a Resize.

type Select

type Select struct {
	SelectStyle
	// Above displays the popup above the select widget.
	Above bool
	// Values defines the list of values to select from.
	Values []string
	// Placeholder is displayed when no value is selected.
	Placeholder string
	// contains filtered or unexported fields
}

Select can display a popup list of values to select from.

func (*Select) Changed

func (b *Select) Changed() bool

func (*Select) Layout

func (s *Select) Layout(gtx layout.Context) layout.Dimensions

func (*Select) Select

func (s *Select) Select(pos int)

Select sets the selected item. Use -1 for no selection.

func (*Select) Selected

func (s *Select) Selected() int

type SelectStyle

type SelectStyle struct {
	Inset    layout.Inset
	Text     Text
	Popup    Background
	Default  Background
	Hover    Background
	Disabled Background
	Closed   Icon
	Opened   Icon
}

SelectStyle defines the stylistic elements of a Select.

type Slider

type Slider struct {
	SliderStyle
	widget.Float
	// contains filtered or unexported fields
}

Slider displays a ruler with a handle.

func (*Slider) Layout

func (s *Slider) Layout(gtx layout.Context, min, max float32) layout.Dimensions

Layout lays out the ruler and its handle. If Float.Axis is Horizontal,

    gtx.Constraints.Min.Y determines the handle height
and gtx.Constraints.Min.X determines the ruler width.

If Float.Axis is Vertical,

    gtx.Constraints.Min.X determines the handle width
and gtx.Constraints.Min.Y determines the ruler height.

type SliderStyle

type SliderStyle struct {
	// Width is the ruler and handle width.
	Width    unit.Value
	Default  Background
	Hover    Background
	Disabled Background
}

SliderStyle defines the stylistic elements of a Slider.

type Style

type Style struct {
	Palette
	NW, NE, SE, SW unit.Value // corner radius
	CheckRadius    unit.Value
	Text           Text
}

Style defines groups stylistic elements for various modes (Default, Hovered...).

func (Style) Background

func (s Style) Background() Background

type Tab

type Tab struct {
	TabStyle
	Position    layout.Direction
	ScrollToEnd bool
	Alignment   layout.Alignment
	// Closable defines whether tabs can be closed.
	Closable bool
	// contains filtered or unexported fields
}

Tab defines selectable widgets and display the content of the selected one.

func (*Tab) Close

func (t *Tab) Close(idx int)

Close closes the tab at the given index. If the index is negative, all tabs are closed.

func (*Tab) Closed

func (t *Tab) Closed() int

Closed returns the tab index that was closed on the previous Layout.

func (*Tab) Layout

func (t *Tab) Layout(gtx layout.Context, n int, tab, content layout.ListElement) layout.Dimensions

Layout displays the list of tabs and the content of the selected one. If no tab is selected, then content is called with a negative index.

func (*Tab) Pin

func (t *Tab) Pin(idx int)

Pin pins the tab at index idx. A pinned tab cannot be selected.

func (*Tab) Pinned

func (t *Tab) Pinned(idx int) bool

Pinned returns whether the tab at index idx is pinned.

func (*Tab) Select

func (t *Tab) Select(idx int)

Select selects the tab at index idx.

func (*Tab) Selected

func (t *Tab) Selected() int

Selected returns the currently selected tab index.

func (*Tab) Unpin

func (t *Tab) Unpin(idx int)

Unpin unpins the tab at index idx.

type TabStyle

type TabStyle struct {
	Inset          layout.Inset
	TabInset       layout.Inset
	SepSize        unit.Value
	SepSelected    color.NRGBA
	SepNotSelected color.NRGBA
	Close          Icon
	Button         ButtonStyle
}

TabStyle defines the stylistic elements of a Tab.

type TabText

type TabText struct {
	TabTextStyle
	Tab
	Tabs []string
	// Rename defines whether tabs can be renamed.
	Rename bool
	// contains filtered or unexported fields
}

TabText supports a Tab with string labels.

func (*TabText) Close

func (t *TabText) Close(idx int)

Close closes the tab at index idx. If the index is invalid, it panics.

func (*TabText) Closed

func (t *TabText) Closed() int

func (*TabText) Layout

func (t *TabText) Layout(gtx layout.Context, content layout.ListElement) layout.Dimensions

type TabTextStyle

type TabTextStyle struct {
	Text      Text
	Close     Icon
	Button    ButtonStyle
	Input     InputStyle
	InputText InputTextStyle
}

TabTextStyle defines the stylistic elements of a TabText.

type Text

type Text struct {
	Color     color.NRGBA
	Size      unit.Value
	Shaper    text.Shaper
	Font      text.Font
	Alignment text.Alignment
}

func (Text) Layout

func (t Text) Layout(gtx layout.Context, txt string) layout.Dimensions

type Theme

type Theme struct {
	Bar         BarStyle
	Backgrounds [8]Background
	Button      ButtonStyle
	ButtonText  ButtonTextStyle
	Checkbox    CheckboxStyle
	ColorEditor ColorEditorStyle
	Dialog      DialogStyle
	Error       ErrorStyle
	File        FileStyle
	Icon        IconStyle
	Input       InputStyle
	InputInt    InputIntStyle
	InputText   InputTextStyle
	Menu        MenuStyle
	Modal       ModalStyle
	Resizer     ResizeStyle
	Select      SelectStyle
	Slider      SliderStyle
	Style       ThemeStyle
	Tab         TabStyle
	TabText     TabTextStyle
	Tooltip     TooltipStyle
	Tree        TreeStyle
	Wrap        WrapStyle
}

Theme defines a central structure which holds a copy of all widgets.

func NewTheme

func NewTheme(s ThemeStyle) Theme

NewTheme creates the theme for the supplied style.

type ThemeStyle

type ThemeStyle struct {
	Inset       layout.Inset
	Backgrounds [8]color.NRGBA
	Default     Style
	Hover       Style // input selection
	Click       Style // input editing
	Disabled    Style
	Tooltip     Background
}

ThemeStyle defines all styles for an UI.

func (ThemeStyle) LoadIcon

func (s ThemeStyle) LoadIcon(data []byte) Icon

func (ThemeStyle) Spacer

func (s ThemeStyle) Spacer(axis layout.Axis) layout.Spacer

type Tooltip

type Tooltip struct {
	TooltipStyle
	// contains filtered or unexported fields
}

Tooltip displays a widget next to another one if hovered for some time.

func (*Tooltip) Layout

func (t *Tooltip) Layout(gtx layout.Context, w, tip layout.Widget) layout.Dimensions

type TooltipStyle

type TooltipStyle struct {
	Inset      layout.Inset
	Pos        Popup
	Wait       time.Duration
	Background Background
}

TooltipStyle defines the stylistic elements of a Tooltip.

type Tree

type Tree struct {
	TreeStyle
	Axis        layout.Axis
	ScrollToEnd bool
	Alignment   layout.Alignment
	Root        []*TreeNode
	// contains filtered or unexported fields
}

Tree provides a way to organize widgets in a generic tree fashion. The nodes must be provided to the tree and can change between calls to the Layout method.

func (*Tree) Add

func (t *Tree) Add(parent, id int)

Add adds id to the parent. If parent is nil, it is added to the root of the tree. If a node with the same id already exists for the parent, it is not added.

func (*Tree) AddParent

func (t *Tree) AddParent(id int)

AddParent adds id to the root of the tree.

func (*Tree) CanMoveDown

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

CanMoveDown returns whether id can be moved down.

func (*Tree) CanMoveUp

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

CanMoveUp returns whether id can be moved up.

func (*Tree) Changed

func (b *Tree) Changed() bool

func (*Tree) Del

func (t *Tree) Del(id int)

Del removes id from the tree.

func (*Tree) Layout

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

func (*Tree) MoveDown

func (t *Tree) MoveDown(id int)

MoveDown moves id after its parent next child or to the parent of the parent if there is no previous child.

func (*Tree) MoveUp

func (t *Tree) MoveUp(id int)

MoveUp moves id before its parent previous child or to the parent of the parent if there is no previous child.

func (*Tree) Select

func (t *Tree) Select(node *TreeNode)

Select selects the given node.

func (*Tree) Selected

func (t *Tree) Selected() *TreeNode

Selected returns the id of the selected node and whether there is a selection.

func (*Tree) Unselect

func (t *Tree) Unselect()

Unselect removes any previous selection.

func (*Tree) Walk

func (t *Tree) Walk(fn func(level int, node *TreeNode) (stop bool))

Walk runs fn on each id until instructed to stop or to the end of the tree (depth first).

type TreeElement

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

TreeElement is called for every visible tree node.

type TreeNode

type TreeNode struct {
	ID    int
	Nodes []*TreeNode
	// Open is the subtree open status.
	Open bool
	// Hidden hides the current node and all its children.
	Hidden bool

	Parent *TreeNode
	// contains filtered or unexported fields
}

TreeNode is a tree node.

func (*TreeNode) Clicked

func (t *TreeNode) Clicked() bool

Clicked returns whether the node was selected.

func (*TreeNode) ClickedN

func (t *TreeNode) ClickedN(n int) bool

ClickedN returns whether the node had a click of n.

func (*TreeNode) Hovered

func (t *TreeNode) Hovered() bool

func (*TreeNode) Walk

func (t *TreeNode) Walk(fn func(node *TreeNode) (stop bool))

type TreeStyle

type TreeStyle struct {
	Inset layout.Inset
	// Opened is the style applied when the node is opened.
	Opened TreeSubStyle
	// Closed is the style applied when the node is closed.
	Closed TreeSubStyle
	// Spacing prepends items with space based on their level in the tree.
	Spacing bool
	// SelectMode allows selection of tree items.
	SelectMode bool
	Selected   ButtonStyle
	Unselected ButtonStyle
	// AccordionMode make non leaf nodes behave as an open/close button.
	AccordionMode bool
}

TreeStyle defines the stylistic elements of a Tree.

type TreeSubStyle

type TreeSubStyle struct {
	Icon
	ButtonStyle
	Selected   ButtonStyle
	Unselected ButtonStyle
}

TreeSubStyle defines the stylistic elements of a Tree.

type TreeText

type TreeText struct {
	Tree
	// contains filtered or unexported fields
}

TreeText implements a tree which nodes are accessible via a path string. A path is / separated.

func (*TreeText) Add

func (t *TreeText) Add(path string)

Add adds the path to the tree. Empty or "/" paths are ignored.

func (*TreeText) Changed

func (b *TreeText) Changed() bool

func (*TreeText) Clear

func (t *TreeText) Clear()

func (*TreeText) Del

func (t *TreeText) Del(path string)

Del removes path from the tree.

func (*TreeText) Path

func (t *TreeText) Path(id int) string

Path returns the string corresponding to id.

func (*TreeText) Select

func (t *TreeText) Select(path string)

Select makes the path selected.

func (*TreeText) Selected

func (t *TreeText) Selected() string

Selected returns the path being selected. If none is selected, the empty string is returned.

type Widgets

Widgets lays out a widget based on its index.

Examples of Widgets:

- layout.List.Layout
- gotoki.Wrap.Layout

type Wrap

type Wrap struct {
	WrapStyle
	Axis layout.Axis
	// contains filtered or unexported fields
}

Wrap lays out as many items as possible along its main axis before moving to its cross axis.

func (*Wrap) Layout

func (w *Wrap) Layout(gtx layout.Context, n int, el layout.ListElement) layout.Dimensions

type WrapScroll

type WrapScroll struct {
	Wrap
	// contains filtered or unexported fields
}

WrapScroll makes the content of a Wrap scrollable along its cross axis.

func (*WrapScroll) Layout

func (*WrapScroll) ScrollTo

func (w *WrapScroll) ScrollTo(idx int)

ScrollTo jumps to the first line/column containing element at the given index.

type WrapStyle

type WrapStyle struct {
	Inset      layout.Inset
	Background Background
	Alignment  layout.Alignment
}

WrapStyle defines the stylistic elements of a Wrap.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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