-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol.go
More file actions
43 lines (36 loc) · 1.1 KB
/
control.go
File metadata and controls
43 lines (36 loc) · 1.1 KB
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
package main
import (
"github.com/gen2brain/iup-go/iup"
)
const controlButtonSize = "100x"
func enabledDisabled(boolean bool) string {
if boolean {
return "Disable"
}
return "Enable"
}
func enableDisableCallback(ih iup.Ihandle) int {
changeState()
return iup.DEFAULT
}
func forceUpdateCallback(ih iup.Ihandle) int {
updatePresence(true)
return iup.DEFAULT
}
func forceReconnectCallback(ih iup.Ihandle) int {
reconnect()
return iup.DEFAULT
}
func controlFrame() iup.Ihandle {
return iup.Frame(
iup.Hbox(
iup.Vbox(
iup.Button(enabledDisabled(config.state)).SetAttribute("SIZE", controlButtonSize).SetCallback("ACTION", iup.ActionFunc(enableDisableCallback)).SetHandle("controlButton"),
iup.Button("Force Update").SetAttribute("SIZE", controlButtonSize).SetCallback("ACTION", iup.ActionFunc(forceUpdateCallback)).SetHandle("forceUpdateButton"),
iup.Button("Force Reconnect").SetAttribute("SIZE", controlButtonSize).SetCallback("ACTION", iup.ActionFunc(forceReconnectCallback)).SetHandle("forceReconnectButton"),
iup.Fill(),
),
iup.Fill(),
),
).SetAttributes("TITLE=Controls")
}