diff --git a/java/src/org/futo/inputmethod/v2keyboard/Keyboard.kt b/java/src/org/futo/inputmethod/v2keyboard/Keyboard.kt index 2624629bf5..e5c05dd719 100644 --- a/java/src/org/futo/inputmethod/v2keyboard/Keyboard.kt +++ b/java/src/org/futo/inputmethod/v2keyboard/Keyboard.kt @@ -293,7 +293,16 @@ data class Keyboard( val autoShift: Boolean = true, val subKeyboards: Map = emptyMap(), - val imeHint: String? = null + val imeHint: String? = null, + + /** + * (optional) Whether keyboard rows use staggered (center-gapped) alignment. + * When true (default), rows with fewer keys than the widest row are centered with + * gaps on either side, matching the traditional staggered keyboard layout. + * When false, rows are left-aligned with no centering gaps, producing an + * ortholinear/grid-style layout. + */ + val staggered: Boolean = true //val element: KeyboardElement = KeyboardElement.Alphabet, diff --git a/java/src/org/futo/inputmethod/v2keyboard/LayoutEngine.kt b/java/src/org/futo/inputmethod/v2keyboard/LayoutEngine.kt index f4519e35f3..19f2731bde 100644 --- a/java/src/org/futo/inputmethod/v2keyboard/LayoutEngine.kt +++ b/java/src/org/futo/inputmethod/v2keyboard/LayoutEngine.kt @@ -360,7 +360,15 @@ data class LayoutEngine( val totalRowWidth = computedRow.sumOf { it.widthPx.toDouble() }.toFloat() val rowLayoutWidth = if(splittable) { layoutWidth } else { unsplitLayoutWidth } - val entries = mergeDuplicates(computedRow.addGap(rowLayoutWidth - totalRowWidth)) + val entries = if(keyboard.staggered) { + mergeDuplicates(computedRow.addGap(rowLayoutWidth - totalRowWidth)) + } else { + // Stretch keys to fill the entire row width (ortholinear/grid layout) + val extraPerKey = (rowLayoutWidth - totalRowWidth) / computedRow.size + computedRow.map { key -> + LayoutEntry.Key(key.data, key.widthPx + extraPerKey) + } + } return LayoutRow( entries = entries,