mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 13:07:26 +01:00
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package cocoa
|
|
|
|
import (
|
|
"github.com/hajimehoshi/go-ebiten/ui"
|
|
)
|
|
|
|
type uiEvents struct {
|
|
screenSizeUpdated chan ui.ScreenSizeUpdatedEvent // initialized lazily
|
|
inputStateUpdated chan ui.InputStateUpdatedEvent // initialized lazily
|
|
}
|
|
|
|
func (u *uiEvents) ScreenSizeUpdated() <-chan ui.ScreenSizeUpdatedEvent {
|
|
if u.screenSizeUpdated != nil {
|
|
return u.screenSizeUpdated
|
|
}
|
|
u.screenSizeUpdated = make(chan ui.ScreenSizeUpdatedEvent)
|
|
return u.screenSizeUpdated
|
|
}
|
|
|
|
func (u *uiEvents) notifyScreenSizeUpdated(e ui.ScreenSizeUpdatedEvent) {
|
|
if u.screenSizeUpdated == nil {
|
|
return
|
|
}
|
|
go func() {
|
|
u.screenSizeUpdated <- e
|
|
}()
|
|
}
|
|
|
|
func (u *uiEvents) InputStateUpdated() <-chan ui.InputStateUpdatedEvent {
|
|
if u.inputStateUpdated != nil {
|
|
return u.inputStateUpdated
|
|
}
|
|
u.inputStateUpdated = make(chan ui.InputStateUpdatedEvent)
|
|
return u.inputStateUpdated
|
|
}
|
|
|
|
func (u *uiEvents) notifyInputStateUpdated(e ui.InputStateUpdatedEvent) {
|
|
if u.inputStateUpdated == nil {
|
|
return
|
|
}
|
|
go func() {
|
|
u.inputStateUpdated <- e
|
|
}()
|
|
}
|