basicwidget

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 26 Imported by: 2

README

Licenses

InterVariable.ttf

Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL

-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION AND CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Documentation

Index

Constants

Variables

View Source
var EnvKeyListItemColorType guigui.EnvKey = guigui.GenerateEnvKey()

EnvKeyListItemColorType is the environment key for obtaining a ListItemColorType from a list item. This is provided by the list's internal content widget, so descendant widgets of list items can query their color type without needing to know their index.

This value is available after the build phase (e.g., during the layout phase).

guigui.Context.Env with this key might return (nil, false) when the item is out of the viewport.

Functions

func AccentTintColor

func AccentTintColor() color.Color

AccentTintColor returns the tint marking the primary action of the theme.

func CreateMonochromeImage

func CreateMonochromeImage(colorMode ebiten.ColorMode, img image.Image) image.Image

func DangerTintColor

func DangerTintColor() color.Color

DangerTintColor returns the tint marking a destructive action or an error.

func FontSize

func FontSize(context *guigui.Context) float64

func InfoTintColor

func InfoTintColor() color.Color

InfoTintColor returns the tint marking neutral information.

func LineHeight

func LineHeight(context *guigui.Context) int

func ListItemIndentSize

func ListItemIndentSize(context *guigui.Context, level int) int

func ListItemTextPadding

func ListItemTextPadding(context *guigui.Context) guigui.Padding

func MoveItemsInSlice

func MoveItemsInSlice[T any](slice []T, from int, count int, to int) int

func RegisterFaceSourceEntries

func RegisterFaceSourceEntries(add func(*guigui.Context, *FaceSourceEntryAdder))

RegisterFaceSourceEntries registers add as a contributor to the fallback resolution stack. add adds its face source entries through the provided FaceSourceEntryAdder.

func RoundedCornerRadius

func RoundedCornerRadius(context *guigui.Context) int

func SuccessTintColor

func SuccessTintColor() color.Color

SuccessTintColor returns the tint marking a successful result.

func TextColorFromTint

func TextColorFromTint(context *guigui.Context, tint color.Color) color.Color

TextColorFromTint returns the color to draw text tinted with tint, for use with TextStyle.SetColor. A nil tint returns the color for enabled text.

func TooltipTextPadding

func TooltipTextPadding(context *guigui.Context) guigui.Padding

TooltipTextPadding returns the padding for tooltip text content.

func UnitSize

func UnitSize(context *guigui.Context) int

func WarningTintColor

func WarningTintColor() color.Color

WarningTintColor returns the tint marking a condition that needs attention.

Types

type Background

type Background struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*Background) Draw

func (b *Background) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*Background) SetTintColor

func (b *Background) SetTintColor(tint color.Color)

SetTintColor sets the color the background derives its fill from. A nil tint restores the default fill.

func (*Background) WriteStateKey

func (b *Background) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type Button

type Button struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*Button) Build

func (b *Button) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Button) CursorShape

func (b *Button) CursorShape(context *guigui.Context, widgetBounds *guigui.WidgetBounds) (ebiten.CursorShapeType, bool)

func (*Button) Draw

func (b *Button) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*Button) HandlePointingInput

func (b *Button) HandlePointingInput(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult

func (*Button) Layout

func (b *Button) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Button) Measure

func (b *Button) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Button) OnDown

func (b *Button) OnDown(f func(context *guigui.Context))

func (*Button) OnUp

func (b *Button) OnUp(f func(context *guigui.Context))

func (*Button) SetContent

func (b *Button) SetContent(content guigui.Widget)

func (*Button) SetIcon

func (b *Button) SetIcon(icon *ebiten.Image)

func (*Button) SetIconAlign

func (b *Button) SetIconAlign(align IconAlign)

func (*Button) SetPressed

func (b *Button) SetPressed(pressed bool)

SetPressed sets whether the button stays pressed.

A pressed button ignores clicks unless the button is toggleable.

func (*Button) SetSharpCorners

func (b *Button) SetSharpCorners(sharpCorners Corners)

func (*Button) SetText

func (b *Button) SetText(text string)

func (*Button) SetTextBold

func (b *Button) SetTextBold(bold bool)

func (*Button) SetTintColor

func (b *Button) SetTintColor(tint color.Color)

SetTintColor sets the color the button derives its appearance from. A nil tint restores the default appearance. A primary button ignores the tint.

func (*Button) SetToggleable

func (b *Button) SetToggleable(toggleable bool)

SetToggleable sets whether the button works as a toggle button.

A toggleable button accepts clicks even while it is pressed.

func (*Button) SetType

func (b *Button) SetType(typ ButtonType)

func (*Button) Tick

func (b *Button) Tick(context *guigui.Context, widgetBounds *guigui.WidgetBounds) error

func (*Button) WriteStateKey

func (b *Button) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type ButtonType

type ButtonType int
const (
	ButtonTypeNormal ButtonType = iota
	ButtonTypePrimary
)

type Checkbox

type Checkbox struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*Checkbox) Build

func (c *Checkbox) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Checkbox) CursorShape

func (c *Checkbox) CursorShape(context *guigui.Context, widgetBounds *guigui.WidgetBounds) (ebiten.CursorShapeType, bool)

func (*Checkbox) Draw

func (c *Checkbox) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*Checkbox) HandlePointingInput

func (c *Checkbox) HandlePointingInput(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult

func (*Checkbox) Layout

func (c *Checkbox) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Checkbox) Measure

func (c *Checkbox) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Checkbox) OnValueChanged

func (c *Checkbox) OnValueChanged(f func(context *guigui.Context, value bool))

func (*Checkbox) SetValue

func (c *Checkbox) SetValue(value bool)

func (*Checkbox) Tick

func (c *Checkbox) Tick(context *guigui.Context, widgetBounds *guigui.WidgetBounds) error

func (*Checkbox) Value

func (c *Checkbox) Value() bool

func (*Checkbox) WriteStateKey

func (c *Checkbox) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type Combobox

type Combobox struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

Combobox is a composite widget that combines a TextInput with a PopupMenu. The popup menu shows filtered items based on the current input text. When the user focuses the text input, the popup opens below (or above) the text input. The popup is modeless, so the text input retains focus while the popup is shown. The popup closes when the text input loses focus.

func (*Combobox) Build

func (c *Combobox) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Combobox) IsError

func (c *Combobox) IsError() bool

IsError reports whether the combobox is in the error state.

func (*Combobox) Layout

func (c *Combobox) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Combobox) Measure

func (c *Combobox) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Combobox) OnValueChanged

func (c *Combobox) OnValueChanged(f func(context *guigui.Context, value string, committed bool))

OnValueChanged sets the event handler that is called when the combobox value changes. The handler receives the current text and whether the change is committed.

func (*Combobox) SetAllowFreeInput

func (c *Combobox) SetAllowFreeInput(allow bool)

SetAllowFreeInput sets whether the combobox allows values that are not in the items list. When false, the value is reverted to the last valid value on commit if it does not match any item.

func (*Combobox) SetError

func (c *Combobox) SetError(hasError bool)

SetError sets whether the combobox is in the error state. When the error state is true, the combobox border is drawn in a danger color.

func (*Combobox) SetItems

func (c *Combobox) SetItems(items []string)

SetItems sets the list of items for the combobox.

func (*Combobox) SetSupportText

func (c *Combobox) SetSupportText(text string)

SetSupportText sets the support text displayed below the combobox. The support text is shown in a subdued color, or in a danger color when the error state is true. A line break starts a new line.

func (*Combobox) SetValue

func (c *Combobox) SetValue(value string)

SetValue sets the text value.

func (*Combobox) SupportText

func (c *Combobox) SupportText() string

SupportText returns the support text displayed below the combobox.

func (*Combobox) TextInput

func (c *Combobox) TextInput() *TextInput

TextInput returns the internal TextInput widget for customization.

func (*Combobox) Tick

func (c *Combobox) Tick(context *guigui.Context, widgetBounds *guigui.WidgetBounds) error

func (*Combobox) Value

func (c *Combobox) Value() string

Value returns the current text value.

type ContextMenuArea

type ContextMenuArea[T comparable] struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

ContextMenuArea is a standalone widget that shows a popup menu when the user right-clicks inside the area specified by its bounds.

ContextMenuArea shows a modeless popup that closes when the user clicks outside. The previously focused widget retains focus while the context menu is open, so that widgets like TextInput can continue to show their cursor and selection.

Use ContextMenuArea.PopupMenu to configure the menu items.

func (*ContextMenuArea[T]) Build

func (c *ContextMenuArea[T]) Build(context *guigui.Context, adder *guigui.ChildAdder) error

Build implements guigui.Widget.Build.

func (*ContextMenuArea[T]) HandlePointingInput

func (c *ContextMenuArea[T]) HandlePointingInput(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult

HandlePointingInput implements guigui.Widget.HandlePointingInput.

func (*ContextMenuArea[T]) Layout

func (c *ContextMenuArea[T]) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

Layout implements guigui.Widget.Layout.

func (*ContextMenuArea[T]) Measure

func (c *ContextMenuArea[T]) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

Measure implements guigui.Widget.Measure.

func (*ContextMenuArea[T]) PopupMenu

func (c *ContextMenuArea[T]) PopupMenu() *PopupMenu[T]

PopupMenu returns the popup menu so that the caller can configure its items and event handlers.

type Corners

type Corners struct {
	TopStart    bool
	TopEnd      bool
	BottomStart bool
	BottomEnd   bool
}

type Divider

type Divider struct {
	guigui.DefaultWidget
}

func (*Divider) Draw

func (d *Divider) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*Divider) Measure

func (d *Divider) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

type Drawer

type Drawer struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*Drawer) Build

func (d *Drawer) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Drawer) IsOpen

func (d *Drawer) IsOpen() bool

func (*Drawer) Layout

func (d *Drawer) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Drawer) Measure

func (d *Drawer) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Drawer) OnClose

func (d *Drawer) OnClose(onClose func(context *guigui.Context, reason PopupCloseReason))

func (*Drawer) SetAnimated

func (d *Drawer) SetAnimated(animateOnFading bool)

func (*Drawer) SetBackgroundBlurred

func (d *Drawer) SetBackgroundBlurred(blurred bool)

func (*Drawer) SetBackgroundBounds

func (d *Drawer) SetBackgroundBounds(bounds image.Rectangle)

func (*Drawer) SetBackgroundDark

func (d *Drawer) SetBackgroundDark(dark bool)

func (*Drawer) SetCloseByClickingOutside

func (d *Drawer) SetCloseByClickingOutside(closeByClickingOutside bool)

func (*Drawer) SetContent

func (d *Drawer) SetContent(widget guigui.Widget)

func (*Drawer) SetDrawerEdge

func (d *Drawer) SetDrawerEdge(edge DrawerEdge)

func (*Drawer) SetOpen

func (d *Drawer) SetOpen(open bool)

func (*Drawer) SetTintColor

func (d *Drawer) SetTintColor(tint color.Color)

SetTintColor sets the color the drawer derives its background from. A nil tint restores the default background.

type DrawerEdge

type DrawerEdge int
const (
	DrawerEdgeStart DrawerEdge = iota
	DrawerEdgeTop
	DrawerEdgeEnd
	DrawerEdgeBottom
)

type Expander

type Expander struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*Expander) Build

func (e *Expander) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Expander) Draw

func (e *Expander) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*Expander) Layout

func (e *Expander) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Expander) Measure

func (e *Expander) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Expander) OnExpansionChanged

func (e *Expander) OnExpansionChanged(callback func(context *guigui.Context, expanded bool))

func (*Expander) SetContentWidget

func (e *Expander) SetContentWidget(w guigui.Widget)

func (*Expander) SetExpanded

func (e *Expander) SetExpanded(expanded bool)

func (*Expander) SetHeaderWidget

func (e *Expander) SetHeaderWidget(w guigui.Widget)

func (*Expander) Tick

func (e *Expander) Tick(context *guigui.Context, widgetBounds *guigui.WidgetBounds) error

func (*Expander) WriteStateKey

func (e *Expander) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type FaceSourceEntry

type FaceSourceEntry struct {
	FaceSource    *text.GoTextFaceSource
	UnicodeRanges []UnicodeRange
}

func DefaultFaceSourceEntry

func DefaultFaceSourceEntry() FaceSourceEntry

DefaultFaceSourceEntry returns the entry for the bundled default face.

type FaceSourceEntryAdder

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

FaceSourceEntryAdder collects face source entries for the fallback resolution stack.

func (*FaceSourceEntryAdder) Add

func (a *FaceSourceEntryAdder) Add(entry FaceSourceEntry)

Add adds entry to the fallback resolution stack at the adder's current priority, which is FaceSourceEntryPriorityNormal until changed by SetPriority.

func (*FaceSourceEntryAdder) SetPriority

func (a *FaceSourceEntryAdder) SetPriority(priority FaceSourceEntryPriority)

SetPriority sets the priority applied to entries added afterward. A higher priority resolves earlier; entries of equal priority resolve in the order they are added.

type FaceSourceEntryPriority

type FaceSourceEntryPriority int

FaceSourceEntryPriority orders providers registered with RegisterFaceSourceEntries; a higher value resolves earlier.

