uiengine

package
v0.0.0-...-c4945e0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERTICAL   = 0x1
	HORIZONTAL = 0x2
)
View Source
const (
	X = 0
	Y = 1
	Z = 2
)
View Source
const (
	FIT  = 0x0001
	FULL = 0x2
)

Simple layout engine for Window

Variables

This section is empty.

Functions

func CreateTexture

func CreateTexture(glctx gl.Context, c image_color.RGBA) (tex gl.Texture, err error)

CreateTexture reads and decodes an image from the asset repository and creates a texture object based on the full dimensions of the image.

func LoadAsset

func LoadAsset(name string) ([]byte, error)

func LoadProgram

func LoadProgram(glctx gl.Context, vertexAsset, fragmentAsset string) (p gl.Program, err error)

LoadProgram reads shader sources from the asset repository, compiles, and links them into a program.

func LoadTexture

func LoadTexture(glctx gl.Context, name string) (tex gl.Texture, err error)

LoadTexture reads and decodes an image from the asset repository and creates a texture object based on the full dimensions of the image.

Types

type BaseWidget

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

func CreateBaseWidget

func CreateBaseWidget(ui *UiEngine, min, max Point, zLevel float32) *BaseWidget

func (*BaseWidget) Build

func (base *BaseWidget) Build(ui *UiEngine)

func (*BaseWidget) CreateDisplayGeom

func (base *BaseWidget) CreateDisplayGeom(ui *UiEngine)

CreateDisplayGeom - Creates the geometry that is used for rendering the widget to screen

func (*BaseWidget) Draw

func (base *BaseWidget) Draw(ui *UiEngine, hint bool)

type Button

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

func CreateButton

func CreateButton(text string) *Button

func (*Button) Build

func (b *Button) Build(ui *UiEngine)

func (*Button) CallHandler

func (b *Button) CallHandler() interface{}

func (*Button) CreateTextTexture

func (b *Button) CreateTextTexture(ui *UiEngine)

func (*Button) Draw

func (b *Button) Draw(ui *UiEngine)

func (*Button) Pressed

func (b *Button) Pressed(ui *UiEngine, touchx, touchy float32) bool

func (*Button) RegisterHandler

func (b *Button) RegisterHandler(handler interface{}, handlerData interface{})

func (*Button) SetText

func (b *Button) SetText(ui *UiEngine, text string)

func (*Button) UpdateTexture

func (b *Button) UpdateTexture(ui *UiEngine, force bool)

type ButtonOld

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

FIXME Remove after refactoring UI Code

type DeviceSpecs

type DeviceSpecs struct {
	ScreenDim   [2]int
	AspectRatio float32
	PixelsPerPt float32
}

type DisplayGeom

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

DisplayGeom - Object containing all the information required to draw

a rectangle to the screen

func CreateDisplayGeom

func CreateDisplayGeom(glctx gl.Context, xmin, ymin, xmax, ymax, zlevel, ar float32) *DisplayGeom

ar = Aspect Ratio

type FPS

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

FPS draws a count of the frames rendered per second.

func NewFPS

func NewFPS() *FPS

NewFPS creates an FPS tied to the current GL context.

func (*FPS) GetFps

func (p *FPS) GetFps() int

Draw draws the per second framerate in the bottom-left of the screen.

type FontEngine

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

func CreateFontEngine

func CreateFontEngine(device *DeviceSpecs) *FontEngine

func (*FontEngine) CenterText

func (fe *FontEngine) CenterText(text string, xmax, ymax int) fixed.Point26_6

func (*FontEngine) PtToPx

func (fe *FontEngine) PtToPx(p int) int

func (*FontEngine) RenderText

func (fe *FontEngine) RenderText(text string, xmax, ymax int) *image.RGBA

func (*FontEngine) RenderTextCustom

func (fe *FontEngine) RenderTextCustom(text string, xmax, ymax int, col image_color.RGBA) *image.RGBA

RenderText - Renders text using the freetype font

func (*FontEngine) SetFontSize

func (fe *FontEngine) SetFontSize(size int)

Sets the font size to be used for rendering text using the FontEngine

func (*FontEngine) SetHinting

func (fe *FontEngine) SetHinting(hinting string)

Sets the options of if font hinting (none|full) is to be used

type Label

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

func CreateLabel

func CreateLabel(text string) *Label

func (*Label) Build

func (l *Label) Build(ui *UiEngine)

func (*Label) CreateTextTexture

func (l *Label) CreateTextTexture(ui *UiEngine)

CreateTextTexture creares a text texture based on label text This method shares a decent bit of code with Button::CreateTextTexture, refactor as utility

func (*Label) Draw

func (l *Label) Draw(ui *UiEngine)

func (*Label) SetText

func (l *Label) SetText(ui *UiEngine, text string)

func (*Label) UpdateTexture

func (l *Label) UpdateTexture(ui *UiEngine, force bool)

type Layout

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

func (*Layout) AddButton

func (l *Layout) AddButton(text string) *Button

func (*Layout) AddLabel

func (l *Layout) AddLabel(text string) *Label

func (*Layout) AddSlider

func (l *Layout) AddSlider(label string, initialValue interface{}) *Slider

func (*Layout) Build

func (l *Layout) Build(ui *UiEngine)

Build - This method sizes all the widgets in the layout accorting to the layoutType

func (*Layout) BuildElement

func (l *Layout) BuildElement(ui *UiEngine, index int, min, max Point)

func (*Layout) Draw

func (l *Layout) Draw(ui *UiEngine)

func (*Layout) Init

