plugin

package
v0.0.0-...-3331d8c Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: BSD-3-Clause, MIT Imports: 10 Imported by: 0

README

Plugin

This package is required to interact with any other package in this repository.

You MUST use plugin.Install() in your event-loop:

for evt := range w.Events() { // Gio main event loop
+    plugin.Install(w, evt)

    switch evt := evt.(type) {
        // ...
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

func Install(w *app.Window, evt event.Event)

func NewHandlerFunc

func NewHandlerFunc(ops []reflect.Type, events []reflect.Type, listenOp func(op interface{}), listenEvents func(event.Event)) func(w *app.Window, h *Plugin) Handler

NewHandlerFunc returns a Handler that calls the given functions.

func Register

func Register(plugin func(w *app.Window, handler *Plugin) Handler)

Register registers the Handler, it will be called when the window is created. You MUST call Register during init() function, otherwise it will not work or may cause unexpected behavior.

func WriteOp

func WriteOp(op *op.Ops, c any)

WriteOp writes the given op into the op.Ops queue.

Types

type EndFrameEvent

type EndFrameEvent struct{}

func (EndFrameEvent) ImplementsEvent

func (EndFrameEvent) ImplementsEvent()

type Handler

type Handler interface {
	TypeOp() []reflect.Type
	TypeEvent() []reflect.Type

	ListenOps(op interface{})
	ListenEvents(evt event.Event)
}

Handler is the interface that represents the Plugin.

type OpPool

type OpPool[T any] struct {
	// contains filtered or unexported fields
}

OpPool is a pool of specific type of op.

func NewOpPool

func NewOpPool[T any]() OpPool[T]

NewOpPool returns a new OpPool. That is useful to avoid memory allocation, you MUST call Release() after you done using the op.

func (*OpPool[T]) Get

func (x *OpPool[T]) Get() *T

Get returns a new op from the pool.

func (*OpPool[T]) Release

func (x *OpPool[T]) Release(data *T)

Release releases the given data, so it can be reused.

func (*OpPool[T]) WriteOp

func (x *OpPool[T]) WriteOp(op *op.Ops, data T)

WriteOp adds the given data into the op.Ops queue.

type Plugin

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

func (*Plugin) Events

func (l *Plugin) Events(t event.Tag) []event.Event

func (*Plugin) SendEvent

func (l *Plugin) SendEvent(tag event.Tag, data event.Event)

Jump to

Keyboard shortcuts

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