diff --git a/gui/sdlimgui/manager.go b/gui/sdlimgui/manager.go index b493400b..54a2a74e 100644 --- a/gui/sdlimgui/manager.go +++ b/gui/sdlimgui/manager.go @@ -73,8 +73,8 @@ type manager struct { // proxy value screenPos imgui.Vec2 - // is true if mouse is not over any of the playmode windows - playmodeHover bool + // is true if mouse over any of the playmode windows + playmodeWindowHover bool // for convenience the dbgScr window gets it's own field // @@ -152,13 +152,13 @@ func (wm *manager) draw() { case govern.ModePlay: // reset playmodeHover flag by default. it's only ever true if a window is open (and that // window is being hovered over) - wm.playmodeHover = false + wm.playmodeWindowHover = false // playmode draws the screen and other windows that have been listed // as being safe to draw in playmode for _, w := range wm.playmodeWindows { _ = w.playmodeDraw() - wm.playmodeHover = wm.playmodeHover || imgui.IsWindowHoveredV(imgui.HoveredFlagsAnyWindow) + wm.playmodeWindowHover = wm.playmodeWindowHover || w.playmodeGeometry().hovered } case govern.ModeDebugger: // see commentary for screenPos in windowManager declaration diff --git a/gui/sdlimgui/manager_window.go b/gui/sdlimgui/manager_window.go index 3fcfaa77..f2ba3bda 100644 --- a/gui/sdlimgui/manager_window.go +++ b/gui/sdlimgui/manager_window.go @@ -32,9 +32,11 @@ type window interface { id() string } -// size and position of the window. is embedded in playmodeWin and debuggerWin -// interfaces. for window type that implent interfaces then windowGeom -// method calls will need to disambiguate which geometry to use +// information about the window, including window geometry +// +// is embedded in playmodeWin and debuggerWin interfaces. for window type that +// implent interfaces then windowGeom method calls will need to disambiguate +// which geometry to use type windowGeom struct { position imgui.Vec2 size imgui.Vec2 @@ -42,6 +44,9 @@ type windowGeom struct { // whether the window is focused focused bool + // whether the window is hovered over with the mouse + hovered bool + // whether the window should be raised on the next draw raise bool @@ -54,6 +59,7 @@ func (g *windowGeom) update() { g.position = imgui.WindowPos() g.size = imgui.WindowSize() g.focused = imgui.IsWindowFocused() + g.hovered = imgui.IsWindowHovered() } type playmodeWindow interface { diff --git a/gui/sdlimgui/service.go b/gui/sdlimgui/service.go index 6cc2f134..f4268dbf 100644 --- a/gui/sdlimgui/service.go +++ b/gui/sdlimgui/service.go @@ -174,7 +174,7 @@ func (img *SdlImgui) Service() { } } else if img.isPlaymode() { // set mouse capture if mouse is not over a window - if !img.wm.playmodeHover { + if !img.wm.playmodeWindowHover { img.setCapture(true) } }