forked from dennwc/inkview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.go
73 lines (57 loc) · 1.43 KB
/
ui.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 ink
/*
#include "inkview.h"
#cgo CFLAGS: -pthread
#cgo LDFLAGS: -pthread -lpthread -linkview
*/
import "C"
import (
"fmt"
"image"
"time"
)
var DefaultDelay = time.Second
type Icon int
const (
Info = Icon(C.ICON_INFORMATION)
Question = Icon(C.ICON_QUESTION)
Warning = Icon(C.ICON_WARNING)
Error = Icon(C.ICON_ERROR)
)
func Message(icon Icon, title, text string, dt time.Duration) {
if dt == 0 {
dt = DefaultDelay
}
// void Message(int icon, const char *title, const char *text, int timeout);
C.Message(C.int(icon), C.CString(title), C.CString(text), C.int(dt/time.Millisecond))
}
func messagef(icon Icon, title, def, format string, args ...interface{}) {
if title == "" {
title = def
}
Message(icon, title, fmt.Sprintf(format, args...), 0)
}
func Infof(title, format string, args ...interface{}) {
messagef(Info, title, "Info", format, args...)
}
func Questionf(title, format string, args ...interface{}) {
messagef(Question, title, "Question", format, args...)
}
func Warningf(title, format string, args ...interface{}) {
messagef(Warning, title, "Warning", format, args...)
}
func Errorf(title, format string, args ...interface{}) {
messagef(Error, title, "Error", format, args...)
}
func ShowHourglass() {
C.ShowHourglass()
}
func ShowHourglassAt(p image.Point) {
C.ShowHourglassAt(C.int(p.X), C.int(p.Y))
}
func HideHourglass() {
C.HideHourglass()
}
func DisableExitHourglass() {
C.DisableExitHourglass()
}