app

package
v0.0.2-0...-24379f4 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package app provides the ability to run a window.

A minimum window instance must implements Window interface that require a Size method to provide the size of the window. If the window instance additionaly implements a Draw method that returns an image.RGBA pointer, the created window will draw the provided image on the window.

To handle resize, keyboard, and mouse events, the window instance must additionally implements OnResize, OnKey and OnMouse methods. See ResizeHandler, KeyboardHandler, and MouseHandler interfaces.

Platform Specific Dependencies

- Darwin: xcode-install --select - Linux: sudo apt install -y libx11-dev libgles2-mesa-dev libegl1-mesa-dev

Index

Constants

View Source
const (
	ModNone     = ModifierKey(0)
	ModShift    = ModifierKey(1 << 0)
	ModCapsLock = ModifierKey(1 << 1)
	ModControl  = ModifierKey(1 << 2)
	Mod1        = ModifierKey(1 << 3)
	Mod2        = ModifierKey(1 << 4)
	Mod3        = ModifierKey(1 << 5)
	Mod4        = ModifierKey(1 << 6)
	Mod5        = ModifierKey(1 << 7)
)

Variables

This section is empty.

Functions

func Run

func Run(instance Window, opts ...Option)

Run runs a object that implements Window interface. The window can be configured by a list of options.

Types

type DrawHandler

type DrawHandler interface {
	Window
	Draw() (screen *image.RGBA, needRedraw bool)
}

DrawHandler is an extended interface of a Window which presents a method to draw an image to show on top of the window.

type Key

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

Key corresponds to a keyboard key.

func (Key) String

func (key Key) String() string

type KeyEvent

type KeyEvent struct {
	Keycode Key
	Mods    ModifierKey
	Pressed bool
}

KeyEvent describes a key event over the window

func (KeyEvent) String

func (kev KeyEvent) String() string

type KeyboardHanlder

type KeyboardHanlder interface {
	Window
	OnKey(key KeyEvent)
}

KeyboardHanlder is an extended Interface of a Window which presents a method to handle keyboard inputs.

type ModifierKey

type ModifierKey int

ModifierKey corresponds to a set of modifier keys (bitmask). The provided modifiers are platform dependent.

func (ModifierKey) Contain

func (mod ModifierKey) Contain(mod2 ModifierKey) bool

func (ModifierKey) String

func (mod ModifierKey) String() string

type MouseAction

type MouseAction int

MouseAction corresponds to a mouse action.

const (
	MouseMove MouseAction = iota
	MouseUp
	MouseDown
	MouseScroll
)

func (MouseAction) String

func (a MouseAction) String() string

type MouseButton

type MouseButton int

MouseButton corresponds to a mouse button.

const (
	MouseBtnNone MouseButton = iota
	MouseBtnLeft
	MouseBtnRight
	MouseBtnMiddle
)

Mouse buttons

func (MouseButton) String

func (btn MouseButton) String() string

type MouseEvent

type MouseEvent struct {
	Action  MouseAction
	Button  MouseButton
	Mods    ModifierKey
	Xpos    float32
	Ypos    float32
	Xoffset float32
	Yoffset float32
}

MouseEvent describes a mouse event over the window

func (MouseEvent) String

func (mev MouseEvent) String() string

type MouseHandler

type MouseHandler interface {
	Window
	OnMouse(mo MouseEvent)
}

MouseHandler is an extended Interface of a Window which presents a method to handle mouse inputs.

type Option

type Option func(*config)

func FPS

func FPS(enable bool) Option

FPS enables FPS indicator on the top left corner of the window.

func MaxSize

func MaxSize(w, h int) Option

MaxSize sets the maximum size of the window.

func MinSize

func MinSize(w, h int) Option

MinSize sets the minimum size of the window.

func Title

func Title(t string) Option

Title sets the title of the window.

type ResizeHandler

type ResizeHandler interface {
	Window
	OnResize(w, h int)
}

ResizeHandler is an extended Interface of a Window which presents a method to handle window resizes.

type SizeHandler

type SizeHandler interface {
	Window
	Size() (w, h int)
}

SizeHandler is an extended interface of a Window which reports the desired size of a window.

type Window

type Window any

Window is a minimum abstraction of a Window.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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