type FontFamily

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

FontFamily is an immutable ordered list of FaceSourceEntry values, optionally followed by the registered fallback stack. Size, weight, language, and OpenType features are not part of a FontFamily; they are applied at render time.

func NewFontFamily

func NewFontFamily(entries []FaceSourceEntry, opts *FontFamilyOptions) *FontFamily

NewFontFamily returns a FontFamily that renders using entries. A nil opts is treated the same as the zero FontFamilyOptions.

type FontFamilyOptions

type FontFamilyOptions struct {
	// DisableFallback restricts rendering to the FontFamily's own entries,
	// skipping the fallback stack.
	DisableFallback bool
}

FontFamilyOptions controls how a FontFamily resolves glyphs.

type Form

type Form struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*Form) Build

func (f *Form) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Form) Draw

func (f *Form) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*Form) Layout

func (f *Form) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Form) Measure

func (f *Form) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Form) SetItems

func (f *Form) SetItems(items []FormItem)

type FormItem

type FormItem struct {
	PrimaryWidget   guigui.Widget
	SecondaryWidget guigui.Widget
}

type IconAlign

type IconAlign int
const (
	IconAlignStart IconAlign = iota
	IconAlignEnd
)

type Image

type Image struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*Image) Draw

func (i *Image) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*Image) HasImage

func (i *Image) HasImage() bool

func (*Image) Measure

func (i *Image) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Image) SetImage

func (i *Image) SetImage(image *ebiten.Image)

func (*Image) WriteStateKey

func (i *Image) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type ItemTextStyle

type ItemTextStyle struct {
	// Style is the base style of the text. A widget can override the
	// properties it owns, such as the text color of a selected item.
	Style TextStyle

	HorizontalAlign HorizontalAlign
	VerticalAlign   VerticalAlign
	WrapMode        WrapMode
}

ItemTextStyle bundles the styling attributes applied to the fallback text rendered when a widget's Content is nil.

type LineHeightMode

type LineHeightMode int

LineHeightMode selects how a visual line's height responds to the font sizes on it.

const (
	// LineHeightModeFixed gives every visual line the same height. Text
	// larger than the line height overflows into the adjacent lines.
	LineHeightModeFixed LineHeightMode = LineHeightMode(textutil.LineHeightModeFixed)

	// LineHeightModeFlexible sizes each visual line to fit the largest font
	// on it: the line height and the baseline scale by the ratio of that
	// font's size to the base font size.
	LineHeightModeFlexible LineHeightMode = LineHeightMode(textutil.LineHeightModeFlexible)
)

type List

type List[T comparable] struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*List[T]) AppendSelectedItemIndices

func (l *List[T]) AppendSelectedItemIndices(indices []int) []int

func (*List[T]) Build

func (l *List[T]) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*List[T]) EnsureItemVisibleByIndex

func (l *List[T]) EnsureItemVisibleByIndex(index int)

func (*List[T]) ForceEnsureItemVisibleByIndex

func (l *List[T]) ForceEnsureItemVisibleByIndex(index int)

func (*List[T]) ForceSetScrollPosition

func (l *List[T]) ForceSetScrollPosition(position ListScrollPosition)

ForceSetScrollPosition scrolls to the given position without animation.

func (*List[T]) ID

func (l *List[T]) ID(index int) any

func (*List[T]) IndexByValue

func (l *List[T]) IndexByValue(value T) int

func (*List[T]) IsItemAvailable

func (l *List[T]) IsItemAvailable(index int) bool

IsItemAvailable reports whether the item at the given index is available in the list (i.e., not hidden by a collapsed ancestor).

func (*List[T]) IsItemInViewport

func (l *List[T]) IsItemInViewport(index int) bool

IsItemInViewport reports whether the item at the given index is currently visible in the viewport.

IsItemInViewport is available after the layout phase.

func (*List[T]) ItemBounds

func (l *List[T]) ItemBounds(index int) image.Rectangle

func (*List[T]) ItemByIndex

func (l *List[T]) ItemByIndex(index int) (ListItem[T], bool)

func (*List[T]) ItemCount

func (l *List[T]) ItemCount() int

func (*List[T]) JumpToItemByIndex

func (l *List[T]) JumpToItemByIndex(index int)

func (*List[T]) Layout

func (l *List[T]) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*List[T]) Measure

func (l *List[T]) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*List[T]) OnItemExpanderToggled

func (l *List[T]) OnItemExpanderToggled(f func(context *guigui.Context, index int, expanded bool))

func (*List[T]) OnItemSelected

func (l *List[T]) OnItemSelected(f func(context *guigui.Context, index int))

func (*List[T]) OnItemsCanMove

func (l *List[T]) OnItemsCanMove(f func(context *guigui.Context, from, count, to int) bool)

func (*List[T]) OnItemsMoved

func (l *List[T]) OnItemsMoved(f func(context *guigui.Context, from, count, to int))

func (*List[T]) OnItemsSelected

func (l *List[T]) OnItemsSelected(f func(context *guigui.Context, indices []int))

func (*List[T]) OnScroll

func (l *List[T]) OnScroll(callback func(context *guigui.Context, position ListScrollPosition))

OnScroll sets the handler invoked when the scroll position changes.

func (*List[T]) ScrollPosition

func (l *List[T]) ScrollPosition() ListScrollPosition

ScrollPosition returns a snapshot of the current scroll position, restorable with List.SetScrollPosition or List.ForceSetScrollPosition.

func (*List[T]) SelectAllItems

func (l *List[T]) SelectAllItems()

func (*List[T]) SelectItemByIndex

func (l *List[T]) SelectItemByIndex(index int)

func (*List[T]) SelectItemByValue

func (l *List[T]) SelectItemByValue(value T)

func (*List[T]) SelectItemsByIndices

func (l *List[T]) SelectItemsByIndices(indices []int)

func (*List[T]) SelectItemsByValues

func (l *List[T]) SelectItemsByValues(values []T)

func (*List[T]) SelectedItem

func (l *List[T]) SelectedItem() (ListItem[T], bool)

func (*List[T]) SelectedItemCount

func (l *List[T]) SelectedItemCount() int

func (*List[T]) SelectedItemIndex

func (l *List[T]) SelectedItemIndex() int

func (*List[T]) SetBackground

func (l *List[T]) SetBackground(widget guigui.Widget)

func (*List[T]) SetBackgroundStyle

func (l *List[T]) SetBackgroundStyle(style ListBackgroundStyle)

SetBackgroundStyle sets the background fill drawn behind the items.

func (*List[T]) SetCornerRounded

func (l *List[T]) SetCornerRounded(rounded bool)

SetCornerRounded sets whether the list clips its contents to rounded corners.

func (*List[T]) SetFooterHeight

func (l *List[T]) SetFooterHeight(height int)

func (*List[T]) SetFrameVisible

func (l *List[T]) SetFrameVisible(visible bool)

SetFrameVisible sets whether the list draws its frame, header, and footer.

func (*List[T]) SetHeaderHeight

func (l *List[T]) SetHeaderHeight(height int)

func (*List[T]) SetHighlightStyle

func (l *List[T]) SetHighlightStyle(style ListItemHighlightStyle)

SetHighlightStyle sets which item the list highlights.

func (*List[T]) SetHighlightVisibleWhenUnfocused

func (l *List[T]) SetHighlightVisibleWhenUnfocused(visible bool)

SetHighlightVisibleWhenUnfocused sets whether the highlight stays drawn while the list is unfocused.

func (*List[T]) SetHoverBackgroundVisible

func (l *List[T]) SetHoverBackgroundVisible(visible bool)

SetHoverBackgroundVisible sets whether the hovered item shows a background in the selection highlight style.

func (*List[T]) SetItemHeight

func (l *List[T]) SetItemHeight(height int)

func (*List[T]) SetItemString

func (l *List[T]) SetItemString(str string, index int)

func (*List[T]) SetItems

func (l *List[T]) SetItems(items []ListItem[T])

func (*List[T]) SetItemsByStrings

func (l *List[T]) SetItemsByStrings(strs []string)

func (*List[T]) SetMultiSelection

func (l *List[T]) SetMultiSelection(multi bool)

func (*List[T]) SetReservesCheckmarkSpace

func (l *List[T]) SetReservesCheckmarkSpace(reserves bool)

SetReservesCheckmarkSpace sets whether the list reserves space for the checkmark column even when no item is currently checked. This keeps item widths and positions stable across check-state changes.

Items can independently toggle ListItem.Checked to render a checkmark. The column is automatically reserved when at least one item is checked, so this setter is only needed when no items are currently checked but might be in the future.

func (*List[T]) SetScrollPosition

func (l *List[T]) SetScrollPosition(position ListScrollPosition)

SetScrollPosition scrolls to the given position with animation.

func (*List[T]) SetSelectedItemBold

func (l *List[T]) SetSelectedItemBold(bold bool)

SetSelectedItemBold sets whether the selected item's text is drawn in bold.

func (*List[T]) SetStripeVisible

func (l *List[T]) SetStripeVisible(visible bool)

func (*List[T]) SetStyle

func (l *List[T]) SetStyle(style ListStyle)

SetStyle applies the preset combination of orthogonal properties for the given style. SetStyle re-applies every property on each call, so a per-property override takes effect only when its setter is called after SetStyle.

func (*List[T]) SetUnfocusedSelectionVisible

func (l *List[T]) SetUnfocusedSelectionVisible(visible bool)

SetUnfocusedSelectionVisible sets whether to show the selection background when the list is unfocused. The default is true.

func (*List[T]) Tick

func (l *List[T]) Tick(context *guigui.Context, widgetBounds *guigui.WidgetBounds) error

func (*List[T]) WriteStateKey

func (l *List[T]) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type ListBackgroundStyle

type ListBackgroundStyle int

ListBackgroundStyle represents the background fill drawn behind a list's items.

const (
	// ListBackgroundStyleContent fills the background with the content background color.
	ListBackgroundStyleContent ListBackgroundStyle = iota
	// ListBackgroundStyleMenu fills the background with the menu background color.
	ListBackgroundStyleMenu
	// ListBackgroundStyleNone draws no background fill.
	ListBackgroundStyleNone
)

type ListItem

type ListItem[T comparable] struct {
	Text         string
	TextStyle    ItemTextStyle
	Header       bool
	Content      guigui.Widget
	KeyText      string
	Unselectable bool
	Border       bool
	Disabled     bool
	Movable      bool
	Value        T
	IndentLevel  int
	Padding      guigui.Padding
	Collapsed    bool
	Checked      bool
}

type ListItemColorType

type ListItemColorType int

ListItemColorType represents the color state of a list item.

const (
	ListItemColorTypeDefault ListItemColorType = iota
	ListItemColorTypeHighlighted
	ListItemColorTypeSelectedInUnfocusedList
	ListItemColorTypeItemDisabled
	ListItemColorTypeListDisabled
	ListItemColorTypeHovered
)

func (ListItemColorType) BackgroundColor

func (t ListItemColorType) BackgroundColor(context *guigui.Context) color.Color

BackgroundColor returns the background color for the given color type. BackgroundColor returns nil when no special background should be applied.

func (ListItemColorType) TextColor

func (t ListItemColorType) TextColor(context *guigui.Context) color.Color

TextColor returns the text color for the given color type.

type ListItemHighlightStyle

type ListItemHighlightStyle int

ListItemHighlightStyle represents which item a list draws its highlight on.

const (
	// ListItemHighlightStyleSelection highlights the selected item; arrow keys move the selection.
	ListItemHighlightStyleSelection ListItemHighlightStyle = iota
	// ListItemHighlightStyleHover highlights the hovered item; arrow keys move a transient highlight committed by Enter.
	ListItemHighlightStyleHover
)

type ListScrollPosition

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

ListScrollPosition is an opaque snapshot of a list widget's scroll position (e.g. List or Table), obtained from List.ScrollPosition and restored with List.SetScrollPosition or List.ForceSetScrollPosition. The zero value is the top of the list.

type ListStyle

type ListStyle int
const (
	ListStyleNormal ListStyle = iota
	ListStyleSidebar
	ListStyleMenu
)
type Menubar[T comparable] struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

Menubar is a horizontal row of title texts. Clicking a title shows the associated popup menu. While any popup is open, moving the cursor onto a different title automatically switches to that title's popup. Clicking the already-open title closes its popup.

func (m *Menubar[T]) Build(context *guigui.Context, adder *guigui.ChildAdder) error

Build implements guigui.Widget.Build.

func (m *Menubar[T]) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

Layout implements guigui.Widget.Layout.

func (m *Menubar[T]) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

Measure implements guigui.Widget.Measure.

func (m *Menubar[T]) OnItemSelected(f func(context *guigui.Context, menuIndex, itemIndex int))

OnItemSelected sets the event handler that is invoked when a popup menu item is selected. menuIndex identifies the title and itemIndex identifies the selected item within that title's popup.

func (m *Menubar[T]) PopupMenuAt(index int) *PopupMenu[T]

PopupMenuAt returns the popup menu associated with the i-th item. Menubar.SetItems must be called first so that the popup at i exists.

