mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 14:02:44 +00:00
remove fillGapsWithSpacers
was only necessary for old AOSP keyboard parser
This commit is contained in:
parent
e707ade006
commit
4255dc2ce8
1 changed files with 0 additions and 33 deletions
|
@ -117,7 +117,6 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
||||||
var currentY = mParams.mTopPadding.toFloat()
|
var currentY = mParams.mTopPadding.toFloat()
|
||||||
for (row in keysInRows) {
|
for (row in keysInRows) {
|
||||||
if (row.isEmpty()) continue
|
if (row.isEmpty()) continue
|
||||||
fillGapsWithSpacers(row)
|
|
||||||
var currentX = mParams.mLeftPadding.toFloat()
|
var currentX = mParams.mLeftPadding.toFloat()
|
||||||
row.forEach {
|
row.forEach {
|
||||||
it.setAbsoluteDimensions(currentX, currentY)
|
it.setAbsoluteDimensions(currentX, currentY)
|
||||||
|
@ -129,37 +128,6 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// necessary for adjusting widths and positions properly
|
|
||||||
// without adding spacers whose width can then be adjusted, we would have to deal with keyXPos,
|
|
||||||
// which is more complicated than expected
|
|
||||||
// todo: remove? maybe was only necessary with old parser
|
|
||||||
private fun fillGapsWithSpacers(row: MutableList<KeyParams>) {
|
|
||||||
if (mParams.mId.mElementId !in KeyboardId.ELEMENT_ALPHABET..KeyboardId.ELEMENT_SYMBOLS_SHIFTED) return
|
|
||||||
if (row.isEmpty()) return
|
|
||||||
if (row.all { it.xPos == 0f }) return // need existing xPos to determine gaps
|
|
||||||
var currentX = 0f + mParams.mLeftPadding
|
|
||||||
var i = 0
|
|
||||||
while (i < row.size) {
|
|
||||||
val currentKeyXPos = row[i].xPos
|
|
||||||
if (currentKeyXPos > currentX) {
|
|
||||||
// insert spacer
|
|
||||||
val spacer = KeyParams.newSpacer(mParams, (currentKeyXPos - currentX) / mParams.mBaseWidth)
|
|
||||||
spacer.yPos = row[i].yPos
|
|
||||||
row.add(i, spacer)
|
|
||||||
i++
|
|
||||||
currentX += currentKeyXPos - currentX
|
|
||||||
}
|
|
||||||
currentX += row[i].mAbsoluteWidth
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
if (currentX < mParams.mOccupiedWidth) {
|
|
||||||
// insert spacer
|
|
||||||
val spacer = KeyParams.newSpacer(mParams, (mParams.mOccupiedWidth - currentX) / mParams.mBaseWidth)
|
|
||||||
spacer.yPos = row.last().yPos
|
|
||||||
row.add(spacer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun addSplit() {
|
private fun addSplit() {
|
||||||
val spacerRelativeWidth = Settings.getInstance().current.mSplitKeyboardSpacerRelativeWidth
|
val spacerRelativeWidth = Settings.getInstance().current.mSplitKeyboardSpacerRelativeWidth
|
||||||
// adjust gaps for the whole keyboard, so it's the same for all rows
|
// adjust gaps for the whole keyboard, so it's the same for all rows
|
||||||
|
@ -168,7 +136,6 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
||||||
var maxWidthBeforeSpacer = 0f
|
var maxWidthBeforeSpacer = 0f
|
||||||
var maxWidthAfterSpacer = 0f
|
var maxWidthAfterSpacer = 0f
|
||||||
for (row in keysInRows) {
|
for (row in keysInRows) {
|
||||||
fillGapsWithSpacers(row)
|
|
||||||
val y = row.first().yPos // all have the same y, so this is fine
|
val y = row.first().yPos // all have the same y, so this is fine
|
||||||
val relativeWidthSum = row.sumOf { it.mWidth } // sum up relative widths
|
val relativeWidthSum = row.sumOf { it.mWidth } // sum up relative widths
|
||||||
val spacer = KeyParams.newSpacer(mParams, spacerRelativeWidth)
|
val spacer = KeyParams.newSpacer(mParams, spacerRelativeWidth)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue