forked from 0x61726b/electron-vibrancy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
69 lines (58 loc) · 1.83 KB
/
index.js
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
var Vibrancy = require('bindings')('Vibrancy')
module.exports = require('bindings')('Vibrancy')
function AddView (buffer, options) {
var viewOptions = {
Material: options.Material,
Position: { x: options.X, y: options.Y},
Size: { width: options.Width, height: options.Height},
BorderRadius: options.borderRadius,
ResizeMask: options.ResizeMask
}
return Vibrancy.AddView(buffer, viewOptions)
}
function RemoveView (buffer, viewId) {
var viewOptions = { ViewId: (viewId) }
return Vibrancy.RemoveView(buffer, viewOptions)
}
function UpdateView (buffer, options) {
var viewOptions = {
Material: options.Material,
Position: { x: options.X, y: options.Y},
Size: { width: options.Width, height: options.Height},
ViewId: options.ViewId
}
return Vibrancy.UpdateView(buffer, viewOptions)
}
function DisableVibrancy (buffer) {
Vibrancy.SetVibrancy(false, buffer)
}
module.exports = {
SetVibrancy: function (window, material) {
if (window == null) { return -1 }
var width = window.getSize()[0]
var height = window.getSize()[1]
if (material === null || typeof material === 'undefined') { material = 0 }
var resizeMask = 2 // auto resize on both axis
var viewOptions = {
Material: material,
Width: width,
Height: height,
X: 0,
Y: 0,
ResizeMask: resizeMask
}
return AddView(window.getNativeWindowHandle(), viewOptions)
},
AddView: function (window, options) {
return AddView(window.getNativeWindowHandle(), options)
},
UpdateView: function (window, options) {
return UpdateView(window.getNativeWindowHandle(), options)
},
RemoveView: function (window, viewId) {
return RemoveView(window.getNativeWindowHandle(), viewId)
},
DisableVibrancy: function (window) {
return DisableVibrancy(window.getNativeWindowHandle())
}
}