Documentation ¶
Overview ¶
Package etk provides an Ebitengine tool kit for creating graphical user interfaces.
Widgets ¶
Custom widgets may be created entirely from scratch or may be based on official widgets.
The following official widgets are available:
Box - Building block for creating other widgets. Button - Clickable button. Flex - Flexible stack-based layout. Each Flex widget may be oriented horizontally or vertically. Frame - Widget container. All child widgets are displayed at once. Child widgets are not repositioned by default. Grid - Highly customizable cell-based layout. Widgets added to the Grid may span multiple cells. Input - Text input widget. The Input widget is simply a Text widget that also accepts user input. Keyboard - On-screen keyboard. List - List of widgets as selectable items. Select - Dropdown selection widget. Sprite - Resizable image. Text - Text display widget. Window - Widget paging mechanism. Only one widget added to a window is displayed at a time.
Input Propagation ¶
Mouse events are passed to the topmost widget under the mouse. If a widget returns a handled value of false, the event continues to propagate down the stack of widgets under the mouse.
Clicking or tapping on a widget focuses the widget. This is handled by etk automatically when a widget returns a handled value of true.
Keyboard events are passed to the focused widget.
Focus Propagation ¶
When attempting to change which widget is focused, etk checks whether the widget to be focused accepts this focus. If it does, the previously focused widget is un-focused. If the widget does not accept the focus, the previously focused widget remains focused.
Cursor Unification ¶
Input events generated by desktop mice and touch screens are unified in etk. These input events are simplified into an image.Point specifying the location of the event and two parameters: clicked and pressed.
Clicked is true the first frame the mouse event or touch screen event is received. When the mouse click or touch screen tap is released, the widget that was originally clicked or tapped always receives a final event where clicked and pressed are both false.
Draw Order ¶
Each time etk draws a widget it subsequently draws all of the widget's children in the order they are returned.
Subpackages ¶
There are two subpackages in etk: messeji and kibodo. These are available for use without requiring etk. Usually you will not need to reference any subpackages, as etk wraps them to provide widgets with additional features.
Index ¶
- Variables
- func BoundString(f *text.GoTextFace, s string) image.Rectangle
- func Draw(screen *ebiten.Image) error
- func FontFace(source *text.GoTextFaceSource, size int) *text.GoTextFace
- func Layout(outsideWidth int, outsideHeight int)
- func Scale(v int) int
- func ScaleFactor() float64
- func ScreenSize() (width int, height int)
- func SetDebug(debug bool)
- func SetFocus(w Widget)
- func SetRoot(w Widget)
- func Update() error
- type Alignment
- type Attributes
- type Box
- func (b *Box) AddChild(w ...Widget)
- func (b *Box) Background() color.RGBA
- func (b *Box) Children() []Widget
- func (b *Box) Clear()
- func (b *Box) Cursor() ebiten.CursorShapeType
- func (b *Box) Draw(screen *ebiten.Image) error
- func (b *Box) Focus() bool
- func (b *Box) HandleKeyboard(key ebiten.Key, r rune) (handled bool, err error)
- func (b *Box) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
- func (b *Box) Rect() image.Rectangle
- func (b *Box) SetBackground(background color.RGBA)
- func (b *Box) SetFocus(focus bool) bool
- func (b *Box) SetRect(r image.Rectangle)
- func (b *Box) SetVisible(visible bool)
- func (b *Box) Visible() bool
- type Button
- func (b *Button) Cursor() ebiten.CursorShapeType
- func (b *Button) Draw(screen *ebiten.Image) error
- func (b *Button) HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
- func (b *Button) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
- func (b *Button) SetBackground(background color.RGBA)
- func (b *Button) SetBorderColors(top color.RGBA, right color.RGBA, bottom color.RGBA, left color.RGBA)
- func (b *Button) SetBorderSize(size int)
- func (b *Button) SetFont(fnt *text.GoTextFaceSource, size int)
- func (b *Button) SetForeground(c color.RGBA)
- func (b *Button) SetHorizontal(h Alignment)
- func (b *Button) SetRect(r image.Rectangle)
- func (b *Button) SetText(text string)
- func (b *Button) SetVertical(v Alignment)
- func (b *Button) Text() string
- type Checkbox
- func (c *Checkbox) Cursor() ebiten.CursorShapeType
- func (c *Checkbox) Draw(screen *ebiten.Image) error
- func (c *Checkbox) HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
- func (c *Checkbox) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
- func (c *Checkbox) Selected() bool
- func (c *Checkbox) SetBorderColor(borderColor color.RGBA)
- func (c *Checkbox) SetCheckColor(checkColor color.RGBA)
- func (c *Checkbox) SetRect(r image.Rectangle)
- func (c *Checkbox) SetSelected(selected bool)
- type Flex
- func (f *Flex) AddChild(w ...Widget)
- func (f *Flex) Draw(screen *ebiten.Image) error
- func (f *Flex) HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
- func (f *Flex) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
- func (f *Flex) SetChildSize(width int, height int)
- func (f *Flex) SetGaps(columnGap int, rowGap int)
- func (f *Flex) SetRect(r image.Rectangle)
- func (f *Flex) SetVertical(v bool)
- type Frame
- type Grid
- func (g *Grid) AddChild(wgt ...Widget)
- func (g *Grid) AddChildAt(wgt Widget, x int, y int, columns int, rows int)
- func (g *Grid) Clear()
- func (g *Grid) Draw(screen *ebiten.Image) error
- func (g *Grid) HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
- func (g *Grid) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
- func (g *Grid) SetColumnPadding(padding int)
- func (g *Grid) SetColumnSizes(size ...int)
- func (g *Grid) SetRect(r image.Rectangle)
- func (g *Grid) SetRowPadding(padding int)
- func (g *Grid) SetRowSizes(size ...int)
- type Input
- func (i *Input) Cursor() ebiten.CursorShapeType
- func (i *Input) Draw(screen *ebiten.Image) error
- func (i *Input) Focus() bool
- func (i *Input) Foreground() color.RGBA
- func (i *Input) HandleKeyboard(key ebiten.Key, r rune) (handled bool, err error)
- func (i *Input) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
- func (i *Input) Padding() int
- func (i *Input) SetAutoHideScrollBar(autoHide bool)
- func (i *Input) SetBorderColors(focused color.RGBA, unfocused color.RGBA)
- func (i *Input) SetBorderSize(size int)
- func (i *Input) SetCursor(cursor string)
- func (i *Input) SetFocus(focus bool) bool
- func (t *Input) SetFont(fnt *text.GoTextFaceSource, size int)
- func (i *Input) SetForeground(c color.RGBA)
- func (i *Input) SetHorizontal(h Alignment)
- func (i *Input) SetMask(r rune)
- func (i *Input) SetPadding(padding int)
- func (i *Input) SetPrefix(prefix string)
- func (i *Input) SetRect(r image.Rectangle)
- func (i *Input) SetScrollBarColors(area color.RGBA, handle color.RGBA)
- func (i *Input) SetScrollBarVisible(scrollVisible bool)
- func (i *Input) SetScrollBarWidth(width int)
- func (i *Input) SetSuffix(suffix string)
- func (i *Input) SetText(text string)
- func (i *Input) SetVertical(v Alignment)
- func (i *Input) SetWordWrap(wrap bool)
- func (i *Input) Text() string
- func (i *Input) Write(p []byte) (n int, err error)
- type Keyboard
- func (k *Keyboard) Cursor() ebiten.CursorShapeType
- func (k *Keyboard) Draw(screen *ebiten.Image) error
- func (k *Keyboard) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
- func (k *Keyboard) Keys() [][]*kibodo.Key
- func (k *Keyboard) SetExtendedKeys(keys [][]*kibodo.Key)
- func (k *Keyboard) SetKeys(keys [][]*kibodo.Key)
- func (k *Keyboard) SetRect(r image.Rectangle)
- func (k *Keyboard) SetScheduleFrameFunc(f func())
- func (k *Keyboard) SetShowExtended(show bool)
- func (k *Keyboard) SetVisible(visible bool)
- func (k *Keyboard) Visible() bool
- type List
- func (l *List) AddChildAt(w Widget, x int, y int)
- func (l *List) Background() color.RGBA
- func (l *List) Children() []Widget
- func (l *List) Clear()
- func (l *List) Cursor() ebiten.CursorShapeType
- func (l *List) Draw(screen *ebiten.Image) error
- func (l *List) Focus() bool
- func (l *List) HandleKeyboard(key ebiten.Key, r rune) (handled bool, err error)
- func (l *List) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
- func (l *List) Rect() image.Rectangle
- func (l *List) Rows() int
- func (l *List) SelectedItem() (x int, y int)
- func (l *List) SetBackground(background color.RGBA)
- func (l *List) SetColumnSizes(size ...int)
- func (l *List) SetConfirmedFunc(f func(index int))
- func (l *List) SetDrawBorder(drawBorder bool)
- func (l *List) SetFocus(focus bool) (accept bool)
- func (l *List) SetHighlightColor(c color.RGBA)
- func (l *List) SetItemHeight(itemHeight int)
- func (l *List) SetRect(r image.Rectangle)
- func (l *List) SetScrollBarColors(area color.RGBA, handle color.RGBA)
- func (l *List) SetScrollBarWidth(width int)
- func (l *List) SetScrollBorderColors(top color.RGBA, right color.RGBA, bottom color.RGBA, left color.RGBA)
- func (l *List) SetScrollBorderSize(size int)
- func (l *List) SetSelectedFunc(f func(index int) (accept bool))
- func (l *List) SetSelectedItem(x int, y int)
- func (l *List) SetSelectionMode(selectionMode SelectionMode)
- func (l *List) SetVisible(visible bool)
- func (l *List) Visible() bool
- type Select
- func (s *Select) AddChild(w ...Widget)
- func (s *Select) AddOption(label string)
- func (s *Select) Children() []Widget
- func (s *Select) Clear()
- func (s *Select) Cursor() ebiten.CursorShapeType
- func (s *Select) Draw(screen *ebiten.Image) error
- func (s *Select) HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
- func (s *Select) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
- func (s *Select) SetHighlightColor(c color.RGBA)
- func (s *Select) SetMenuVisible(visible bool)
- func (s *Select) SetRect(r image.Rectangle)
- func (s *Select) SetSelectedItem(index int)
- type SelectionMode
- type Shortcuts
- type Sprite
- type Text
- func (t *Text) AddChild(w ...Widget)
- func (t *Text) Children() []Widget
- func (t *Text) Cursor() ebiten.CursorShapeType
- func (t *Text) Draw(screen *ebiten.Image) error
- func (t *Text) Focus() bool
- func (t *Text) FontSize() int
- func (t *Text) Foreground() color.RGBA
- func (t *Text) HandleKeyboard(key ebiten.Key, r rune) (handled bool, err error)
- func (t *Text) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
- func (t *Text) Padding() int
- func (t *Text) SetAutoHideScrollBar(autoHide bool)
- func (t *Text) SetAutoResize(resize bool)
- func (t *Text) SetFocus(focus bool) bool
- func (t *Text) SetFollow(follow bool)
- func (t *Text) SetFont(fnt *text.GoTextFaceSource, size int)
- func (t *Text) SetForeground(c color.RGBA)
- func (t *Text) SetHorizontal(h Alignment)
- func (t *Text) SetLast(text string)
- func (t *Text) SetMask(r rune)
- func (t *Text) SetPadding(padding int)
- func (t *Text) SetRect(r image.Rectangle)
- func (t *Text) SetScrollBarColors(area color.RGBA, handle color.RGBA)
- func (t *Text) SetScrollBarVisible(scrollVisible bool)
- func (t *Text) SetScrollBarWidth(width int)
- func (t *Text) SetScrollBorderColors(top color.RGBA, right color.RGBA, bottom color.RGBA, left color.RGBA)
- func (t *Text) SetSingleLine(single bool)
- func (t *Text) SetText(text string)
- func (t *Text) SetVertical(v Alignment)
- func (t *Text) SetWordWrap(wrap bool)
- func (t *Text) Text() string
- func (t *Text) Write(p []byte) (n int, err error)
- type Widget
- type Window
- func (w *Window) AddChild(wgt ...Widget)
- func (w *Window) AddChildWithLabel(wgt Widget, defaultFocus Widget, label string) int
- func (w *Window) Children() []Widget
- func (w *Window) Clear()
- func (w *Window) Draw(screen *ebiten.Image) error
- func (w *Window) HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
- func (w *Window) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
- func (w *Window) Hide()
- func (w *Window) SetFont(fnt *text.GoTextFaceSource, size int)
- func (w *Window) SetFrameSize(size int)
- func (w *Window) SetListHorizontal(h Alignment)
- func (w *Window) SetListSize(size int)
- func (w *Window) SetListVertical(v Alignment)
- func (w *Window) SetRect(r image.Rectangle)
- func (w *Window) Show(index int)
- type WithoutFocus
- type WithoutMouse
- type WithoutMouseExceptScroll
Constants ¶
This section is empty.
Variables ¶
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}, }
Bindings is the current keyboard, mouse and gamepad input configurations.
var ResizeDebounce = 250 * time.Millisecond
ResizeDebounce is the minimum duration between screen layout changes. This setting can greatly improve performance when resizing the window.
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}, }
Style is the current default attribute configuration. Integer values will be scaled.
Functions ¶
func BoundString ¶
BoundString returns the bounds of the provided string.
func Draw ¶
func Draw(screen *ebiten.Image) error
Draw draws the root widget and its children to the screen.
func FontFace ¶
func FontFace(source *text.GoTextFaceSource, size int) *text.GoTextFace
FontFace returns a face for the provided font and size. Scaling is not applied.
func Scale ¶
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 ¶
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 ¶
ScreenSize returns the current screen size.
func SetDebug ¶
func SetDebug(debug bool)
SetDebug sets whether debug information is drawn on screen. When enabled, all visible widgets are outlined.
Types ¶
type Attributes ¶
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 }
Attributes represents a default attribute configuration. Integer values will be scaled.
type Box ¶
Box is a building block for other widgets. It may also be used as a spacer in layout widgets.
func (*Box) Background ¶
Background returns the background color of the widget.
func (*Box) Children ¶
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 (*Box) Cursor ¶
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 (*Box) HandleKeyboard ¶
HandleKeyboard is called when a keyboard event occurs.
func (*Box) HandleMouse ¶
HandleMouse is called when a mouse event occurs. Only mouse events that are on top of the widget are passed to the widget.
func (*Box) SetBackground ¶
SetBackground sets the background color of the widget.
func (*Box) SetVisible ¶
SetVisible sets the visibility of the widget.
type Button ¶
type Button struct { *Box // contains filtered or unexported fields }
Button is a clickable button.
func (*Button) Cursor ¶
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 (*Button) HandleKeyboard ¶
HandleKeyboard is called when a keyboard event occurs.
func (*Button) HandleMouse ¶
func (b *Button) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (*Button) SetBackground ¶
SetBackground sets the background color of the button label.
func (*Button) SetBorderColors ¶
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 (*Button) SetBorderSize ¶
SetBorderSize sets the size of the border around the button.
func (*Button) SetFont ¶
SetFont sets the font and text size of button label. Scaling is not applied.
func (*Button) SetForeground ¶
SetForeground sets the color of the button label.
func (*Button) SetHorizontal ¶
SetHorizontal sets the horizontal alignment of the button label.
func (*Button) SetVertical ¶
SetVertical sets the vertical alignment of the button label.
type Checkbox ¶
type Checkbox struct { *Box // contains filtered or unexported fields }
Checkbox is a toggleable Checkbox.
func NewCheckbox ¶
NewCheckbox returns a new Checkbox widget.
func (*Checkbox) Cursor ¶
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 (*Checkbox) HandleKeyboard ¶
HandleKeyboard is called when a keyboard event occurs.
func (*Checkbox) HandleMouse ¶
func (c *Checkbox) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (*Checkbox) SetBorderColor ¶
SetBorderColor sets the border color of the Checkbox.
func (*Checkbox) SetCheckColor ¶
SetCheckColor sets the check mark color of the Checkbox.
func (*Checkbox) SetRect ¶
SetRect sets the position and size of the Checkbox. The checkbox is always a square shape.
func (*Checkbox) SetSelected ¶
SetSelected sets the Checkbox selection state. The onSelect function is not called when the value is set manually via SetSelected.
type Flex ¶
type Flex struct { *Box // contains filtered or unexported fields }
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.
func (*Flex) HandleKeyboard ¶
HandleKeyboard is called when a keyboard event occurs.
func (*Flex) HandleMouse ¶
func (f *Flex) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (*Flex) SetChildSize ¶
SetChildSize sets the minimum size of each child in the Flex.
func (*Flex) SetVertical ¶
SetVertical sets the orientation of the child widget stacking.
type Frame ¶
type Frame struct { *Box // contains filtered or unexported fields }
Frame is a widget container. All children are displayed at once. Children are not repositioned by default. Repositioning may be enabled via SetPositionChildren.
func (*Frame) SetMaxHeight ¶
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 (*Frame) SetMaxWidth ¶
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 (*Frame) SetPadding ¶
SetPadding sets the amount of padding around widgets in the frame.
func (*Frame) SetPositionChildren ¶
SetPositionChildren sets a flag that determines whether child widgets are repositioned when the Frame is repositioned.
type Grid ¶
type Grid struct { *Box // contains filtered or unexported fields }
Grid is a highly customizable cell-based layout. Widgets added to the Grid may span multiple cells.
func (*Grid) AddChild ¶
AddChild adds a widget to the Grid at 0,0. To add widgets to a Grid, you should use AddChildAt instead.
func (*Grid) AddChildAt ¶
AddChildAt adds a widget to the Grid at the specified position. Each widget added to the grid may span multiple cells.
func (*Grid) HandleKeyboard ¶
HandleKeyboard is called when a keyboard event occurs.
func (*Grid) HandleMouse ¶
func (g *Grid) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (*Grid) SetColumnPadding ¶
SetColumnPadding sets the amount of padding between each column.
func (*Grid) SetColumnSizes ¶
SetColumnSizes sets the size of each column. A size of -1 represents an equal proportion of the available space.
func (*Grid) SetRowPadding ¶
SetRowPadding sets the amount of padding between each row.
func (*Grid) SetRowSizes ¶
SetRowSizes sets the size of each row. A size of -1 represents an equal proportion of the available space.
type Input ¶
type Input struct { *Box // contains filtered or unexported fields }
Input is a text input widget. The Input widget is simply a Text widget that also accepts user input.
func (*Input) Cursor ¶
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 (*Input) Foreground ¶
Foreground return the color of the text within the field.
func (*Input) HandleKeyboard ¶
HandleKeyboard is called when a keyboard event occurs.
func (*Input) HandleMouse ¶
func (i *Input) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (*Input) SetAutoHideScrollBar ¶
SetAutoHideScrollBar sets whether the scroll bar is automatically hidden when the entire text buffer is visible.
func (*Input) SetBorderColors ¶
SetBorderColors sets the border colors of the field when focused and unfocused.
func (*Input) SetBorderSize ¶
SetBorderSize sets the size of the border around the field.
func (*Input) SetForeground ¶
SetForegroundColor sets the color of the text within the field.
func (*Input) SetHorizontal ¶
SetHorizontal sets the horizontal alignment of the text within the field.
func (*Input) SetMask ¶
SetMask sets the rune used to mask the text buffer contents. Set to 0 to disable.
func (*Input) SetPadding ¶
SetPadding sets the amount of padding around the text within the field.
func (*Input) SetScrollBarColors ¶
SetScrollBarColors sets the color of the scroll bar area and handle.
func (*Input) SetScrollBarVisible ¶
SetScrollBarVisible sets whether the scroll bar is visible on the screen.
func (*Input) SetScrollBarWidth ¶
SetScrollBarWidth sets the width of the scroll bar.
func (*Input) SetVertical ¶
SetVertical sets the vertical alignment of the text within the field.
func (*Input) SetWordWrap ¶
SetWordWrap sets a flag which, when enabled, causes text to wrap without breaking words.
type Keyboard ¶
type Keyboard struct { *Box // contains filtered or unexported fields }
Keyboard is an on-screen keyboard widget. User input is automatically passed to the focused widget.
func (*Keyboard) Cursor ¶
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 (*Keyboard) HandleMouse ¶
func (k *Keyboard) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (*Keyboard) SetExtendedKeys ¶
SetExtendedKeys sets the keys of the keyboard when the .
func (*Keyboard) SetScheduleFrameFunc ¶
func (k *Keyboard) SetScheduleFrameFunc(f func())
SetScheduleFrameFunc sets the function called whenever the screen should be redrawn.
func (*Keyboard) SetShowExtended ¶
SetShowExtended sets whether the normal or extended keyboard is shown.
func (*Keyboard) SetVisible ¶
SetVisible sets the visibility of the keyboard.
type List ¶
List is a list of widgets.
func (*List) AddChildAt ¶
AddChildAt adds a widget to the list at the specified position.
func (*List) Background ¶
Background returns the background color of the widget.
func (*List) Children ¶
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 (*List) Cursor ¶
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 (*List) HandleKeyboard ¶
HandleKeyboard is called when a keyboard event occurs.
func (*List) HandleMouse ¶
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 (*List) SelectedItem ¶
SelectedItem returns the selected list item.
func (*List) SetBackground ¶
SetBackground sets the background color of the widget.
func (*List) SetColumnSizes ¶
SetColumnSizes sets the size of each column. A size of -1 represents an equal proportion of the available space.
func (*List) SetConfirmedFunc ¶
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 (*List) SetDrawBorder ¶
SetDrawBorder enables or disables borders being drawn around the list.
func (*List) SetHighlightColor ¶
SetHighlightColor sets the color used to highlight the currently selected item.
func (*List) SetItemHeight ¶
SetItemHeight sets the height of the list items.
func (*List) SetScrollBarColors ¶
SetScrollBarColors sets the color of the scroll bar area and handle.
func (*List) SetScrollBarWidth ¶
SetScrollBarWidth sets the width of the scroll bar.
func (*List) SetScrollBorderColors ¶
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 (*List) SetScrollBorderSize ¶
SetScrollBorderSize sets the size of the border around the scroll bar handle.
func (*List) SetSelectedFunc ¶
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 (*List) SetSelectedItem ¶
SetSelectedItem sets the selected list item.
func (*List) SetSelectionMode ¶
func (l *List) SetSelectionMode(selectionMode SelectionMode)
SetSelectionMode sets the selection mode of the list.
func (*List) SetVisible ¶
SetVisible sets the visibility of the widget.
type Select ¶
type Select struct { *Box // contains filtered or unexported fields }
Select is a dropdown selection widget.
func (*Select) AddChild ¶
AddChild adds a child to the widget. Selection options are added via AddOption.
func (*Select) Cursor ¶
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 (*Select) HandleKeyboard ¶
HandleKeyboard is called when a keyboard event occurs.
func (*Select) HandleMouse ¶
func (s *Select) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (*Select) SetHighlightColor ¶
SetHighlightColor sets the color used to highlight the currently selected item.
func (*Select) SetMenuVisible ¶
SetMenuVisible sets the visibility of the dropdown menu.
func (*Select) SetSelectedItem ¶
SetSelectedItem sets the currently selected item.
type SelectionMode ¶
type SelectionMode int
SelectionMode represents a mode of selection.
const ( // SelectNone disables selection. SelectNone SelectionMode = iota // SelectRow enables selection by row. SelectRow // SelectColumn enables selection by column. SelectColumn )
Selection modes.
type Shortcuts ¶
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 }
Shortcuts represents the keyboard, mouse and gamepad input configurations.
type Sprite ¶
type Sprite struct { *Box // contains filtered or unexported fields }
Sprite is a resizable image.
func (*Sprite) SetHorizontal ¶
SetHorizontal sets the horizontal alignment of the Sprite.
func (*Sprite) SetImage ¶
func (s *Sprite) SetImage(img *ebiten.Image)
SetImage sets the image of the Sprite.
func (*Sprite) SetVertical ¶
SetVertical sets the vertical alignment of the Sprite.
type Text ¶
type Text struct { *Box // contains filtered or unexported fields }
Text is a text display widget.
func (*Text) Cursor ¶
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 (*Text) Foreground ¶
Foreground return the color of the text within the field.
func (*Text) HandleKeyboard ¶
HandleKeyboard is called when a keyboard event occurs.
func (*Text) HandleMouse ¶
func (t *Text) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (*Text) SetAutoHideScrollBar ¶
SetAutoHideScrollBar sets whether the scroll bar is automatically hidden when the entire text buffer is visible.
func (*Text) SetAutoResize ¶
SetAutoResize sets whether the font is automatically scaled down when it is too large to fit the entire text buffer on one line.
func (*Text) SetFollow ¶
SetFollow sets whether the field should automatically scroll to the end when content is added to the buffer.
func (*Text) SetForeground ¶
SetForeground sets the color of the text within the field.
func (*Text) SetHorizontal ¶
SetHorizontal sets the horizontal alignment of the text within the field.
func (*Text) SetMask ¶
SetMask sets the rune used to mask the text buffer contents. Set to 0 to disable.
func (*Text) SetPadding ¶
SetPadding sets the amount of padding around the text within the field.
func (*Text) SetScrollBarColors ¶
SetScrollBarColors sets the color of the scroll bar area and handle.
func (*Text) SetScrollBarVisible ¶
SetScrollBarVisible sets whether the scroll bar is visible on the screen.
func (*Text) SetScrollBarWidth ¶
SetScrollBarWidth sets the width of the scroll bar.
func (*Text) SetScrollBorderColors ¶
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 (*Text) SetSingleLine ¶
SetSingleLine sets whether the field displays all text on a single line. When enabled, the field scrolls horizontally. Otherwise, it scrolls vertically.
func (*Text) SetVertical ¶
SetVertical sets the vertical alignment of the text within the field.
func (*Text) SetWordWrap ¶
SetWordWrap sets a flag which, when enabled, causes text to wrap without breaking words.
type Widget ¶
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. HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error) // 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 }
Widget represents an interface element. Most widgets will embed Box and build on top of it.
type Window ¶
type Window struct { *Box // contains filtered or unexported fields }
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.
func (*Window) AddChildWithLabel ¶
AddChildWithLabel adds a child to the window with the specified default focus and list entry label.
func (*Window) HandleKeyboard ¶
HandleKeyboard is called when a keyboard event occurs.
func (*Window) HandleMouse ¶
func (w *Window) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse is called when a mouse event occurs.
func (*Window) SetFont ¶
SetFont sets the font and text size of the window titles. Scaling is not applied.
func (*Window) SetFrameSize ¶
SetFrameSize sets the size of the frame around each window.
func (*Window) SetListHorizontal ¶
SetListHorizontal sets the horizontal alignment of the window tab list.
func (*Window) SetListSize ¶
SetListSize sets the width or height of the window tab list.
func (*Window) SetListVertical ¶
SetListVertical sets the vertical alignment of the window tab list.
type WithoutFocus ¶
type WithoutFocus struct {
Widget
}
WithoutFocus wraps a widget to ignore focus.
func (*WithoutFocus) Focus ¶
func (w *WithoutFocus) Focus() bool
Focus returns the focus state of the widget.
func (*WithoutFocus) SetFocus ¶
func (w *WithoutFocus) SetFocus(focus bool) (accept bool)
SetFocus sets the focus state of the widget.
type WithoutMouse ¶
type WithoutMouse struct {
Widget
}
WithoutMouse wraps a widget to ignore all mouse events.
func (*WithoutMouse) HandleMouse ¶
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.
type WithoutMouseExceptScroll ¶
type WithoutMouseExceptScroll struct { Widget // contains filtered or unexported fields }
WithoutMouseExceptScroll wraps a widget to ignore all mouse events except scroll events.
func (*WithoutMouseExceptScroll) HandleMouse ¶
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.