bento

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: MIT Imports: 20 Imported by: 0

README

bento

An XML based UI builder for Ebiten

<col width="100%" height="100%" justify="center">
  <img path="profile.png"/>
  <Header>Lorem Ipsum</Header>
  <Text>
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
  </Text>
  <Button>Clicks: {{.Clicks}}</Button>
</col>

Screenshot at 2022-02-26 18-12-37

Screenshot at 2022-02-26 18-13-32

Documentation

Overview

Bento is an XML based UI builder for Ebiten

Index

Constants

View Source
const (
	Start = Justification(iota)
	End
	Center
	Evenly
	Stretch
)
View Source
const (
	Idle     = ButtonState(0)
	Hover    = ButtonState(1)
	Active   = ButtonState(2)
	Disabled = ButtonState(3)
)

Variables

View Source
var (
	Scrollspeed = 0.1
)

Functions

This section is empty.

Types

type Box

type Box interface {
	Update(keys []ebiten.Key) ([]ebiten.Key, error)
	Draw(img *ebiten.Image)
	Bounds() image.Rectangle
}

func Build

func Build(c Component) (Box, error)

type Button

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

func NewButton

func NewButton(img *ebiten.Image, widths, heights [3]int, onClick func()) *Button

func (*Button) Bounds

func (b *Button) Bounds() image.Rectangle

func (*Button) Draw

func (b *Button) Draw(screen *ebiten.Image)

func (*Button) Update

func (b *Button) Update(keys []ebiten.Key) ([]ebiten.Key, error)

type ButtonState

type ButtonState int

type Component

type Component interface {
	UI() string
	OnKeyDown(key ebiten.Key) bool
}

type Justification

type Justification int

func ParseJustification

func ParseJustification(s string) Justification

type NineSlice

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

A NineSlice is an image that can be drawn with any width and height. It is basically a 3x3 grid of image tiles: The corner tiles are drawn as-is, while the center columns and rows of tiles will be stretched to fit the desired width and height.

func NewNineSlice

func NewNineSlice(img *ebiten.Image, widths, heights [3]int, offsetX, offsetY int) *NineSlice

func (*NineSlice) Draw

func (n *NineSlice) Draw(screen *ebiten.Image, x, y, width, height int)

type Scrollbar

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

func NewScrollbar

func NewScrollbar(img *ebiten.Image, widths, heights [3]int) *Scrollbar

func (*Scrollbar) Bounds

func (s *Scrollbar) Bounds() image.Rectangle

func (*Scrollbar) Draw

func (s *Scrollbar) Draw(screen *ebiten.Image)

func (*Scrollbar) Position

func (s *Scrollbar) Position() float64

func (*Scrollbar) Update

func (s *Scrollbar) Update(keys []ebiten.Key) ([]ebiten.Key, error)

type Spacing

type Spacing struct {
	Top, Right, Bottom, Left int `xml:",attr,omitempty"`
}

type Style

type Style struct {
	Extends             string
	Attrs               map[string]string
	FontName            string
	FontSize            int
	Font                font.Face
	Border              *NineSlice
	Button              *Button
	Scrollbar           *Scrollbar
	Background          *ebiten.Image
	MinWidth, MinHeight int
	MaxWidth, MaxHeight int
	Margin, Padding     *Spacing
	Color               *color.RGBA
	Hidden              bool
	Display             bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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