2013-12-10 14:12:39 +01:00
|
|
|
package cocoa
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hajimehoshi/go-ebiten/ui"
|
|
|
|
)
|
|
|
|
|
|
|
|
type windowEvents struct {
|
|
|
|
screenSizeUpdated chan ui.ScreenSizeUpdatedEvent // initialized lazily
|
2013-12-15 15:41:33 +01:00
|
|
|
mouseStateUpdated chan ui.MouseStateUpdatedEvent // initialized lazily
|
2013-12-12 16:31:00 +01:00
|
|
|
windowClosed chan ui.WindowClosedEvent // initialized lazily
|
2013-12-10 14:12:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (w *windowEvents) ScreenSizeUpdated() <-chan ui.ScreenSizeUpdatedEvent {
|
|
|
|
if w.screenSizeUpdated != nil {
|
|
|
|
return w.screenSizeUpdated
|
|
|
|
}
|
|
|
|
w.screenSizeUpdated = make(chan ui.ScreenSizeUpdatedEvent)
|
|
|
|
return w.screenSizeUpdated
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *windowEvents) notifyScreenSizeUpdated(e ui.ScreenSizeUpdatedEvent) {
|
|
|
|
if w.screenSizeUpdated == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
go func() {
|
|
|
|
w.screenSizeUpdated <- e
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
2013-12-15 15:41:33 +01:00
|
|
|
func (w *windowEvents) MouseStateUpdated() <-chan ui.MouseStateUpdatedEvent {
|
|
|
|
if w.mouseStateUpdated != nil {
|
|
|
|
return w.mouseStateUpdated
|
2013-12-10 14:12:39 +01:00
|
|
|
}
|
2013-12-15 15:41:33 +01:00
|
|
|
w.mouseStateUpdated = make(chan ui.MouseStateUpdatedEvent)
|
|
|
|
return w.mouseStateUpdated
|
2013-12-10 14:12:39 +01:00
|
|
|
}
|
|
|
|
|
2013-12-15 15:41:33 +01:00
|
|
|
func (w *windowEvents) notifyInputStateUpdated(e ui.MouseStateUpdatedEvent) {
|
|
|
|
if w.mouseStateUpdated == nil {
|
2013-12-10 14:12:39 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
go func() {
|
2013-12-15 15:41:33 +01:00
|
|
|
w.mouseStateUpdated <- e
|
2013-12-10 14:12:39 +01:00
|
|
|
}()
|
|
|
|
}
|
2013-12-10 16:49:30 +01:00
|
|
|
|
|
|
|
func (w *windowEvents) WindowClosed() <-chan ui.WindowClosedEvent {
|
|
|
|
if w.windowClosed != nil {
|
|
|
|
return w.windowClosed
|
|
|
|
}
|
|
|
|
w.windowClosed = make(chan ui.WindowClosedEvent)
|
|
|
|
return w.windowClosed
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *windowEvents) notifyWindowClosed(e ui.WindowClosedEvent) {
|
|
|
|
if w.windowClosed == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
go func() {
|
|
|
|
w.windowClosed <- e
|
|
|
|
}()
|
|
|
|
}
|