native

package
v0.0.0-...-1f00af5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package native provides native system functions for Linux, MacOS and Windows to perform operating system-specific tasks such as open web links or native dialog boxes.

Index

Constants

This section is empty.

Variables

View Source
var (
	USER          string = os.Getenv("USER")
	DefaultAuthor        = USER
)
View Source
var (
	// This is set to True when a file dialog driver is available.
	// If false, a fallback uses the developer shell Prompt()
	// to ask for a file name.
	FileDialogsReady bool
)

FileDialog common variables.

View Source
var (
	// Force the TouchScreenMode to always be enabled.
	ForceTouchScreenModeAlwaysOn bool
)

Functions

func CopyToClipboard

func CopyToClipboard(text string) error

CopyToClipboard puts some text on your clipboard.

func CountTextures

func CountTextures(e render.Engine) string

CountTextures returns the count of loaded SDL2 textures, for the F3 debug overlay, or "n/a"

func FreeTextures

func FreeTextures(e render.Engine)

FreeTextures will free all SDL2 textures currently in memory.

func IsTouchScreenMode

func IsTouchScreenMode() bool

IsTouchScreenMode is activated when the user has touched the screen, and false when the mouse is moved.

func MaximizeWindow

func MaximizeWindow(e render.Engine)

Set the window to maximized.

func OpenFile

func OpenFile(title string, filter string) (string, error)

OpenFile invokes a native File Chooser dialog with the title and a set of file filters. The filters are a sequence of label and comma-separated file extensions.

Example: OpenFile("Pick a file", "Images", "png,gif,jpg", "Audio", "mp3")

func OpenLocalURL

func OpenLocalURL(path string)

OpenLocalURL opens a web browser to a local HTML path. It converts a relative path like "guidebook/index.html" to its absolute filesystem location.

func OpenURL

func OpenURL(url string)

OpenURL opens a web browser to the given URL.

On Linux this will look for xdg-open or try a few common browser names. On Windows this uses the “start“ command. On MacOS this uses the “open“ command.

func SaveFile

func SaveFile(title string, filter string) (string, error)

SaveFile invokes a native File Chooser dialog with the title and a set of file filters. The filters are a sequence of label and comma-separated file extensions.

Example: SaveFile("Pick a file", "Images", "png,gif,jpg", "Audio", "mp3")

func TextToImage

func TextToImage(e render.Engine, text render.Text) (image.Image, error)

TextToImage takes an SDL2_TTF texture and makes it into a Go image.

Notes: - The text is made Black & White with a white background on the image. - Drop shadow, stroke, etc. probably not supported. - Returns a non-antialiased image.

func UpdateTouchScreenMode

func UpdateTouchScreenMode(ev *event.State)

UpdateTouchScreenMode evaluates whether the primary game input is a touch screen rather than a mouse cursor.

The game always hides the OS cursor (if it exists) and may draw its own custom mouse cursor.

On a touch screen device (such as a mobile), the custom mouse cursor should not be drawn, either, as it would jump around to wherever the user last touched and be distracting.

TouchScreenMode is activated when a touch event has been triggered (at least one finger was down).

TouchScreenMode deactivates and shows the mouse cursor when no finger is held down, and then a mouse event has occurred. So if the user has a touch screen laptop, wiggling the actual mouse input will bring the cursor back.

Types

This section is empty.

Jump to

Keyboard shortcuts

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