ui: Rename IsForeground -> IsFocused

Updates #1102
This commit is contained in:
Hajime Hoshi 2020-03-21 00:08:40 +09:00
parent 4ef3b3e804
commit 56358fd0c4
6 changed files with 18 additions and 18 deletions

View File

@ -287,7 +287,7 @@ func (g *game) Update(screen *ebiten.Image) error {
msgR = "Press R key to switch the window resizable state (only for desktops)\n"
}
fg := "Yes"
if !ebiten.IsForeground() {
if !ebiten.IsFocused() {
fg = "No"
}
@ -302,7 +302,7 @@ Press T key to switch TPS (ticks per second)
Press D key to switch the window decoration (only for desktops)
Press L key to switch the window floating state (only for desktops)
%s
IsForeground?: %s
IsFocused?: %s
Windows Position: (%d, %d)
Cursor: (%d, %d)
TPS: Current: %0.2f / Max: %s

View File

@ -37,7 +37,7 @@ type UI interface {
DeviceScaleFactor() float64
CursorMode() CursorMode
IsFullscreen() bool
IsForeground() bool
IsFocused() bool
IsRunnableInBackground() bool
IsVsyncEnabled() bool
ScreenSizeInFullscreen() (int, int)

View File

@ -416,17 +416,17 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
u.setWindowSize(w, h, fullscreen, u.vsync)
}
func (u *UserInterface) IsForeground() bool {
func (u *UserInterface) IsFocused() bool {
if !u.isRunning() {
return false
}
var foreground bool
var focused bool
_ = u.t.Call(func() error {
foreground = u.window.GetAttrib(glfw.Focused) == glfw.True
focused = u.window.GetAttrib(glfw.Focused) == glfw.True
return nil
})
return foreground
return focused
}
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {

View File

@ -76,8 +76,8 @@ func (u *UserInterface) IsFullscreen() bool {
return false
}
func (u *UserInterface) IsForeground() bool {
return u.isForeground()
func (u *UserInterface) IsFocused() bool {
return u.isFocused()
}
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
@ -145,10 +145,10 @@ func (u *UserInterface) suspended() bool {
if u.runnableInBackground {
return false
}
return !u.isForeground()
return !u.isFocused()
}
func (u *UserInterface) isForeground() bool {
func (u *UserInterface) isFocused() bool {
if !document.Call("hasFocus").Bool() {
return false
}

View File

@ -74,7 +74,7 @@ func (u *UserInterface) Update() error {
default:
}
if !u.IsForeground() {
if !u.IsFocused() {
return nil
}
@ -398,7 +398,7 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
// Do nothing
}
func (u *UserInterface) IsForeground() bool {
func (u *UserInterface) IsFocused() bool {
u.m.Lock()
fg := u.foreground
u.m.Unlock()

10
run.go
View File

@ -359,14 +359,14 @@ func SetFullscreen(fullscreen bool) {
uiDriver().SetFullscreen(fullscreen)
}
// IsForeground returns a boolean value indicating whether
// IsFocused returns a boolean value indicating whether
// the game is in focus or in the foreground.
//
// IsForeground will only return true if IsRunnableInBackground is false.
// IsFocused will only return true if IsRunnableInBackground is false.
//
// IsForeground is concurrent-safe.
func IsForeground() bool {
return uiDriver().IsForeground()
// IsFocused is concurrent-safe.
func IsFocused() bool {
return uiDriver().IsFocused()
}
// IsRunnableInBackground returns a boolean value indicating whether