Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion java/src/org/futo/inputmethod/v2keyboard/Keyboard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,16 @@ data class Keyboard(
val autoShift: Boolean = true,

val subKeyboards: Map<KeyboardLayoutKind, SubKeyboard> = 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,
Expand Down
10 changes: 9 additions & 1 deletion java/src/org/futo/inputmethod/v2keyboard/LayoutEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down