Items shown in the popup are configured via PopupMenu.SetItems. A title whose popup has no items is automatically disabled.

func (m *Menubar[T]) SetItems(items []MenubarItem)

SetItems sets the menubar's items. After this call, the popup menu for each item can be configured via Menubar.PopupMenuAt.

func (m *Menubar[T]) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

WriteStateKey implements guigui.Widget.WriteStateKey.

type MenubarItem struct {
	Text     string
	Disabled bool
}

MenubarItem is a single entry in a Menubar. Each entry has a title text; the popup menu shown when the title is clicked is configured separately via Menubar.PopupMenuAt.

type NumberInput

type NumberInput struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*NumberInput) Build

func (n *NumberInput) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*NumberInput) CanCopy

func (n *NumberInput) CanCopy() bool

func (*NumberInput) CanCut

func (n *NumberInput) CanCut() bool

func (*NumberInput) CanPaste

func (n *NumberInput) CanPaste() bool

func (*NumberInput) CommitWithCurrentInputValue

func (n *NumberInput) CommitWithCurrentInputValue()

func (*NumberInput) Copy

func (n *NumberInput) Copy() bool

func (*NumberInput) Cut

func (n *NumberInput) Cut() bool

func (*NumberInput) ForceSetValue

func (n *NumberInput) ForceSetValue(value int)

func (*NumberInput) ForceSetValueBigInt

func (n *NumberInput) ForceSetValueBigInt(value *big.Int)

func (*NumberInput) ForceSetValueInt64

func (n *NumberInput) ForceSetValueInt64(value int64)

func (*NumberInput) ForceSetValueUint64

func (n *NumberInput) ForceSetValueUint64(value uint64)

func (*NumberInput) IsEditable

func (n *NumberInput) IsEditable() bool

func (*NumberInput) IsError

func (n *NumberInput) IsError() bool

IsError reports whether the number input is in the error state.

func (*NumberInput) Layout

func (n *NumberInput) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*NumberInput) MaximumValueBigInt

func (n *NumberInput) MaximumValueBigInt() *big.Int

func (*NumberInput) Measure

func (n *NumberInput) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*NumberInput) MinimumValueBigInt

func (n *NumberInput) MinimumValueBigInt() *big.Int

func (*NumberInput) OnHandleButtonInput

func (n *NumberInput) OnHandleButtonInput(f func(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult)

func (*NumberInput) OnValueChanged

func (n *NumberInput) OnValueChanged(f func(context *guigui.Context, value int, committed bool))

func (*NumberInput) OnValueChangedBigInt

func (n *NumberInput) OnValueChangedBigInt(f func(context *guigui.Context, value *big.Int, committed bool))

func (*NumberInput) OnValueChangedInt64

func (n *NumberInput) OnValueChangedInt64(f func(context *guigui.Context, value int64, committed bool))

func (*NumberInput) OnValueChangedUint64

func (n *NumberInput) OnValueChangedUint64(f func(context *guigui.Context, value uint64, committed bool))

func (*NumberInput) Paste

func (n *NumberInput) Paste() bool

func (*NumberInput) SetEditable

func (n *NumberInput) SetEditable(editable bool)

func (*NumberInput) SetError

func (n *NumberInput) SetError(hasError bool)

SetError sets whether the number input is in the error state. When the error state is true, the number input border is drawn in a danger color.

func (*NumberInput) SetMaximumValue

func (n *NumberInput) SetMaximumValue(maximum int)

func (*NumberInput) SetMaximumValueBigInt

func (n *NumberInput) SetMaximumValueBigInt(maximum *big.Int)

func (*NumberInput) SetMaximumValueInt64

func (n *NumberInput) SetMaximumValueInt64(maximum int64)

func (*NumberInput) SetMaximumValueUint64

func (n *NumberInput) SetMaximumValueUint64(maximum uint64)

func (*NumberInput) SetMinimumValue

func (n *NumberInput) SetMinimumValue(minimum int)

func (*NumberInput) SetMinimumValueBigInt

func (n *NumberInput) SetMinimumValueBigInt(minimum *big.Int)

func (*NumberInput) SetMinimumValueInt64

func (n *NumberInput) SetMinimumValueInt64(minimum int64)

func (*NumberInput) SetMinimumValueUint64

func (n *NumberInput) SetMinimumValueUint64(minimum uint64)

func (*NumberInput) SetStep

func (n *NumberInput) SetStep(step int)

func (*NumberInput) SetStepBigInt

func (n *NumberInput) SetStepBigInt(step *big.Int)

func (*NumberInput) SetStepInt64

func (n *NumberInput) SetStepInt64(step int64)

func (*NumberInput) SetStepUint64

func (n *NumberInput) SetStepUint64(step uint64)

func (*NumberInput) SetSupportText

func (n *NumberInput) SetSupportText(text string)

SetSupportText sets the support text displayed below the number input. The support text is shown in a subdued color, or in a danger color when the error state is true. A line break starts a new line.

func (*NumberInput) SetValue

func (n *NumberInput) SetValue(value int)

func (*NumberInput) SetValueBigInt

func (n *NumberInput) SetValueBigInt(value *big.Int)

func (*NumberInput) SetValueInt64

func (n *NumberInput) SetValueInt64(value int64)

func (*NumberInput) SetValueUint64

func (n *NumberInput) SetValueUint64(value uint64)

func (*NumberInput) SupportText

func (n *NumberInput) SupportText() string

SupportText returns the support text displayed below the number input.

func (*NumberInput) Value

func (n *NumberInput) Value() int

func (*NumberInput) ValueBigInt

func (n *NumberInput) ValueBigInt() *big.Int

func (*NumberInput) ValueInt64

func (n *NumberInput) ValueInt64() int64

func (*NumberInput) ValueUint64

func (n *NumberInput) ValueUint64() uint64

type Panel

type Panel struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*Panel) Build

func (p *Panel) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Panel) EnsureRectangleVisible

func (p *Panel) EnsureRectangleVisible(rect image.Rectangle)

EnsureRectangleVisible ensures the given rectangle, in content-local coordinates, is visible in the viewport by scrolling if necessary. If the rectangle is larger than the viewport, its top-left corner is aligned with the top-left of the viewport.

func (*Panel) ForceSetScrollOffset

func (p *Panel) ForceSetScrollOffset(offsetX, offsetY float64)

func (*Panel) ForceSetScrollOffsetByDelta

func (p *Panel) ForceSetScrollOffsetByDelta(offsetXDelta, offsetYDelta float64)

func (*Panel) Layout

func (p *Panel) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Panel) Measure

func (p *Panel) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Panel) OnScroll

func (p *Panel) OnScroll(callback func(context *guigui.Context, offsetX, offsetY float64))

func (*Panel) SetAutoBorder

func (p *Panel) SetAutoBorder(auto bool)

func (*Panel) SetBackgroundStyle

func (p *Panel) SetBackgroundStyle(style PanelBackgroundStyle)

SetBackgroundStyle sets the background fill drawn behind the content.

func (*Panel) SetBorders

func (p *Panel) SetBorders(borders PanelBorders)

func (*Panel) SetContent

func (p *Panel) SetContent(widget guigui.Widget)

func (*Panel) SetContentConstraints

func (p *Panel) SetContentConstraints(c PanelContentConstraints)

func (*Panel) SetScrollOffset

func (p *Panel) SetScrollOffset(offsetX, offsetY float64)

func (*Panel) SetScrollOffsetByDelta

func (p *Panel) SetScrollOffsetByDelta(offsetXDelta, offsetYDelta float64)

func (*Panel) SetStyle

func (p *Panel) SetStyle(typ PanelStyle)

SetStyle applies the preset combination of orthogonal properties for the given style. SetStyle re-applies every property on each call, so a per-property override takes effect only when its setter is called after SetStyle.

type PanelBackgroundStyle

type PanelBackgroundStyle int

PanelBackgroundStyle represents the background fill drawn behind a panel's content.

const (
	// PanelBackgroundStyleNone draws no background fill.
	PanelBackgroundStyleNone PanelBackgroundStyle = iota
	// PanelBackgroundStyleSecondary fills the background with the secondary background color.
	PanelBackgroundStyleSecondary
)

type PanelBorders

type PanelBorders struct {
	Start  bool
	Top    bool
	End    bool
	Bottom bool
}

type PanelContentConstraints

type PanelContentConstraints int
const (
	PanelContentConstraintsNone PanelContentConstraints = iota
	PanelContentConstraintsFixedWidth
	PanelContentConstraintsFixedHeight
)

type PanelStyle

type PanelStyle int
const (
	PanelStyleDefault PanelStyle = iota
	PanelStyleSide
)
type Popup struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

Popup is a widget that displays its content on a separate layer.

Popup manages its own passthrough state based on whether it is open. Do not call guigui.Context.SetPassthrough on a Popup.

func (*Popup) BringToFrontLayer

func (p *Popup) BringToFrontLayer(context *guigui.Context)

BringToFrontLayer brings the popup to the front layer.

func (*Popup) Build

func (p *Popup) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Popup) Env

func (p *Popup) Env(context *guigui.Context, key guigui.EnvKey, source *guigui.EnvSource) (any, bool)

func (*Popup) IsOpen

func (p *Popup) IsOpen() bool

func (*Popup) Layout

func (p *Popup) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Popup) Measure

func (p *Popup) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Popup) OnClose

func (p *Popup) OnClose(f func(context *guigui.Context, reason PopupCloseReason))

func (*Popup) SetAnimated

func (p *Popup) SetAnimated(animateOnFading bool)

func (*Popup) SetBackgroundBlurred

func (p *Popup) SetBackgroundBlurred(blurred bool)

func (*Popup) SetBackgroundBounds

func (p *Popup) SetBackgroundBounds(bounds image.Rectangle)

func (*Popup) SetBackgroundDark

func (p *Popup) SetBackgroundDark(dark bool)

func (*Popup) SetCloseByClickingOutside

func (p *Popup) SetCloseByClickingOutside(closeByClickingOutside bool)

func (*Popup) SetContent

func (p *Popup) SetContent(widget guigui.Widget)

func (*Popup) SetModal

func (p *Popup) SetModal(modal bool)

func (*Popup) SetOpen

func (p *Popup) SetOpen(open bool)

func (*Popup) SetTintColor

func (p *Popup) SetTintColor(tint color.Color)

SetTintColor sets the color the popup derives its background from. A nil tint restores the default background.

type PopupCloseReason

type PopupCloseReason int
const (
	PopupCloseReasonNone PopupCloseReason = iota
	PopupCloseReasonFuncCall
	PopupCloseReasonClickOutside
	PopupCloseReasonReopen
	PopupCloseReasonAuto
)

type PopupMenu

type PopupMenu[T comparable] struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*PopupMenu[T]) Build

func (p *PopupMenu[T]) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*PopupMenu[T]) HandleButtonInput

func (p *PopupMenu[T]) HandleButtonInput(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult

HandleButtonInput implements guigui.Widget.HandleButtonInput.

func (*PopupMenu[T]) IsOpen

func (p *PopupMenu[T]) IsOpen() bool

func (*PopupMenu[T]) ItemByIndex

func (p *PopupMenu[T]) ItemByIndex(index int) (PopupMenuItem[T], bool)

func (*PopupMenu[T]) Layout

func (p *PopupMenu[T]) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*PopupMenu[T]) Measure

func (p *PopupMenu[T]) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*PopupMenu[T]) OnClose

func (p *PopupMenu[T]) OnClose(f func(context *guigui.Context, reason PopupCloseReason))

func (*PopupMenu[T]) OnItemSelected

func (p *PopupMenu[T]) OnItemSelected(f func(context *guigui.Context, index int))

func (*PopupMenu[T]) SelectItemByIndex

func (p *PopupMenu[T]) SelectItemByIndex(index int)

func (*PopupMenu[T]) SelectItemByValue

func (p *PopupMenu[T]) SelectItemByValue(value T)

func (*PopupMenu[T]) SelectedItem

func (p *PopupMenu[T]) SelectedItem() (PopupMenuItem[T], bool)

func (*PopupMenu[T]) SelectedItemIndex

func (p *PopupMenu[T]) SelectedItemIndex() int

func (*PopupMenu[T]) SetItems

func (p *PopupMenu[T]) SetItems(items []PopupMenuItem[T])

func (*PopupMenu[T]) SetItemsByStrings

func (p *PopupMenu[T]) SetItemsByStrings(items []string)

func (*PopupMenu[T]) SetOpen

func (p *PopupMenu[T]) SetOpen(open bool)

func (*PopupMenu[T]) SetReservesCheckmarkSpace

func (p *PopupMenu[T]) SetReservesCheckmarkSpace(reserves bool)

SetReservesCheckmarkSpace sets whether the popup menu reserves space for the checkmark column even when no item is currently checked. This keeps item widths and positions stable across check-state changes.

Items can independently toggle PopupMenuItem.Checked to render a checkmark. The column is automatically reserved when at least one item is checked, so this setter is only needed when no items are currently checked but might be in the future.

type PopupMenuItem

type PopupMenuItem[T comparable] struct {
	Text         string
	TextStyle    ItemTextStyle
	Header       bool
	Content      guigui.Widget
	KeyText      string
	Unselectable bool
	Border       bool
	Disabled     bool
	Checked      bool
	Value        T
}

