0.122.1 (versionCode 314): the Originals row never trails focus; Orbit Rush's rocks redrawn

- The Originals row scrolls itself: the focused card whole on screen at once (any running scroll
  dropped), the peek easing in over 140 ms; rapid or held presses and Reduce motion scroll at once.
  RowScrollTest checks the card is whole after every rapid press both ways.
- Asteroid Alley's rock: lumpy angular asteroids in three shapes and rotations, off-centre
  craters of different sizes, a darker rim (Paul: the round one with a dot looked wrong). The
  shield pickup is a shield shape, Double Stars two stars, the Forbidden gate three marks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 13:33:14 +00:00
co-authored by Claude Opus 5.5
parent 3379437cec
commit 7b4e82a882
7 changed files with 198 additions and 25 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ android {
applicationId = "tv.orbit.classic"
minSdk = 26
targetSdk = 36
versionCode = 313
versionName = "0.122.0-orbit-rush"
versionCode = 314
versionName = "0.122.1-smooth-row"
}
buildFeatures { compose = true }
// The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so
@@ -1,5 +1,7 @@
package tv.orbit.classic.arcade
import androidx.compose.runtime.rememberCoroutineScope
import kotlinx.coroutines.launch
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.foundation.gestures.LocalBringIntoViewSpec
@@ -280,18 +282,33 @@ private fun GameShelves(visible: List<ArcadeGame>, data: ArcadeProfileData, pick
Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) {
// Five cards fill the row; more than five (Quiz Night and the new games after it) scroll along it, each card the same
// width, the remote's focus bringing the next one into view.
// Paul, 9 November 2026: the row "cuts either end off or clips". Now: room at both ends and above and below, so the
// focused card's grow and border never touch an edge; cards a little narrower than a fifth, so the next one always
// peeks in; and the remote's focus scrolls the row smoothly so the chosen card sits fully in view with a part of its
// neighbour showing (none needed at either end).
// Paul, 9 November 2026: the row "cuts either end off or clips", then (313) "can scroll before it catches up". Room at
// both ends and above and below, so the focused card's grow and border never touch an edge; cards a little narrower
// than a fifth, so the next one peeks in. The row scrolls itself, never trailing focus: the moment a card is focused
// it is put fully on screen (any scroll still running is dropped), then the next card's peek eases in over 140 ms.
// Presses in quick succession, or a held key, and Reduce motion, scroll at once with nothing animated.
if (originals.isNotEmpty()) BoxWithConstraints(Modifier.fillMaxWidth().height(176.dp)) {
val edge = 12.dp; val gap = 10.dp
val many = originals.size > 5
val card = if (many) (maxWidth - edge * 2 - gap * 4) / 4.6f else (maxWidth - edge * 2 - gap * 4) / 5
val peek = with(LocalDensity.current) { (gap + card * .35f).toPx() }
CompositionLocalProvider(LocalBringIntoViewSpec provides remember(peek) { peekIntoView(peek) }) {
Row(Modifier.fillMaxSize().horizontalScroll(rememberScrollState()).padding(horizontal = edge, vertical = 8.dp), horizontalArrangement = Arrangement.spacedBy(gap)) {
originals.forEach { g -> OriginalCard(g, data.game(g.id), Modifier.width(card).fillMaxHeight().then(if (g == start) Modifier.focusRequester(firstCard) else Modifier), onChosen, onPlay, onMenu) }
val px = LocalDensity.current
val cardPx = with(px) { card.toPx() }; val gapPx = with(px) { gap.toPx() }; val edgePx = with(px) { edge.toPx() }; val viewPx = with(px) { maxWidth.toPx() }
val scroll = rememberScrollState()
val scope = rememberCoroutineScope()
val pacer = remember { RowPacer() }
fun focused(i: Int) {
val plan = rowScroll(i, scroll.value, cardPx, gapPx, edgePx, viewPx, gapPx + cardPx * .35f, scroll.maxValue)
val rapid = pacer.rapid(android.os.SystemClock.uptimeMillis())
pacer.job?.cancel()
pacer.job = scope.launch {
if (rapid || Motion.reduce) scroll.scrollTo(plan.target)
else { scroll.scrollTo(plan.now); scroll.animateScrollTo(plan.target, androidx.compose.animation.core.tween(140, easing = androidx.compose.animation.core.LinearOutSlowInEasing)) }
}
}
CompositionLocalProvider(LocalBringIntoViewSpec provides NoAutoScroll) {
Row(Modifier.fillMaxSize().horizontalScroll(scroll).padding(horizontal = edge, vertical = 8.dp), horizontalArrangement = Arrangement.spacedBy(gap)) {
originals.forEachIndexed { i, g -> OriginalCard(g, data.game(g.id), Modifier.width(card).fillMaxHeight().onFocusChanged { if (it.isFocused) focused(i) }
.then(if (g == start) Modifier.focusRequester(firstCard) else Modifier), onChosen, onPlay, onMenu) }
}
}
}
@@ -309,16 +326,31 @@ private fun GameShelves(visible: List<ArcadeGame>, data: ArcadeProfileData, pick
}
}
/**
* Scrolling the Originals row to a focused card: far enough that the whole card shows with [peek] pixels of the next one
* beside it, eased (Compose's own smooth scroll; a plain jump with Reduce motion). At either end the row simply stops.
*/
/** The Originals row scrolls itself ([rowScroll]); Compose's own scroll-to-focus is switched off there so the two never fight. */
@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)
internal fun peekIntoView(peek: Float): BringIntoViewSpec = object : BringIntoViewSpec {
@Suppress("DEPRECATION", "OVERRIDE_DEPRECATION")
override val scrollAnimationSpec: androidx.compose.animation.core.AnimationSpec<Float>
get() = if (Motion.reduce) androidx.compose.animation.core.snap() else androidx.compose.animation.core.tween(360, easing = androidx.compose.animation.core.FastOutSlowInEasing)
override fun calculateScrollDistance(offset: Float, size: Float, containerSize: Float): Float = peekScroll(offset, size, containerSize, peek)
internal val NoAutoScroll: BringIntoViewSpec = object : BringIntoViewSpec {
override fun calculateScrollDistance(offset: Float, size: Float, containerSize: Float): Float = 0f
}
/** Presses in quick succession (a held key repeats about every 50 ms): then the row keeps up at once instead of animating. */
internal class RowPacer {
private var last = Long.MIN_VALUE / 2
var job: kotlinx.coroutines.Job? = null
fun rapid(nowMs: Long): Boolean { val r = nowMs - last < RAPID_MS; last = nowMs; return r }
companion object { const val RAPID_MS = 220L }
}
/** Where the row scrolls for a focused card: at once to [now] (the card fully on screen), then easing on to [target] (with the peek). */
internal data class RowPlan(val now: Int, val target: Int)
/**
* The scroll for card [index] of equal cards [card] wide, [gap] apart, after [edge] padding, in a [view]-wide row at [current]
* of [max]: the card whole on screen straight away, then with [peek] of its neighbour beside it.
*/
internal fun rowScroll(index: Int, current: Int, card: Float, gap: Float, edge: Float, view: Float, peek: Float, max: Int): RowPlan {
val offset = edge + index * (card + gap) - current
fun at(p: Float) = peekScroll(offset, card, view, p).let { d -> (current + if (d > 0f) kotlin.math.ceil(d) else kotlin.math.floor(d)).toInt() }.coerceIn(0, max)
return RowPlan(at(0f), at(peek))
}
/** How far to scroll so an item from [offset] to [offset] + [size] shows whole with [peek] either side (0 when it already does). */
@@ -23,6 +23,7 @@ import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.drawscope.CanvasDrawScope
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.graphics.drawscope.rotate
import androidx.compose.ui.graphics.drawscope.scale
import androidx.compose.ui.graphics.drawscope.translate
import androidx.compose.ui.graphics.graphicsLayer
@@ -156,6 +157,34 @@ internal class RushArt(val faces: Array<ImageBitmap>, val portalSign: androidx.c
val star = Path()
val crystal = Path()
/**
* Asteroid Alley's rocks (Paul, 9 November 2026: the old round one with a dot in the middle looked like something it
* shouldn't on a family TV). Now lumpy, angular silhouettes in three shapes, each turned its own way, with craters of
* different sizes all off-centre and a darker rim, so no rock is round and no two side by side match.
*/
val rocks: Array<Path> = arrayOf(
floatArrayOf(1f, .78f, .93f, .66f, .88f, .97f, .72f, .9f, .8f),
floatArrayOf(.9f, 1f, .7f, .84f, .62f, .95f, .86f, .74f, .98f, .7f),
floatArrayOf(.82f, .96f, .64f, 1f, .78f, .9f, .68f, .92f),
).map { radii ->
Path().apply {
for (k in radii.indices) {
// Uneven steps round as well as uneven radii: angular, never a circle.
val a = (k + .35f * kotlin.math.sin(k * 2.1f)) * 6.2832f / radii.size
val x = kotlin.math.sin(a) * radii[k]; val y = -kotlin.math.cos(a) * radii[k]
if (k == 0) moveTo(x, y) else lineTo(x, y)
}
close()
}
}.toTypedArray()
/** Each shape's craters, at radius 1: x, y and size, never at the middle. */
val craters = arrayOf(
floatArrayOf(-.38f, -.22f, .2f, .3f, .28f, .13f, .42f, -.4f, .08f),
floatArrayOf(.32f, -.3f, .22f, -.42f, .3f, .1f, -.1f, .48f, .07f),
floatArrayOf(-.3f, .3f, .17f, .4f, -.12f, .14f, -.46f, -.36f, .09f),
)
val rim = Stroke(1f)
fun DrawScope.rocket(x: Float, y: Float, s: RushSim, flicker: Float) {
val fin = pilotColour(s.pilot)
translate(x, y) {
@@ -394,7 +423,7 @@ private fun DrawScope.drawRush(art: RushArt, s: RushSim, calm: Boolean, steady:
val x = xAt(s.laneOf[i].toFloat(), sc) + if (shiver && s.kind[i] <= RKind.TALL) u * .03f * kotlin.math.sin(s.clock * 40f + i) else 0f
val y = yAt(sc)
when (s.kind[i]) {
RKind.ROCK -> block(s.region, look, x, y, u, art)
RKind.ROCK -> block(s.region, look, x, y, u, art, i)
RKind.LOW -> low(s.region, look, x, y, u)
RKind.TALL -> tall(s.region, look, x, y, u)
RKind.STAR -> with(art) { starAt(Offset(x, y - u * .3f), u * .16f) }
@@ -402,13 +431,16 @@ private fun DrawScope.drawRush(art: RushArt, s: RushSim, calm: Boolean, steady:
val c = Offset(x, y - u * .3f); val col = RColours.power(s.power[i])
drawCircle(col, u * .18f, c); drawCircle(Color.White, u * .18f, c, style = Stroke(u * .03f))
when (s.power[i]) {
RPower.SHIELD -> drawCircle(Color.White, u * .09f, c, style = Stroke(u * .03f))
RPower.SHIELD -> {
val sh = art.crystal.apply { reset(); moveTo(c.x - u * .08f, c.y - u * .08f); lineTo(c.x + u * .08f, c.y - u * .08f); lineTo(c.x + u * .07f, c.y + u * .02f); lineTo(c.x, c.y + u * .1f); lineTo(c.x - u * .07f, c.y + u * .02f); close() }
drawPath(sh, Color.White)
}
RPower.MAGNET -> {
drawLine(Color.White, Offset(c.x - u * .07f, c.y - u * .07f), Offset(c.x - u * .07f, c.y + u * .04f), u * .035f)
drawLine(Color.White, Offset(c.x + u * .07f, c.y - u * .07f), Offset(c.x + u * .07f, c.y + u * .04f), u * .035f)
drawLine(Color.White, Offset(c.x - u * .07f, c.y + u * .04f), Offset(c.x + u * .07f, c.y + u * .04f), u * .035f)
}
else -> { drawCircle(Color.White, u * .04f, Offset(c.x - u * .05f, c.y)); drawCircle(Color.White, u * .04f, Offset(c.x + u * .05f, c.y)) }
else -> { with(art) { starAt(Offset(c.x - u * .06f, c.y + u * .03f), u * .06f) }; with(art) { starAt(Offset(c.x + u * .06f, c.y - u * .03f), u * .06f) } }
}
}
RKind.PORTAL -> {
@@ -464,9 +496,22 @@ private fun DrawScope.drawRush(art: RushArt, s: RushSim, calm: Boolean, steady:
}
/** Solid in its lane at every height (red: change lane). Each region's own: a rock, a broken TV, a rogue-pixel cluster, a dark crystal. */
private fun DrawScope.block(region: Int, look: RegionLook, x: Float, y: Float, u: Float, art: RushArt) {
private fun DrawScope.block(region: Int, look: RegionLook, x: Float, y: Float, u: Float, art: RushArt, slot: Int) {
when (region) {
RRegion.ALLEY -> { drawCircle(look.blockDark, u * .42f, Offset(x, y - u * .3f)); drawCircle(look.block, u * .36f, Offset(x - u * .04f, y - u * .34f)); drawCircle(look.blockDark, u * .08f, Offset(x + u * .1f, y - u * .42f)) }
RRegion.ALLEY -> {
// A lumpy asteroid: one of three shapes, turned by its slot, so neighbours never match.
val v = slot % art.rocks.size; val c = Offset(x, y - u * .34f); val r = u * .42f
rotate((slot * 53 % 360).toFloat(), c) {
translate(c.x, c.y) {
scale(r, r, Offset.Zero) {
drawPath(art.rocks[v], look.block)
val cr = art.craters[v]
for (j in 0 until cr.size / 3) drawCircle(look.blockDark.copy(alpha = .75f), cr[j * 3 + 2], Offset(cr[j * 3], cr[j * 3 + 1]))
drawPath(art.rocks[v], look.blockDark, style = Stroke(.09f))
}
}
}
}
RRegion.BOULEVARD -> {
// A broken old telly: its cabinet, a cracked grey screen, two knobs.
drawRect(look.block, Offset(x - u * .4f, y - u * .66f), Size(u * .8f, u * .6f))
@@ -505,7 +550,7 @@ private fun DrawScope.tall(region: Int, look: RegionLook, x: Float, y: Float, u:
when (region) {
RRegion.BOULEVARD -> { drawLine(look.tall, Offset(x, y - u * .9f), Offset(x, y - u * 1.1f), u * .03f); drawCircle(Color(0xFFFFDE59), u * .04f, Offset(x, y - u * 1.1f)) }
RRegion.STATIC -> for (j in 0 until 4) drawRect(Color.White.copy(alpha = .5f), Offset(x - u * .38f + j * u * .2f, y - u * .84f), Size(u * .08f, u * .05f))
RRegion.FORBIDDEN -> drawCircle(look.lowLight, u * .06f, Offset(x, y - u * .75f))
RRegion.FORBIDDEN -> for (j in 0 until 3) drawLine(look.lowLight, Offset(x - u * .2f + j * u * .2f, y - u * .84f), Offset(x - u * .24f + j * u * .2f, y - u * .66f), u * .03f) // three slanting marks, not a single dot
else -> {}
}
}
@@ -0,0 +1,67 @@
package tv.orbit.classic.arcade
import org.junit.Assert.*
import org.junit.Test
/**
* The Originals row never trails focus (Paul, 313: "can scroll before it catches up"): at every press the focused card is
* fully on screen straight away, whether the presses come one at a time (then the peek eases in) or rapidly (all at once).
*/
class RowScrollTest {
// The Arcade home at 1080p: 736 dp of shelf at 2 px a dp; ten Originals 4.6 across.
private val d = 2f
private val view = 736 * d; private val edge = 12 * d; private val gap = 10 * d
private val card = (view - edge * 2 - gap * 4) / 4.6f
private val peek = gap + card * .35f
private val n = 10
private val max = (edge * 2 + n * card + (n - 1) * gap - view).toInt()
private fun whole(i: Int, scroll: Int): Boolean {
val left = edge + i * (card + gap) - scroll; val right = left + card
return left >= -.5f && right <= view + .5f
}
@Test fun rapidPressesKeepTheFocusedCardWhole() {
var scroll = 0
// ▶ held: each press scrolls at once to the target.
for (i in 0 until n) {
val plan = rowScroll(i, scroll, card, gap, edge, view, peek, max)
scroll = plan.target
assertTrue("▶ to $i: card not whole at $scroll", whole(i, scroll))
}
assertEquals(max, scroll)
// ◀ held all the way back.
for (i in n - 1 downTo 0) {
scroll = rowScroll(i, scroll, card, gap, edge, view, peek, max).target
assertTrue("◀ to $i: card not whole at $scroll", whole(i, scroll))
}
assertEquals(0, scroll)
}
@Test fun anUnhurriedPressShowsTheCardWholeAtOnceThenEasesToThePeek() {
// The animation may be cut short by the next press at any point: the card is whole at the start of the ease, and the
// ease only moves further the same way, so it stays whole all along it.
var scroll = 0
for (i in 0 until n) {
val plan = rowScroll(i, scroll, card, gap, edge, view, peek, max)
assertTrue("$i: not whole at once", whole(i, plan.now))
for (k in 0..10) { val mid = plan.now + (plan.target - plan.now) * k / 10; assertTrue("$i: not whole mid-ease", whole(i, mid)) }
// Cut short halfway: the next press starts from there.
scroll = (plan.now + plan.target) / 2
}
}
@Test fun theNextCardPeeksInWhenThereIsOne() {
var scroll = 0
for (i in 0 until n - 1) {
scroll = rowScroll(i, scroll, card, gap, edge, view, peek, max).target
val nextLeft = edge + (i + 1) * (card + gap) - scroll
assertTrue("$i: no peek of the next card", nextLeft < view - card * .2f)
}
}
@Test fun pressesCloseTogetherCountAsRapid() {
val p = RowPacer()
assertFalse(p.rapid(1_000)); assertTrue(p.rapid(1_050)); assertTrue(p.rapid(1_100)); assertFalse(p.rapid(1_600))
}
}