theme

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDividerWidth                   unit.Dp = 1
	DefaultDividerMargin                  unit.Dp = 1
	DefaultDividerHandleMinVerticalMargin unit.Dp = 2
	DefaultDividerHandleMaxHeight         unit.Dp = 12
	DefaultDividerHandleWidth             unit.Dp = 3
	DefaultDividerHandleRadius            unit.Dp = 2
	DefaultHeaderPadding                  unit.Dp = 5
	DefaultHeaderBorder                   unit.Dp = 1
	DefaultExpandedBorder                 unit.Dp = 1
)

Variables

View Source
var DefaultPalette = Palette{
	Background:         oklch(99.44, 0.027, 106.89),
	Foreground:         oklch(0, 0, 0),
	ForegroundDisabled: oklch(55.21, 0, 0),
	NavigationLink:     oklch(57.32, 0.235, 29.23),
	OpenLink:           oklch(45.2, 0.31, 264.05),
	Link:               oklch(45.2, 0.31, 264.05),
	PrimarySelection:   oklcha(93.11, 0.101, 108.21, 0.6),
	Border:             oklch(0, 0, 0),

	Popup: struct {
		TitleForeground color.Oklch
		TitleBackground color.Oklch
		Background      color.Oklch
	}{
		TitleForeground: oklch(0, 0, 0),
		TitleBackground: oklch(98.82, 0.017, 196.89),
		Background:      oklch(98.29, 0.029, 145.35),
	},

	Menu: struct {
		Background color.Oklch
		Selected   color.Oklch
		Border     color.Oklch
		Disabled   color.Oklch
	}{
		Background: oklch(98.82, 0.017, 196.89),
		Selected:   oklch(89.92, 0.081, 195.81),
		Border:     oklch(89.92, 0.081, 195.81),
		Disabled:   oklch(73.8, 0, 0),
	},

	Table: struct {
		EvenRowBackground    color.Oklch
		OddRowBackground     color.Oklch
		HoveredRowBackground color.Oklch
		HeaderBackground     color.Oklch
		Divider              color.Oklch
		DragHandle           color.Oklch
		ExpandedBorder       color.Oklch
		ExpandedBackground   color.Oklch
	}{
		EvenRowBackground:    oklch(99.44, 0.027, 106.89),
		OddRowBackground:     oklch(99.44, 0.027, 106.89),
		HoveredRowBackground: oklch(95.63, 0.024, 106.84),
		HeaderBackground:     oklch(96.48, 0.026, 106.88),
		Divider:              oklch(80.15, 0, 0),
		DragHandle:           oklch(0, 0, 0),
		ExpandedBorder:       oklch(80.15, 0, 0),
		ExpandedBackground:   oklch(88.63, 0.053, 346),
	},
}

Functions

func Dumb

func Dumb(win *Window, w Widget) layout.Widget

func EaseBezier added in v0.4.0

func EaseBezier(t float64) float64

func FairlySimpleTable added in v0.4.0

func FairlySimpleTable(
	win *Window,
	gtx layout.Context,
	tbl *Table,
	scroll *YScrollableListState,
	nrows int,
	rowFn RowFn,
) layout.Dimensions

func Fill added in v0.4.0

func Fill(win *Window, ops *op.Ops, c color.Oklch)

Fill paints an infinitely large plane with the provided color. It is intended to be used with a clip.Op already in place to limit the painted area. Use FillShape unless you need to paint several times within the same clip.Op.

func FillShape added in v0.4.0

func FillShape(win *Window, ops *op.Ops, c color.Oklch, shape clip.Op)

FillShape fills the clip shape with a color.

func FromListPosition added in v0.4.0

func FromListPosition(lp layout.Position, elements int, majorAxisSize int) (start, end float32)

FromListPosition converts a layout.Position into two floats representing the location of the viewport on the underlying content. It needs to know the number of elements in the list and the major-axis size of the list in order to do this. The returned values will be in the range [0,1], and start will be less than or equal to end.

func Lerp added in v0.4.0

func Lerp[T constraints.Integer | constraints.Float](start, end T, r float64) T

func SimpleTable added in v0.4.0

func SimpleTable(
	win *Window,
	gtx layout.Context,
	tbl *Table,
	scroll *YScrollableListState,
	nrows int,
	cellFn CellFn,
) layout.Dimensions

func StartSimpleAnimation added in v0.4.0

