Documentation ¶
Index ¶
- Variables
- func GlfwKeyCode(kcode glfw.Key) key.Codes
- func GlfwMods(mod glfw.ModifierKey) key.Modifiers
- func Init()
- type App
- func (a *App) Clipboard(win system.Window) system.Clipboard
- func (a *App) Cursor(win system.Window) system.Cursor
- func (a *App) DataDir() string
- func (a *App) FindScreenInfo(name string) (*system.Screen, bool)
- func (a *App) GetScreens()
- func (a *App) InitGPU()
- func (a *App) MainLoop()
- func (a *App) MonitorChange(monitor *glfw.Monitor, event glfw.PeripheralEvent)
- func (a *App) NewWindow(opts *system.NewWindowOptions) (system.Window, error)
- func (a *App) OpenURL(url string)
- func (a *App) Platform() system.Platforms
- func (a *App) PollScreenChanges()
- func (a *App) SaveScreenInfo(sc *system.Screen) bool
- func (a *App) SendEmptyEvent()
- type Clipboard
- type Cursor
- type Window
- func (w *Window) Activate() bool
- func (w *Window) CharEvent(gw *glfw.Window, char rune, mod glfw.ModifierKey)
- func (w *Window) Close()
- func (w *Window) ConstrainFrame(topOnly bool) styles.Sides[int]
- func (w *Window) CurMousePosPoint(gw *glfw.Window) image.Point
- func (w *Window) CursorEnterEvent(gw *glfw.Window, entered bool)
- func (w *Window) CursorPosEvent(gw *glfw.Window, x, y float64)
- func (w *Window) DeActivate()
- func (w *Window) DropEvent(gw *glfw.Window, names []string)
- func (w *Window) FbResized(gw *glfw.Window, width, height int)
- func (w *Window) FocusWindow() *Window
- func (w *Window) Focused(gw *glfw.Window, focused bool)
- func (w *Window) GetScreenOverlap() *system.Screen
- func (w *Window) Iconify(gw *glfw.Window, iconified bool)
- func (w *Window) IsVisible() bool
- func (w *Window) KeyEvent(gw *glfw.Window, ky glfw.Key, scancode int, action glfw.Action, ...)
- func (w *Window) Minimize()
- func (w *Window) MouseButtonEvent(gw *glfw.Window, button glfw.MouseButton, action glfw.Action, ...)
- func (w *Window) MousePosToPoint(x, y float64) image.Point
- func (w *Window) Moved(gw *glfw.Window, x, y int)
- func (w *Window) OnCloseReq(gw *glfw.Window)
- func (w *Window) Position(screen *system.Screen) image.Point
- func (w *Window) Raise()
- func (w *Window) Screen() *system.Screen
- func (w *Window) ScrollEvent(gw *glfw.Window, xoff, yoff float64)
- func (w *Window) SendPaintEvent()
- func (w *Window) SetCursorEnabled(enabled, raw bool)
- func (w *Window) SetGeometry(fullscreen bool, pos, size image.Point, screen *system.Screen)
- func (w *Window) SetIcon(images []image.Image)
- func (w *Window) SetMousePos(x, y float64)
- func (w *Window) SetPos(pos image.Point, screen *system.Screen)
- func (w *Window) SetSize(sz image.Point)
- func (w *Window) SetTitle(title string)
- func (w *Window) SetWinSize(sz image.Point)
- func (w *Window) Show()
- func (w *Window) WinResized(gw *glfw.Window, width, height int)
Constants ¶
This section is empty.
Variables ¶
var ( // ScreenDebug turns on various debugging statements about monitor changes // and updates from glfw. ScreenDebug = false // ScreenPollInterval is the time between checking if screens have changed. // This is primarily for detecting changes after sleep, in which case // the interval has likely been much longer than a few seconds. ScreenPollInterval = time.Second // Note: MacOS monitor situation is significantly buggy. we try to work around this. // https://github.com/glfw/glfw/issues/2160 MacOsBuiltinMonitor = "Built-in Retina Display" )
var TheApp = &App{AppMulti: base.NewAppMulti[*Window]()}
TheApp is the single system.App for the desktop platform
var TheClipboard = &Clipboard{}
TheClipboard is the single system.Clipboard for Linux
var TheCursor = &Cursor{CursorBase: system.CursorBase{Vis: true, Size: 32}, Cursors: map[enums.Enum]map[int]*glfw.Cursor{}}
TheCursor is the single system.Cursor for the desktop platform
Functions ¶
Types ¶
type App ¶
type App struct { base.AppMulti[*Window] // GPU is the system GPU used for the app GPU *gpu.GPU // Monitors are pointers to the glfw monitors corresponding to Screens. Monitors []*glfw.Monitor }
App is the system.App implementation for the desktop platform
func (*App) FindScreenInfo ¶
FindScreenInfo finds saved screen info based on name
func (*App) GetScreens ¶
func (a *App) GetScreens()
func (*App) InitGPU ¶ added in v0.3.2
func (a *App) InitGPU()
InitGPU initializes glfw, gpu, and the screens.
func (*App) MainLoop ¶
func (a *App) MainLoop()
MainLoop starts running event loop on main thread (must be called from the main thread).
func (*App) MonitorChange ¶
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) PollScreenChanges ¶ added in v0.3.6
func (a *App) PollScreenChanges()
func (*App) SaveScreenInfo ¶
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 ¶
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 Cursor ¶
type Cursor struct { system.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
type Window ¶
type Window struct { base.WindowMulti[*App, *gpudraw.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 system.Window for the desktop platform.
func (*Window) Activate ¶
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 system.TheApp.RunOnMain
system.TheApp.RunOnMain(func() { if !win.Activate() { return } // do GPU calls here })
func (*Window) ConstrainFrame ¶ added in v0.3.6
func (*Window) DeActivate ¶
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 system.TheApp.RunOnMain
func (*Window) FocusWindow ¶
func (*Window) GetScreenOverlap ¶
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) KeyEvent ¶
func (w *Window) KeyEvent(gw *glfw.Window, ky glfw.Key, scancode int, action glfw.Action, mod glfw.ModifierKey)
physical key
func (*Window) MouseButtonEvent ¶
func (w *Window) MouseButtonEvent(gw *glfw.Window, button glfw.MouseButton, action glfw.Action, mod glfw.ModifierKey)
func (*Window) OnCloseReq ¶
func (*Window) SendPaintEvent ¶ added in v0.3.6
func (w *Window) SendPaintEvent()