event

package
v0.0.0-...-2de55c8 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoEventCategory          EventCategory = 0
	EventCategoryApplication               = BIT(1)
	EventCategoryInput                     = BIT(2)
	EventCategoryKeyboard                  = BIT(3)
	EventCategoryMouse                     = BIT(4)
	EventCategoryMouseButton               = BIT(5)
)

Enum to represent each of the possible Event Categories

Functions

func BIT

func BIT(i int) int

BIT is a shorthand to return a single-bit Bitmask, so that we can indicate an events type(s) with flipped bits

Types

type AppRenderEvent

type AppRenderEvent struct {
	*Event
}

----APP RENDER EVENT----

func NewAppRenderEvent

func NewAppRenderEvent() *AppRenderEvent

func (AppRenderEvent) GetEventForDispatch

func (are AppRenderEvent) GetEventForDispatch() *Event

func (AppRenderEvent) String

func (are AppRenderEvent) String() string

type AppTickEvent

type AppTickEvent struct {
	*Event
}

----APP TICK EVENT----

func NewAppTickEvent

func NewAppTickEvent() *AppTickEvent

func (AppTickEvent) GetEventForDispatch

func (ate AppTickEvent) GetEventForDispatch() *Event

func (AppTickEvent) String

func (ate AppTickEvent) String() string

type AppUpdateEvent

type AppUpdateEvent struct {
	*Event
}

----APP UPDATE EVENT----

func NewAppUpdateEvent

func NewAppUpdateEvent() *AppUpdateEvent

func (AppUpdateEvent) GetEventForDispatch

func (aue AppUpdateEvent) GetEventForDispatch() *Event

func (AppUpdateEvent) String

func (aue AppUpdateEvent) String() string

type Dispatcher

type Dispatcher struct {
	Event IEvent
}

func (Dispatcher) Dispatch

func (d Dispatcher) Dispatch(eventType EventType, eventFunc func(IEvent) bool) bool

Dispatch dispatches an Dispatchable event to an eventFunction, checking that it matches the appropriate type.

type Event

type Event struct {
	EventType     EventType
	CategoryFlags int
	Name          string
	Handled       bool
}

Events might be blocking depending on how I can implement this in Go. Just something to keep in mind. Good thing Go is great at concurrency, so this should be easy to fix down the line.

func (Event) IsInCategory

func (e Event) IsInCategory(category EventCategory) bool

Checks if Bitmask contains the flag for the specific EventCategory

type EventCategory

type EventCategory int

type EventType

type EventType int
const (
	NoEventType EventType = iota
	EventTypeWindowResize
	EventTypeWindowClose
	EventTypeWindowFocus
	EventTypeWindowLostFocus
	EventTypeWindowMoved
	EventTypeAppTick
	EventTypeAppUpdate
	EventTypeAppRender
	EventTypeKeyPressed
	EventTypeKeyReleased
	EventTypeMouseButtonPressed
	EventTypeMouseButtonReleased
	EventTypeMouseMoved
	EventTypeMouseScrolled
)

Enum to represent each of the possible Event Types

type IEvent

type IEvent interface {
	String() string
	GetEventForDispatch() *Event // This will probably be deprecated at some point
}

type KeyPressedEvent

type KeyPressedEvent struct {
	*Event
	KeyCode     glfw.Key
	RepeatCount int // Represents the key pressed repeat state, and how many times that key-press has been repeated
}

----KEY PRESSED EVENT----

func NewKeyPressedEvent

func NewKeyPressedEvent(keycode glfw.Key, repeatCount int) *KeyPressedEvent

func (KeyPressedEvent) GetEventForDispatch

func (kpe KeyPressedEvent) GetEventForDispatch() *Event

func (KeyPressedEvent) String

func (kpe KeyPressedEvent) String() string

type KeyReleasedEvent

type KeyReleasedEvent struct {
	*Event
	KeyCode glfw.Key
}

----KEY RELEASED EVENT----

func NewKeyReleasedEvent

func NewKeyReleasedEvent(keycode glfw.Key) *KeyReleasedEvent

func (KeyReleasedEvent) GetEventForDispatch

func (kre KeyReleasedEvent) GetEventForDispatch() *Event

func (KeyReleasedEvent) String

func (kre KeyReleasedEvent) String() string

type MouseButtonPressedEvent

type MouseButtonPressedEvent struct {
	*Event
	Button glfw.MouseButton
}

----MOUSE BUTTON PRESSED EVENT----

func NewMouseButtonPressedEvent

func NewMouseButtonPressedEvent(button glfw.MouseButton) *MouseButtonPressedEvent

func (MouseButtonPressedEvent) GetEventForDispatch

func (mbpe MouseButtonPressedEvent) GetEventForDispatch() *Event

func (MouseButtonPressedEvent) String

func (mbpe MouseButtonPressedEvent) String() string

type MouseButtonReleasedEvent

type MouseButtonReleasedEvent struct {
	*Event
	Button glfw.MouseButton
}

----MOUSE BUTTON RELEASED EVENT----

func NewMouseButtonReleasedEvent

func NewMouseButtonReleasedEvent(button glfw.MouseButton) *MouseButtonReleasedEvent

func (MouseButtonReleasedEvent) GetEventForDispatch

func (mbre MouseButtonReleasedEvent) GetEventForDispatch() *Event

func (MouseButtonReleasedEvent) String

func (mbre MouseButtonReleasedEvent) String() string

type MouseMovedEvent

type MouseMovedEvent struct {
	*Event
	X float64
	Y float64
}

----MOUSE MOVED EVENT----

func NewMouseMovedEvent

func NewMouseMovedEvent(x, y float64) *MouseMovedEvent

func (MouseMovedEvent) GetEventForDispatch

func (mme MouseMovedEvent) GetEventForDispatch() *Event

func (MouseMovedEvent) String

func (mme MouseMovedEvent) String() string

type MouseScrolledEvent

type MouseScrolledEvent struct {
	*Event
	XOffset float64 // X Position of the cursor at scroll event
	YOffset float64 // Y Position of the cursor at scroll event
}

----MOUSE SCROLLED EVENT----

func NewMouseScrolledEvent

func NewMouseScrolledEvent(xoff, yoff float64) *MouseScrolledEvent

func (MouseScrolledEvent) GetEventForDispatch

func (mse MouseScrolledEvent) GetEventForDispatch() *Event

func (MouseScrolledEvent) String

func (mse MouseScrolledEvent) String() string

type WindowCloseEvent

type WindowCloseEvent struct {
	*Event
}

----WINDOW CLOSE EVENT----

func NewWindowCloseEvent

func NewWindowCloseEvent() *WindowCloseEvent

func (WindowCloseEvent) GetEventForDispatch

func (wce WindowCloseEvent) GetEventForDispatch() *Event

func (WindowCloseEvent) String

func (wce WindowCloseEvent) String() string

type WindowResizeEvent

type WindowResizeEvent struct {
	*Event
	Width  uint
	Height uint
}

----WINDOW RESIZE EVENT----

func NewWindowResizeEvent

func NewWindowResizeEvent(height, width uint) *WindowResizeEvent

func (WindowResizeEvent) GetEventForDispatch

func (wre WindowResizeEvent) GetEventForDispatch() *Event

func (WindowResizeEvent) String

func (wre WindowResizeEvent) String() string

Jump to

Keyboard shortcuts

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