This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.go
60 lines (49 loc) · 1.56 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package ultralight
// #cgo CPPFLAGS: -I"./SDK/include"
// #cgo windows LDFLAGS: -L'./SDK/lib' -lUltralight -lUltralightCore -lWebCore -lAppCore
// #cgo linux LDFLAGS: -L'./SDK/bin' -lUltralight -lUltralightCore -lWebCore -lAppCore -Wl,-rpath,.
// #cgo darwin LDFLAGS: -L'./SDK/bin' -lUltralight -lUltralightCore -lWebCore -lAppCore -Wl,-rpath,.
// #include <ultralight.h>
import "C"
// App wraps the underlying App struct
type App struct {
a C.ULApp
}
// CreateApp creates an App instance (create only one per application lifetime)
func CreateApp(settings *Settings, conf *Config) *App {
return &App{C.ulCreateApp(settings.s, conf.c)}
}
// Destroy deletes the App instance
func (a *App) Destroy() {
C.ulDestroyApp(a.a)
}
// SetWindow sets the main window. This must be called before
// App.Run()
func (a *App) SetWindow(win *Window) {
C.ulAppSetWindow(a.a, win.w)
}
// GetWindow returns the main Window
func (a *App) GetWindow() *Window {
return &Window{C.ulAppGetWindow(a.a)}
}
// IsRunning returns whether the App is running
func (a *App) IsRunning() bool {
return bool(C.ulAppIsRunning(a.a))
}
// GetMainMonitor returns the main Monitor instance
func (a *App) GetMainMonitor() *Monitor {
return &Monitor{C.ulAppGetMainMonitor(a.a)}
}
// GetRenderer returns the underlying Renderer instance
func (a *App) GetRenderer() *Renderer {
return &Renderer{C.ulAppGetRenderer(a.a)}
}
// Run executes the main loop. Ensure App.SetWindow() has been called
// prior to calling
func (a *App) Run() {
C.ulAppRun(a.a)
}
// Quit exits the application
func (a *App) Quit() {
C.ulAppQuit(a.a)
}