desktop

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MacOsBuiltinMonitor = "Built-in Retina Display"
View Source
var MonitorDebug = false

MonitorDebug turns on various debugging statements about monitor changes and updates from glfw.

View Source
var TheApp = &App{AppMulti: base.NewAppMulti[*Window]()}

TheApp is the single goosi.App for the desktop platform

View Source
var TheClip = &Clip{}

TheClip is the single clip.Board for Linux

View Source
var TheCursor = &Cursor{CursorBase: cursor.CursorBase{Vis: true, Size: 32}, Cursors: map[enums.Enum]map[int]*glfw.Cursor{}}

TheCursor is the single goosi.Cursor for the desktop platform

Functions

func GlfwKeyCode added in v0.0.15

func GlfwKeyCode(kcode glfw.Key) key.Codes

TODO: should this be a map?

func GlfwMods added in v0.0.15

func GlfwMods(mod glfw.ModifierKey) key.Modifiers

func Main

func Main(f func(goosi.App))

Main is called from main thread when it is time to start running the main loop. When function f returns, the app ends automatically.

func NewGlfwWindow added in v0.0.15

func NewGlfwWindow(opts *goosi.NewWindowOptions, sc *goosi.Screen) (*glfw.Window, error)

NewGlfwWindow makes a new glfw window. It must be run on main.

Types

type App added in v0.0.15

type App struct {
	base.AppMulti[*Window]

	// GPU is the system GPU used for the app
	GPU *vgpu.GPU

	// ShareWin is a non-visible, always-present window that all windows share gl context with
	ShareWin *glfw.Window
}

App is the goosi.App implementation for the desktop platform

func (*App) ClipBoard added in v0.0.15

func (a *App) ClipBoard(win goosi.Window) clip.Board

func (*App) Cursor added in v0.0.15

func (a *App) Cursor(win goosi.Window) cursor.Cursor

func (*App) DataDir added in v0.0.18

func (a *App) DataDir() string

func (*App) FindScreenInfo added in v0.0.15

func (a *App) FindScreenInfo(name string) (*goosi.Screen, bool)

FindScreenInfo finds saved screen info based on name

func (*App) GetScreens added in v0.0.15

func (a *App) GetScreens()

func (*App) InitVk added in v0.0.15

func (a *App) InitVk()

InitVk initializes glfw, vulkan, vgpu, and the screens.

func (*App) MainLoop added in v0.0.15

func (a *App) MainLoop()

MainLoop starts running event loop on main thread (must be called from the main thread).

func (*App) MonitorChange added in v0.0.15

func (a *App) MonitorChange(monitor *glfw.Monitor, event glfw.PeripheralEvent)

MonitorChange is called when a monitor is connected to or disconnected from the system.

func (*App) NewWindow added in v0.0.15

func (a *App) NewWindow(opts *goosi.NewWindowOptions) (goosi.Window, error)

func (*App) OpenURL added in v0.0.15

func (a *App) OpenURL(url string)

func (*App) Platform added in v0.0.15

func (a *App) Platform() goosi.Platforms

func (*App) SaveScreenInfo added in v0.0.15

func (a *App) SaveScreenInfo(sc *goosi.Screen) bool

SaveScreenInfo saves a copy of given screen info to screensAll list if unique based on name. Returns true if added a new screen.

func (*App) SendEmptyEvent added in v0.0.15

func (a *App) SendEmptyEvent()

SendEmptyEvent sends an empty, blank event to global event processing system, which has the effect of pushing the system along during cases when the event loop needs to be "pinged" to get things moving along..

type Clip added in v0.0.15

type Clip struct{}

Clip is the clip.Board implementation for Linux

func (*Clip) Clear added in v0.0.15

func (cl *Clip) Clear()

func (*Clip) IsEmpty added in v0.0.15

func (cl *Clip) IsEmpty() bool

func (*Clip) Read added in v0.0.15

func (cl *Clip) Read(types []string) mimedata.Mimes

func (*Clip) Write added in v0.0.15

func (cl *Clip) Write(data mimedata.Mimes) error

type Cursor added in v0.0.15

type Cursor struct {
	cursor.CursorBase

	// Cursors are the cached glfw cursors
	Cursors map[enums.Enum]map[int]*glfw.Cursor

	// Mu is a mutex protecting access to the cursors
	Mu sync.Mutex

	// PrevSize is the cached previous size
	PrevSize int
}

Cursor is the cursor.Cursor implementation for the desktop platform

func (*Cursor) Set added in v0.0.15

func (cu *Cursor) Set(cursor enums.Enum) error

type Window added in v0.0.15

type Window struct {
	base.WindowMulti[*App, *vdraw.Drawer]

	// Glw is the glfw window associated with this window
	Glw *glfw.Window

	// ScreenName is the name of the last known screen this window was on
	ScreenWindow string
}

