/
label_test.go
155 lines (128 loc) · 3.78 KB
/
label_test.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package ui
import (
"fmt"
"image"
"image/color"
"testing"
"time"
"github.com/usedbytes/s4548"
"github.com/usedbytes/fonts"
)
//import _ "image/png"
func TestAlign(t *testing.T) {
//screen := s4548.NewS4548("/dev/s4548-0")
screen := s4548.NewS4548(s4548.GetS4548EnvPath())
font := fonts.NewFontFromFile("/home/kernelcode/tiny_font.fnt")
fmt.Println("Font Loaded")
short:= NewLabel(nil, font)
short.AutoWidth = false
short.AutoHeight = false
short.SetWidth(101)
short.SetHeight(40)
short.VAlign = Middle
short.HAlign = Centre
short.Text = "Short"
short.Background = color.Black
short.Foreground = color.White
for i := 0; i < 3; i++ {
switch i {
case 0:
short.VAlign = Top
case 1:
short.VAlign = Middle
case 2:
short.VAlign = Bottom
}
for j := 0; j < 3; j++ {
switch j {
case 0:
short.HAlign = Left
case 1:
short.HAlign = Centre
case 2:
short.HAlign = Right
}
time.Sleep(500 * time.Millisecond)
short.Update()
short.Draw(screen)
screen.Scanout()
}
}
screen.Close()
time.Sleep(1000 * time.Millisecond)
/*
for {v
l.Update()
l.Draw(screen)
l.Text = "Today I learned that writing word wrapping for the second time was still around 100,000,000 times harder than I was expecting"
l.Widget.AutoWidth = true
//l.SetWidth(101)
l.SetPos(image.Point{0,0})
l.Update()
l.Draw(screen)
screen.Scanout()
time.Sleep(300 * time.Millisecond)
}
*/
}
func TestHorizontal(t *testing.T) {
//screen := s4548.NewS4548("/dev/s4548-0")
screen := s4548.NewS4548(s4548.GetS4548EnvPath())
font := fonts.NewFontFromFile("/home/kernelcode/tiny_font.fnt")
fmt.Println("Font Loaded")
longLine := NewLabel(nil, font)
longLine.AutoWidth = false
longLine.AutoHeight = true
longLine.Wrap = false
longLine.Scroll = false
longLine.SetWidth(80)
longLine.SetPos(image.Point{10, 8})
longLine.VAlign = Middle
longLine.HAlign = Centre
longLine.Text = "Lazee ft. Neverstore - Hold On (Matrix & Futurebound Remix)"
longLine.Update()
longLine.Draw(screen)
screen.Scanout()
time.Sleep(1000 * time.Millisecond)
longLine.Scroll = true
longLine.Active = true
for i := 0; i < 50; i++ {
longLine.Update()
longLine.Draw(screen)
screen.Scanout()
time.Sleep(200 * time.Millisecond)
}
screen.Close()
time.Sleep(1000 * time.Millisecond)
}
func TestVertical(t *testing.T) {
//screen := s4548.NewS4548("/dev/s4548-0")
screen := s4548.NewS4548(s4548.GetS4548EnvPath())
font := fonts.NewFontFromFile("/home/kernelcode/tiny_font.fnt")
fmt.Println("Font Loaded")
multiLine := NewLabel(nil, font)
multiLine.AutoWidth = false
multiLine.AutoHeight = false
multiLine.Wrap = true
multiLine.Scroll = false
multiLine.SetWidth(101)
multiLine.SetHeight(40)
multiLine.SetPos(image.Point{0, 0})
multiLine.VAlign = Middle
multiLine.HAlign = Centre
multiLine.Text = "Once upon a time in a galaxy far away... STAR WARS The evil galactic empire have taken over hundreds of systems"
multiLine.Update()
multiLine.Draw(screen)
screen.Scanout()
time.Sleep(5000 * time.Millisecond)
multiLine.Scroll = true
multiLine.Active = true
for i := 0; i < 20; i++ {
multiLine.Update()
multiLine.Draw(screen)
screen.Scanout()
time.Sleep(300 * time.Millisecond)
}
screen.Close()
time.Sleep(5000 * time.Millisecond)
}