type ProgressBar

type ProgressBar struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

ProgressBar is a horizontal gauge showing how far a task has come. The gauge is empty until both the minimum and the maximum value are set.

func (*ProgressBar) Draw

func (p *ProgressBar) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*ProgressBar) MaximumValueBigInt

func (p *ProgressBar) MaximumValueBigInt() *big.Int

func (*ProgressBar) Measure

func (p *ProgressBar) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*ProgressBar) MinimumValueBigInt

func (p *ProgressBar) MinimumValueBigInt() *big.Int

func (*ProgressBar) SetMaximumValue

func (p *ProgressBar) SetMaximumValue(maximum int)

func (*ProgressBar) SetMaximumValueBigInt

func (p *ProgressBar) SetMaximumValueBigInt(maximum *big.Int)

func (*ProgressBar) SetMaximumValueInt64

func (p *ProgressBar) SetMaximumValueInt64(maximum int64)

func (*ProgressBar) SetMaximumValueUint64

func (p *ProgressBar) SetMaximumValueUint64(maximum uint64)

func (*ProgressBar) SetMinimumValue

func (p *ProgressBar) SetMinimumValue(minimum int)

func (*ProgressBar) SetMinimumValueBigInt

func (p *ProgressBar) SetMinimumValueBigInt(minimum *big.Int)

func (*ProgressBar) SetMinimumValueInt64

func (p *ProgressBar) SetMinimumValueInt64(minimum int64)

func (*ProgressBar) SetMinimumValueUint64

func (p *ProgressBar) SetMinimumValueUint64(minimum uint64)

func (*ProgressBar) SetValue

func (p *ProgressBar) SetValue(value int)

func (*ProgressBar) SetValueBigInt

func (p *ProgressBar) SetValueBigInt(value *big.Int)

func (*ProgressBar) SetValueInt64

func (p *ProgressBar) SetValueInt64(value int64)

func (*ProgressBar) SetValueUint64

func (p *ProgressBar) SetValueUint64(value uint64)

func (*ProgressBar) Value

func (p *ProgressBar) Value() int

func (*ProgressBar) ValueBigInt

func (p *ProgressBar) ValueBigInt() *big.Int

func (*ProgressBar) ValueInt64

func (p *ProgressBar) ValueInt64() int64

func (*ProgressBar) ValueUint64

func (p *ProgressBar) ValueUint64() uint64

func (*ProgressBar) WriteStateKey

func (p *ProgressBar) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type RadioButton

type RadioButton[T comparable] struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

RadioButton is a radio button to choose one value from a group of values.

RadioButton should not be created directly. Use RadioButtonGroup instead.

func (*RadioButton[T]) Build

func (r *RadioButton[T]) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*RadioButton[T]) CursorShape

func (r *RadioButton[T]) CursorShape(context *guigui.Context, widgetBounds *guigui.WidgetBounds) (ebiten.CursorShapeType, bool)

func (*RadioButton[T]) Draw

func (r *RadioButton[T]) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*RadioButton[T]) HandlePointingInput

func (r *RadioButton[T]) HandlePointingInput(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult

func (*RadioButton[T]) Layout

func (r *RadioButton[T]) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*RadioButton[T]) Measure

func (r *RadioButton[T]) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*RadioButton[T]) Tick

func (r *RadioButton[T]) Tick(context *guigui.Context, widgetBounds *guigui.WidgetBounds) error

func (*RadioButton[T]) WriteStateKey

func (r *RadioButton[T]) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type RadioButtonGroup

type RadioButtonGroup[T comparable] struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

RadioButtonGroup is a group of radio buttons.

RadioButtonGroup holds RadioButton widgets, but doesn't add them to the widget tree. The user must add the RadioButton widgets to the widget tree manually.

func (*RadioButtonGroup[T]) OnItemSelected

func (r *RadioButtonGroup[T]) OnItemSelected(f func(context *guigui.Context, index int))

func (*RadioButtonGroup[T]) RadioButton

func (r *RadioButtonGroup[T]) RadioButton(index int) *RadioButton[T]

RadioButton returns the radio button at the specified index.

func (*RadioButtonGroup[T]) SelectItemByIndex

func (r *RadioButtonGroup[T]) SelectItemByIndex(index int)

func (*RadioButtonGroup[T]) SelectItemByValue

func (r *RadioButtonGroup[T]) SelectItemByValue(value T)

func (*RadioButtonGroup[T]) SelectedIndex

func (r *RadioButtonGroup[T]) SelectedIndex() int

func (*RadioButtonGroup[T]) SelectedValue

func (r *RadioButtonGroup[T]) SelectedValue() (T, bool)

func (*RadioButtonGroup[T]) SetValues

func (r *RadioButtonGroup[T]) SetValues(values []T)

SetValues sets the values of the radio buttons. The length of the values slice determines the number of radio buttons.

func (*RadioButtonGroup[T]) WriteStateKey

func (r *RadioButtonGroup[T]) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type SegmentedControl

type SegmentedControl[T comparable] struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*SegmentedControl[T]) AppendSelectedItemIndices

func (s *SegmentedControl[T]) AppendSelectedItemIndices(indices []int) []int

func (*SegmentedControl[T]) Build

func (s *SegmentedControl[T]) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*SegmentedControl[T]) ItemByIndex

func (s *SegmentedControl[T]) ItemByIndex(index int) (SegmentedControlItem[T], bool)

func (*SegmentedControl[T]) Layout

func (s *SegmentedControl[T]) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*SegmentedControl[T]) Measure

func (s *SegmentedControl[T]) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*SegmentedControl[T]) OnItemSelected

func (s *SegmentedControl[T]) OnItemSelected(f func(context *guigui.Context, index int))

func (*SegmentedControl[T]) OnItemsSelected

func (s *SegmentedControl[T]) OnItemsSelected(f func(context *guigui.Context, indices []int))

func (*SegmentedControl[T]) SelectItemByIndex

func (s *SegmentedControl[T]) SelectItemByIndex(index int)

func (*SegmentedControl[T]) SelectItemByValue

func (s *SegmentedControl[T]) SelectItemByValue(value T)

func (*SegmentedControl[T]) SelectItemsByIndices

func (s *SegmentedControl[T]) SelectItemsByIndices(indices []int)

func (*SegmentedControl[T]) SelectItemsByValues

func (s *SegmentedControl[T]) SelectItemsByValues(values []T)

func (*SegmentedControl[T]) SelectedItem

func (s *SegmentedControl[T]) SelectedItem() (SegmentedControlItem[T], bool)

func (*SegmentedControl[T]) SelectedItemCount

func (s *SegmentedControl[T]) SelectedItemCount() int

func (*SegmentedControl[T]) SelectedItemIndex

func (s *SegmentedControl[T]) SelectedItemIndex() int

func (*SegmentedControl[T]) SetDirection

func (s *SegmentedControl[T]) SetDirection(direction SegmentedControlDirection)

func (*SegmentedControl[T]) SetItems

func (s *SegmentedControl[T]) SetItems(items []SegmentedControlItem[T])

func (*SegmentedControl[T]) SetMultiSelection

func (s *SegmentedControl[T]) SetMultiSelection(multi bool)

func (*SegmentedControl[T]) WriteStateKey

func (s *SegmentedControl[T]) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type SegmentedControlDirection

type SegmentedControlDirection int
const (
	SegmentedControlDirectionHorizontal SegmentedControlDirection = iota
	SegmentedControlDirectionVertical
)

type SegmentedControlItem

type SegmentedControlItem[T comparable] struct {
	Text      string
	Icon      *ebiten.Image
	IconAlign IconAlign
	Disabled  bool
	Value     T
}

type Select

type Select[T comparable] struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*Select[T]) Build

func (s *Select[T]) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Select[T]) IsPopupOpen

func (s *Select[T]) IsPopupOpen() bool

func (*Select[T]) ItemByIndex

func (s *Select[T]) ItemByIndex(index int) (SelectItem[T], bool)

func (*Select[T]) Layout

func (s *Select[T]) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Select[T]) Measure

func (s *Select[T]) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Select[T]) OnItemSelected

func (s *Select[T]) OnItemSelected(f func(context *guigui.Context, index int))

func (*Select[T]) SelectItemByIndex

func (s *Select[T]) SelectItemByIndex(index int)

func (*Select[T]) SelectItemByValue

func (s *Select[T]) SelectItemByValue(value T)

func (*Select[T]) SelectedItem

func (s *Select[T]) SelectedItem() (SelectItem[T], bool)

func (*Select[T]) SelectedItemIndex

func (s *Select[T]) SelectedItemIndex() int

func (*Select[T]) SetItems

func (s *Select[T]) SetItems(items []SelectItem[T])

func (*Select[T]) SetItemsByStrings

func (s *Select[T]) SetItemsByStrings(items []string)

type SelectItem

type SelectItem[T comparable] struct {
	Text         string
	TextStyle    ItemTextStyle
	Header       bool
	Content      guigui.Widget
	Unselectable bool
	Border       bool
	Disabled     bool
	Value        T
}

type Slider

type Slider struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*Slider) Build

func (s *Slider) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Slider) CursorShape

func (s *Slider) CursorShape(context *guigui.Context, widgetBounds *guigui.WidgetBounds) (ebiten.CursorShapeType, bool)

func (*Slider) Draw

func (s *Slider) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*Slider) HandlePointingInput

func (s *Slider) HandlePointingInput(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult

func (*Slider) MaximumValueBigInt

func (s *Slider) MaximumValueBigInt() *big.Int

func (*Slider) Measure

func (s *Slider) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Slider) MinimumValueBigInt

func (s *Slider) MinimumValueBigInt() *big.Int

func (*Slider) OnValueChanged

func (s *Slider) OnValueChanged(f func(context *guigui.Context, value int))

func (*Slider) OnValueChangedBigInt

func (s *Slider) OnValueChangedBigInt(f func(context *guigui.Context, value *big.Int))

func (*Slider) OnValueChangedInt64

func (s *Slider) OnValueChangedInt64(f func(context *guigui.Context, value int64))

func (*Slider) OnValueChangedUint64

func (s *Slider) OnValueChangedUint64(f func(context *guigui.Context, value uint64))

func (*Slider) SetMaximumValue

func (s *Slider) SetMaximumValue(maximum int)

func (*Slider) SetMaximumValueBigInt

func (s *Slider) SetMaximumValueBigInt(maximum *big.Int)

func (*Slider) SetMaximumValueInt64

func (s *Slider) SetMaximumValueInt64(maximum int64)

func (*Slider) SetMaximumValueUint64

func (s *Slider) SetMaximumValueUint64(maximum uint64)

func (*Slider) SetMinimumValue

func (s *Slider) SetMinimumValue(minimum int)

func (*Slider) SetMinimumValueBigInt

func (s *Slider) SetMinimumValueBigInt(minimum *big.Int)

func (*Slider) SetMinimumValueInt64

func (s *Slider) SetMinimumValueInt64(minimum int64)

func (*Slider) SetMinimumValueUint64

func (s *Slider) SetMinimumValueUint64(minimum uint64)

func (*Slider) SetSnapOnly

func (s *Slider) SetSnapOnly(snapOnly bool)

func (*Slider) SetStep

func (s *Slider) SetStep(step int)

func (*Slider) SetStepBigInt

func (s *Slider) SetStepBigInt(step *big.Int)

func (*Slider) SetStepInt64

func (s *Slider) SetStepInt64(step int64)

func (*Slider) SetStepUint64

func (s *Slider) SetStepUint64(step uint64)

func (*Slider) SetValue

func (s *Slider) SetValue(value int)

func (*Slider) SetValueBigInt

func (s *Slider) SetValueBigInt(value *big.Int)

func (*Slider) SetValueInt64

func (s *Slider) SetValueInt64(value int64)

func (*Slider) SetValueUint64

func (s *Slider) SetValueUint64(value uint64)

func (*Slider) Tick

func (s *Slider) Tick(context *guigui.Context, widgetBounds *guigui.WidgetBounds) error

func (*Slider) Value

func (s *Slider) Value() int

func (*Slider) ValueBigInt

func (s *Slider) ValueBigInt() *big.Int

func (*Slider) ValueInt64

func (s *Slider) ValueInt64() int64

func (*Slider) ValueUint64

func (s *Slider) ValueUint64() uint64

func (*Slider) WriteStateKey

func (s *Slider) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type Table

type Table[T comparable] struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*Table[T]) AppendSelectedItemIndices

func (t *Table[T]) AppendSelectedItemIndices(indices []int) []int

func (*Table[T]) Build

func (t *Table[T]) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Table[T]) CellBounds

func (t *Table[T]) CellBounds(rowIndex, colIndex int) image.Rectangle

CellBounds returns the bounds for the cell at the given row and column indices. CellBounds is valid only after the table's layout finishes.

func (*Table[T]) EnsureItemVisibleByIndex

func (t *Table[T]) EnsureItemVisibleByIndex(index int)

func (*Table[T]) ForceEnsureItemVisibleByIndex

func (t *Table[T]) ForceEnsureItemVisibleByIndex(index int)

