forked from Grivel-l/CustomBar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
window.go
64 lines (54 loc) · 1.84 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
package main
import "C"
import (
"fmt"
"strconv"
"unsafe"
"github.com/jakejarrett/CustomBar/structs"
"github.com/BurntSushi/xgbutil"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/widgets"
)
//export updateMargin
func updateMargin(layoutP unsafe.Pointer, size int) {
var layout *widgets.QHBoxLayout
layout = (*widgets.QHBoxLayout)(layoutP)
layout.SetContentsMargins(0, 0, size, 0)
}
func initWindow(config structs.GeneralConfig, widget *widgets.QWidget) {
widget.SetMinimumSize2(config.Width, config.Height)
widget.SetMaximumSize2(config.Width, config.Height)
widget.SetAttribute(core.Qt__WA_X11NetWmWindowTypeDock, true)
widget.SetAttribute(core.Qt__WA_TranslucentBackground, config.Opacity < 100)
widget.SetStyleSheet(fmt.Sprintf("background-color: rgba(0, 0, 0, %s)", strconv.Itoa(int(config.Opacity*255/100))))
fmt.Printf("Stylesheet: %v\n\n\n", widget.StyleSheet())
}
func createLayout(widget *widgets.QWidget, xutil *xgbutil.XUtil, config structs.GeneralConfig) error {
var err error
var grid *widgets.QHBoxLayout
var box [3]*widgets.QHBoxLayout
if err != nil {
return err
}
grid = widgets.NewQHBoxLayout()
grid.SetContentsMargins(0, 0, 0, 0)
grid.SetSpacing(0)
box[0] = widgets.NewQHBoxLayout()
box[0].SetSpacing(0)
box[1] = widgets.NewQHBoxLayout()
box[2] = widgets.NewQHBoxLayout()
box[0].AddWidget(texts["launcher"], 0, 0)
box[0].AddWidget(widgets.NewQWidget(nil, 0), 1, 0)
box[1].AddWidget(texts["time"], 0, 0)
box[2].AddWidget(widgets.NewQWidget(nil, 0), 1, 0)
box[2].AddWidget(texts["audio"], 0, 0)
texts["audio"].SetContentsMargins(10, 0, 10, 0)
grid.AddLayout(box[0], 1)
grid.AddLayout(box[1], 1)
grid.AddLayout(box[2], 1)
grid.SetAlignment2(box[0], core.Qt__AlignLeft)
grid.SetAlignment2(box[2], core.Qt__AlignRight)
widget.SetLayout(grid)
widget.SetLayoutDirection(core.Qt__LeftToRight)
return nil
}