mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-11 00:12:24 +01:00
car: the card column only moves the map's center, so Vela's speedometer keeps its size
This commit is contained in:
1 parent
f414a3c2c8
commit
de01448f1b
2 files changed
+12
-3
No files matched your search
@@ -102,10 +102,18 @@ private fun AppSurface(
|
||||
// changing size moves the visible area even though the surface itself hasn't changed.
|
||||
val (width, height) = size
|
||||
val measured = bounds?.takeIf { width > 0 && height > 0 }?.let { cover?.visibleWithin(it, width, height) }
|
||||
LaunchedEffect(template, size, measured) {
|
||||
// The card column moves the map's centre but isn't taken out of the stable area: apps size
|
||||
// their own overlays from it, and Vela's speedometer shrank to fit the strip right of the cards.
|
||||
val measuredStable = bounds?.takeIf { width > 0 && height > 0 }?.let { cover?.visibleWithin(it, width, height, skip = CoverEdge.START) }
|
||||
LaunchedEffect(template, size, measured, measuredStable) {
|
||||
if (width > 0 && height > 0) {
|
||||
val visible = visibleAreaFor(template, width, height, measured)
|
||||
connection.reportAreas(visible = visible, stable = visible)
|
||||
val stable = if (template is androidx.car.app.navigation.model.NavigationTemplate) {
|
||||
visibleAreaFor(template, width, height, measuredStable)
|
||||
} else {
|
||||
visible
|
||||
}
|
||||
connection.reportAreas(visible = visible, stable = stable)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,12 +129,13 @@ internal class ChromeCover {
|
||||
}
|
||||
|
||||
/** What is left of a [width] x [height] surface at [surface] (window pixels), in surface pixels. */
|
||||
fun visibleWithin(surface: ComposeRect, width: Int, height: Int): Rect {
|
||||
fun visibleWithin(surface: ComposeRect, width: Int, height: Int, skip: CoverEdge? = null): Rect {
|
||||
var left = 0f
|
||||
var top = 0f
|
||||
var right = width.toFloat()
|
||||
var bottom = height.toFloat()
|
||||
pieces.values.forEach { (edge, b) ->
|
||||
if (edge == skip) return@forEach
|
||||
when (edge) {
|
||||
CoverEdge.TOP -> top = maxOf(top, b.bottom - surface.top)
|
||||
CoverEdge.BOTTOM -> bottom = minOf(bottom, b.top - surface.top)
|
||||
|
||||
Reference in new issue
Block a user