func (*Table[T]) ForceSetScrollPosition

func (t *Table[T]) ForceSetScrollPosition(position ListScrollPosition)

ForceSetScrollPosition scrolls to the given position without animation.

func (*Table[T]) ID

func (t *Table[T]) ID(index int) any

func (*Table[T]) IndexByValue

func (t *Table[T]) IndexByValue(value T) int

func (*Table[T]) IsItemAvailable

func (t *Table[T]) IsItemAvailable(index int) bool

IsItemAvailable reports whether the item at the given index is available in the list (i.e., not hidden by a collapsed ancestor).

func (*Table[T]) IsItemInViewport

func (t *Table[T]) IsItemInViewport(index int) bool

func (*Table[T]) ItemBounds

func (t *Table[T]) ItemBounds(index int) image.Rectangle

func (*Table[T]) ItemByIndex

func (t *Table[T]) ItemByIndex(index int) (TableRow[T], bool)

func (*Table[T]) ItemCount

func (t *Table[T]) ItemCount() int

func (*Table[T]) JumpToItemByIndex

func (t *Table[T]) JumpToItemByIndex(index int)

func (*Table[T]) Layout

func (t *Table[T]) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Table[T]) Measure

func (t *Table[T]) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Table[T]) OnItemSelected

func (t *Table[T]) OnItemSelected(f func(context *guigui.Context, index int))

func (*Table[T]) OnItemsCanMove

func (t *Table[T]) OnItemsCanMove(f func(context *guigui.Context, from, count, to int) bool)

func (*Table[T]) OnItemsMoved

func (t *Table[T]) OnItemsMoved(f func(context *guigui.Context, from, count, to int))

func (*Table[T]) OnItemsSelected

func (t *Table[T]) OnItemsSelected(f func(context *guigui.Context, indices []int))

func (*Table[T]) OnScroll

func (t *Table[T]) OnScroll(callback func(context *guigui.Context, position ListScrollPosition))

OnScroll sets the handler invoked when the scroll position changes.

func (*Table[T]) ScrollPosition

func (t *Table[T]) ScrollPosition() ListScrollPosition

ScrollPosition returns a snapshot of the current scroll position, restorable with Table.SetScrollPosition or Table.ForceSetScrollPosition.

func (*Table[T]) SelectAllItems

func (t *Table[T]) SelectAllItems()

func (*Table[T]) SelectItemByIndex

func (t *Table[T]) SelectItemByIndex(index int)

func (*Table[T]) SelectItemByValue

func (t *Table[T]) SelectItemByValue(value T)

func (*Table[T]) SelectItemsByIndices

func (t *Table[T]) SelectItemsByIndices(indices []int)

func (*Table[T]) SelectItemsByValues

func (t *Table[T]) SelectItemsByValues(values []T)

func (*Table[T]) SelectedItem

func (t *Table[T]) SelectedItem() (TableRow[T], bool)

func (*Table[T]) SelectedItemCount

func (t *Table[T]) SelectedItemCount() int

func (*Table[T]) SelectedItemIndex

func (t *Table[T]) SelectedItemIndex() int

func (*Table[T]) SetColumns

func (t *Table[T]) SetColumns(columns []TableColumn)

func (*Table[T]) SetFooterHeight

func (t *Table[T]) SetFooterHeight(height int)

func (*Table[T]) SetItemHeight

func (t *Table[T]) SetItemHeight(height int)

func (*Table[T]) SetItems

func (t *Table[T]) SetItems(items []TableRow[T])

func (*Table[T]) SetMultiSelection

func (t *Table[T]) SetMultiSelection(multi bool)

func (*Table[T]) SetReservesCheckmarkSpace

func (t *Table[T]) SetReservesCheckmarkSpace(reserves bool)

SetReservesCheckmarkSpace sets whether the table reserves space for the checkmark column even when no row is currently checked. See List.SetReservesCheckmarkSpace for details.

func (*Table[T]) SetScrollPosition

func (t *Table[T]) SetScrollPosition(position ListScrollPosition)

SetScrollPosition scrolls to the given position with animation.

func (*Table[T]) SetUnfocusedSelectionVisible

func (t *Table[T]) SetUnfocusedSelectionVisible(visible bool)

type TableCell

type TableCell struct {
	Text      string
	TextStyle ItemTextStyle
	Content   guigui.Widget
}

type TableColumn

type TableColumn struct {
	HeaderText                string
	HeaderTextHorizontalAlign HorizontalAlign
	Width                     guigui.Size
	MinWidth                  int
}

type TableRow

type TableRow[T comparable] struct {
	Cells        []TableCell
	Unselectable bool
	Movable      bool
	Checked      bool
	Value        T
}

type Text

type Text struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

Text is a widget that shows or edits a text value. It wraps the theme-free textwidget.Text core with theme policy: the default text colors, font family resolution, locales, and the placeholder.

func (*Text) AppendBoundsOfTextRange

func (t *Text) AppendBoundsOfTextRange(dst []image.Rectangle, context *guigui.Context, bounds image.Rectangle, startInBytes, endInBytes int) []image.Rectangle

AppendBoundsOfTextRange appends the bounding rectangles covering the text range [startInBytes, endInBytes) to dst and returns the extended slice, one rectangle per crossed visual line, in order. bounds is the widget's bounds; the rectangles are in the same coordinate space. A masked value appends nothing. Endpoints outside the text are clamped.

func (*Text) AppendHotspotRanges

func (t *Text) AppendHotspotRanges(dst []TextRange) []TextRange

AppendHotspotRanges appends the current hotspot ranges to dst and returns the extended slice, reflecting the adjustments made for edits since Text.SetHotspotRanges.

func (*Text) Build

func (t *Text) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Text) CanCopy

func (t *Text) CanCopy() bool

func (*Text) CanCut

func (t *Text) CanCut() bool

func (*Text) CanPaste

func (t *Text) CanPaste() bool

func (*Text) CanRedo

func (t *Text) CanRedo() bool

func (*Text) CanUndo

func (t *Text) CanUndo() bool

func (*Text) CaretPositionAtTextIndexInBytes

func (t *Text) CaretPositionAtTextIndexInBytes(context *guigui.Context, textIndexInBytes int) (top, bottom image.Point, ok bool)

CaretPositionAtTextIndexInBytes returns the on-screen top and bottom endpoints of a caret drawn at byte offset textIndexInBytes in the text value. ok is false when textIndexInBytes is out of range, or when the caret's logical line is outside the current viewport.

CaretPositionAtTextIndexInBytes is available after the layout phase.

func (*Text) CommitWithCurrentInputValue

func (t *Text) CommitWithCurrentInputValue()

func (*Text) Copy

func (t *Text) Copy() bool

func (*Text) Cut

func (t *Text) Cut() bool

func (*Text) Draw

func (t *Text) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*Text) ForceSetValue

func (t *Text) ForceSetValue(text string)

func (*Text) HasValue

func (t *Text) HasValue() bool

HasValue reports whether the text has a non-empty value. This is more efficient than checking Value() != "" as it avoids allocating a string.

func (*Text) HorizontalAlign

func (t *Text) HorizontalAlign() HorizontalAlign

func (*Text) IsEditable

func (t *Text) IsEditable() bool

func (*Text) IsMultiline

func (t *Text) IsMultiline() bool

IsMultiline reports whether the value may span multiple lines. It is always false while masking, which is single-line.

func (*Text) Layout

func (t *Text) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Text) LineCount

func (t *Text) LineCount() int

LineCount returns the number of logical lines in the value. A logical line is a span between hard line breaks; soft-wrapped visual lines are not counted. The empty value has one logical line; a trailing line break creates an extra empty line at the end, so "abc\n" has 2 lines.

func (*Text) LineIndexFromTextIndexInBytes

func (t *Text) LineIndexFromTextIndexInBytes(textIndexInBytes int) int

LineIndexFromTextIndexInBytes returns the index of the logical line containing textIndexInBytes. textIndexInBytes is clamped: negative values map to line 0, values past the end map to the last line.

See Text.LineCount for what counts as a logical line.

func (*Text) LineStartInBytes

func (t *Text) LineStartInBytes(lineIndex int) int

LineStartInBytes returns the byte offset where the lineIndex-th logical line begins within the value. lineIndex must be in [0, Text.LineCount).

func (*Text) Measure

func (t *Text) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Text) OnHandleButtonInput

