Skip to content

Commit

Permalink
Update ComponentUtils.kt moveToCenter
Browse files Browse the repository at this point in the history
Divide char size by 2 to move the cursor to the center
  • Loading branch information
CptbeffHeart authored Mar 26, 2024
1 parent 88f4641 commit d9ff8c2
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ fun <C : BuildableComponent<C, B>, B : ComponentBuilder<C, B>> ComponentBuilder<
}

fun <C : BuildableComponent<C, B>, B : ComponentBuilder<C, B>> ComponentBuilder<C, B>.moveToCenter(lang: String = "en_us"): B {
return move(-CharSizes.calculateComponentWidth(build(), lang))
return move(-CharSizes.calculateComponentWidth(build(), lang) / 2)
}

fun <C : BuildableComponent<C, B>, B : ComponentBuilder<C, B>> ComponentBuilder<C, B>.moveTo(afterStart: Number, lang: String = "en_us"): B {
return move(-CharSizes.calculateComponentWidth(build(), lang) + afterStart.toFloat())
}
}

0 comments on commit d9ff8c2

Please sign in to comment.