func StartSimpleAnimation[T constraints.Integer | constraints.Float](gtx layout.Context, anim *Animation[T], v1, v2 T, d time.Duration, ease EasingFunction)

Types

type Action added in v0.4.0

type Action interface{ IsAction() }

type AnchorStrategy

type AnchorStrategy uint8

AnchorStrategy defines a means of attaching a scrollbar to content.

const (
	// Occupy reserves space for the scrollbar, making the underlying
	// content region smaller on one axis.
	Occupy AnchorStrategy = iota
	// Overlay causes the scrollbar to float atop the content without
	// occupying any space. Content in the underlying area can be occluded
	// by the scrollbar.
	Overlay
)

type Animation added in v0.4.0

type Animation[T any] struct {
	StartValue T
	EndValue   T
	StartTime  time.Time
	Duration   time.Duration
	Ease       EasingFunction
	Lerp       LerpFunction[T]
	// contains filtered or unexported fields
}

func (*Animation[T]) Cancel added in v0.4.0

func (anim *Animation[T]) Cancel()

func (*Animation[T]) Done added in v0.4.0

func (anim *Animation[T]) Done() bool

func (*Animation[T]) Start added in v0.4.0

func (anim *Animation[T]) Start(gtx layout.Context, v1, v2 T, d time.Duration, ease EasingFunction)

func (*Animation[T]) Value added in v0.4.0

func (anim *Animation[T]) Value(gtx layout.Context) T

type Background added in v0.4.0

type Background struct {
	Color color.Oklch
}

func (Background) Layout added in v0.4.0

func (b Background) Layout(win *Window, gtx layout.Context, w Widget) layout.Dimensions

type Border added in v0.4.0

type Border struct {
	Color color.Oklch
	Width unit.Dp
}

Border draws a border and renders a widget inside it.

func (Border) Layout added in v0.4.0

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

type Bordered added in v0.4.0

type Bordered struct {
	Color color.Oklch
	Width unit.Dp
}

Bordered is like Border, but automatically applys an inset.

func (Bordered) Layout added in v0.4.0

func (b Bordered) Layout(win *Window, gtx layout.Context, w Widget) layout.Dimensions

type BorderedTextStyle

type BorderedTextStyle struct {
	Text string

	Padding         unit.Dp
	BorderSize      unit.Dp
	BorderColor     color.Oklch
	TextSize        unit.Sp
	TextColor       color.Oklch
	BackgroundColor color.Oklch
}

func BorderedText

func BorderedText(th *Theme, s string) BorderedTextStyle

func (BorderedTextStyle) Layout

