commonMain.org.jetbrains.skia.paragraph.TextBox.kt Maven / Gradle / Ivy
package org.jetbrains.skia.paragraph
import org.jetbrains.skia.*
import org.jetbrains.skia.impl.*
class TextBox(val rect: Rect, direction: Direction) {
val _direction: Direction
constructor(l: Float, t: Float, r: Float, b: Float, direction: Int) : this(
Rect.makeLTRB(l, t, r, b),
Direction.values().get(direction)
)
val direction: Direction
get() = _direction
override fun equals(other: Any?): Boolean {
if (other === this) return true
if (other !is TextBox) return false
if (this.rect != other.rect) return false
return this.direction == other.direction
}
override fun hashCode(): Int {
val PRIME = 59
var result = 1
result = result * PRIME + rect.hashCode()
result = result * PRIME + direction.hashCode()
return result
}
override fun toString(): String {
return "TextBox(_rect=$rect, _direction=$direction)"
}
init {
_direction = direction
}
companion object : ArrayInteropDecoder {
override fun getArrayElement(array: InteropPointer, index: Int): TextBox {
val rect = FloatArray(4)
val direction = IntArray(1)
interopScope {
TextBox_nGetArrayElement(array, index, toInterop(rect), toInterop(direction))
}
return TextBox(rect[0], rect[1], rect[2], rect[3], direction[0])
}
override fun getArraySize(array: InteropPointer) = TextBox_nGetArraySize(array)
override fun disposeArray(array: InteropPointer) = TextBox_nDisposeArray(array)
}
}
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextBox__1nGetArraySize")
private external fun TextBox_nGetArraySize(array: InteropPointer): Int
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextBox__1nDisposeArray")
private external fun TextBox_nDisposeArray(array: InteropPointer)
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextBox__1nGetArrayElement")
private external fun TextBox_nGetArrayElement(array: InteropPointer, index: Int, rectArray: InteropPointer, directionArray: InteropPointer)