Move SSD selected cell membership to typed Kotlin
ober
f24b5bd1ba8d4f435550734ba7526ca113f128a5
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -486,6 +486,7 @@ ssdSessionFindGroupById ssdSessionSelectedGroup ssdSessionSelectedGroupId ssdSessionRelativeGroupId ssdSessionCellIdsForGroupId + ssdSessionGroupContainsCellId ssdSessionCellIdSet ssdSessionFindCellById ssdSessionCellsByIds ssdSessionBBoxForCellIds ssdSessionRecomputeGroup @@ -742,6 +743,13 @@ (if (nullable-null? group) (mutable-list-empty String) (SsdGroup-cellIds (nullable-get group))))) + (def (ssdSessionGroupContainsCellId (session : SsdSession) + (groupId : (Nullable String)) + (cellId : String)) : Bool + (let ((group (ssdSessionFindGroupById session groupId))) + (if (nullable-null? group) + #f + (ssdGroupCellIdPresent? (nullable-get group) cellId)))) (def (ssdSessionCellIdSet (session : SsdSession)) : (MutableSet String) (for/fold ((ids (mutable-set-empty String))) ((i (in-range (int32 0) (list-size (SsdSession-cells session))))) @@ -5584,11 +5592,10 @@ "" " private fun drawCells(canvas: Canvas) {" " val sess = session ?: return" - " val selectedIds = ssdSessionCellIdsForGroupId(sess, selectedGroupId).toSet()" " paint.style = Paint.Style.STROKE" " paint.strokeWidth = 2f / scale" " for (cell in sess.cells) {" - " if (selectedIds.contains(cell.id)) {" + " if (ssdSessionGroupContainsCellId(sess, selectedGroupId, cell.id)) {" " paint.color = Color.rgb(37, 99, 235)" " canvas.drawRect(cell.x, cell.y, cell.x + cell.w, cell.y + cell.h, paint)" " }"