Option to combine top bar with the app switcher

This commit is contained in:
James Babcock committed 2026-10-02 00:45:17 -07:00
1 parent eab839f811
commit 756e21feb8
19 files changed
+462 -168

No files matched your search

@@ -21,3 +21,5 @@ const val CFW_TEXTURE_OPT_INVERSE = 32
/** Rounded-rectangle border sentinel, not a color or flag bit. */
const val DRAW_ROUNDED_RECT_NO_BORDER = 16
/** Revision 36: the rounded rectangle's optional outside color is absent (bridge sentinel). */
const val DRAW_ROUNDED_RECT_NO_OUTSIDE = 16
@@ -13,7 +13,7 @@ class DrawClip(val x: Int, val y: Int, val width: Int, val height: Int) {
fun translated(dx: Int, dy: Int) = DrawClip(x + dx, y + dy, width, height)
}
/** Revision 35 wire grammar, shared by scene planning and the local renderer. */
/** Revision 36 wire grammar, shared by scene planning and the local renderer. */
object DrawProtocol {
/** Mirrors g2flash/patches/zlib_glue.c. */
const val DRAW = CFW_MSG_DRAW_CALLS
@@ -93,12 +93,17 @@ object DrawProtocol {
border: Int = DRAW_ROUNDED_RECT_NO_BORDER, depth: Int? = null,
): ByteArray = roundedRect(DrawValue.Integer(x), DrawValue.Integer(y), width, height, radius, background, border, depth)
/**
* The background is max-blended, so 0 leaves the interior as it is. [outside] (revision 36),
* when given, is the color for the bounding box's pixels outside the rounded shape.
*/
fun roundedRect(
x: DrawValue, y: DrawValue, width: Int, height: Int, radius: Int, background: Int,
border: Int = DRAW_ROUNDED_RECT_NO_BORDER, depth: Int? = null, clip: DrawClip? = null,
outside: Int? = null,
): ByteArray {
require(width in 1..640 && height in 1..480 && radius in 0..65535)
require(background in 0..15 && border in 0..DRAW_ROUNDED_RECT_NO_BORDER)
require(background in 0..15 && border in 0..DRAW_ROUNDED_RECT_NO_BORDER && (outside == null || outside in 0..15))
return call(DRAW_OP_ROUNDED_RECT, depth = depth, clip = clip) {
writeExtended(x)
writeExtended(y)
@@ -107,6 +112,7 @@ object DrawProtocol {
writeU16(radius)
writeU8(background)
writeU8(border)
if (outside != null) writeU8(outside)
}
}
@@ -487,16 +487,21 @@ class DisplayListRenderer(
val radius = reader.readU16()
val fill = reader.readU8()
val border = reader.readU8()
// Revision 36: an optional trailing color for the corners outside the shape.
val outside = if (reader.remaining == 1) reader.readU8().also { require(it <= 15) } else DRAW_ROUNDED_RECT_NO_OUTSIDE
reader.requireDone()
require(width in 1..640 && height in 1..480 && fill <= 15 && border <= DRAW_ROUNDED_RECT_NO_BORDER)
if (!walk.apply) return
if (x < -width - target.shiftX || x >= target.width - target.shiftX ||
y < -height || y >= target.height) return
for (yy in 0 until height) for (xx in 0 until width) {
if (!roundedContains(xx, yy, width, height, radius)) continue
val tx = x + xx + target.shiftX
val ty = y + yy
if (tx !in 0 until target.width || ty !in 0 until target.height) continue
if (!roundedContains(xx, yy, width, height, radius)) {
if (outside != DRAW_ROUNDED_RECT_NO_OUTSIDE) target.put(x + xx, ty, outside)
continue
}
val edge = !roundedContains(xx - 1, yy - 1, width - 2, height - 2, maxOf(0, radius - 1))
val value = if (edge && border < DRAW_ROUNDED_RECT_NO_BORDER) border else maxOf(fill, target.get(tx, ty))
target.put(x + xx, ty, value)
@@ -45,7 +45,7 @@ class FrameDisplayList private constructor(
val clip = c.clip?.translated(x, y)
when (c.op) {
DRAW_OP_ROUNDED_RECT -> DrawProtocol.roundedRect(bind(c.x, elapsed, x), bind(c.y, elapsed, y),
v[0], v[1], v[2], v[3], v[4], depth + c.depth, clip)
v[0], v[1], v[2], v[3], v[4], depth + c.depth, clip, v[5].takeIf { it != DRAW_ROUNDED_RECT_NO_OUTSIDE })
DRAW_OP_IMAGE -> DrawProtocol.image(resource(v[0]), bind(c.x, elapsed, x + v[1]), bind(c.y, elapsed, y + v[2]),
v[3], depth = depth + c.depth, clip = clip)
DRAW_OP_TEXT -> DrawProtocol.text(resource(v[0]), bind(c.x, elapsed, x + v[1]), bind(c.y, elapsed, y + v[2]),
@@ -185,9 +185,9 @@ class FrameDisplayList private constructor(
DRAW_OP_ROUNDED_RECT -> {
val xx = value(); val yy = value()
val w = r.readU16(); val h = r.readU16(); val radius = r.readU16()
val background = r.readU8(); val border = r.readU8()
require(w in 1..640 && h in 1..480 && background in 0..15 && border in 0..16)
commands.add(Command(op, d, intArrayOf(w, h, radius, background, border), xx, yy, clip = clip))
val background = r.readU8(); val border = r.readU8(); val outside = r.readU8()
require(w in 1..640 && h in 1..480 && background in 0..15 && border in 0..16 && outside in 0..16)
commands.add(Command(op, d, intArrayOf(w, h, radius, background, border, outside), xx, yy, clip = clip))
}
DRAW_OP_IMAGE -> {
val id = resource(); require(id != DrawProtocol.SCREEN)