Move SSD group stroke colors to typed Kotlin
ober
2011475d1b2123e47ed3aa826bf0969a49752487
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -3699,8 +3699,17 @@ manualGroupLabel manualCellCount editedGroupCount clampPageIndex shiftPageIndex displayGroupCanvasLabel dropdownHeight dialogPageNumber nullableLowercaseOrEmpty - selectModeStatus selectionResultStatus) + selectModeStatus selectionResultStatus groupStrokeColor) (type Int32) + (extern (androidColorRgb (red : Int32) + (green : Int32) + (blue : Int32)) : Int32 + (kotlin-call android graphics Color rgb)) + (extern (androidColorArgb (alpha : Int32) + (red : Int32) + (green : Int32) + (blue : Int32)) : Int32 + (kotlin-call android graphics Color argb)) (def (normalizeFiringArc (value : String)) : String (string-uppercase (string-trim value))) (def (normalizeLabel (value : String)) : String @@ -3858,6 +3867,14 @@ (int32->string matchingCount) " detected boxes")) "Shrank rough selection to SSD boxes"))) + (def (groupStrokeColor (selected : Bool) (status : String)) : Int32 + (if selected + (androidColorRgb (int32 37) (int32 99) (int32 235)) + (if (or (equal? status "approved") (equal? status "reviewed")) + (androidColorRgb (int32 5) (int32 150) (int32 105)) + (if (equal? status "rejected") + (androidColorRgb (int32 185) (int32 28) (int32 28)) + (androidColorArgb (int32 155) (int32 245) (int32 158) (int32 11)))))) (def (editedGroupCount (count : (Nullable Int32)) (fallback : Int32)) : Int32 (if (nullable-null? count) @@ -6876,13 +6893,7 @@ " paint.strokeWidth = 4f / scale" " for (group in sess.groups) {" " val selected = group.id == selectedGroupId" - " val reviewed = group.status == \"approved\" || group.status == \"reviewed\"" - " paint.color = when {" - " selected -> Color.rgb(37, 99, 235)" - " reviewed -> Color.rgb(5, 150, 105)" - " group.status == \"rejected\" -> Color.rgb(185, 28, 28)" - " else -> Color.argb(155, 245, 158, 11)" - " }" + " paint.color = groupStrokeColor(selected, group.status)" " paint.strokeWidth = if (selected) 7f / scale else 3f / scale" " canvas.drawRect(group.bbox[0], group.bbox[1], group.bbox[2], group.bbox[3], paint)" " if (selected) {"