-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
board.go
55 lines (49 loc) · 1.19 KB
/
board.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
package board
import (
"context"
"image"
"image/draw"
"net/http"
)
// HTTPHandler is the type returned to the sportsmatrix for HTTP endpoints
type HTTPHandler struct {
Handler func(http.ResponseWriter, *http.Request)
Path string
}
// Enabler is an interface for basic Enable/Disable functions
type Enabler interface {
Enabled() bool
Enable() bool
Disable() bool
Store(bool) bool
SetStateChangeCallback(func())
}
// Board is the interface to implement for displaying on the matrix
type Board interface {
Name() string
Render(ctx context.Context, canvases Canvas) error
ScrollRender(ctx context.Context, canvas Canvas, padding int) (Canvas, error)
GetHTTPHandlers() ([]*HTTPHandler, error)
ScrollMode() bool
GetRPCHandler() (string, http.Handler)
InBetween() bool
Enabler() Enabler
}
// Canvas ...
type Canvas interface {
image.Image
draw.Image
Enabler
Name() string
Clear() error
Render(ctx context.Context) error
GetHTTPHandlers() ([]*HTTPHandler, error)
Close() error
Scrollable() bool
AlwaysRender() bool
SetWidth(int)
GetWidth() int
}
// StateChangeNotifier is a func that an Enabler uses to notify when its
// enabled/disabled state changes
type StateChangeNotifier func()