From 0f78a25382d41208f94d0d09549f3819817d25fe Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Thu, 11 Sep 2025 01:53:13 +0100 Subject: [PATCH] add z-index parameter to cursors, and refactor code to use them --- fcore/normal-mode/normal-search-finish.sml | 2 ++ fcore/pipe-cursor.sml | 8 +++++++- fcore/rect.sml | 8 +++++++- fcore/text-builder.sml | 13 +++++++++++-- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/fcore/normal-mode/normal-search-finish.sml b/fcore/normal-mode/normal-search-finish.sml index bfe7832..28600d5 100644 --- a/fcore/normal-mode/normal-search-finish.sml +++ b/fcore/normal-mode/normal-search-finish.sml @@ -39,6 +39,7 @@ struct PipeCursor.lerp ( x , y + , 0.01 , TextConstants.scale , floatWindowWidth , floatWindowHeight @@ -109,6 +110,7 @@ struct PipeCursor.lerp ( x , y + , 0.01 , TextConstants.scale , floatWindowWidth , floatWindowHeight diff --git a/fcore/pipe-cursor.sml b/fcore/pipe-cursor.sml index 836fe0b..b46aa82 100644 --- a/fcore/pipe-cursor.sml +++ b/fcore/pipe-cursor.sml @@ -6,7 +6,7 @@ struct fun yToNdc (yOffset, ypos, scale, halfHeight) = ~(((ypos * scale + yOffset) - halfHeight) / halfHeight) - fun lerp (xOffset: Real32.real, yOffset, scale, windowWidth, windowHeight, r, g, b) = + fun lerp (xOffset: Real32.real, yOffset, z, scale, windowWidth, windowHeight, r, g, b) = let val halfWidth = windowWidth / 2.0 val halfHeight = windowHeight / 2.0 @@ -14,21 +14,27 @@ struct #[ xToNdc (xOffset, 0.000000000000000, scale, halfWidth), yToNdc (yOffset, 13.000000000000000, scale, halfHeight), +z, r, g, b, xToNdc (xOffset, 1.000000000000000, scale, halfWidth), yToNdc (yOffset, 13.000000000000000, scale, halfHeight), +z, r, g, b, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), yToNdc (yOffset, 0.000000000000000, scale, halfHeight), +z, r, g, b, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), yToNdc (yOffset, 0.000000000000000, scale, halfHeight), +z, r, g, b, xToNdc (xOffset, 1.000000000000000, scale, halfWidth), yToNdc (yOffset, 13.000000000000000, scale, halfHeight), +z, r, g, b, xToNdc (xOffset, 1.000000000000000, scale, halfWidth), yToNdc (yOffset, 0.000000000000000, scale, halfHeight), +z, r, g, b ] end diff --git a/fcore/rect.sml b/fcore/rect.sml index 6f3bbba..1a0e13e 100644 --- a/fcore/rect.sml +++ b/fcore/rect.sml @@ -6,7 +6,7 @@ struct fun yToNdc (yOffset, ypos, scale, halfHeight) = ~(((ypos * scale + yOffset) - halfHeight) / halfHeight) - fun lerp (xOffset: Real32.real, yOffset, scale, windowWidth, windowHeight, r, g, b) = + fun lerp (xOffset: Real32.real, yOffset, z, scale, windowWidth, windowHeight, r, g, b) = let val halfWidth = windowWidth / 2.0 val halfHeight = windowHeight / 2.0 @@ -14,21 +14,27 @@ struct #[ xToNdc (xOffset, 0.000000000000000, scale, halfWidth), yToNdc (yOffset, 13.000000000000000, scale, halfHeight), +z, r, g, b, xToNdc (xOffset, 6.000000000000000, scale, halfWidth), yToNdc (yOffset, 13.000000000000000, scale, halfHeight), +z, r, g, b, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), yToNdc (yOffset, 0.000000000000000, scale, halfHeight), +z, r, g, b, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), yToNdc (yOffset, 0.000000000000000, scale, halfHeight), +z, r, g, b, xToNdc (xOffset, 6.000000000000000, scale, halfWidth), yToNdc (yOffset, 13.000000000000000, scale, halfHeight), +z, r, g, b, xToNdc (xOffset, 6.000000000000000, scale, halfWidth), yToNdc (yOffset, 0.000000000000000, scale, halfHeight), +z, r, g, b ] end diff --git a/fcore/text-builder.sml b/fcore/text-builder.sml index 7555c06..9d4be70 100644 --- a/fcore/text-builder.sml +++ b/fcore/text-builder.sml @@ -41,7 +41,7 @@ struct val textAcc = Vector.concat textAcc val bgAcc = Vector.concat bgAcc val vec = Vector.concat [textAcc, bgAcc, cursorAcc] - val drawMsg = DRAW_TEXT vec + val drawMsg = DRAW_TEXT cursorAcc in DRAW drawMsg :: msgs end @@ -63,7 +63,16 @@ struct fun makeRect (posX, posY, fw, fh, r, g, b) = Rect.lerp - (Real32.fromInt (posX - 1), Real32.fromInt posY, scale, fw, fh, r, g, b) + ( Real32.fromInt (posX - 1) + , Real32.fromInt posY + , 0.01 + , scale + , fw + , fh + , r + , g + , b + ) fun makeChr (chr, posX, posY, windowWidth, windowHeight, r, g, b) = CozetteAscii.make