func (l *Layout) Init(ui *UiEngine, min, max Point, zLevel float32, layoutType int)

func (*Layout) Pressed

func (l *Layout) Pressed(ui *UiEngine, touchx, touchy float32)

func (*Layout) UpdateTexture

func (l *Layout) UpdateTexture(ui *UiEngine, force bool)

type Point

type Point struct {
	E [3]float32
}

Point - Data structure to store a point

type ShaderVariables

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

type Slider

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

func CreateSlider

func CreateSlider(label string, initialValue interface{}) *Slider

func (*Slider) Build

func (s *Slider) Build(ui *UiEngine)

func (*Slider) Draw

func (s *Slider) Draw(ui *UiEngine)

func (*Slider) Pressed

func (s *Slider) Pressed(ui *UiEngine, touchx, touchy float32) bool

func (*Slider) RegisterHandlerLeft

func (s *Slider) RegisterHandlerLeft(handler interface{}, handlerData interface{})

func (*Slider) RegisterHandlerRight

func (s *Slider) RegisterHandlerRight(handler interface{}, handlerData interface{})

func (*Slider) SetValueText

func (s *Slider) SetValueText(ui *UiEngine, text string)

func (*Slider) UpdateTexture

func (s *Slider) UpdateTexture(ui *UiEngine, force bool)

type UiEngine

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

UiEngine - Struct reponsible for creating and managing all UI Assets on screen

func CreateUiEngine

func CreateUiEngine(glctx gl.Context, device *DeviceSpecs) *UiEngine

func (*UiEngine) AddHorizontalWindow

func (ui *UiEngine) AddHorizontalWindow(min, max Point, c image_color.RGBA) *Window

func (*UiEngine) AddWindow

func (ui *UiEngine) AddWindow(min, max Point, c image_color.RGBA) *Window

func (*UiEngine) AspectRatio

func (ui *UiEngine) AspectRatio() float32

func (*UiEngine) Build

func (ui *UiEngine) Build()

func (*UiEngine) ButtonPressed

func (ui *UiEngine) ButtonPressed(button *ButtonOld, touchx, touchy float32) bool

func (*UiEngine) CheckButtonPresses

func (ui *UiEngine) CheckButtonPresses(touchx, touchy float32) int

func (*UiEngine) CleanUp

func (ui *UiEngine) CleanUp()

func (*UiEngine) ConvertToPx

func (ui *UiEngine) ConvertToPx(delta float32, dim int) int

func (*UiEngine) CreateButtonOld

func (ui *UiEngine) CreateButtonOld(text string, min, max Point) *ButtonOld

func (*UiEngine) CreateWindow

func (ui *UiEngine) CreateWindow(min, max Point, c image_color.RGBA)

func (*UiEngine) DeleteBaseGeom

func (ui *UiEngine) DeleteBaseGeom(geom *DisplayGeom)

func (*UiEngine) DrawAllButtons

func (ui *UiEngine) DrawAllButtons()

func (*UiEngine) DrawAllWindows

func (ui *UiEngine) DrawAllWindows()

func (*UiEngine) DrawBaseGeom

func (ui *UiEngine) DrawBaseGeom(geom *DisplayGeom)

func (*UiEngine) DrawButton

func (ui *UiEngine) DrawButton(id int)

func (*UiEngine) InitAllButtons

func (ui *UiEngine) InitAllButtons()

func (*UiEngine) InitAllWindows

func (ui *UiEngine) InitAllWindows()

func (*UiEngine) InitBaseGeom

func (ui *UiEngine) InitBaseGeom(geom *DisplayGeom)

func (*UiEngine) InitButton

func (ui *UiEngine) InitButton(id int)

func (*UiEngine) SetDevice

func (ui *UiEngine) SetDevice(dev *DeviceSpecs)

func (*UiEngine) SetFontSize

func (ui *UiEngine) SetFontSize(size int)

func (*UiEngine) String

func (ui *UiEngine) String() string

func (*UiEngine) UpdateButtonText

func (ui *UiEngine) UpdateButtonText(button *ButtonOld, newText string)

type UiGesture

type UiGesture struct {
	LongTouchPrevTime     time.Time
	DoubleTouchPrevTime   time.Time
	LongTouchMeasure      bool
	LongTouch             bool
	DoubleTouch           bool
	TouchDrag             bool
	ProcessingClickBottom bool
	ProcessingClick       bool
	TouchX                float32
	TouchY                float32
	PrevTouchX            float32
	PrevTouchY            float32
}

func CreateUiGesture

func CreateUiGesture() *UiGesture

type Window

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

func CreateWindow

func CreateWindow(ui *UiEngine, min, max Point, layoutType int, col color.RGBA) *Window

func (*Window) AddButton

func (win *Window) AddButton(text string) *Button

func (*Window) AddLabel

func (win *Window) AddLabel(text string) *Label

func (*Window) AddLayout

func (win *Window) AddLayout(layoutType int)

func (*Window) AddSlider

func (win *Window) AddSlider(label string, value interface{}) *Slider

func (*Window) Build

func (win *Window) Build(ui *UiEngine)

func (*Window) Draw

func (win *Window) Draw(ui *UiEngine)

func (*Window) HandleTouch

func (win *Window) HandleTouch(ui *UiEngine, touchx, touchy float32)

func (*Window) SetPadding

func (win *Window) SetPadding(padding float32)

Padding for the default window layout

func (*Window) UpdateTexture

func (win *Window) UpdateTexture(ui *UiEngine, force bool)

Jump to

Keyboard shortcuts

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