func (bt BorderedTextStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions

type ButtonStyle

type ButtonStyle struct {
	Text   string
	Button *widget.Clickable

	ActiveBackgroundColor color.Oklch
	BackgroundColor       color.Oklch
	BorderColor           color.Oklch
	TextColor             color.Oklch
	TextColorDisabled     color.Oklch
}

func Button

func Button(th *Theme, button *widget.Clickable, txt string) ButtonStyle

func (ButtonStyle) Layout

func (b ButtonStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions

type CellFn added in v0.4.0

type CellFn func(win *Window, gtx layout.Context, row, col int) layout.Dimensions

type CheckBoxGroupStyle added in v0.2.0

type CheckBoxGroupStyle struct {
	Clickable       *widget.Clickable
	Label           string
	TextSize        unit.Sp
	ForegroundColor color.Oklch
	BackgroundColor color.Oklch
	TextColor       color.Oklch
}

func CheckBoxGroup added in v0.2.0

func CheckBoxGroup(th *Theme, clickable *widget.Clickable, label string) CheckBoxGroupStyle

func (CheckBoxGroupStyle) Layout added in v0.2.0

func (chkgrp CheckBoxGroupStyle) Layout(win *Window, gtx layout.Context, checkboxes ...CheckBoxStyle) layout.Dimensions

type CheckBoxStyle

type CheckBoxStyle struct {
	Checkbox        widget.Boolean
	Label           string
	TextSize        unit.Sp
	ForegroundColor color.Oklch
	BackgroundColor color.Oklch
	TextColor       color.Oklch
}

func CheckBox

func CheckBox(th *Theme, checkbox widget.Boolean, label string) CheckBoxStyle

func (CheckBoxStyle) Layout

func (c CheckBoxStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions

type Column added in v0.4.0

type Column struct {
	Name      string
	Width     float32
	MinWidth  float32
	Alignment text.Alignment
	Clickable bool
}

type Command added in v0.4.0

type Command interface {
	Layout(win *Window, gtx layout.Context, current bool) layout.Dimensions
	Filter(input string) bool
	Link() Action
}

type CommandPalette added in v0.4.0

type CommandPalette struct {
	Prompt string
	// contains filtered or unexported fields
}

XXX split into style and state

func (*CommandPalette) Layout added in v0.4.0

func (pl *CommandPalette) Layout(win *Window, gtx layout.Context) layout.Dimensions

func (*CommandPalette) Set added in v0.4.0

func (pl *CommandPalette) Set(cmds CommandProvider)

type CommandProvider added in v0.4.0

type CommandProvider interface {
	At(idx int) Command
	Len() int
}

type CommandSlice added in v0.4.0

type CommandSlice []Command

func (CommandSlice) At added in v0.4.0

func (cs CommandSlice) At(idx int) Command

func (CommandSlice) Len added in v0.4.0

func (cs CommandSlice) Len() int

type Component added in v0.4.0

type Component interface {
	Layout(win *Window, gtx layout.Context) layout.Dimensions
	// Title is the title to display as the window or tab title.
	Title() string
	// WantsTransition indicates that the component wants to transition to a different state. It is not
	// guaranteed that the request will be honored. Calling WantsTransition clears the desired state
	// transition.
	//
	// This method is not thread-safe.
	WantsTransition(gtx layout.Context) ComponentState
	// Transition notifies the component of its new state. This is called at least once before drawing the
	// component for the first time. There may or may not be a transition to the closed state.
	Transition(state ComponentState)
}

A Component is a widget that can be displayed as a panel, tab, or in its own window.

type ComponentButtons added in v0.4.0

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

func (*ComponentButtons) Backed added in v0.4.0

func (pb *ComponentButtons) Backed(gtx layout.Context) bool

func (*ComponentButtons) Layout added in v0.4.0

func (pb *ComponentButtons) Layout(win *Window, gtx layout.Context) layout.Dimensions

func (*ComponentButtons) Transition added in v0.4.0

func (pb *ComponentButtons) Transition(state ComponentState)

func (*ComponentButtons) WantsTransition added in v0.4.0

func (pb *ComponentButtons) WantsTransition(gtx layout.Context) ComponentState

type ComponentState added in v0.4.0

type ComponentState int

ComponentState describes a component's current state or desired state.

const (
	ComponentStateNone ComponentState = iota
	ComponentStatePanel
	ComponentStateTab
	ComponentStateWindow
	ComponentStateClosed
)

func (ComponentState) String added in v0.4.0

func (state ComponentState) String() string

type DialogStyle

type DialogStyle struct {
	BorderWidth     unit.Dp
	BorderColor     color.Oklch
	Title           string
	TitleSize       unit.Sp
	TitleColor      color.Oklch
	TitleBackground color.Oklch
	TitlePadding    unit.Dp
	Background      color.Oklch
	Padding         unit.Dp
}

func Dialog

func Dialog(th *Theme, title string) DialogStyle

func (DialogStyle) Layout

func (ds DialogStyle) Layout(win *Window, gtx layout.Context, w Widget) layout.Dimensions

type EasingFunction added in v0.4.0

type EasingFunction func(float64) float64

func EaseIn added in v0.4.0

func EaseIn(power int) EasingFunction

func EaseOut added in v0.4.0

func EaseOut(power int) EasingFunction

type EditorStyle

type EditorStyle struct {
	Font     font.Font
	TextSize unit.Sp
	// Color is the text color.
	Color color.Oklch
	// Hint contains the text displayed when the editor is empty.
	Hint string
	// HintColor is the color of hint text.
	HintColor color.Oklch
	// SelectionColor is the color of the background for selected text.
	SelectionColor color.Oklch
	Editor         *widget.Editor
	// contains filtered or unexported fields
}

func Editor

func Editor(th *Theme, editor *widget.Editor, hint string) EditorStyle

func (EditorStyle) Layout

func (e EditorStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions

type ExecuteAction added in v0.4.0

type ExecuteAction func(gtx layout.Context)

func (ExecuteAction) IsAction added in v0.4.0

func (ExecuteAction) IsAction()

type FauxTableRowStyle added in v0.4.0

type FauxTableRowStyle struct {
	Table      *Table
	Background color.Oklch
}

func FauxTableRow added in v0.4.0

func FauxTableRow(tbl *Table, bg color.Oklch) FauxTableRowStyle

func (FauxTableRowStyle) Layout added in v0.4.0

func (row FauxTableRowStyle) Layout(win *Window, gtx layout.Context, w Widget) layout.Dimensions

type Filter

type Filter interface {
	Filter(item ListWindowItem) bool
}

type FlameGraphState added in v0.4.0

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

type FlameGraphStyle added in v0.4.0

type FlameGraphStyle struct {
	State      *widget.FlameGraph
	StyleState *FlameGraphState
	Color      func(level, idx int, f *widget.FlamegraphFrame, hovered bool) color.Oklch
}

func FlameGraph added in v0.4.0

func FlameGraph(state *widget.FlameGraph, sstate *FlameGraphState) FlameGraphStyle

func (FlameGraphStyle) Layout added in v0.4.0

func (fg FlameGraphStyle) Layout(win *Window, gtx layout.Context) (dims layout.Dimensions)

type FoldableStyle

type FoldableStyle struct {
	Title  string
	Closed *widget.Bool

	TextSize  unit.Sp
	TextColor color.Oklch
}

func Foldable

func Foldable(th *Theme, b *widget.Bool, title string) FoldableStyle

func (FoldableStyle) Layout

func (f FoldableStyle) Layout(win *Window, gtx layout.Context, contents Widget) layout.Dimensions

type Future added in v0.3.0

type Future[T any] struct {
	// contains filtered or unexported fields
}

func Immediate added in v0.3.0

func Immediate[T any](value T) *Future[T]

func NewFuture added in v0.3.0

func NewFuture[T any](win *Window, fn func(cancelled <-chan struct{}) T) *Future[T]

func (*Future[T]) MustResult added in v0.3.0

func (ft *Future[T]) MustResult() T

func (*Future[T]) Result added in v0.3.0

func (ft *Future[T]) Result() (T, bool)

func (*Future[T]) ResultNoWait added in v0.3.0

func (ft *Future[T]) ResultNoWait() (T, bool)

func (*Future[T]) Wait added in v0.3.0

func (ft *Future[T]) Wait() T

type Futures added in v0.3.0

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

func (*Futures) Sweep added in v0.3.0

func (ff *Futures) Sweep()

type GridStyle

type GridStyle struct {
	State           *component.GridState
	VScrollbarStyle ScrollbarStyle
	HScrollbarStyle ScrollbarStyle
}

func Grid

func Grid(th *Theme, state *component.GridState) GridStyle

Grid makes a grid with its persistent state.

func (GridStyle) Layout

func (g GridStyle) Layout(win *Window, gtx layout.Context, rows, cols int, dimensioner outlay.Dimensioner, cellFunc outlay.Cell) layout.Dimensions

Layout will draw a grid, using fixed column widths and row height.

type HistogramState added in v0.3.0

type HistogramState struct {
	Histogram *widget.Histogram
	// contains filtered or unexported fields
}

func (*HistogramState) Update added in v0.4.0

func (hs *HistogramState) Update(gtx layout.Context) (start, end widget.FloatDuration, ok bool)

type HistogramStyle added in v0.3.0

type HistogramStyle struct {
	State *HistogramState

	XLabel, YLabel   string
	TextColor        color.Oklch
	TextSize         unit.Sp
	LineColor        color.Oklch
	BinColor         color.Oklch
	HoveredBinColor  color.Oklch
	SelectedBinColor color.Oklch
	OverflowBinColor color.Oklch
}

func Histogram added in v0.3.0

func Histogram(th *Theme, state *HistogramState) HistogramStyle

func (HistogramStyle) Layout added in v0.3.0

func (hs HistogramStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions

type LabelStyle added in v0.4.0

type LabelStyle struct {
	Font      font.Font
	Color     color.Oklch
	Alignment text.Alignment
	MaxLines  int
	TextSize  unit.Sp
	Text      string
}

func Label added in v0.4.0

func Label(th *Theme, txt string) LabelStyle

func LineLabel added in v0.4.0

func LineLabel(th *Theme, txt string) LabelStyle

func (LabelStyle) Dimensions added in v0.4.0

func (ls LabelStyle) Dimensions(win *Window, gtx layout.Context) layout.Dimensions

func (LabelStyle) Layout added in v0.4.0

func (ls LabelStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions

func (LabelStyle) Length added in v0.4.0

func (ls LabelStyle) Length(win *Window, gtx layout.Context) int

type LerpFunction added in v0.4.0

type LerpFunction[T any] func(start, end T, r float64) T

type Lerper added in v0.4.0

type Lerper[T any] interface {
	Lerp(end T, ratio float64) T
}

type ListStyle

type ListStyle struct {
	Main  ScrollbarStyle
	Cross ScrollbarStyle
	AnchorStrategy
	EnableCrossScrolling bool
	// contains filtered or unexported fields
}

ListStyle configures the presentation of a layout.List with a scrollbar.

func List

func List(th *Theme, state *widget.List) ListStyle

List constructs a ListStyle using the provided theme and state.

func (ListStyle) Layout

func (l ListStyle) Layout(win *Window, gtx layout.Context, length int, w layout.ListElement) layout.Dimensions

Layout the list and its scrollbar.

type ListWindow

type ListWindow struct {
	BuildFilter func(string) Filter
	// contains filtered or unexported fields
}

func NewListWindow

func NewListWindow(th *Theme) *ListWindow

func (*ListWindow) Cancelled

func (w *ListWindow) Cancelled() bool

func (*ListWindow) Confirmed

func (w *ListWindow) Confirmed() (any, bool)

func (*ListWindow) Layout

func (w *ListWindow) Layout(win *Window, gtx layout.Context) layout.Dimensions

func (*ListWindow) SetItems

func (w *ListWindow) SetItems(items []ListWindowItem)

type ListWindowItem

type ListWindowItem struct {
	Item         any
	Label        string
	FilterLabels []string
	// contains filtered or unexported fields
}
type Menu struct {
	Groups []MenuGroup
	// contains filtered or unexported fields
}
func (m *Menu) Close()
type MenuDividerStyle struct {
	Color color.Oklch
}
func MenuDivider(th *Theme) MenuDividerStyle
func (mds MenuDividerStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions
type MenuGroup struct {
	Label string
	Items []Widget
	// contains filtered or unexported fields
}
type MenuGroupStyle struct {
	Group      *MenuGroup
	Background color.Oklch
	Border     color.Oklch
}

func NewMenuGroupStyle

func NewMenuGroupStyle(th *Theme, group *MenuGroup) MenuGroupStyle
func (g MenuGroupStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions
type MenuItem struct {
	Label    func() string
	Shortcut string
	Disabled func() bool
	// The action to execute when the menu item is activated. This is only used for context menus, not main
	// menus.
	Action func() Action
	// contains filtered or unexported fields
}
func (item *MenuItem) Clicked(gtx layout.Context) bool
type MenuItemStyle struct {
	Item       *MenuItem
	Foreground color.Oklch
	Background color.Oklch
	Selected   color.Oklch
	Disabled   color.Oklch
}

func NewMenuItemStyle

func NewMenuItemStyle(th *Theme, item *MenuItem) MenuItemStyle
func (item MenuItemStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions
type MenuStyle struct {
	Menu       *Menu
	Foreground color.Oklch
	Background color.Oklch
	Selected   color.Oklch
	Border     color.Oklch
	Disabled   color.Oklch
}

func NewMenuStyle

func NewMenuStyle(th *Theme, menu *Menu) MenuStyle
func (m MenuStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions

type ModalStyle

type ModalStyle struct {
	Background color.Oklch
	Cancelled  *bool
}
func Modal(cancelled *bool) ModalStyle

func (ModalStyle) Layout

func (m ModalStyle) Layout(win *Window, gtx layout.Context, w Widget) layout.Dimensions

type MultiCommandProvider added in v0.4.0

type MultiCommandProvider struct {
	Providers []CommandProvider
}

func (MultiCommandProvider) At added in v0.4.0

func (mcp MultiCommandProvider) At(idx int) Command

func (MultiCommandProvider) Len added in v0.4.0

func (mcp MultiCommandProvider) Len() int

type NormalCommand added in v0.4.0

type NormalCommand struct {
	PrimaryLabel   string
	SecondaryLabel string
	Category       string
	Color          color.Oklch
	Shortcut       string
	Aliases        []string
	Fn             func() Action
}

func (NormalCommand) Filter added in v0.4.0

func (cmd NormalCommand) Filter(input string) bool

func (NormalCommand) Layout added in v0.4.0

func (cmd NormalCommand) Layout(win *Window, gtx layout.Context, current bool) layout.Dimensions
func (cmd NormalCommand) Link() Action

type Palette

type Palette struct {
	Background         color.Oklch
	Foreground         color.Oklch
	ForegroundDisabled color.Oklch
	OpenLink           color.Oklch
	NavigationLink     color.Oklch
	Link               color.Oklch
	PrimarySelection   color.Oklch

	Border color.Oklch

	Popup struct {
		TitleForeground color.Oklch
		TitleBackground color.Oklch
		Background      color.Oklch
	}

	Menu struct {
		Background color.Oklch
		Selected   color.Oklch
		Border     color.Oklch
		Disabled   color.Oklch
	}

	Table struct {
		EvenRowBackground    color.Oklch
		OddRowBackground     color.Oklch
		HoveredRowBackground color.Oklch
		HeaderBackground     color.Oklch
		Divider              color.Oklch
		DragHandle           color.Oklch
		ExpandedBorder       color.Oklch
		ExpandedBackground   color.Oklch
	}
}

type ProgressBarStyle

type ProgressBarStyle struct {
	ForegroundColor color.Oklch
	BackgroundColor color.Oklch
	BorderWidth     unit.Dp
	Progress        float32
}

func ProgressBar

func ProgressBar(th *Theme, progress float32) ProgressBarStyle

func (ProgressBarStyle) Layout

func (p ProgressBarStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions

type Recording added in v0.4.0

type Recording struct {
	Call       op.CallOp
	Dimensions layout.Dimensions
}

func Record added in v0.4.0

func Record(win *Window, gtx layout.Context, w Widget) Recording

func (Recording) Layout added in v0.4.0

func (r Recording) Layout(win *Window, gtx layout.Context) layout.Dimensions

type RememberingList added in v0.4.0

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

func (*RememberingList) Layout added in v0.4.0

func (rlist *RememberingList) Layout(gtx layout.Context, len int, w layout.ListElement) layout.Dimensions

type ResizeStyle

type ResizeStyle struct {
	BorderColor color.Oklch
	// contains filtered or unexported fields
}

func Resize

func Resize(th *Theme, state *component.Resize) ResizeStyle

func (ResizeStyle) Layout

func (rs ResizeStyle) Layout(win *Window, gtx layout.Context, w1, w2 Widget) layout.Dimensions

type RowFn added in v0.4.0

type RowFn func(win *Window, gtx layout.Context, row int) layout.Dimensions

type ScrollIndicatorStyle

type ScrollIndicatorStyle struct {
	// MajorMinLen is the smallest that the scroll indicator is allowed to
	// be along the major axis.
	MajorMinLen unit.Dp
	// MinorWidth is the width of the scroll indicator across the minor axis.
	MinorWidth unit.Dp
	// Color and HoverColor are the normal and hovered colors of the scroll
	// indicator.
	Color, HoverColor color.Oklch
}

ScrollIndicatorStyle configures the presentation of a scroll indicator.

type ScrollTrackStyle

type ScrollTrackStyle struct {
	// MajorPadding and MinorPadding along the major and minor axis of the
	// scrollbar's track. This is used to keep the scrollbar from touching
	// the edges of the content area.
	MinorPadding unit.Dp
	// Color of the track background.
	Color color.Oklch
}

ScrollTrackStyle configures the presentation of a track for a scroll area.

type ScrollbarStyle

type ScrollbarStyle struct {
	Scrollbar *widget.Scrollbar
	Track     ScrollTrackStyle
	Indicator ScrollIndicatorStyle
}

ScrollbarStyle configures the presentation of a scrollbar.

func Scrollbar

func Scrollbar(th *Theme, state *widget.Scrollbar) ScrollbarStyle

Scrollbar configures the presentation of a scrollbar using the provided theme and state.

func (ScrollbarStyle) Layout

func (s ScrollbarStyle) Layout(win *Window, gtx layout.Context, axis layout.Axis, viewportStart, viewportEnd float32) layout.Dimensions

Layout the scrollbar.

func (ScrollbarStyle) Width

func (s ScrollbarStyle) Width() unit.Dp

Width returns the minor axis width of the scrollbar in its current configuration (taking padding for the scroll track into account).

type Shortcut added in v0.3.0

type Shortcut struct {
	Modifiers key.Modifiers
	Name      string
}

type SortOrder added in v0.4.0

type SortOrder uint8
const (
	SortNone SortOrder = iota
	SortAscending
	SortDescending
)

type SwitchStyle added in v0.3.0

type SwitchStyle struct {
	State       widget.Boolean
	Left, Right string
}

func Switch added in v0.3.0

func Switch(b widget.Boolean, left, right string) SwitchStyle

func (SwitchStyle) Layout added in v0.3.0

func (ss SwitchStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions

type TabClick added in v0.4.0

type TabClick struct {
	Index int
	Click widget.Click
}

type TabbedState added in v0.3.0

type TabbedState struct {
	Current int
	// contains filtered or unexported fields
}

func (*TabbedState) Update added in v0.4.0

func (ts *TabbedState) Update(gtx layout.Context) []TabClick

type TabbedStyle added in v0.3.0

type TabbedStyle struct {
	State *TabbedState
	Tabs  []string
}

func Tabbed added in v0.3.0

func Tabbed(state *TabbedState, tabs []string) TabbedStyle

func (TabbedStyle) Layout added in v0.3.0

func (ts TabbedStyle) Layout(win *Window, gtx layout.Context, w Widget) layout.Dimensions

type Table added in v0.4.0

type Table struct {
	Columns   []Column
	SortOrder SortOrder
	SortedBy  int
	// contains filtered or unexported fields
}

TODO(dh): this should be in package widget

func (*Table) ClickedColumn added in v0.4.0

func (tbl *Table) ClickedColumn() (int, bool)

func (*Table) Layout added in v0.4.0

func (tbl *Table) Layout(win *Window, gtx layout.Context, w Widget) layout.Dimensions

func (*Table) SetColumns added in v0.4.0

func (tbl *Table) SetColumns(win *Window, gtx layout.Context, cols []Column)

func (*Table) SortByClickedColumn added in v0.4.0

func (tbl *Table) SortByClickedColumn() (int, bool)

func (*Table) Update added in v0.4.0

func (tbl *Table) Update(gtx layout.Context)

type TableExpandedRowStyle added in v0.4.0

type TableExpandedRowStyle struct {
	Table *Table
}

func TableExpandedRow added in v0.4.0

func TableExpandedRow(tbl *Table) TableExpandedRowStyle

func (TableExpandedRowStyle) Layout added in v0.4.0

type TableHeaderRowStyle added in v0.4.0

type TableHeaderRowStyle struct {
	Table *Table
}

func TableHeaderRow added in v0.4.0

func TableHeaderRow(tbl *Table) TableHeaderRowStyle

func (TableHeaderRowStyle) Layout added in v0.4.0

func (row TableHeaderRowStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions

type TableRowStyle added in v0.4.0

type TableRowStyle struct {
	Table  *Table
	Header bool
}

func TableRow added in v0.4.0

func TableRow(tbl *Table, hdr bool) TableRowStyle

func (TableRowStyle) Layout added in v0.4.0

func (row TableRowStyle) Layout(win *Window, gtx layout.Context, w RowFn) layout.Dimensions

type TableSimpleRowStyle added in v0.4.0

type TableSimpleRowStyle struct {
	Table *Table
}

func TableSimpleRow added in v0.4.0

func TableSimpleRow(tbl *Table) TableSimpleRowStyle

func (TableSimpleRowStyle) Layout added in v0.4.0

func (row TableSimpleRowStyle) Layout(
	win *Window,
	gtx layout.Context,
	rowIdx int,
	cellFn CellFn,
) layout.Dimensions

type TextBoxStyle added in v0.3.0

type TextBoxStyle struct {
	EditorStyle
	Validate func(s string) bool
}

func TextBox added in v0.3.0

func TextBox(th *Theme, editor *widget.Editor, hint string) TextBoxStyle

func (TextBoxStyle) Layout added in v0.3.0

func (tb TextBoxStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions

type Theme

type Theme struct {
	Shaper        *text.Shaper
	Palette       Palette
	TextSize      unit.Sp
	TextSizeLarge unit.Sp

	WindowPadding unit.Dp
	WindowBorder  unit.Dp
}

func NewTheme

func NewTheme(fontCollection []font.FontFace) *Theme

type TooltipStyle

type TooltipStyle struct {
	Message string

	Padding         unit.Dp
	BorderSize      unit.Dp
	BorderColor     color.Oklch
	TextSize        unit.Sp
	TextColor       color.Oklch
	BackgroundColor color.Oklch
}

func Tooltip

func Tooltip(th *Theme, msg string) TooltipStyle

func (TooltipStyle) Layout

func (tt TooltipStyle) Layout(win *Window, gtx layout.Context) layout.Dimensions

type Unit added in v0.4.0

type Unit float32

type Widget

type Widget func(win *Window, gtx layout.Context) layout.Dimensions

type WidgetComponent added in v0.4.0

type WidgetComponent struct {
	ComponentButtons
	// contains filtered or unexported fields
}

WidgetComponent turns any widget into a Component. You are responsible for handling component button events.

func (*WidgetComponent) Layout added in v0.4.0

func (wp *WidgetComponent) Layout(win *Window, gtx layout.Context) layout.Dimensions

type Window

type Window struct {
	AppWindow *app.Window
	Futures   *Futures
	Theme     *Theme
	Menu      *Menu
	// The current frame number
	Frame uint64
	// contains filtered or unexported fields
}

func NewWindow added in v0.3.0

func NewWindow(win *app.Window) *Window

func (*Window) Actions added in v0.4.0

func (win *Window) Actions() []Action

func (*Window) AddCommandProvider added in v0.4.0

func (win *Window) AddCommandProvider(cp CommandProvider)

func (*Window) AddShortcut added in v0.3.0

func (win *Window) AddShortcut(s Shortcut)

AddShortcut adds a new shortcut. The shortcut will only remain registered until the next call to Render.

func (*Window) CloseModal

func (win *Window) CloseModal()

func (*Window) ColorMaterial added in v0.4.0

func (win *Window) ColorMaterial(gtx layout.Context, c color.Oklch) op.CallOp

func (*Window) CommandProviders added in v0.4.0

func (win *Window) CommandProviders() []CommandProvider

func (*Window) ConvertColor added in v0.3.0

func (win *Window) ConvertColor(c color.Oklch) stdcolor.NRGBA

func (*Window) EmitAction added in v0.4.0

func (win *Window) EmitAction(l Action)

func (*Window) Layout added in v0.4.0

func (win *Window) Layout(ops *op.Ops, ev system.FrameEvent, w func(win *Window, gtx layout.Context) layout.Dimensions)

func (*Window) PressedShortcuts added in v0.3.0

func (win *Window) PressedShortcuts() []Shortcut

PressedShortcuts returns the shortcuts that have been pressed since the last call to Render. The slice is only valid until the next call to Render.

func (*Window) SetContextMenu

func (win *Window) SetContextMenu(items []*MenuItem)

func (*Window) SetModal

func (win *Window) SetModal(w Widget)

func (*Window) SetPopup

func (win *Window) SetPopup(w Widget)

TODO(dh): support specifying the minimum/maximum size of the modal, but make it optional

func (*Window) SetTooltip

func (win *Window) SetTooltip(w Widget)

func (*Window) ShowNotification

func (win *Window) ShowNotification(gtx layout.Context, msg string)

func (*Window) TextDimensions added in v0.3.0

func (win *Window) TextDimensions(gtx layout.Context, l widget.Label, font font.Font, size unit.Sp, s string) layout.Dimensions

func (*Window) TextLength added in v0.3.0

func (win *Window) TextLength(gtx layout.Context, l widget.Label, font font.Font, size unit.Sp, s string) int

func (*Window) Update added in v0.4.0

func (win *Window) Update(ops *op.Ops, ev system.FrameEvent, w func(win *Window, gtx layout.Context))

type YScrollableListState added in v0.4.0

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

type YScrollableListStyle added in v0.4.0

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

func YScrollableList added in v0.4.0

func YScrollableList(state *YScrollableListState) YScrollableListStyle

func (YScrollableListStyle) Layout added in v0.4.0

func (tbl YScrollableListStyle) Layout(
	win *Window,
	gtx layout.Context,
	body func(win *Window, gtx layout.Context, list *RememberingList) layout.Dimensions,
) layout.Dimensions

Jump to

Keyboard shortcuts

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