Documentation ¶
Overview ¶
Package ebui provides an immediate mode GUI built on top of Ebitengine.
Index ¶
- func CursorPosition() image.Point
- func InitGame(g ebiten.Game) ebiten.Game
- func Overlay(w Widget, viewport image.Rectangle)
- type Alignment
- type Applier
- type Apply
- type Axis
- type Clickable
- type ClickableList
- type Cursor
- type Debug
- type Flex
- type FlexChild
- type Image
- type Inset
- type Label
- type LineEditor
- func (ed *LineEditor) DeFocus()
- func (ed *LineEditor) Draw(screen *ebiten.Image, viewport image.Rectangle)
- func (ed *LineEditor) Focus()
- func (ed *LineEditor) IsEscaped() bool
- func (ed *LineEditor) IsFocused() bool
- func (ed *LineEditor) IsSubmitted() bool
- func (ed *LineEditor) Len() int
- func (ed *LineEditor) SetCursorPos(i int)
- func (ed *LineEditor) SetValue(v string)
- func (ed *LineEditor) Size(viewsize image.Point) image.Point
- func (ed *LineEditor) Submit()
- func (ed *LineEditor) Value() string
- type List
- type MouseState
- type Outset
- type Pad
- type Path
- type Place
- type Position
- type RRectangle
- type Slice
- type Slider
- type Spacing
- type Stack
- type StackChild
- type Tile
- type Tree
- type TreeIf
- type TreeNodeIterator
- type View
- type Widget
- type WidgetList
- type Wrap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CursorPosition ¶
Types ¶
type Apply ¶
type Apply struct { Widget Applier WidgetList }
Apply the Widget to all elements in the WidgetList.
type Axis ¶
type Axis uint8
Axis is represents either the horizontal or vertical axis.
type Clickable ¶
type Clickable struct { Button ebiten.MouseButton // State tracks the Pressed, Hovering, Clicked and DoubleClicked states. State MouseState }
Clickable keeps track of the mouse gestures in the widget's area.
type ClickableList ¶
type ClickableList struct { Button ebiten.MouseButton WidgetList // contains filtered or unexported fields }
ClickableList wraps a WidgetList and adds a Clickable to all of its elements.
func (*ClickableList) At ¶
func (c *ClickableList) At(index int) Widget
func (*ClickableList) StateAt ¶
func (c *ClickableList) StateAt(index int) *MouseState
StateAt returns the MouseState at the given index, nil if the index is invalid.
type Cursor ¶
type Cursor struct { // Blink is in milliseconds. Blink time.Duration Color color.Color Dims image.Point }
Cursor defines the attributes of an editor's cursor.
type Debug ¶
Debug a widget by wrapping its content in a colored rectangle. The default color is red.
type Flex ¶
type Flex struct { Axis Axis // Alignment on the cross axis. Alignment Alignment // Spacing along the main axis. Spacing Spacing // Children is one of: // - WidgetList // - []any, where any can be is one of: // - Widget // - FlexChild // - nil Children any }
Flex draws widgets along the given axis.
type FlexChild ¶
FlexChild defines how a flex child is drawn. A zero weight means that the widget is drawn with the remaining space, else its container space is relative to its weight and the sum of all weights.
type LineEditor ¶
type LineEditor struct { Font font.Face Color color.Color Click Clickable Cursor Cursor // contains filtered or unexported fields }
LineEditor for single line text.
func (*LineEditor) Draw ¶
func (ed *LineEditor) Draw(screen *ebiten.Image, viewport image.Rectangle)
func (*LineEditor) IsEscaped ¶
func (ed *LineEditor) IsEscaped() bool
IsEscaped returns whether the content was escaped (hit ESC).
func (*LineEditor) IsFocused ¶
func (ed *LineEditor) IsFocused() bool
IsFocused returns whether the editor is in focus.
func (*LineEditor) IsSubmitted ¶
func (ed *LineEditor) IsSubmitted() bool
IsSubmitted returns whether the content was submitted (hit Enter).
func (*LineEditor) Len ¶
func (ed *LineEditor) Len() int
Len returns the number of runes currently stored in the editor.
func (*LineEditor) SetCursorPos ¶
func (ed *LineEditor) SetCursorPos(i int)
SetCursorPos sets the cursor at the given position. An invalid position has no effect.
func (*LineEditor) SetValue ¶
func (ed *LineEditor) SetValue(v string)
SetValue sets the content of the editor.
func (*LineEditor) Value ¶
func (ed *LineEditor) Value() string
Value returns the current content of the editor.
type List ¶
type List struct { Axis Axis Widgets WidgetList First int FirstOffset int Last int }
List fills its viewport with widgets and allows scrolling them.
type MouseState ¶
type MouseState uint8
MouseState stores the current state(s) of the mouse. Use its Has method to check state presence.
const ( Normal MouseState = iota Hovering Pressed Clicked DoubleClicked Dragging Dropped Disabled )
func (*MouseState) Has ¶
func (ms *MouseState) Has(state MouseState) bool
Has returns whether the state is present.
func (MouseState) String ¶
func (ms MouseState) String() string
type Pad ¶
Pad does not draw anything but takes up space. Negative or zero values make Pad use the viewport's.
type Path ¶
type Path struct { Path vector.Path Color color.Color Stroke *vector.StrokeOptions // contains filtered or unexported fields }
Path caches a vector.Path.
type RRectangle ¶
type RRectangle struct { Radius int // Width for the rectangle, if negative, the rectangle is filled. Width int Color color.Color Dims image.Point }
RRectangle is a rectangle with rounded corners.
func (RRectangle) Draw ¶
func (rr RRectangle) Draw(screen *ebiten.Image, viewport image.Rectangle)
type Slider ¶
type Slider struct { Axis Axis Drag Clickable Value float32 // contains filtered or unexported fields }
Slider updates its Value field when its area is dragged. The value is between 0.0 and 1.0 and, while dragging, corresponds to the mouse pointer current position within the widget's area along the main axis.
type Spacing ¶
type Spacing uint8
Spacing between widgets in a Flex.
const ( // Ending adds space at the end. Ending Spacing = iota // Beginning adds space at the start. Beginning // Sides splits space at the start and end. Sides // Around splits space between elements, and half of that for start and end. Around // Between splits space between elements. Between // Evenly splits space evenly between elements, start and end. Evenly )
type StackChild ¶
type StackChild struct { // Expand sets the viewport/viewsize from the stack size // for the given axis/axes. Expand Axis Widget Widget }
Stack widgets on top of each other (last one on top).
type Tile ¶
type Tile struct { Position Position Source *ebiten.Image }
Tile an image in its viewport.
type Tree ¶
type Tree[T comparable] struct { Button ebiten.MouseButton Tree TreeIf[T] // List's Widgets field will be automatically set. List List // contains filtered or unexported fields }
Tree fills its viewport with the content of a tree-like data structure. The tree is interactive where parent nodes can expand when clicked to display their children.
func (*Tree[T]) Click ¶
func (t *Tree[T]) Click(v T)
Click on element v, which opens or closes it if it is a parent node.
type TreeIf ¶
type TreeIf[T comparable] interface { // Root elements of the tree. Root() TreeNodeIterator[T] // Children for a given node. Children(node T) TreeNodeIterator[T] // At returns the widget to be displayed for an element. // click is nil if the node is a leaf. // The returned widget should also display the click widget. At(node T, click *Clickable, depth uint16) (content Widget) }
TreeIf is the interface to represent a tree-like data structure. T is the type used to uniquely identify any element in the tree.
type TreeNodeIterator ¶
type TreeNodeIterator[T comparable] interface { Len() int At(int) T }
TreeNodeIterator provides the elements for a root or parent node.
type View ¶
View restricts the view of a widget. If a dimension is <= 0 then the widget's value is used.
type WidgetList ¶
type Wrap ¶
type Wrap struct { Axis Axis Alignment Alignment Widgets WidgetList }
Wrap widgets along an axis. They must all have the same size.