Sfoglia il codice sorgente

moving down to the bar hides an open control center

Milan Jurkulak 3 mesi fa
parent
commit
063778e8ce

+ 7 - 1
shared/src/desktopMain/kotlin/org/mjdev/desktop/state/DesktopState.kt

@@ -51,6 +51,7 @@ class DesktopState(
     // facts about the world
     // facts about the world
     private var barOverlapped = false
     private var barOverlapped = false
     private var pointerInBarZone = false
     private var pointerInBarZone = false
+    private var pointerWasInBarZone = false
     private var pointerWasInCcHotspot = false
     private var pointerWasInCcHotspot = false
 
 
     fun register(
     fun register(
@@ -82,10 +83,15 @@ class DesktopState(
         if (inCcHotspot && !pointerWasInCcHotspot) controlCenterOpen = true
         if (inCcHotspot && !pointerWasInCcHotspot) controlCenterOpen = true
         pointerWasInCcHotspot = inCcHotspot
         pointerWasInCcHotspot = inCcHotspot
         // the bar's zone = the bar itself plus its bottom reveal strip; only matters when overlapped
         // the bar's zone = the bar itself plus its bottom reveal strip; only matters when overlapped
-        pointerInBarZone =
+        val inBarZone =
             surfaces[SurfaceKind.Bar]?.let { bar ->
             surfaces[SurfaceKind.Bar]?.let { bar ->
                 bar.bounds().contains(px, py) || bar.revealHotspot()?.contains(px, py) == true
                 bar.bounds().contains(px, py) || bar.revealHotspot()?.contains(px, py) == true
             } ?: false
             } ?: false
+        // moving down to the bar while the control center is open hides the control center and
+        // brings the bar back (edge-triggered so it only fires on entering the zone).
+        if (inBarZone && !pointerWasInBarZone && controlCenterOpen) controlCenterOpen = false
+        pointerInBarZone = inBarZone
+        pointerWasInBarZone = inBarZone
         reconcile()
         reconcile()
     }
     }