display

package
v0.1.1-0...-1ecdc53 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Display

type Display struct {
	Events

	Window *sdl.Window
	// contains filtered or unexported fields
}

Display describes a display rendering scenes.

func (*Display) CreateCanvas

func (d *Display) CreateCanvas(innerWidth, innerHeight int32,
	bg api.Background, borders render.Directions) (c render.Canvas, content render.Rectangle)

CreateCanvas creates a canvas to draw content into, and fills it with the given background.

func (*Display) Destroy

func (d *Display) Destroy()

Destroy destroys window and renderer

func (*Display) DrawImage

func (d *Display) DrawImage(image render.Image, t render.Transform, alpha uint8)

DrawImage renders the given image if it is not empty, using the given transformation. alpha modifies the image's opacity.

func (*Display) FillRect

func (d *Display) FillRect(t render.Transform, color api.RGBA)

FillRect fills the rectangle with the specified dimensions with the specified color. The rectangle is positions via the given transformation.

func (*Display) FreeImage

func (d *Display) FreeImage(i *render.Image)

FreeImage destroys the texture associated with the image (if one exists) and sets i to be the empty image. Does nothing on empty images.

func (*Display) Init

func (d *Display) Init(
	owner app.App, events Events, fullscreen bool, port uint16,
	actions []KeyAction, window *sdl.Window, debug bool) error

Init initializes the display. The renderer and window need to be generated before since the app needs to load fonts based on the window size.

func (*Display) LoadImageFile

func (d *Display) LoadImageFile(
	location *url.URL, scaleDownToOutput bool) (render.Image, error)

LoadImageFile loads an image file from the specified path. if an error is returned, the returned image is empty.

func (*Display) LoadImageMem

func (d *Display) LoadImageMem(
	data []byte, scaleDownToOutput bool) (render.Image, error)

LoadImageMem loads an image from data in memory. if an error is returned, the returned image is empty.

func (*Display) OutputSize

func (d *Display) OutputSize() render.Rectangle

OutputSize returns a rectangle that describes the dimensions in pixels of the current rendering area. X and Y are always 0.

func (*Display) RenderLoop

func (d *Display) RenderLoop() int

RenderLoop implements the rendering loop for the display. This function MUST be called in the main thread

func (*Display) RenderText

func (d *Display) RenderText(text string, font api.Font) render.Image

RenderText renders the given text with the given font into an image with transparent background. Returns an empty image if it wasn't able to create the texture.

func (*Display) StartRequest

func (d *Display) StartRequest(eventID uint32, eventCode int32) (Request,
	server.Error)

StartRequest starts a new request to the display thread. Returns an error if there is already a pending request.

func (*Display) Unit

func (d *Display) Unit() int32

Unit is the scaled smallest unit in pixels.

type Events

type Events struct {
	// issued for updates to the module state via transitioning
	ModuleUpdateID uint32
	// issued for updates of module configuration
	ModuleConfigID uint32
	// issued when changing the current scene
	SceneChangeID uint32
	// issued when the list of heroes is edited
	HeroesChangedID uint32
	// issued when the user leaves the current group
	// (resets display to welcome screen)
	LeaveGroupID uint32
}

Events lists the event IDs used with SDL's UserEvent

func GenEvents

func GenEvents() Events

GenEvents generates a set of event IDs. Only call this once!

type KeyAction

type KeyAction struct {
	Key         sdl.Keycode
	ReturnValue int
	Description string
}

KeyAction describes a key that closes the app with the given return value

type Request

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

Request is a pending message to the display thread. Successful generation of a request leads to exclusive access to the display's communication channel. A Request must be either committed or closed.

func (*Request) Close

func (r *Request) Close()

Close closes the request. If the request has not been committed, the queued data will be erased. This function is idempotent.

func (*Request) Commit

func (r *Request) Commit() error

Commit sends the request to the display thread

func (*Request) SendEnabledModulesList

func (r *Request) SendEnabledModulesList(value []bool) error

SendEnabledModulesList queues the list of enabled modules as part of the request.

func (*Request) SendModuleConfig

func (r *Request) SendModuleConfig(index shared.ModuleIndex, config interface{}) error

SendModuleConfig queues the given config for the module at the given ID as part of the request.

func (*Request) SendRendererData

func (r *Request) SendRendererData(index shared.ModuleIndex, data interface{}) error

SendRendererData queues the given data for the module at the given ID as part of the request. Whether the data is used for RebuiltState or InitTransition depends on the event ID of the request.

Jump to

Keyboard shortcuts

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