func (t *Text) OnHandleButtonInput(f func(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult)

func (*Text) OnHotspotDown

func (t *Text) OnHotspotDown(f func(context *guigui.Context, textRange TextRange))

OnHotspotDown sets the event handler that is called when the left mouse button is pressed on a hotspot range. The handler is given the pressed range.

func (*Text) OnHotspotUp

func (t *Text) OnHotspotUp(f func(context *guigui.Context, textRange TextRange))

OnHotspotUp sets the event handler that is called when the left mouse button is released on the hotspot range it was pressed on. For selectable text, the click is canceled when the cursor moved or a selection was made between the press and the release: a drag selects, it does not click. The handler is given the released range.

func (*Text) OnInsertionStyleReset

func (t *Text) OnInsertionStyleReset(f func(context *guigui.Context))

OnInsertionStyleReset sets an event handler invoked when the widget resets the insertion style: after applying it to inserted text, or when discarding it without applying, such as on a selection change. The handler is not invoked for Text.SetInsertionStyle.

func (*Text) OnValueChanged

func (t *Text) OnValueChanged(f func(context *guigui.Context, text string, committed bool))

OnValueChanged sets the event handler that is called when the text value changes. The handler receives the current text and whether the change is committed. A committed change is a finalized value: the user presses Enter (for single-line text), the text input loses focus, or the value is set programmatically via Text.ForceSetValue / Text.ReadValueFrom (and equivalent paths on wrapping widgets). An uncommitted change is a mid-flight edit such as IME composition.

Pressing Enter on single-line text always dispatches a committed change, even when the value equals the last committed value. Every other path fires only when the text content actually advances: input activity that doesn't modify the text — caret moves, focus changes, IME state replays, a focus-loss commit on an unchanged buffer — does not trigger the handler.

An undo or redo also dispatches an uncommitted change when it restores the ranged style overrides alone, with the text itself unchanged. The handler can read the current overrides back via Text.ReadOverrideStyles.

If the handler does not need the text payload, prefer Text.OnValueChangedWithoutText to avoid materializing the value on every change.

func (*Text) OnValueChangedWithoutText

func (t *Text) OnValueChangedWithoutText(f func(context *guigui.Context, committed bool))

OnValueChangedWithoutText sets a handler that fires under the same conditions as Text.OnValueChanged but is not given the current text. Use this when the handler only needs to know that the value changed (e.g. to mark a document dirty) so the underlying value is not materialized into a string on every change.

The handler can be registered alongside Text.OnValueChanged; both fire on the same change.

func (*Text) Paste

func (t *Text) Paste() bool

func (*Text) PasteWithoutStyles

func (t *Text) PasteWithoutStyles() bool

PasteWithoutStyles pastes the clipboard text without the ranged styles copied along with it, even when the widget is rich text editable. The inserted text adopts the style of the surrounding text.

func (*Text) ReadBaseStyle

func (t *Text) ReadBaseStyle(style *TextStyle)

ReadBaseStyle replaces style with the base style: the style properties applied to the whole value, underneath the ranged style overrides. A property is unset when the theme default applies.

func (*Text) ReadEffectiveStyleAt

func (t *Text) ReadEffectiveStyleAt(style *TextStyle, textIndexInBytes int)

ReadEffectiveStyleAt replaces style with the effective style that text typed at textIndexInBytes adopts: the base style and the rendering defaults with the overrides adopted from the byte right before the index merged on top, so every property is set.

func (*Text) ReadEffectiveStyles

func (t *Text) ReadEffectiveStyles(styles *TextStyles)

ReadEffectiveStyles replaces styles with the effective styles of the whole value. The effective style of a byte is the base style and the rendering defaults with the byte's ranged overrides merged on top, so every property is set.

func (*Text) ReadEffectiveStylesInRange

func (t *Text) ReadEffectiveStylesInRange(styles *TextStyles, startInBytes, endInBytes int)

ReadEffectiveStylesInRange replaces styles with the effective styles of [startInBytes, endInBytes), rebased so that startInBytes maps to 0. The effective style of a byte is the base style and the rendering defaults with the byte's ranged overrides merged on top, so every property is set.

func (*Text) ReadOverrideStyles

func (t *Text) ReadOverrideStyles(styles *TextStyles)

ReadOverrideStyles replaces styles with a copy of the ranged style overrides, reflecting the adjustments made for edits since the overrides were set.

func (*Text) ReadOverrideStylesInRange

func (t *Text) ReadOverrideStylesInRange(styles *TextStyles, startInBytes, endInBytes int)

ReadOverrideStylesInRange replaces styles with a copy of the ranged style overrides in [startInBytes, endInBytes), rebased so that startInBytes maps to 0.

func (*Text) ReadValueFrom

func (t *Text) ReadValueFrom(r io.Reader) (int64, error)

ReadValueFrom resets the value to the bytes read from r until EOF and returns the number of bytes read. It is the streaming counterpart of Text.ForceSetValue: the change is applied immediately, the undo history is cleared, and the selection is reset to (0, 0).

If r returns a non-EOF error, the value is reset to empty and the error is returned.

func (*Text) Redo

func (t *Text) Redo() bool

func (*Text) ReplaceValueAtSelection

func (t *Text) ReplaceValueAtSelection(text string)

func (*Text) Selection

func (t *Text) Selection() (start, end int)

func (*Text) SetBaseStyle

func (t *Text) SetBaseStyle(style *TextStyle)

SetBaseStyle replaces the base style with style. Unset properties restore the theme defaults. The base style holds the font family, the italic face selection, OpenType variations and features (including the weight), and the text color; the scale and the language are ignored, as they come from Text.SetScale and Text.SetLocales.

func (*Text) SetCaretBlinking

func (t *Text) SetCaretBlinking(caretBlinking bool)

SetCaretBlinking sets whether the caret blinks. The default value is true.

func (*Text) SetEditable

func (t *Text) SetEditable(editable bool)

func (*Text) SetEllipsisString

func (t *Text) SetEllipsisString(str string)

func (*Text) SetFontSize

func (t *Text) SetFontSize(size float64)

SetFontSize sets the font size at scale 1. A non-positive size selects the default font size (FontSize). Unlike the default, the specified size is not multiplied by guigui.Context.Scale, so it can express a size independent of the app scale; multiply it explicitly when it should follow the app scale.

func (*Text) SetHorizontalAlign

func (t *Text) SetHorizontalAlign(align HorizontalAlign)

func (*Text) SetHotspotRanges

func (t *Text) SetHotspotRanges(ranges []TextRange)

SetHotspotRanges sets the hotspot ranges: over their rectangles the cursor turns into a pointer, and mouse presses and releases fire the hotspot down and up events. The ranges follow the text through edits like the ranged styles. While the value is editable, the hotspots are inert.

func (*Text) SetInsertionStyle

func (t *Text) SetInsertionStyle(style *TextStyle)

SetInsertionStyle replaces the insertion style with style. Its set properties are applied as ranged style overrides over the next text inserted at the caret, on top of the adopted overrides, and the style is then reset. The widget also resets it without applying on other interactions, such as a selection change, a deletion, or an undo; neither setting nor resetting is recorded in the undo history. SetInsertionStyle is typically called on every build with application-owned state, updated in the Text.OnInsertionStyleReset handler so the next build sets the cleared style.

func (*Text) SetLineHeight

func (t *Text) SetLineHeight(lineHeight float64)

SetLineHeight sets the line height at scale 1. A non-positive height selects the default line height (LineHeight). Unlike the default, the specified height is not multiplied by guigui.Context.Scale, so it can express a height independent of the app scale; multiply it explicitly when it should follow the app scale.

func (*Text) SetLineHeightMode

func (t *Text) SetLineHeightMode(lineHeightMode LineHeightMode)

SetLineHeightMode sets how a visual line's height responds to the font sizes on it. The default is LineHeightModeFixed.

func (*Text) SetLocales

func (t *Text) SetLocales(locales []language.Tag)

func (*Text) SetMaskRune

func (t *Text) SetMaskRune(maskRune rune)

SetMaskRune sets the character drawn in place of each grapheme cluster of the value. A non-zero rune masks the text and forces it to a single line; the zero value renders it normally.

func (*Text) SetMultiline

func (t *Text) SetMultiline(multiline bool)

func (*Text) SetOpacity

func (t *Text) SetOpacity(opacity float64)

func (*Text) SetOverrideStyles

func (t *Text) SetOverrideStyles(styles *TextStyles, recorded bool)

SetOverrideStyles replaces the ranged style overrides with styles. recorded sets whether the replacement is recorded in the undo history; a recorded replacement leaving the overrides unchanged records nothing. Pass false when restoring the overrides from a model, such as on every build.

func (*Text) SetOverrideStylesInRange

func (t *Text) SetOverrideStylesInRange(styles *TextStyles, startInBytes, endInBytes int, recorded bool)

SetOverrideStylesInRange replaces the ranged style overrides in [startInBytes, endInBytes) with styles' overrides in [0, endInBytes-startInBytes), shifted so that 0 maps to startInBytes. styles' overrides outside [0, endInBytes-startInBytes) are ignored. recorded sets whether the replacement is recorded in the undo history; a recorded replacement leaving the overrides unchanged records nothing.

func (*Text) SetPlaceholder

func (t *Text) SetPlaceholder(placeholder string)

SetPlaceholder sets the placeholder text shown in a subdued color while the value is empty and the text is editable. The empty string disables the placeholder.

func (*Text) SetRichTextEditable

func (t *Text) SetRichTextEditable(richTextEditable bool)

SetRichTextEditable sets whether pasting applies the ranged styles copied along with the text. The default is false: pasting inserts plain text and the inserted text adopts the style of the surrounding text.

func (*Text) SetScale

func (t *Text) SetScale(scale float64)

func (*Text) SetSelectable

func (t *Text) SetSelectable(selectable bool)

func (*Text) SetSelection

func (t *Text) SetSelection(start, end int)

SetSelection sets the selection to [start, end) in bytes. Offsets inside a UTF-8 sequence are snapped to rune boundaries: an empty selection moves to the start of the rune containing it, and a non-empty one expands to cover whole runes.

func (*Text) SetSelectionVisibleWhenUnfocused

func (t *Text) SetSelectionVisibleWhenUnfocused(visible bool)

SetSelectionVisibleWhenUnfocused sets whether the selection range stays drawn while the widget is not focused. By default the selection is hidden when the widget loses focus. Enable this when a separate UI (e.g. a Find dialog) holds focus but the user still needs to see what was matched.

func (*Text) SetTabWidth

func (t *Text) SetTabWidth(tabWidth float64)

func (*Text) SetValue

func (t *Text) SetValue(text string)

func (*Text) SetVerticalAlign

func (t *Text) SetVerticalAlign(align VerticalAlign)

func (*Text) SetWrapMode

func (t *Text) SetWrapMode(wrapMode WrapMode)

SetWrapMode selects how visual lines wrap when text exceeds the available width. See WrapMode for the available modes.

func (*Text) Undo

func (t *Text) Undo() bool

func (*Text) Value

func (t *Text) Value() string

Value returns the current value as a string. For large values, prefer Text.WriteValueTo to avoid allocating a copy.

func (*Text) VerticalAlign

func (t *Text) VerticalAlign() VerticalAlign

func (*Text) WrapMode

func (t *Text) WrapMode() WrapMode

WrapMode reports how visual lines wrap when text exceeds the available width. The default is WrapModeNone.

func (*Text) WriteStateKey

func (t *Text) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

func (*Text) WriteValueRangeTo

func (t *Text) WriteValueRangeTo(w io.Writer, startInBytes, endInBytes int) (int64, error)

WriteValueRangeTo writes the bytes of the current value in [startInBytes, endInBytes) to w. startInBytes and endInBytes are clamped to [0, len(value)]. If the clamped start is not less than the clamped end, nothing is written.

func (*Text) WriteValueTo

func (t *Text) WriteValueTo(w io.Writer) (int64, error)

WriteValueTo writes the current value to w and returns the number of bytes written. It is the streaming counterpart of Text.Value and avoids materializing the full value as a string.

type TextInput

type TextInput struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*TextInput) Build

func (t *TextInput) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*TextInput) CanCopy

func (t *TextInput) CanCopy() bool

func (*TextInput) CanCut

func (t *TextInput) CanCut() bool

func (*TextInput) CanPaste

func (t *TextInput) CanPaste() bool

func (*TextInput) CanRedo

func (t *TextInput) CanRedo() bool

func (*TextInput) CanUndo

func (t *TextInput) CanUndo() bool

func (*TextInput) CaretPositionAtTextIndexInBytes

func (t *TextInput) CaretPositionAtTextIndexInBytes(context *guigui.Context, textIndexInBytes int) (top, bottom image.Point, ok bool)

CaretPositionAtTextIndexInBytes returns the on-screen top and bottom endpoints of a caret drawn at byte offset textIndexInBytes in the text value. See Text.CaretPositionAtTextIndexInBytes for details.

func (*TextInput) CommitWithCurrentInputValue

func (t *TextInput) CommitWithCurrentInputValue()

func (*TextInput) Copy

func (t *TextInput) Copy() bool

func (*TextInput) Cut

func (t *TextInput) Cut() bool

func (*TextInput) ForceSetValue

func (t *TextInput) ForceSetValue(text string)

func (*TextInput) HasValue

func (t *TextInput) HasValue() bool

HasValue reports whether the text input has a non-empty value. This is more efficient than checking Value() != "" as it avoids allocating a string.

func (*TextInput) IsEditable

func (t *TextInput) IsEditable() bool

func (*TextInput) IsError

func (t *TextInput) IsError() bool

IsError reports whether the text input is in the error state.

func (*TextInput) Layout

func (t *TextInput) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*TextInput) LineCount

func (t *TextInput) LineCount() int

LineCount returns the number of logical lines in the value. See Text.LineCount for details.

func (*TextInput) LineIndexFromTextIndexInBytes

func (t *TextInput) LineIndexFromTextIndexInBytes(textIndexInBytes int) int

LineIndexFromTextIndexInBytes returns the index of the logical line containing textIndexInBytes. See Text.LineIndexFromTextIndexInBytes for details.

func (*TextInput) LineStartInBytes

func (t *TextInput) LineStartInBytes(lineIndex int) int

LineStartInBytes returns the byte offset where the lineIndex-th logical line begins within the value. See Text.LineStartInBytes for details.

func (*TextInput) Measure

func (t *TextInput) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*TextInput) OnHandleButtonInput

