This repository was 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 pathwindow.go
73 lines (60 loc) · 2.27 KB
/
window.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
61
62
63
64
65
66
67
68
69
70
71
72
73
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"
import "unsafe"
// Window wraps the underlying struct
type Window struct {
w C.ULWindow
}
// CreateWindow creates a new Window with the specified size (in device coordinates)
func CreateWindow(m *Monitor, width, height uint, isTransparent bool, windowType WindowFlag) *Window {
return &Window{C.ulCreateWindow(m.m, C.uint(width), C.uint(height), C.bool(isTransparent), C.uint(windowType))}
}
// Destroy deletes the Window instance
func (win *Window) Destroy() {
C.ulDestroyWindow(win.w)
}
// GetWidth returns the width of the Window instance (in device coordinates)
func (win *Window) GetWidth() uint {
return uint(C.ulWindowGetWidth(win.w))
}
// GetHeight returns the height of the Window instance (in device coordinates)
func (win *Window) GetHeight() uint {
return uint(C.ulWindowGetHeight(win.w))
}
// IsFullscreen returns whether the Window is fullscreen
func (win *Window) IsFullscreen() bool {
return bool(C.ulWindowIsFullscreen(win.w))
}
// GetScale returns the DPI scale of the Window as a percentage
func (win *Window) GetScale() float64 {
return float64(C.ulWindowGetScale(win.w))
}
// SetTitle sets the title of the Window instance
func (win *Window) SetTitle(title string) {
cTitle := C.CString(title)
defer C.free(unsafe.Pointer(cTitle))
C.ulWindowSetTitle(win.w, cTitle)
}
// SetCursor sets the cursor for the Window instance
func (win *Window) SetCursor(cursor Cursor) {
C.ulWindowSetCursor(win.w, C.ULCursor(cursor))
}
// Close closes the Window
func (win *Window) Close() {
C.ulWindowClose(win.w)
}
// DeviceToPixel converts device coordinates to pixels using the current
// DPI scale
func (win *Window) DeviceToPixel(value int) int {
return int(C.ulWindowDeviceToPixel(win.w, C.int(value)))
}
// PixelsToDevice converts pixels to device coordinates using the current
// DPI scale
func (win *Window) PixelsToDevice(value int) int {
return int(C.ulWindowPixelsToDevice(win.w, C.int(value)))
}