diff options
| author | faiface <faiface@ksp.sk> | 2017-09-01 21:50:48 +0200 |
|---|---|---|
| committer | faiface <faiface@ksp.sk> | 2017-09-01 21:50:48 +0200 |
| commit | f3916a01581c66961c8e70f79f77c0520bc5a66d (patch) | |
| tree | 789c1c86b8a8afd9061e257537b8302901ca9e04 | |
| parent | 7efcefe0d6bf828fcdff81a4e75694d1f3d45a94 (diff) | |
| download | gui-f3916a01581c66961c8e70f79f77c0520bc5a66d.zip | |
layout: simplify the interface even furthur
| -rw-r--r-- | layout/interface.go | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/layout/interface.go b/layout/interface.go index d203c3f..28b6a01 100644 --- a/layout/interface.go +++ b/layout/interface.go @@ -7,24 +7,17 @@ import ( ) type EventDrawer interface { - Event() <-chan EventConsume - Draw(func(draw.Image) image.Rectangle) -} - -type EventConsume struct { - Event - Consume chan<- bool + Event() <-chan Event + Draw() chan<- func(draw.Image) image.Rectangle } type Event string +func Eventf(format string, a ...interface{}) Event { + return Event(fmt.Sprintf(format, a...)) +} + func (e Event) Matches(format string, a ...interface{}) bool { _, err := fmt.Sscanf(string(e), format, a...) return err == nil } - -func SendEvent(ch chan<- EventConsume, format string, a ...interface{}) (consume <-chan bool) { - cons := make(chan bool) - ch <- EventConsume{Event(fmt.Sprintf(format, a...)), cons} - return cons -} |