Window is the implementation of goosi.Window for the desktop platform.

func (*Window) Activate added in v0.0.15

func (w *Window) Activate() bool

Activate() sets this window as the current render target for gpu rendering functions, and the current context for gpu state (equivalent to MakeCurrentContext on OpenGL). If it returns false, then window is not visible / valid and nothing further should happen. Must call this on app main thread using goosi.TheApp.RunOnMain

goosi.TheApp.RunOnMain(func() {
   if !win.Activate() {
       return
   }
   // do GPU calls here
})

func (*Window) CharEvent added in v0.0.15

func (w *Window) CharEvent(gw *glfw.Window, char rune, mod glfw.ModifierKey)

char input

func (*Window) Close added in v0.0.15

func (w *Window) Close()

func (*Window) CurMousePosPoint added in v0.0.15

func (w *Window) CurMousePosPoint(gw *glfw.Window) image.Point

func (*Window) CursorEnterEvent added in v0.0.15

func (w *Window) CursorEnterEvent(gw *glfw.Window, entered bool)

func (*Window) CursorPosEvent added in v0.0.15

func (w *Window) CursorPosEvent(gw *glfw.Window, x, y float64)

func (*Window) DeActivate added in v0.0.15

func (w *Window) DeActivate()

DeActivate() clears the current render target and gpu rendering context. Generally more efficient to NOT call this and just be sure to call Activate where relevant, so that if the window is already current context no switching is required. Must call this on app main thread using goosi.TheApp.RunOnMain

func (*Window) DropEvent added in v0.0.15

func (w *Window) DropEvent(gw *glfw.Window, names []string)

func (*Window) FbResized added in v0.0.15

func (w *Window) FbResized(gw *glfw.Window, width, height int)

func (*Window) FocusWindow added in v0.0.15

func (w *Window) FocusWindow() *Window

func (*Window) Focused added in v0.0.15

func (w *Window) Focused(gw *glfw.Window, focused bool)

func (*Window) GetScreenOverlap added in v0.0.15

func (w *Window) GetScreenOverlap() *goosi.Screen

GetScreenOverlap gets the monitor for given window based on overlap of geometry, using limited glfw 3.3 api, which does not provide this functionality. See: https://github.com/glfw/glfw/issues/1699 This is adapted from slawrence2302's code posted there.

func (*Window) Handle added in v0.0.15

func (w *Window) Handle() any

func (*Window) Iconify added in v0.0.15

func (w *Window) Iconify(gw *glfw.Window, iconified bool)

func (*Window) KeyEvent added in v0.0.15

func (w *Window) KeyEvent(gw *glfw.Window, ky glfw.Key, scancode int, action glfw.Action, mod glfw.ModifierKey)

physical key

func (*Window) Minimize added in v0.0.15

func (w *Window) Minimize()

func (*Window) MouseButtonEvent added in v0.0.15

func (w *Window) MouseButtonEvent(gw *glfw.Window, button glfw.MouseButton, action glfw.Action, mod glfw.ModifierKey)

func (*Window) MousePosToPoint added in v0.0.15

func (w *Window) MousePosToPoint(x, y float64) image.Point

func (*Window) Moved added in v0.0.15

func (w *Window) Moved(gw *glfw.Window, x, y int)

func (*Window) OnCloseReq added in v0.0.15

func (w *Window) OnCloseReq(gw *glfw.Window)

func (*Window) Raise added in v0.0.15

func (w *Window) Raise()

func (*Window) Screen added in v0.0.15

func (w *Window) Screen() *goosi.Screen

Screen gets the screen of the window, computing various window parameters.

func (*Window) ScrollEvent added in v0.0.15

func (w *Window) ScrollEvent(gw *glfw.Window, xoff, yoff float64)

func (*Window) SetCursorEnabled added in v0.0.15

func (w *Window) SetCursorEnabled(enabled, raw bool)

func (*Window) SetGeom added in v0.0.15

func (w *Window) SetGeom(pos image.Point, sz image.Point)

func (*Window) SetMousePos added in v0.0.15

func (w *Window) SetMousePos(x, y float64)

func (*Window) SetPos added in v0.0.15

func (w *Window) SetPos(pos image.Point)

func (*Window) SetTitle added in v0.0.15

func (w *Window) SetTitle(title string)

func (*Window) SetWinSize added in v0.0.15

func (w *Window) SetWinSize(sz image.Point)

func (*Window) Show added in v0.0.15

func (w *Window) Show()

func (*Window) UpdateGeom added in v0.0.15

func (w *Window) UpdateGeom()

func (*Window) WinResized added in v0.0.15

func (w *Window) WinResized(gw *glfw.Window, width, height int)

Jump to

Keyboard shortcuts

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