func (t *TextInput) OnHandleButtonInput(f func(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult)

func (*TextInput) OnInsertionStyleReset

func (t *TextInput) OnInsertionStyleReset(f func(context *guigui.Context))

OnInsertionStyleReset sets an event handler invoked when the widget resets the insertion style: after applying it to inserted text, or when discarding it without applying, such as on a selection change. The handler is not invoked for TextInput.SetInsertionStyle.

func (*TextInput) OnValueChanged

func (t *TextInput) OnValueChanged(f func(context *guigui.Context, text string, committed bool))

OnValueChanged sets a handler with the same dispatch and commit semantics as Text.OnValueChanged. The handler receives the current text and whether the change is committed.

If the handler does not need the text payload, prefer TextInput.OnValueChangedWithoutText to avoid materializing the value on every change.

func (*TextInput) OnValueChangedWithoutText

func (t *TextInput) OnValueChangedWithoutText(f func(context *guigui.Context, committed bool))

OnValueChangedWithoutText sets a handler that fires under the same conditions as TextInput.OnValueChanged but is not given the current text. Use this when the handler only needs to know that the value changed so the underlying value is not materialized into a string on every change.

func (*TextInput) Paste

func (t *TextInput) Paste() bool

func (*TextInput) PasteWithoutStyles

func (t *TextInput) PasteWithoutStyles() bool

PasteWithoutStyles pastes the clipboard text without the ranged styles copied along with it, even when the widget is rich text editable. The inserted text adopts the style of the surrounding text.

func (*TextInput) ReadBaseStyle

func (t *TextInput) ReadBaseStyle(style *TextStyle)

ReadBaseStyle replaces style with the base style: the style properties applied to the whole value, underneath the ranged style overrides. A property is unset when the theme default applies.

func (*TextInput) ReadEffectiveStyleAt

func (t *TextInput) ReadEffectiveStyleAt(style *TextStyle, textIndexInBytes int)

ReadEffectiveStyleAt replaces style with the effective style that text typed at textIndexInBytes adopts: the base style and the rendering defaults with the overrides adopted from the byte right before the index merged on top, so every property is set.

func (*TextInput) ReadEffectiveStyles

func (t *TextInput) ReadEffectiveStyles(styles *TextStyles)

ReadEffectiveStyles replaces styles with the effective styles of the whole value. The effective style of a byte is the base style and the rendering defaults with the byte's ranged overrides merged on top, so every property is set.

func (*TextInput) ReadEffectiveStylesInRange

func (t *TextInput) ReadEffectiveStylesInRange(styles *TextStyles, startInBytes, endInBytes int)

ReadEffectiveStylesInRange replaces styles with the effective styles of [startInBytes, endInBytes), rebased so that startInBytes maps to 0. The effective style of a byte is the base style and the rendering defaults with the byte's ranged overrides merged on top, so every property is set.

func (*TextInput) ReadOverrideStyles

func (t *TextInput) ReadOverrideStyles(styles *TextStyles)

ReadOverrideStyles replaces styles with a copy of the ranged style overrides, reflecting the adjustments made for edits since the overrides were set.

func (*TextInput) ReadOverrideStylesInRange

func (t *TextInput) ReadOverrideStylesInRange(styles *TextStyles, startInBytes, endInBytes int)

ReadOverrideStylesInRange replaces styles with a copy of the ranged style overrides in [startInBytes, endInBytes), rebased so that startInBytes maps to 0.

func (*TextInput) ReadValueFrom

func (t *TextInput) ReadValueFrom(r io.Reader) (int64, error)

ReadValueFrom resets the value to the bytes read from r until EOF. See Text.ReadValueFrom for details.

func (*TextInput) Redo

func (t *TextInput) Redo() bool

func (*TextInput) ReplaceValueAtSelection

func (t *TextInput) ReplaceValueAtSelection(text string)

func (*TextInput) SelectAll

func (t *TextInput) SelectAll()

func (*TextInput) Selection

func (t *TextInput) Selection() (start, end int)

func (*TextInput) SetBaseStyle

func (t *TextInput) SetBaseStyle(style *TextStyle)

SetBaseStyle replaces the base style with style. Unset properties restore the theme defaults. The base style holds the font family, the italic face selection, OpenType variations and features (including the weight), and the text color; the scale and the language are ignored.

func (*TextInput) SetCaretBlinking

func (t *TextInput) SetCaretBlinking(caretBlinking bool)

SetCaretBlinking sets whether the caret blinks. The default value is true.

func (*TextInput) SetEditable

func (t *TextInput) SetEditable(editable bool)

func (*TextInput) SetError

func (t *TextInput) SetError(hasError bool)

SetError sets whether the text input is in the error state. When the error state is true, the text input border is drawn in a danger color.

func (*TextInput) SetFocusBorderVisible

func (t *TextInput) SetFocusBorderVisible(visible bool)

SetFocusBorderVisible sets whether the focus border is drawn around the text input when it has focus. The default is true.

func (*TextInput) SetHorizontalAlign

func (t *TextInput) SetHorizontalAlign(halign HorizontalAlign)

func (*TextInput) SetIcon

func (t *TextInput) SetIcon(icon *ebiten.Image)

func (*TextInput) SetInsertionStyle

func (t *TextInput) SetInsertionStyle(style *TextStyle)

SetInsertionStyle replaces the insertion style with style. Its set properties are applied as ranged style overrides over the next text inserted at the caret, on top of the adopted overrides, and the style is then reset. The widget also resets it without applying on other interactions, such as a selection change, a deletion, or an undo; neither setting nor resetting is recorded in the undo history. SetInsertionStyle is typically called on every build with application-owned state, updated in the TextInput.OnInsertionStyleReset handler so the next build sets the cleared style.

func (*TextInput) SetLineHeight

func (t *TextInput) SetLineHeight(lineHeight float64)

SetLineHeight sets the line height at scale 1. See Text.SetLineHeight for details.

func (*TextInput) SetLineHeightMode

func (t *TextInput) SetLineHeightMode(lineHeightMode LineHeightMode)

SetLineHeightMode sets how a visual line's height responds to the font sizes on it. The default is LineHeightModeFixed.

func (*TextInput) SetMaskRune

func (t *TextInput) SetMaskRune(maskRune rune)

SetMaskRune sets the character drawn in place of each grapheme cluster of the value, masking it for password-style entry. A non-zero rune also disables copy and cut and forces the input to a single line; the zero value restores normal text.

func (*TextInput) SetMultiline

func (t *TextInput) SetMultiline(multiline bool)

func (*TextInput) SetOverrideStyles

func (t *TextInput) SetOverrideStyles(styles *TextStyles, recorded bool)

SetOverrideStyles replaces the ranged style overrides with styles. recorded sets whether the replacement is recorded in the undo history; a recorded replacement leaving the overrides unchanged records nothing. Pass false when restoring the overrides from a model, such as on every build.

func (*TextInput) SetOverrideStylesInRange

func (t *TextInput) SetOverrideStylesInRange(styles *TextStyles, startInBytes, endInBytes int, recorded bool)

SetOverrideStylesInRange replaces the ranged style overrides in [startInBytes, endInBytes) with styles' overrides in [0, endInBytes-startInBytes), shifted so that 0 maps to startInBytes. styles' overrides outside [0, endInBytes-startInBytes) are ignored. recorded sets whether the replacement is recorded in the undo history; a recorded replacement leaving the overrides unchanged records nothing.

func (*TextInput) SetPlaceholder

func (t *TextInput) SetPlaceholder(placeholder string)

SetPlaceholder sets the placeholder text shown in a subdued color while the value is empty and the text input is editable. The empty string disables the placeholder.

func (*TextInput) SetRichTextEditable

func (t *TextInput) SetRichTextEditable(richTextEditable bool)

SetRichTextEditable sets whether pasting applies the ranged styles copied along with the text. The default is false: pasting inserts plain text and the inserted text adopts the style of the surrounding text.

func (*TextInput) SetSelection

func (t *TextInput) SetSelection(start, end int)

SetSelection sets the selection to [start, end) in bytes. Offsets inside a UTF-8 sequence are snapped to rune boundaries: an empty selection moves to the start of the rune containing it, and a non-empty one expands to cover whole runes.

func (*TextInput) SetSelectionVisibleWhenUnfocused

func (t *TextInput) SetSelectionVisibleWhenUnfocused(visible bool)

SetSelectionVisibleWhenUnfocused sets whether the selection range stays drawn while the widget is not focused. By default the selection is hidden when the widget loses focus.

func (*TextInput) SetStyle

func (t *TextInput) SetStyle(style TextInputStyle)

SetStyle applies the preset combination of orthogonal properties for the given style. SetStyle re-applies every property on each call, so a per-property override takes effect only when its setter is called after SetStyle.

func (*TextInput) SetSupportText

func (t *TextInput) SetSupportText(text string)

SetSupportText sets the support text displayed below the text input. The support text is shown in a subdued color, or in a danger color when the error state is true. A line break starts a new line.

func (*TextInput) SetValue

func (t *TextInput) SetValue(text string)

func (*TextInput) SetVerticalAlign

func (t *TextInput) SetVerticalAlign(valign VerticalAlign)

func (*TextInput) SetWrapMode

func (t *TextInput) SetWrapMode(wrapMode WrapMode)

SetWrapMode sets how visual lines wrap when text exceeds the available width. See WrapMode for the available modes.

func (*TextInput) SupportText

func (t *TextInput) SupportText() string

SupportText returns the support text displayed below the text input.

func (*TextInput) Tick

func (t *TextInput) Tick(context *guigui.Context, widgetBounds *guigui.WidgetBounds) error

func (*TextInput) Undo

func (t *TextInput) Undo() bool

func (*TextInput) Value

func (t *TextInput) Value() string

Value returns the current value as a string. For large values, prefer TextInput.WriteValueTo to avoid allocating a copy.

func (*TextInput) WrapMode

func (t *TextInput) WrapMode() WrapMode

WrapMode reports the WrapMode currently applied to this text input.

func (*TextInput) WriteStateKey

func (t *TextInput) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

func (*TextInput) WriteValueRangeTo

func (t *TextInput) WriteValueRangeTo(w io.Writer, startInBytes, endInBytes int) (int64, error)

WriteValueRangeTo writes the bytes of the current value in [startInBytes, endInBytes) to w. See Text.WriteValueRangeTo for details.

func (*TextInput) WriteValueTo

func (t *TextInput) WriteValueTo(w io.Writer) (int64, error)

WriteValueTo writes the current value to w and returns the number of bytes written. See Text.WriteValueTo for details.

type TextInputStyle

type TextInputStyle int
const (
	TextInputStyleNormal TextInputStyle = iota
	TextInputStyleInline
)

type TextRange

type TextRange struct {
	// StartInBytes is the inclusive start of the range in bytes.
	StartInBytes int

	// EndInBytes is the exclusive end of the range in bytes.
	EndInBytes int
}

TextRange is a byte range of a text value.

type TextStyle

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

TextStyle is a set of text style properties where each property is individually set or unset. The zero value has every property unset. A TextStyle carries a widget's base style through Text.ReadBaseStyle and Text.SetBaseStyle, and an effective style through Text.ReadEffectiveStyleAt.

func (*TextStyle) BackgroundColor

func (s *TextStyle) BackgroundColor() (color.Color, bool)

BackgroundColor returns the background color and whether it is set.

func (*TextStyle) Color

func (s *TextStyle) Color() (color.Color, bool)

Color returns the text color and whether it is set.

func (*TextStyle) Feature

func (s *TextStyle) Feature(tag text.Tag) (uint32, bool)

Feature returns the value of the OpenType feature tag and whether it is set.

func (*TextStyle) FontFamily

func (s *TextStyle) FontFamily() (*FontFamily, bool)

FontFamily returns the font family and whether it is set.

func (*TextStyle) Italic

func (s *TextStyle) Italic() (italic, ok bool)

Italic returns the italic face selection and whether it is set.

func (*TextStyle) Lang

func (s *TextStyle) Lang() (language.Tag, bool)

Lang returns the language used for rendering and whether it is set.

func (*TextStyle) Scale

func (s *TextStyle) Scale() (float64, bool)

Scale returns the multiplier of the font size and whether it is set.

func (*TextStyle) SetBackgroundColor

func (s *TextStyle) SetBackgroundColor(clr color.Color)

SetBackgroundColor sets the background color.

func (*TextStyle) SetBold

func (s *TextStyle) SetBold(bold bool)

SetBold sets the font weight to the bold or the medium weight by setting the wght variation axis. Use TextStyle.UnsetWeight to unset the weight and TextStyle.Weight to read it back.

func (*TextStyle) SetColor

func (s *TextStyle) SetColor(clr color.Color)

SetColor sets the text color.

func (*TextStyle) SetFeature

func (s *TextStyle) SetFeature(tag text.Tag, value uint32)

SetFeature sets the OpenType feature tag to value.

func (*TextStyle) SetFontFamily

func (s *TextStyle) SetFontFamily(family *FontFamily)

SetFontFamily sets the font family. A nil family renders with the registered face source stack alone.

func (*TextStyle) SetItalic

func (s *TextStyle) SetItalic(italic bool)

SetItalic sets the italic face selection.

func (*TextStyle) SetLang

func (s *TextStyle) SetLang(lang language.Tag)

SetLang sets the language used for rendering.

func (*TextStyle) SetScale

func (s *TextStyle) SetScale(scale float64)

SetScale sets the multiplier of the font size. scale must be positive.

func (*TextStyle) SetStrikethrough

func (s *TextStyle) SetStrikethrough(strikethrough bool)

SetStrikethrough sets whether a strikethrough is drawn.

func (*TextStyle) SetTabular

func (s *TextStyle) SetTabular(tabular bool)

SetTabular sets whether the digits are rendered with a uniform advance by setting the tnum OpenType feature.

func (*TextStyle) SetUnderline

func (s *TextStyle) SetUnderline(underline bool)

SetUnderline sets whether an underline is drawn.

func (*TextStyle) SetVariation

func (s *TextStyle) SetVariation(tag text.Tag, value float32)

SetVariation sets the OpenType variation axis tag to value.

func (*TextStyle) SetWeight

func (s *TextStyle) SetWeight(weight text.Weight)

SetWeight sets the font weight by setting the wght variation axis.

func (*TextStyle) Strikethrough

func (s *TextStyle) Strikethrough() (strikethrough, ok bool)

Strikethrough returns whether a strikethrough is drawn and whether the property is set.

func (*TextStyle) Tabular

func (s *TextStyle) Tabular() (tabular, ok bool)

Tabular returns whether the digits are rendered with a uniform advance, the value of the tnum OpenType feature, and whether it is set.

func (*TextStyle) Underline

func (s *TextStyle) Underline() (underline, ok bool)

Underline returns whether an underline is drawn and whether the property is set.

func (*TextStyle) UnsetBackgroundColor

func (s *TextStyle) UnsetBackgroundColor()

UnsetBackgroundColor unsets the background color.

func (*TextStyle) UnsetColor

func (s *TextStyle) UnsetColor()

UnsetColor unsets the text color.

func (*TextStyle) UnsetFeature

func (s *TextStyle) UnsetFeature(tag text.Tag)

UnsetFeature unsets the OpenType feature tag.

func (*TextStyle) UnsetFontFamily

func (s *TextStyle) UnsetFontFamily()

UnsetFontFamily unsets the font family.

func (*TextStyle) UnsetItalic

func (s *TextStyle) UnsetItalic()

UnsetItalic unsets the italic face selection.

func (*TextStyle) UnsetLang

func (s *TextStyle) UnsetLang()

UnsetLang unsets the language used for rendering.

func (*TextStyle) UnsetScale

func (s *TextStyle) UnsetScale()

UnsetScale unsets the multiplier of the font size.

func (*TextStyle) UnsetStrikethrough

func (s *TextStyle) UnsetStrikethrough()

UnsetStrikethrough unsets whether a strikethrough is drawn.

func (*TextStyle) UnsetTabular

func (s *TextStyle) UnsetTabular()

UnsetTabular unsets whether the digits are rendered with a uniform advance by unsetting the tnum OpenType feature.

func (*TextStyle) UnsetUnderline

func (s *TextStyle) UnsetUnderline()

UnsetUnderline unsets whether an underline is drawn.

func (*TextStyle) UnsetVariation

func (s *TextStyle) UnsetVariation(tag text.Tag)

UnsetVariation unsets the OpenType variation axis tag.

func (*TextStyle) UnsetWeight

func (s *TextStyle) UnsetWeight()

UnsetWeight unsets the font weight by unsetting the wght variation axis.

func (*TextStyle) Variation

func (s *TextStyle) Variation(tag text.Tag) (float32, bool)

Variation returns the value of the OpenType variation axis tag and whether it is set.

func (*TextStyle) Weight

func (s *TextStyle) Weight() (text.Weight, bool)

Weight returns the font weight, the value of the wght variation axis, and whether it is set.

type TextStyles

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

TextStyles is a set of ranged style overrides for a Text value. The zero value is an empty set ready for use. A set built with the Set* methods is applied to a widget with Text.SetOverrideStyles or Text.SetOverrideStylesInRange; Text.ReadOverrideStyles and Text.ReadOverrideStylesInRange read a widget's current overrides back.

func (*TextStyles) ColorInRange

func (s *TextStyles) ColorInRange(startInBytes, endInBytes int, fallback color.Color) (clr color.Color, uniform bool)

ColorInRange returns the text color every byte of [startInBytes, endInBytes) takes and whether the color is uniform. A byte with a color override takes the override's value; every other byte takes fallback. An empty range is uniform with fallback.

func (*TextStyles) ItalicInRange

func (s *TextStyles) ItalicInRange(startInBytes, endInBytes int, fallback bool) (italic, uniform bool)

ItalicInRange returns the italic state every byte of [startInBytes, endInBytes) takes and whether the state is uniform. A byte with an italic override takes the override's value; every other byte takes fallback. An empty range is uniform with fallback.

func (*TextStyles) ResetStylesInRange

func (s *TextStyles) ResetStylesInRange(startInBytes, endInBytes int)

ResetStylesInRange removes all style overrides in [startInBytes, endInBytes).

func (*TextStyles) ScaleInRange

func (s *TextStyles) ScaleInRange(startInBytes, endInBytes int, fallback float64) (scale float64, uniform bool)

ScaleInRange returns the font size multiplier every byte of [startInBytes, endInBytes) takes and whether the multiplier is uniform. A byte with a scale override takes the override's value; every other byte takes fallback. An empty range is uniform with fallback.

func (*TextStyles) SetBackgroundColorInRange

func (s *TextStyles) SetBackgroundColorInRange(startInBytes, endInBytes int, clr color.Color)

SetBackgroundColorInRange overrides the background color in [startInBytes, endInBytes).

func (*TextStyles) SetColorInRange

func (s *TextStyles) SetColorInRange(startInBytes, endInBytes int, clr color.Color)

SetColorInRange overrides the text color in [startInBytes, endInBytes).

func (*TextStyles) SetFeatureInRange

func (s *TextStyles) SetFeatureInRange(startInBytes, endInBytes int, tag text.Tag, value uint32)

SetFeatureInRange overrides the OpenType feature tag in [startInBytes, endInBytes) with value.

func (*TextStyles) SetFontFamilyInRange

func (s *TextStyles) SetFontFamilyInRange(startInBytes, endInBytes int, family *FontFamily)

SetFontFamilyInRange overrides the font family in [startInBytes, endInBytes). A nil family renders the range with the registered face source stack alone.

func (*TextStyles) SetItalicInRange

func (s *TextStyles) SetItalicInRange(startInBytes, endInBytes int, italic bool)

SetItalicInRange overrides the italic face selection in [startInBytes, endInBytes).

func (*TextStyles) SetLangInRange

func (s *TextStyles) SetLangInRange(startInBytes, endInBytes int, lang language.Tag)

SetLangInRange overrides the language used for rendering in [startInBytes, endInBytes).

func (*TextStyles) SetScaleInRange

func (s *TextStyles) SetScaleInRange(startInBytes, endInBytes int, scale float64)

SetScaleInRange overrides the multiplier of the font size in [startInBytes, endInBytes). scale must be positive.

func (*TextStyles) SetStrikethroughInRange

func (s *TextStyles) SetStrikethroughInRange(startInBytes, endInBytes int, strikethrough bool)

SetStrikethroughInRange overrides whether a strikethrough is drawn in [startInBytes, endInBytes).

func (*TextStyles) SetUnderlineInRange

func (s *TextStyles) SetUnderlineInRange(startInBytes, endInBytes int, underline bool)

SetUnderlineInRange overrides whether an underline is drawn in [startInBytes, endInBytes).

func (*TextStyles) SetVariationInRange

func (s *TextStyles) SetVariationInRange(startInBytes, endInBytes int, tag text.Tag, value float32)

SetVariationInRange overrides the OpenType variation axis tag in [startInBytes, endInBytes) with value.

func (*TextStyles) SetWeightInRange

func (s *TextStyles) SetWeightInRange(startInBytes, endInBytes int, weight text.Weight)

SetWeightInRange overrides the font weight in [startInBytes, endInBytes) by setting the wght variation axis.

func (*TextStyles) StrikethroughInRange

func (s *TextStyles) StrikethroughInRange(startInBytes, endInBytes int, fallback bool) (strikethrough, uniform bool)

StrikethroughInRange returns the strikethrough state every byte of [startInBytes, endInBytes) takes and whether the state is uniform. A byte with a strikethrough override takes the override's value; every other byte takes fallback. An empty range is uniform with fallback.

func (*TextStyles) UnderlineInRange

func (s *TextStyles) UnderlineInRange(startInBytes, endInBytes int, fallback bool) (underline, uniform bool)

UnderlineInRange returns the underline state every byte of [startInBytes, endInBytes) takes and whether the state is uniform. A byte with an underline override takes the override's value; every other byte takes fallback. An empty range is uniform with fallback.

func (*TextStyles) UnsetBackgroundColorInRange

func (s *TextStyles) UnsetBackgroundColorInRange(startInBytes, endInBytes int)

UnsetBackgroundColorInRange removes the background color override in [startInBytes, endInBytes).

func (*TextStyles) UnsetColorInRange

func (s *TextStyles) UnsetColorInRange(startInBytes, endInBytes int)

UnsetColorInRange removes the text color override in [startInBytes, endInBytes).

func (*TextStyles) UnsetFeatureInRange

func (s *TextStyles) UnsetFeatureInRange(startInBytes, endInBytes int, tag text.Tag)

UnsetFeatureInRange removes the override of the OpenType feature tag in [startInBytes, endInBytes).

func (*TextStyles) UnsetFontFamilyInRange

func (s *TextStyles) UnsetFontFamilyInRange(startInBytes, endInBytes int)

UnsetFontFamilyInRange removes the font family override in [startInBytes, endInBytes).

func (*TextStyles) UnsetItalicInRange

func (s *TextStyles) UnsetItalicInRange(startInBytes, endInBytes int)

UnsetItalicInRange removes the italic override in [startInBytes, endInBytes).

func (*TextStyles) UnsetLangInRange

func (s *TextStyles) UnsetLangInRange(startInBytes, endInBytes int)

UnsetLangInRange removes the language override in [startInBytes, endInBytes).

func (*TextStyles) UnsetScaleInRange

func (s *TextStyles) UnsetScaleInRange(startInBytes, endInBytes int)

UnsetScaleInRange removes the font size multiplier override in [startInBytes, endInBytes).

func (*TextStyles) UnsetStrikethroughInRange

func (s *TextStyles) UnsetStrikethroughInRange(startInBytes, endInBytes int)

UnsetStrikethroughInRange removes the strikethrough override in [startInBytes, endInBytes).

func (*TextStyles) UnsetUnderlineInRange

func (s *TextStyles) UnsetUnderlineInRange(startInBytes, endInBytes int)

UnsetUnderlineInRange removes the underline override in [startInBytes, endInBytes).

func (*TextStyles) UnsetVariationInRange

func (s *TextStyles) UnsetVariationInRange(startInBytes, endInBytes int, tag text.Tag)

UnsetVariationInRange removes the override of the OpenType variation axis tag in [startInBytes, endInBytes).

func (*TextStyles) UnsetWeightInRange

func (s *TextStyles) UnsetWeightInRange(startInBytes, endInBytes int)

UnsetWeightInRange removes the font weight override in [startInBytes, endInBytes).

func (*TextStyles) VariationInRange

func (s *TextStyles) VariationInRange(startInBytes, endInBytes int, tag text.Tag, fallback float32) (value float32, uniform bool)

VariationInRange returns the value of the OpenType variation axis tag every byte of [startInBytes, endInBytes) takes and whether the value is uniform. A byte with an override of the axis takes the override's value; every other byte takes fallback. An empty range is uniform with fallback.

func (*TextStyles) WeightInRange

func (s *TextStyles) WeightInRange(startInBytes, endInBytes int, fallback text.Weight) (weight text.Weight, uniform bool)

WeightInRange returns the font weight every byte of [startInBytes, endInBytes) takes and whether the weight is uniform. A byte with a wght variation override takes the override's value; every other byte takes fallback. An empty range is uniform with fallback.

type Toggle

type Toggle struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

func (*Toggle) CursorShape

func (t *Toggle) CursorShape(context *guigui.Context, widgetBounds *guigui.WidgetBounds) (ebiten.CursorShapeType, bool)

func (*Toggle) Draw

func (t *Toggle) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*Toggle) HandlePointingInput

