Bindings is the current keyboard, mouse and gamepad input configurations.
var Bindings = &Shortcuts{ DoubleClickThreshold: 200 * time.Millisecond, MoveLeftKeyboard: []ebiten.Key{ebiten.KeyLeft}, MoveRightKeyboard: []ebiten.Key{ebiten.KeyRight}, MoveDownKeyboard: []ebiten.Key{ebiten.KeyDown}, MoveUpKeyboard: []ebiten.Key{ebiten.KeyUp}, MoveLeftGamepad: []ebiten.StandardGamepadButton{ebiten.StandardGamepadButtonLeftLeft}, MoveRightGamepad: []ebiten.StandardGamepadButton{ebiten.StandardGamepadButtonLeftRight}, MoveDownGamepad: []ebiten.StandardGamepadButton{ebiten.StandardGamepadButtonLeftBottom}, MoveUpGamepad: []ebiten.StandardGamepadButton{ebiten.StandardGamepadButtonLeftTop}, ConfirmKeyboard: []ebiten.Key{ebiten.KeyEnter, ebiten.KeyKPEnter}, ConfirmMouse: []ebiten.MouseButton{ebiten.MouseButtonLeft, ebiten.MouseButtonRight}, ConfirmGamepad: []ebiten.StandardGamepadButton{ebiten.StandardGamepadButtonRightBottom}, }
ResizeDebounce is the minimum duration between screen layout changes. This setting can greatly improve performance when resizing the window.
var ResizeDebounce = 250 * time.Millisecond
Style is the current default attribute configuration. Integer values will be scaled.
var Style = &Attributes{ TextSize: 32, TextColorLight: color.RGBA{255, 255, 255, 255}, TextColorDark: color.RGBA{0, 0, 0, 255}, TextBgColor: transparent, InputBorderSize: 2, InputBorderFocused: color.RGBA{220, 220, 220, 255}, InputBorderUnfocused: color.RGBA{0, 0, 0, 255}, ScrollAreaColor: color.RGBA{200, 200, 200, 255}, ScrollHandleColor: color.RGBA{108, 108, 108, 255}, ScrollBorderSize: 2, ScrollBorderTop: color.RGBA{240, 240, 240, 255}, ScrollBorderRight: color.RGBA{0, 0, 0, 255}, ScrollBorderBottom: color.RGBA{0, 0, 0, 255}, ScrollBorderLeft: color.RGBA{240, 240, 240, 255}, InputBgColor: color.RGBA{0, 64, 0, 255}, ButtonBgColor: color.RGBA{255, 255, 255, 255}, ButtonBgColorDisabled: color.RGBA{110, 110, 110, 255}, ButtonBorderSize: 4, ButtonBorderTop: color.RGBA{220, 220, 220, 255}, ButtonBorderRight: color.RGBA{0, 0, 0, 255}, ButtonBorderBottom: color.RGBA{0, 0, 0, 255}, ButtonBorderLeft: color.RGBA{220, 220, 220, 255}, CheckboxBgColor: color.RGBA{255, 255, 255, 255}, }
func BoundString(f *text.GoTextFace, s string) image.Rectangle
BoundString returns the bounds of the provided string.
func Draw(screen *ebiten.Image) error
Draw draws the root widget and its children to the screen.
func FontFace(source *text.GoTextFaceSource, size int) *text.GoTextFace
FontFace returns a face for the provided font and size. Scaling is not applied.
func Layout(outsideWidth int, outsideHeight int)
Layout sets the current screen size and resizes the root widget.
func Open(target string) error
Open opens a file, directory or URI using the default application registered in the OS to handle it. Only URIs are supported on WebAssembly.
func Scale(v int) int
Scale applies the device scale factor to the provided value and returns the result. When running on Android, this function may only be called during or after the first Layout call made by Ebitengine.
func ScaleFactor() float64
ScaleFactor returns the device scale factor. When running on Android, this function may only be called during or after the first Layout call made by Ebitengine.
func ScreenSize() (width int, height int)
ScreenSize returns the current screen size.
func SetDebug(debug bool)
SetDebug sets whether debug information is drawn on screen. When enabled, all visible widgets are outlined.
func SetFocus(w Widget)
SetFocus focuses a widget.
func SetRoot(w Widget)
SetRoot sets the root widget. The root widget and all of its children will be drawn on the screen and receive user input. The root widget will also be focused. To temporarily disable etk, set a nil root widget.
func Update() error
Update handles user input and passes it to the focused or clicked widget.
Alignment specifies how text is aligned within the field.
type Alignment int
const ( // AlignStart aligns text at the start of the field. AlignStart Alignment = 0 // AlignCenter aligns text at the center of the field. AlignCenter Alignment = 1 // AlignEnd aligns text at the end of the field. AlignEnd Alignment = 2 )
Attributes represents a default attribute configuration. Integer values will be scaled.
type Attributes struct { TextFont *text.GoTextFaceSource TextSize int TextColorLight color.RGBA TextColorDark color.RGBA TextBgColor color.RGBA InputBorderSize int InputBorderFocused color.RGBA InputBorderUnfocused color.RGBA ScrollAreaColor color.RGBA ScrollHandleColor color.RGBA ScrollBorderSize int ScrollBorderTop color.RGBA ScrollBorderRight color.RGBA ScrollBorderBottom color.RGBA ScrollBorderLeft color.RGBA InputBgColor color.RGBA ButtonTextColor color.RGBA ButtonBgColor color.RGBA ButtonBgColorDisabled color.RGBA ButtonBorderSize int ButtonBorderTop color.RGBA ButtonBorderRight color.RGBA ButtonBorderBottom color.RGBA ButtonBorderLeft color.RGBA CheckboxBgColor color.RGBA }
Box is a building block for other widgets. It may also be used as a spacer in layout widgets.
type Box struct { sync.Mutex // contains filtered or unexported fields }
func NewBox() *Box
NewBox returns a new Box widget.
func (b *Box) AddChild(w ...Widget)
AddChild adds a child to the widget.
func (b *Box) Background() color.RGBA
Background returns the background color of the widget.
func (b *Box) Children() []Widget
Children returns the children of the widget. Children are drawn in the order they are returned. Keyboard and mouse events are passed to children in reverse order.
func (b *Box) Clear()
Clear removes all children from the widget.
func (b *Box) Clip() bool
Clip returns whether the widget and its children are restricted to drawing within the widget's rect area of the screen. For best performance, Clip should return false unless clipping is actually needed.
func (b *Box) Cursor() ebiten.CursorShapeType
Cursor returns the cursor shape shown when a mouse cursor hovers over the widget, or -1 to let widgets beneath determine the cursor shape.
func (b *Box) Draw(screen *ebiten.Image) error
Draw draws the widget on the screen.
func (b *Box) Focus() bool
Focus returns the focus state of the widget.
func (b *Box) HandleKeyboard(key ebiten.Key, r rune) (handled bool, err error)
HandleKeyboard is called when a keyboard event occurs.
func (b *Box) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs. Only mouse events that are on top of the widget are passed to the widget.
func (b *Box) Rect() image.Rectangle
Rect returns the position and size of the widget.
func (b *Box) SetBackground(background color.RGBA)
SetBackground sets the background color of the widget.
func (b *Box) SetFocus(focus bool) bool
SetFocus sets the focus state of the widget.
func (b *Box) SetRect(r image.Rectangle)
SetRect sets the position and size of the widget.
func (b *Box) SetVisible(visible bool)
SetVisible sets the visibility of the widget.
func (b *Box) Visible() bool
Visible returns the visibility of the widget.
Button is a clickable button.
type Button struct { *Box // contains filtered or unexported fields }
func NewButton(label string, onSelected func() error) *Button
NewButton returns a new Button widget.
func (b *Button) Cursor() ebiten.CursorShapeType
Cursor returns the cursor shape shown when a mouse cursor hovers over the widget, or -1 to let widgets beneath determine the cursor shape.
func (b *Button) Draw(screen *ebiten.Image) error
Draw draws the button on the screen.
func (b *Button) HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
HandleKeyboard is called when a keyboard event occurs.
func (b *Button) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (b *Button) SetBackground(background color.RGBA)
SetBackground sets the background color of the button label.
func (b *Button) SetBorderColors(top color.RGBA, right color.RGBA, bottom color.RGBA, left color.RGBA)
SetBorderColors sets the color of the top, right, bottom and left border.
func (b *Button) SetBorderSize(size int)
SetBorderSize sets the size of the border around the button.
func (b *Button) SetFont(fnt *text.GoTextFaceSource, size int)
SetFont sets the font and text size of button label. Scaling is not applied.
func (b *Button) SetForeground(c color.RGBA)
SetForeground sets the color of the button label.
func (b *Button) SetHorizontal(h Alignment)
SetHorizontal sets the horizontal alignment of the button label.
func (b *Button) SetRect(r image.Rectangle)
SetRect sets the position and size of the Button.
func (b *Button) SetText(text string)
SetText sets the text in the field.
func (b *Button) SetVertical(v Alignment)
SetVertical sets the vertical alignment of the button label.
func (b *Button) Text() string
Text returns the content of the text buffer.
Checkbox is a toggleable Checkbox.
type Checkbox struct { *Box // contains filtered or unexported fields }
func NewCheckbox(onSelect func() error) *Checkbox
NewCheckbox returns a new Checkbox widget.
func (c *Checkbox) Cursor() ebiten.CursorShapeType
Cursor returns the cursor shape shown when a mouse cursor hovers over the widget, or -1 to let widgets beneath determine the cursor shape.
func (c *Checkbox) Draw(screen *ebiten.Image) error
Draw draws the Checkbox on the screen.
func (c *Checkbox) HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
HandleKeyboard is called when a keyboard event occurs.
func (c *Checkbox) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (c *Checkbox) Selected() bool
Selected returns the selection state of the Checkbox.
func (c *Checkbox) SetBorderColor(borderColor color.RGBA)
SetBorderColor sets the border color of the Checkbox.
func (c *Checkbox) SetCheckColor(checkColor color.RGBA)
SetCheckColor sets the check mark color of the Checkbox.
func (c *Checkbox) SetRect(r image.Rectangle)
SetRect sets the position and size of the Checkbox. The checkbox is always a square shape.
func (c *Checkbox) SetSelected(selected bool)
SetSelected sets the Checkbox selection state. The onSelect function is not called when the value is set manually via SetSelected.
Flex is a flexible stack-based layout which may be oriented horizontally or vertically. Children are positioned with equal spacing by default. A minimum size may instead be specified via SetChildSize, causing children to be positioned similar to a flexbox, where each child either has the minimum size or the child stretches to fill the remaining row or column.
type Flex struct { *Box // contains filtered or unexported fields }
func NewFlex() *Flex
NewFlex returns a new Flex widget.
func (f *Flex) AddChild(w ...Widget)
AddChild adds a child to the widget.
func (f *Flex) Draw(screen *ebiten.Image) error
Draw draws the widget on the screen.
func (f *Flex) HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
HandleKeyboard is called when a keyboard event occurs.
func (f *Flex) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (f *Flex) SetChildSize(width int, height int)
SetChildSize sets the minimum size of each child in the Flex.
func (f *Flex) SetGaps(columnGap int, rowGap int)
SetGaps sets the gaps between each child in the Flex.
func (f *Flex) SetRect(r image.Rectangle)
SetRect sets the position and size of the widget.
func (f *Flex) SetVertical(v bool)
SetVertical sets the orientation of the child widget stacking.
Frame is a widget container. All children are displayed at once. Children are not repositioned by default. Repositioning may be enabled via SetPositionChildren.
type Frame struct { *Box // contains filtered or unexported fields }
func NewFrame(w ...Widget) *Frame
NewFrame returns a new Frame widget.
func (f *Frame) AddChild(w ...Widget)
AddChild adds a child to the widget.
func (f *Frame) SetHorizontal(h Alignment)
SetHorizontal sets the horizontal alignment of widgets within the Frame. This will only have an effect when a max width is set and there is extra space.
func (f *Frame) SetMaxHeight(h int)
SetMaxHeight sets the maximum height of widgets within the frame. This will only have an effect after SetPositionChildren(true) is called. 0 to disable.
func (f *Frame) SetMaxWidth(w int)
SetMaxWidth sets the maximum width of widgets within the frame. This will only have an effect after SetPositionChildren(true) is called. 0 to disable.
func (f *Frame) SetPadding(padding int)
SetPadding sets the amount of padding around widgets in the frame.
func (f *Frame) SetPositionChildren(position bool)
SetPositionChildren sets a flag that determines whether child widgets are repositioned when the Frame is repositioned.
func (f *Frame) SetRect(r image.Rectangle)
SetRect sets the position and size of the widget.
func (f *Frame) SetVertical(v Alignment)
SetVertical sets the vertical alignment ofwidgets within the Frame. This will only have an effect when a max height is set and there is extra space.
Grid is a highly customizable cell-based layout. Widgets added to the Grid may span multiple cells.
type Grid struct { *Box // contains filtered or unexported fields }
func NewGrid() *Grid
NewGrid returns a new Grid widget.
func (g *Grid) AddChild(wgt ...Widget)
AddChild adds a widget to the Grid at 0,0. To add widgets to a Grid, you should use AddChildAt instead.
func (g *Grid) AddChildAt(wgt Widget, x int, y int, columns int, rows int)
AddChildAt adds a widget to the Grid at the specified position. Each widget added to the grid may span multiple cells.
func (g *Grid) Clear()
Clear removes all children from the Grid.
func (g *Grid) Draw(screen *ebiten.Image) error
Draw draws the widget on the screen.
func (g *Grid) HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
HandleKeyboard is called when a keyboard event occurs.
func (g *Grid) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (g *Grid) SetColumnPadding(padding int)
SetColumnPadding sets the amount of padding between each column.
func (g *Grid) SetColumnSizes(size ...int)
SetColumnSizes sets the size of each column. A size of -1 represents an equal proportion of the available space.
func (g *Grid) SetRect(r image.Rectangle)
SetRect sets the position and size of the widget.
func (g *Grid) SetRowPadding(padding int)
SetRowPadding sets the amount of padding between each row.
func (g *Grid) SetRowSizes(size ...int)
SetRowSizes sets the size of each row. A size of -1 represents an equal proportion of the available space.
Input is a text input widget. The Input widget is simply a Text widget that also accepts user input.
type Input struct { *Box // contains filtered or unexported fields }
func NewInput(text string, onSelected func(text string) (handled bool)) *Input
NewInput returns a new Input widget.
func (i *Input) Cursor() ebiten.CursorShapeType
Cursor returns the cursor shape shown when a mouse cursor hovers over the widget, or -1 to let widgets beneath determine the cursor shape.
func (i *Input) Draw(screen *ebiten.Image) error
Draw draws the widget on the screen.
func (i *Input) Focus() bool
Focus returns the focus state of the widget.
func (i *Input) Foreground() color.RGBA
Foreground return the color of the text within the field.
func (i *Input) HandleKeyboard(key ebiten.Key, r rune) (handled bool, err error)
HandleKeyboard is called when a keyboard event occurs.
func (i *Input) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (i *Input) Padding() int
Padding returns the amount of padding around the text within the field.
func (i *Input) SetAutoHideScrollBar(autoHide bool)
SetAutoHideScrollBar sets whether the scroll bar is automatically hidden when the entire text buffer is visible.
func (t *Input) SetAutoResize(resize bool)
SetAutoResize sets whether the font is automatically scaled down when it is too large to fit the entire text buffer on one line.
func (i *Input) SetBorderColors(focused color.RGBA, unfocused color.RGBA)
SetBorderColors sets the border colors of the field when focused and unfocused.
func (i *Input) SetBorderSize(size int)
SetBorderSize sets the size of the border around the field.
func (i *Input) SetCursor(cursor string)
SetCursor sets the cursor appended to the text buffer when focused.
func (i *Input) SetFocus(focus bool) bool
SetFocus sets the focus state of the widget.
func (t *Input) SetFont(fnt *text.GoTextFaceSource, size int)
SetFont sets the font and text size of the field. Scaling is not applied.
func (i *Input) SetForeground(c color.RGBA)
SetForegroundColor sets the color of the text within the field.
func (i *Input) SetHorizontal(h Alignment)
SetHorizontal sets the horizontal alignment of the text within the field.
func (i *Input) SetMask(r rune)
SetMask sets the rune used to mask the text buffer contents. Set to 0 to disable.
func (i *Input) SetPadding(padding int)
SetPadding sets the amount of padding around the text within the field.
func (i *Input) SetPrefix(prefix string)
SetPrefix sets the text shown before the input text.
func (i *Input) SetRect(r image.Rectangle)
SetRect sets the position and size of the widget.
func (i *Input) SetScrollBarColors(area color.RGBA, handle color.RGBA)
SetScrollBarColors sets the color of the scroll bar area and handle.
func (i *Input) SetScrollBarVisible(scrollVisible bool)
SetScrollBarVisible sets whether the scroll bar is visible on the screen.
func (i *Input) SetScrollBarWidth(width int)
SetScrollBarWidth sets the width of the scroll bar.
func (i *Input) SetSuffix(suffix string)
SetSuffix sets the text shown after the input text.
func (i *Input) SetText(text string)
SetText sets the text in the field.
func (i *Input) SetVertical(v Alignment)
SetVertical sets the vertical alignment of the text within the field.
func (i *Input) SetWordWrap(wrap bool)
SetWordWrap sets a flag which, when enabled, causes text to wrap without breaking words.
func (i *Input) Text() string
Text returns the content of the text buffer.
func (i *Input) Write(p []byte) (n int, err error)
Write writes to the text buffer.
Keyboard is an on-screen keyboard widget. User input is automatically passed to the focused widget.
type Keyboard struct { *Box // contains filtered or unexported fields }
func NewKeyboard() *Keyboard
NewKeyboard returns a new Keyboard widget.
func (k *Keyboard) Cursor() ebiten.CursorShapeType
Cursor returns the cursor shape shown when a mouse cursor hovers over the widget, or -1 to let widgets beneath determine the cursor shape.
func (k *Keyboard) Draw(screen *ebiten.Image) error
Draw draws the keyboard on the screen.
func (k *Keyboard) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (k *Keyboard) Keys() [][]*kibodo.Key
Keys returns the keys of the keyboard.
func (k *Keyboard) SetExtendedKeys(keys [][]*kibodo.Key)
SetExtendedKeys sets the keys of the keyboard when the .
func (k *Keyboard) SetKeys(keys [][]*kibodo.Key)
SetKeys sets the keys of the keyboard.
func (k *Keyboard) SetRect(r image.Rectangle)
SetRect sets the position and size of the keyboard.
func (k *Keyboard) SetScheduleFrameFunc(f func())
SetScheduleFrameFunc sets the function called whenever the screen should be redrawn.
func (k *Keyboard) SetShowExtended(show bool)
SetShowExtended sets whether the normal or extended keyboard is shown.
func (k *Keyboard) SetVisible(visible bool)
SetVisible sets the visibility of the keyboard.
func (k *Keyboard) Visible() bool
Visible returns the visibility of the keyboard.
List is a list of widgets.
type List struct { sync.Mutex // contains filtered or unexported fields }
func NewList(itemHeight int, onSelected func(index int) (accept bool)) *List
NewList returns a new List widget.
func (l *List) AddChildAt(w Widget, x int, y int)
AddChildAt adds a widget to the list at the specified position.
func (l *List) Background() color.RGBA
Background returns the background color of the widget.
func (l *List) Children() []Widget
Children returns the children of the widget. Children are drawn in the order they are returned. Keyboard and mouse events are passed to children in reverse order.
func (l *List) Clear()
Clear clears all items from the list.
func (l *List) Clip() bool
Clip returns whether the widget and its children are restricted to drawing within the widget's rect area of the screen. For best performance, Clip should return false unless clipping is actually needed.
func (l *List) Cursor() ebiten.CursorShapeType
Cursor returns the cursor shape shown when a mouse cursor hovers over the widget, or -1 to let widgets beneath determine the cursor shape.
func (l *List) Draw(screen *ebiten.Image) error
Draw draws the widget on the screen.
func (l *List) Focus() bool
Focus returns the focus state of the widget.
func (l *List) HandleKeyboard(key ebiten.Key, r rune) (handled bool, err error)
HandleKeyboard is called when a keyboard event occurs.
func (l *List) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs. Only mouse events that are on top of the widget are passed to the widget.
func (l *List) Rect() image.Rectangle
Rect returns the position and size of the widget.
func (l *List) Rows() int
Rows returns the number of rows in the list.
func (l *List) SelectedItem() (x int, y int)
SelectedItem returns the selected list item.
func (l *List) SetBackground(background color.RGBA)
SetBackground sets the background color of the widget.
func (l *List) SetColumnSizes(size ...int)
SetColumnSizes sets the size of each column. A size of -1 represents an equal proportion of the available space.
func (l *List) SetConfirmedFunc(f func(index int))
SetConfirmedFunc sets a handler which is called when the list selection is confirmed. Providing a nil function value will remove the existing handler (if set).
func (l *List) SetDrawBorder(drawBorder bool)
SetDrawBorder enables or disables borders being drawn around the list.
func (l *List) SetFocus(focus bool) (accept bool)
SetFocus sets the focus state of the widget.
func (l *List) SetHighlightColor(c color.RGBA)
SetHighlightColor sets the color used to highlight the currently selected item.
func (l *List) SetItemHeight(itemHeight int)
SetItemHeight sets the height of the list items.
func (l *List) SetRect(r image.Rectangle)
SetRect sets the position and size of the widget.
func (l *List) SetScrollBarColors(area color.RGBA, handle color.RGBA)
SetScrollBarColors sets the color of the scroll bar area and handle.
func (l *List) SetScrollBarWidth(width int)
SetScrollBarWidth sets the width of the scroll bar.
func (l *List) SetScrollBorderColors(top color.RGBA, right color.RGBA, bottom color.RGBA, left color.RGBA)
SetScrollBorderColor sets the color of the top, right, bottom and left border of the scroll bar handle.
func (l *List) SetScrollBorderSize(size int)
SetScrollBorderSize sets the size of the border around the scroll bar handle.
func (l *List) SetSelectedFunc(f func(index int) (accept bool))
SetSelectedFunc sets a handler which is called when a list item is selected. Providing a nil function value will remove the existing handler (if set). The handler may return false to return the selection to its original state.
func (l *List) SetSelectedItem(x int, y int)
SetSelectedItem sets the selected list item.
func (l *List) SetSelectionMode(selectionMode SelectionMode)
SetSelectionMode sets the selection mode of the list.
func (l *List) SetVisible(visible bool)
SetVisible sets the visibility of the widget.
func (l *List) Visible() bool
Visible returns the visibility of the widget.
Select is a dropdown selection widget.
type Select struct { *Box // contains filtered or unexported fields }
func NewSelect(itemHeight int, onSelect func(index int) (accept bool)) *Select
NewSelect returns a new Select widget.
func (s *Select) AddChild(w ...Widget)
AddChild adds a child to the widget. Selection options are added via AddOption.
func (s *Select) AddOption(label string)
AddOption adds an option to the widget.
func (s *Select) Children() []Widget
Children returns the children of the widget.
func (s *Select) Clear()
Clear removes all children from the widget.
func (s *Select) Clip() bool
Clip returns whether the widget and its children are restricted to drawing within the widget's rect area of the screen. For best performance, Clip should return false unless clipping is actually needed.
func (s *Select) Cursor() ebiten.CursorShapeType
Cursor returns the cursor shape shown when a mouse cursor hovers over the widget, or -1 to let widgets beneath determine the cursor shape.
func (s *Select) Draw(screen *ebiten.Image) error
Draw draws the widget on the screen.
func (s *Select) HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
HandleKeyboard is called when a keyboard event occurs.
func (s *Select) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (s *Select) SetHighlightColor(c color.RGBA)
SetHighlightColor sets the color used to highlight the currently selected item.
func (s *Select) SetMenuVisible(visible bool)
SetMenuVisible sets the visibility of the dropdown menu.
func (s *Select) SetRect(r image.Rectangle)
SetRect sets the position and size of the widget.
func (s *Select) SetSelectedItem(index int)
SetSelectedItem sets the currently selected item.
SelectionMode represents a mode of selection.
type SelectionMode int
Selection modes.
const ( // SelectNone disables selection. SelectNone SelectionMode = iota // SelectRow enables selection by row. SelectRow // SelectColumn enables selection by column. SelectColumn )
Shortcuts represents the keyboard, mouse and gamepad input configurations.
type Shortcuts struct { DoubleClickThreshold time.Duration MoveLeftKeyboard []ebiten.Key MoveRightKeyboard []ebiten.Key MoveDownKeyboard []ebiten.Key MoveUpKeyboard []ebiten.Key MoveLeftGamepad []ebiten.StandardGamepadButton MoveRightGamepad []ebiten.StandardGamepadButton MoveDownGamepad []ebiten.StandardGamepadButton MoveUpGamepad []ebiten.StandardGamepadButton ConfirmKeyboard []ebiten.Key ConfirmMouse []ebiten.MouseButton ConfirmGamepad []ebiten.StandardGamepadButton // A sentinel rune value may be set for the confirm and back actions. // This allows working around on-screen keyboard issues on Android. ConfirmRune rune BackRune rune }
Sprite is a resizable image.
type Sprite struct { *Box // contains filtered or unexported fields }
func NewSprite(img *ebiten.Image) *Sprite
NewSprite returns a new Sprite widget.
func (s *Sprite) Draw(screen *ebiten.Image) error
Draw draws the Sprite on the screen.
func (s *Sprite) SetHorizontal(h Alignment)
SetHorizontal sets the horizontal alignment of the Sprite.
func (s *Sprite) SetImage(img *ebiten.Image)
SetImage sets the image of the Sprite.
func (s *Sprite) SetVertical(v Alignment)
SetVertical sets the vertical alignment of the Sprite.
Text is a text display widget.
type Text struct { *Box // contains filtered or unexported fields }
func NewText(text string) *Text
NewText returns a new Text widget.
func (t *Text) AddChild(w ...Widget)
AddChild adds a child to the widget.
func (t *Text) Children() []Widget
Children returns the children of the widget.
func (t *Text) Cursor() ebiten.CursorShapeType
Cursor returns the cursor shape shown when a mouse cursor hovers over the widget, or -1 to let widgets beneath determine the cursor shape.
func (t *Text) Draw(screen *ebiten.Image) error
Draw draws the widget on the screen.
func (t *Text) Focus() bool
Focus returns the focus state of the widget.
func (t *Text) FontSize() int
FontSize returns the font size of the field.
func (t *Text) Foreground() color.RGBA
Foreground return the color of the text within the field.
func (t *Text) HandleKeyboard(key ebiten.Key, r rune) (handled bool, err error)
HandleKeyboard is called when a keyboard event occurs.
func (t *Text) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (t *Text) Padding() int
Padding returns the amount of padding around the text within the field.
func (t *Text) SetAutoHideScrollBar(autoHide bool)
SetAutoHideScrollBar sets whether the scroll bar is automatically hidden when the entire text buffer is visible.
func (t *Text) SetAutoResize(resize bool)
SetAutoResize sets whether the font is automatically scaled down when it is too large to fit the entire text buffer on one line.
func (t *Text) SetFocus(focus bool) bool
SetFocus sets the focus state of the widget.
func (t *Text) SetFollow(follow bool)
SetFollow sets whether the field should automatically scroll to the end when content is added to the buffer.
func (t *Text) SetFont(fnt *text.GoTextFaceSource, size int)
SetFont sets the font and text size of the field. Scaling is not applied.
func (t *Text) SetForeground(c color.RGBA)
SetForeground sets the color of the text within the field.
func (t *Text) SetHorizontal(h Alignment)
SetHorizontal sets the horizontal alignment of the text within the field.
func (t *Text) SetLast(text string)
SetLast sets the text of the last line of the field.
func (t *Text) SetMask(r rune)
SetMask sets the rune used to mask the text buffer contents. Set to 0 to disable.
func (t *Text) SetPadding(padding int)
SetPadding sets the amount of padding around the text within the field.
func (t *Text) SetRect(r image.Rectangle)
SetRect sets the position and size of the widget.
func (t *Text) SetScrollBarColors(area color.RGBA, handle color.RGBA)
SetScrollBarColors sets the color of the scroll bar area and handle.
func (t *Text) SetScrollBarVisible(scrollVisible bool)
SetScrollBarVisible sets whether the scroll bar is visible on the screen.
func (t *Text) SetScrollBarWidth(width int)
SetScrollBarWidth sets the width of the scroll bar.
func (t *Text) SetScrollBorderColors(top color.RGBA, right color.RGBA, bottom color.RGBA, left color.RGBA)
SetScrollBorderColor sets the color of the top, right, bottom and left border of the scroll bar handle.
func (t *Text) SetSingleLine(single bool)
SetSingleLine sets whether the field displays all text on a single line. When enabled, the field scrolls horizontally. Otherwise, it scrolls vertically.
func (t *Text) SetText(text string)
SetText sets the text in the field.
func (t *Text) SetVertical(v Alignment)
SetVertical sets the vertical alignment of the text within the field.
func (t *Text) SetWordWrap(wrap bool)
SetWordWrap sets a flag which, when enabled, causes text to wrap without breaking words.
func (t *Text) Text() string
Text returns the content of the text buffer.
func (t *Text) Write(p []byte) (n int, err error)
Write writes to the text buffer.
Widget represents an interface element. Most widgets will embed Box and build on top of it.
type Widget interface { // Rect returns the position and size of the widget. Rect() image.Rectangle // SetRect sets the position and size of the widget. SetRect(r image.Rectangle) // Background returns the background color of the widget. Background() color.RGBA // SetBackground sets the background color of the widget. SetBackground(background color.RGBA) // Focus returns the focus state of the widget. Focus() bool // SetFocus sets the focus state of the widget. SetFocus(focus bool) (accept bool) // Visible returns the visibility of the widget. Visible() bool // SetVisible sets the visibility of the widget. SetVisible(visible bool) // Cursor returns the cursor shape shown when a mouse cursor hovers over // the widget, or -1 to let widgets beneath determine the cursor shape. Cursor() ebiten.CursorShapeType // HandleKeyboard is called when a keyboard event occurs. HandleKeyboard(ebiten.Key, rune) (handled bool, err error) // HandleMouse is called when a mouse event occurs. Only mouse events that // are on top of the widget are passed to the widget, except after clicking // within the widget and then dragging the cursor outside of the widget. HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error) // Clip returns whether the widget and its children are restricted to drawing // within the widget's rect area of the screen. For best performance, Clip // should return false unless clipping is actually needed. Clip() bool // Draw draws the widget on the screen. Draw(screen *ebiten.Image) error // Children returns the children of the widget. Children are drawn in the // order they are returned. Keyboard and mouse events are passed to children // in reverse order. Children() []Widget }
func At(p image.Point) Widget
At returns the widget at the provided screen location.
func Focused() Widget
Focused returns the currently focused widget. If no widget is focused, nil is returned.
Window displays a single child widget at a time, and includes a list to view other child widgets. Window.Show must be called after adding a widget.
type Window struct { *Box // contains filtered or unexported fields }
func NewWindow() *Window
NewWindow returns a new Window widget.
func (w *Window) AddChild(wgt ...Widget)
AddChild adds a child to the window.
func (w *Window) AddChildWithLabel(wgt Widget, defaultFocus Widget, label string) int
AddChildWithLabel adds a child to the window with the specified default focus and list entry label.
func (w *Window) Children() []Widget
Children returns the children of the widget.
func (w *Window) Clear()
Clear removes all children from the widget.
func (w *Window) Clip() bool
Clip returns whether the widget and its children are restricted to drawing within the widget's rect area of the screen. For best performance, Clip should return false unless clipping is actually needed.
func (w *Window) Draw(screen *ebiten.Image) error
Draw draws the widget on the screen.
func (w *Window) HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
HandleKeyboard is called when a keyboard event occurs.
func (w *Window) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (w *Window) Hide()
Hide hides the currently visible child widget.
func (w *Window) SetFont(fnt *text.GoTextFaceSource, size int)
SetFont sets the font and text size of the window titles. Scaling is not applied.
func (w *Window) SetFrameSize(size int)
SetFrameSize sets the size of the frame around each window.
func (w *Window) SetListHorizontal(h Alignment)
SetListHorizontal sets the horizontal alignment of the window tab list.
func (w *Window) SetListSize(size int)
SetListSize sets the width or height of the window tab list.
func (w *Window) SetListVertical(v Alignment)
SetListVertical sets the vertical alignment of the window tab list.
func (w *Window) SetRect(r image.Rectangle)
SetRect sets the position and size of the widget.
func (w *Window) Show(index int)
Show displays the specified child widget within the Window.
WithoutFocus wraps a widget to ignore focus.
type WithoutFocus struct { Widget }
func (w *WithoutFocus) Focus() bool
Focus returns the focus state of the widget.
func (w *WithoutFocus) SetFocus(focus bool) (accept bool)
SetFocus sets the focus state of the widget.
WithoutMouse wraps a widget to ignore all mouse events.
type WithoutMouse struct { Widget }
func (w *WithoutMouse) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs. Only mouse events that are on top of the widget are passed to the widget.
WithoutMouseExceptScroll wraps a widget to ignore all mouse events except scroll events.
type WithoutMouseExceptScroll struct { Widget // contains filtered or unexported fields }
func (w *WithoutMouseExceptScroll) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs. Only mouse events that are on top of the widget are passed to the widget.