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 pathoverlay.go
94 lines (77 loc) · 2.72 KB
/
overlay.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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"
// Overlay wraps the underlying struct
type Overlay struct {
o C.ULOverlay
}
// CreateOverlay creates a new Overlay instance with the specified width and
// height (in device coordinates) at the offset (x,y) from the top-left
// corner of the Window instance
func CreateOverlay(win *Window, width, height uint, x, y int) *Overlay {
return &Overlay{C.ulCreateOverlay(win.w, C.uint(width), C.uint(height), C.int(x), C.int(y))}
}
// Destroy deletes the Overlay instance
func (ol *Overlay) Destroy() {
C.ulDestroyOverlay(ol.o)
}
// GetView returns the underlying View instance
func (ol *Overlay) GetView() *View {
return &View{C.ulOverlayGetView(ol.o)}
}
// GetWidth returns the width of the Overlay (in device coordinates)
func (ol *Overlay) GetWidth() uint {
return uint(C.ulOverlayGetWidth(ol.o))
}
// GetHeight returns the height of the Overlay (in device coordinates)
func (ol *Overlay) GetHeight() uint {
return uint(C.ulOverlayGetHeight(ol.o))
}
// GetX returns the horizontal offset of the Overlay relative
// to it's Window (in device coordinates)
func (ol *Overlay) GetX() int {
return int(C.ulOverlayGetX(ol.o))
}
// GetY returns the vertical offset of the Overlay relative
// to it's Window (in device coordinates)
func (ol *Overlay) GetY() int {
return int(C.ulOverlayGetY(ol.o))
}
// MoveTo moves the Overlay to the specified (x,y) position
// (in device coordinates)
func (ol *Overlay) MoveTo(x, y int) {
C.ulOverlayMoveTo(ol.o, C.int(x), C.int(y))
}
// Resize sets the size of the Overlay and it's
// underlying View to the specified dimensions (in device coordinates)
func (ol *Overlay) Resize(width, height uint) {
C.ulOverlayResize(ol.o, C.uint(width), C.uint(height))
}
// IsHidden returns whether the Overlay is hidden or drawn
func (ol *Overlay) IsHidden() bool {
return bool(C.ulOverlayIsHidden(ol.o))
}
// Hide stops the Overlay from being drawn
func (ol *Overlay) Hide() {
C.ulOverlayHide(ol.o)
}
// Show draws the Overlay instance
func (ol *Overlay) Show() {
C.ulOverlayShow(ol.o)
}
// HasFocus returns whether the Overlay has keyboard focus
func (ol *Overlay) HasFocus() bool {
return bool(C.ulOverlayHasFocus(ol.o))
}
// Focus grants the Overlay exclusive keyboard focus
func (ol *Overlay) Focus() {
C.ulOverlayFocus(ol.o)
}
// Unfocus revokes exclusive keyboard focus from the Overlay
func (ol *Overlay) Unfocus() {
C.ulOverlayUnfocus(ol.o)
}