func (t *Toggle) HandlePointingInput(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult

func (*Toggle) Measure

func (t *Toggle) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Toggle) OnValueChanged

func (t *Toggle) OnValueChanged(f func(context *guigui.Context, value bool))

func (*Toggle) SetValue

func (t *Toggle) SetValue(value bool)

func (*Toggle) Tick

func (t *Toggle) Tick(context *guigui.Context, widgetBounds *guigui.WidgetBounds) error

func (*Toggle) Value

func (t *Toggle) Value() bool

func (*Toggle) WriteStateKey

func (t *Toggle) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type TooltipArea

type TooltipArea struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

TooltipArea is a standalone widget that shows a balloon popup when the mouse cursor hovers over the area specified by its bounds, or over the areas set by TooltipArea.SetHitAreas. The tooltip appears above the hovered area and has a black background regardless of the color mode. The tooltip automatically disappears when the mouse cursor moves out of the area.

TooltipArea shows a modeless popup: it does not prevent user interactions with other widgets.

func (*TooltipArea) Build

func (t *TooltipArea) Build(context *guigui.Context, adder *guigui.ChildAdder) error

Build implements guigui.Widget.Build.

func (*TooltipArea) Layout

func (t *TooltipArea) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

Layout implements guigui.Widget.Layout.

func (*TooltipArea) Measure

func (t *TooltipArea) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

Measure implements guigui.Widget.Measure.

func (*TooltipArea) SetContent

func (t *TooltipArea) SetContent(widget guigui.Widget)

SetContent sets a custom content widget for the tooltip balloon. TooltipArea.SetContent and TooltipArea.SetText are exclusive; TooltipArea.SetContent takes priority.

func (*TooltipArea) SetHitAreas

func (t *TooltipArea) SetHitAreas(areas []image.Rectangle)

SetHitAreas sets the areas, in screen coordinates, where hovering triggers the tooltip. The areas take effect only within the widget's bounds. A nil slice means the whole bounds; a non-nil empty slice means no area triggers the tooltip.

func (*TooltipArea) SetText

func (t *TooltipArea) SetText(text string)

SetText sets the tooltip balloon text. TooltipArea.SetContent and TooltipArea.SetText are exclusive; TooltipArea.SetContent takes priority.

func (*TooltipArea) Tick

func (t *TooltipArea) Tick(context *guigui.Context, widgetBounds *guigui.WidgetBounds) error

Tick implements guigui.Widget.Tick.

func (*TooltipArea) WriteStateKey

func (t *TooltipArea) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type UnicodeRange

type UnicodeRange struct {
	Min rune
	Max rune
}

UnicodeRange is an inclusive range of code points.

type VerticalAlign

type VerticalAlign int

type WrapMode

type WrapMode int

WrapMode selects how visual lines wrap when text exceeds the available width.

const (
	// WrapModeNone disables automatic wrapping; content extends past the
	// available width and only the explicit hard line breaks in the source
	// text introduce new visual lines.
	WrapModeNone WrapMode = WrapMode(textutil.WrapModeNone)

	// WrapModeNormal wraps at Unicode line break opportunities. These
	// coincide with word boundaries in most cases, but not always.
	WrapModeNormal WrapMode = WrapMode(textutil.WrapModeNormal)

	// WrapModeAnywhere wraps at any grapheme cluster boundary, breaking
	// inside words when needed to fit the available width.
	WrapModeAnywhere WrapMode = WrapMode(textutil.WrapModeAnywhere)
)

Directories

Path Synopsis
internal
chunk
Package chunk places cache-friendly boundaries within a single logical line of text.
Package chunk places cache-friendly boundaries within a single logical line of text.
piecetable
Package piecetable provides an editable text buffer with undo/redo support.
Package piecetable provides an editable text buffer with undo/redo support.
textstyle
Package textstyle provides the attributed-run model for ranged text styling: a set of style overrides laid over byte ranges of a single text value.
Package textstyle provides the attributed-run model for ranged text styling: a set of style overrides laid over byte ranges of a single text value.
textwidget
Package textwidget provides the theme-free core of the basicwidget text widgets: the editable Text widget and the input helpers it is built on.
Package textwidget provides the theme-free core of the basicwidget text widgets: the editable Text widget and the input helpers it is built on.

Jump to

Keyboard shortcuts

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