pixelui

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: MIT Imports: 13 Imported by: 1

README

PixelUI

Adds GUIs to the Pixel rendering engine by interpreting imgui-go render data into Pixel render calls.

Examples

The examples repository contains an example demonstrating PixelUI's functionality.

To run an example, navigate to it's directory, then go run the test.go file. For example:

$ cd pixelui_examples
$ go run test.go

Current Expected state

This is where we are currently... Current State

Documentation

Index

Constants

View Source
const (
	WrappedNone = iota
	WrappedSprite
	WrappedBatch
	WrappedCanvas
)
View Source
const (
	NO_DEFAULT_FONT uint8 = 1 << iota
)

pixelui.NewUI flags:

NO_DEFAULT_FONT: Do not load the default font during NewUI.

Variables

This section is empty.

Functions

func Color

func Color(r, g, b uint8) imgui.Vec4

Color converts the given 8-bit r,g,b components to a imgui.Vec4 for color arguments

func ColorA

func ColorA(r, g, b, a uint8) imgui.Vec4

Color converts the given 8-bit r,g,b,a components to a imgui.Vec4 for color arguments

func IV

func IV(x, y float64) imgui.Vec2

IV creates an imgui vector from the given points.

func IVec

func IVec(v pixel.Vec) imgui.Vec2

IVec converts a pixel vector to an imgui vector

func IZV

func IZV() imgui.Vec2

IZV returns an imgui zero vector

func PV

func PV(v imgui.Vec2) pixel.Vec

PV converts an imgui vector to a pixel vector

func ProjectV

func ProjectV(x, y float64) imgui.Vec2

ProjectV creates a pixel vector and projects it using ProjectVec

func ProjectVec

func ProjectVec(v pixel.Vec) imgui.Vec2

ProjectVec projects the vector by the UI's matrix (vertical flip)

and returns that as a imgui vector

func Sprite

func Sprite(sprite *pixel.Sprite) imgui.TextureID

func UnprojectV

func UnprojectV(v imgui.Vec2) pixel.Vec

UnprojectV unprojects the vector by the UI's matrix (vertical flip)

and returns that as a pixel vector

Types

type Clipboard

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

func (Clipboard) SetText

func (c Clipboard) SetText(value string)

func (Clipboard) Text

func (c Clipboard) Text() (text string, err error)

type UI

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

UI Stores the state of the pixelui UI

var CurrentUI *UI

func NewUI

func NewUI(win *pixelgl.Window, flags uint8) *UI

NewUI Creates the UI and setups up its internal structures

func (*UI) AddSprite

func (ui *UI) AddSprite(name string, sprite *pixel.Sprite) imgui.TextureID

func (*UI) AddSpriteFromFile

func (ui *UI) AddSpriteFromFile(path string) (id imgui.TextureID, sprite *pixel.Sprite)

func (*UI) AddSpriteFromFileV

func (ui *UI) AddSpriteFromFileV(name, path string) (id imgui.TextureID, sprite *pixel.Sprite)

func (*UI) AddTTFFont

func (ui *UI) AddTTFFont(path string, size float32)

AddTTFFont loads the given font into imgui.

func (*UI) Destroy

func (ui *UI) Destroy()

Destroy cleans up the imgui context

func (*UI) Draw

func (ui *UI) Draw(win *pixelgl.Window)

Draw Draws the imgui UI to the Pixel Window

func (UI) GetPacker

func (ui UI) GetPacker() *packer.AliasPacker

func (*UI) Image

func (ui *UI) Image(alias interface{}, scale float64)

Image is a helper for imgui.Image that looks up the sprite in the internal packed atlas.

func (*UI) ImageButton

func (ui *UI) ImageButton(alias interface{}, scale float64) bool

ImageButton is a helper for imgui.ImageButton that looks up the sprite in the internal packed atlas.

func (*UI) JustPressed

func (ui *UI) JustPressed(button pixelgl.Button) bool

JustPressed returns true if imgui hasn't handled the button and the button was just pressed

func (*UI) JustReleased

func (ui *UI) JustReleased(button pixelgl.Button) bool

JustPressed returns true if imgui hasn't handled the button and the button was just released

func (*UI) KeyAlt

func (ui *UI) KeyAlt() bool

KeyCtrl returns true if either left or right alt is pressed

func (*UI) KeyCtrl

func (ui *UI) KeyCtrl() bool

KeyCtrl returns true if either left or right control is pressed

func (*UI) KeyShift

func (ui *UI) KeyShift() bool

KeyCtrl returns true if either left or right shift is pressed

func (*UI) KeySuper

func (ui *UI) KeySuper() bool

KeyCtrl returns true if either left or right super (windows key) is pressed

func (*UI) MouseScroll

func (ui *UI) MouseScroll() pixel.Vec

MouseScroll returns the mouse scroll amount if imgui does not want the mouse

(if mouse is not hovering an imgui element)

func (*UI) NewFrame

func (ui *UI) NewFrame()

NewFrame Call this at the beginning of the frame to tell the UI that the frame has started

func (*UI) Pressed

func (ui *UI) Pressed(button pixelgl.Button) bool

JustPressed returns true if imgui hasn't handled the button and the button is pressed

func (*UI) Repeated

func (ui *UI) Repeated(button pixelgl.Button) bool

Repeated returns true if imgui hasn't handled the button and the button was repeated

Jump to

Keyboard shortcuts

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