Unverified Commit 0f799c3e authored by Nikolay Igotti's avatar Nikolay Igotti Committed by GitHub

Make setters more Kotlin'ish (#213)

parent 0f19f7ae
......@@ -124,9 +124,9 @@ class Renderer(
val typeface = Typeface.makeFromFile("fonts/JetBrainsMono-Regular.ttf")
val font = Font(typeface, 40f)
val paint = Paint().apply {
setColor(0xff9BC730L.toInt())
setMode(PaintMode.FILL)
setStrokeWidth(1f)
color = 0xff9BC730L.toInt()
mode = PaintMode.FILL
strokeWidth = 1f
}
var canvas: Canvas? = null
......@@ -165,10 +165,18 @@ private val fontCollection = FontCollection()
fun displayScene(renderer: Renderer, width: Int, height: Int, nanoTime: Long, xpos: Int, ypos: Int, state: State) {
val canvas = renderer.canvas!!
val watchFill = Paint().setColor(0xFFFFFFFF.toInt())
val watchStroke = Paint().setColor(0xFF000000.toInt()).setMode(PaintMode.STROKE).setStrokeWidth(1f)
val watchStrokeAA = Paint().setColor(0xFF000000.toInt()).setMode(PaintMode.STROKE).setStrokeWidth(1f)
val watchFillHover = Paint().setColor(0xFFE4FF01.toInt())
val watchFill = Paint().apply { color = 0xFFFFFFFF.toInt() }
val watchStroke = Paint().apply {
color = 0xFF000000.toInt()
mode = PaintMode.STROKE
strokeWidth = 1f
}
val watchStrokeAA = Paint().apply {
color = 0xFF000000.toInt()
mode = PaintMode.STROKE
strokeWidth = 1f
}
val watchFillHover = Paint().apply { color = 0xFFE4FF01.toInt() }
for (x in 0 .. (width - 50) step 50) {
for (y in 20 .. (height - 50) step 50) {
val hover = xpos > x + 0 && xpos < x + 50 && ypos > y + 0 && ypos < y + 50
......
......@@ -89,13 +89,19 @@ class Font : Managed {
*
* @return true if all glyphs are hinted
*/
val isAutoHintingForced: Boolean
var isAutoHintingForced: Boolean
get() = try {
Stats.onNativeCall()
_nIsAutoHintingForced(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) = try {
Stats.onNativeCall()
_nSetAutoHintingForced(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
* @return true if font engine may return glyphs from font bitmaps instead of from outlines
......@@ -112,13 +118,19 @@ class Font : Managed {
/**
* @return true if glyphs may be drawn at sub-pixel offsets
*/
val isSubpixel: Boolean
var isSubpixel: Boolean
get() = try {
Stats.onNativeCall()
_nIsSubpixel(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) = try {
Stats.onNativeCall()
_nSetSubpixel(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
* @return true if font and glyph metrics are requested to be linearly scalable
......@@ -138,13 +150,19 @@ class Font : Managed {
*
* @return true if bold is approximated through stroke width
*/
val isEmboldened: Boolean
var isEmboldened: Boolean
get() = try {
Stats.onNativeCall()
_nIsEmboldened(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) = try {
Stats.onNativeCall()
_nSetEmboldened(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
* Returns true if baselines will be snapped to pixel positions when the current transformation
......@@ -152,130 +170,53 @@ class Font : Managed {
*
* @return true if baselines may be snapped to pixels
*/
val isBaselineSnapped: Boolean
var isBaselineSnapped: Boolean
get() = try {
Stats.onNativeCall()
_nIsBaselineSnapped(_ptr)
} finally {
reachabilityBarrier(this)
}
/**
* Sets whether to always hint glyphs. If forceAutoHinting is set, instructs the font manager to always hint glyphs. Only affects platforms that use FreeType as the font manager.
*
* @param value setting to always hint glyphs
* @return this
*/
fun setAutoHintingForced(value: Boolean): Font {
Stats.onNativeCall()
_nSetAutoHintingForced(_ptr, value)
return this
}
/**
* Requests, but does not require, to use bitmaps in fonts instead of outlines.
*
* @param value setting to use bitmaps in fonts
* @return this
*/
fun setBitmapsEmbedded(value: Boolean): Font {
Stats.onNativeCall()
_nSetBitmapsEmbedded(_ptr, value)
return this
}
/**
* Requests, but does not require, that glyphs respect sub-pixel positioning.
*
* @param value setting for sub-pixel positioning
* @return this
*/
fun setSubpixel(value: Boolean): Font {
Stats.onNativeCall()
_nSetSubpixel(_ptr, value)
return this
}
/**
* Requests, but does not require, linearly scalable font and glyph metrics.
*
* For outline fonts 'true' means font and glyph metrics should ignore hinting and rounding.
* Note that some bitmap formats may not be able to scale linearly and will ignore this flag.
*
* @param value setting for linearly scalable font and glyph metrics.
* @return this
*/
fun setMetricsLinear(value: Boolean): Font {
Stats.onNativeCall()
_nSetMetricsLinear(_ptr, value)
return this
}
/**
* Increases stroke width when creating glyph bitmaps to approximate a bold typeface.
*
* @param value setting for bold approximation
* @return this
*/
fun setEmboldened(value: Boolean): Font {
Stats.onNativeCall()
_nSetEmboldened(_ptr, value)
return this
}
/**
* Requests that baselines be snapped to pixels when the current transformation matrix is axis
* aligned.
*
* @param value setting for baseline snapping to pixels
* @return this
*/
fun setBaselineSnapped(value: Boolean): Font {
Stats.onNativeCall()
_nSetBaselineSnapped(_ptr, value)
return this
}
set(value) = try {
Stats.onNativeCall()
_nSetBaselineSnapped(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
* Whether edge pixels draw opaque or with partial transparency.
*/
val edging: FontEdging
var edging: FontEdging
get() = try {
Stats.onNativeCall()
FontEdging.values().get(_nGetEdging(_ptr))
} finally {
reachabilityBarrier(this)
}
/**
* Requests, but does not require, that edge pixels draw opaque or with
* partial transparency.
*/
fun setEdging(value: FontEdging): Font {
Stats.onNativeCall()
_nSetEdging(_ptr, value.ordinal)
return this
}
set(value) = try {
Stats.onNativeCall()
_nSetEdging(_ptr, value.ordinal)
} finally {
reachabilityBarrier(this)
}
/**
* @return level of glyph outline adjustment
*/
val hinting: FontHinting
var hinting: FontHinting
get() = try {
Stats.onNativeCall()
FontHinting.values().get(_nGetHinting(_ptr))
} finally {
reachabilityBarrier(this)
}
/**
* Sets level of glyph outline adjustment. Does not check for valid values of hintingLevel.
*/
fun setHinting(value: FontHinting): Font {
Stats.onNativeCall()
_nSetHinting(_ptr, value.ordinal)
return this
}
set(value) = try {
Stats.onNativeCall()
_nSetHinting(_ptr, value.ordinal)
} finally {
reachabilityBarrier(this)
}
/**
* Returns a font with the same attributes of this font, but with the specified size.
......@@ -310,35 +251,54 @@ class Font : Managed {
/**
* @return text size in points
*/
val size: Float
var size: Float
get() = try {
Stats.onNativeCall()
Font_nGetSize(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) = try {
Stats.onNativeCall()
_nSetSize(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
* @return text scale on x-axis. Default value is 1
*/
val scaleX: Float
var scaleX: Float
get() = try {
Stats.onNativeCall()
_nGetScaleX(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) = try {
Stats.onNativeCall()
_nSetScaleX(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
* @return text skew on x-axis. Default value is 0
*/
val skewX: Float
var skewX: Float
get() = try {
Stats.onNativeCall()
_nGetSkewX(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) = try {
Stats.onNativeCall()
_nSetSkewX(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
* Sets Typeface to typeface. Pass null to use the default typeface.
......@@ -356,33 +316,6 @@ class Font : Managed {
}
}
/**
* Sets text size in points. Has no effect if value is not greater than or equal to zero.
*/
fun setSize(value: Float): Font {
Stats.onNativeCall()
_nSetSize(_ptr, value)
return this
}
/**
* Sets text scale on x-axis. Default value is 1.
*/
fun setScaleX(value: Float): Font {
Stats.onNativeCall()
_nSetScaleX(_ptr, value)
return this
}
/**
* Sets text skew on x-axis. Default value is 0.
*/
fun setSkewX(value: Float): Font {
Stats.onNativeCall()
_nSetSkewX(_ptr, value)
return this
}
/**
* Converts text into glyph indices.
*
......
......@@ -90,20 +90,12 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setAntiAlias(value)
set(value) = try {
Stats.onNativeCall()
_nSetAntiAlias(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
* Requests, but does not require, that edge pixels draw opaque or with partial transparency.
*
* @param value setting for antialiasing
*/
fun setAntiAlias(value: Boolean): Paint {
Stats.onNativeCall()
_nSetAntiAlias(_ptr, value)
return this
}
/**
* Requests, but does not require, to distribute color error.
......@@ -117,22 +109,13 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setDither(value)
set(value) = try {
Stats.onNativeCall()
_nSetDither(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
* Requests, but does not require, to distribute color error.
*
* @param value setting for ditering
* @return this
*/
fun setDither(value: Boolean): Paint {
Stats.onNativeCall()
_nSetDither(_ptr, value)
return this
}
/**
* Sets whether the geometry is filled, stroked, or filled and stroked.
*
......@@ -149,23 +132,13 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setMode(value)
set(value) = try {
Stats.onNativeCall()
_nSetMode(_ptr, value.ordinal)
} finally {
reachabilityBarrier(this)
}
/**
* Sets whether the geometry is filled, stroked, or filled and stroked.
*
* @see [https://fiddle.skia.org/c/@Paint_setStyle](https://fiddle.skia.org/c/@Paint_setStyle)
*
* @see [https://fiddle.skia.org/c/@Stroke_Width](https://fiddle.skia.org/c/@Stroke_Width)
*/
fun setMode(style: PaintMode): Paint {
Stats.onNativeCall()
_nSetMode(_ptr, style.ordinal)
return this
}
/**
* Set paint's mode to STROKE if true, or FILL if false.
*
......@@ -196,24 +169,13 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setColor(value)
set(value) = try {
Stats.onNativeCall()
_nSetColor(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
* Sets alpha and RGB used when stroking and filling. The color is a 32-bit value,
* unpremultiplied, packing 8-bit components for alpha, red, blue, and green.
*
* @param color unpremultiplied ARGB
*
* @see [https://fiddle.skia.org/c/@Paint_setColor](https://fiddle.skia.org/c/@Paint_setColor)
*/
fun setColor(color: Int): Paint {
Stats.onNativeCall()
_nSetColor(_ptr, color)
return this
}
/**
* Sets alpha and RGB used when stroking and filling. The color is four floating
* point values, unpremultiplied. The color values are interpreted as being in sRGB.
......@@ -231,19 +193,8 @@ class Paint : Managed {
reachabilityBarrier(this)
}
set(value) {
setColor4f(value)
setColor4f(value, null)
}
/**
* Sets alpha and RGB used when stroking and filling. The color is four floating
* point values, unpremultiplied. The color values are interpreted as being in sRGB.
*
* @param color unpremultiplied RGBA
* @return this
*/
fun setColor4f(color: Color4f): Paint {
return setColor4f(color, null)
}
/**
* Sets alpha and RGB used when stroking and filling. The color is four floating
......@@ -285,8 +236,9 @@ class Paint : Managed {
*
* @return alpha ranging from 0, fully transparent, to 255, fully opaque
*/
val alpha: Int
var alpha: Int
get() = round(alphaf * 255f).toInt()
set(value) { setAlphaf(value / 255f) }
/**
*
......@@ -305,22 +257,6 @@ class Paint : Managed {
return this
}
/**
*
* Replaces alpha, leaving RGB unchanged. An out of range value triggers
* an assert in the debug build. a is a value from 0 to 255.
*
*
* a set to zero makes color fully transparent; a set to 255 makes color
* fully opaque.
*
* @param a alpha component of color
* @return this
*/
fun setAlpha(a: Int): Paint {
return setAlphaf(a / 255f)
}
/**
* Sets color used when drawing solid fills. The color components range from 0 to 255.
* The color is unpremultiplied; alpha sets the transparency independent of RGB.
......@@ -359,27 +295,13 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setStrokeWidth(value)
set(value) = try {
Stats.onNativeCall()
_nSetStrokeWidth(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
* Sets the thickness of the pen used by the paint to outline the shape.
* A stroke-width of zero is treated as "hairline" width. Hairlines are always exactly one
* pixel wide in device space (their thickness does not change as the canvas is scaled).
* Negative stroke-widths are invalid; setting a negative width will have no effect.
*
* @param width zero thickness for hairline; greater than zero for pen thickness
*
* @see [https://fiddle.skia.org/c/@Miter_Limit](https://fiddle.skia.org/c/@Miter_Limit)
*
* @see [https://fiddle.skia.org/c/@Paint_setStrokeWidth](https://fiddle.skia.org/c/@Paint_setStrokeWidth)
*/
fun setStrokeWidth(width: Float): Paint {
Stats.onNativeCall()
_nSetStrokeWidth(_ptr, width)
return this
}
/**
* Sets the limit at which a sharp corner is drawn beveled.
......@@ -399,25 +321,13 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setStrokeMiter(value)
set(value) = try {
Stats.onNativeCall()
_nSetStrokeMiter(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
* Sets the limit at which a sharp corner is drawn beveled.
* Valid values are zero and greater.
* Has no effect if miter is less than zero.
*
* @param miter zero and greater miter limit
* @return this
*
* @see [https://fiddle.skia.org/c/@Paint_setStrokeMiter](https://fiddle.skia.org/c/@Paint_setStrokeMiter)
*/
fun setStrokeMiter(miter: Float): Paint {
Stats.onNativeCall()
_nSetStrokeMiter(_ptr, miter)
return this
}
/**
* Sets the geometry drawn at the beginning and end of strokes.
......@@ -435,26 +345,13 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setStrokeCap(value)
set(value) = try {
Stats.onNativeCall()
_nSetStrokeCap(_ptr, value.ordinal)
} finally {
reachabilityBarrier(this)
}
/**
* Sets the geometry drawn at the beginning and end of strokes.
*
* @return this
*
* @see [https://fiddle.skia.org/c/@Paint_setStrokeCap_a](https://fiddle.skia.org/c/@Paint_setStrokeCap_a)
*
* @see [https://fiddle.skia.org/c/@Paint_setStrokeCap_b](https://fiddle.skia.org/c/@Paint_setStrokeCap_b)
*/
fun setStrokeCap(cap: PaintStrokeCap): Paint {
Stats.onNativeCall()
_nSetStrokeCap(_ptr, cap.ordinal)
return this
}
/**
* Sets the geometry drawn at the corners of strokes.
*
......@@ -469,23 +366,13 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setStrokeJoin(value)
set(value) = try {
Stats.onNativeCall()
_nSetStrokeJoin(_ptr, value.ordinal)
} finally {
reachabilityBarrier(this)
}
/**
* Sets the geometry drawn at the corners of strokes.
*
* @return this
*
* @see [https://fiddle.skia.org/c/@Paint_setStrokeJoin](https://fiddle.skia.org/c/@Paint_setStrokeJoin)
*/
fun setStrokeJoin(join: PaintStrokeJoin): Paint {
Stats.onNativeCall()
_nSetStrokeJoin(_ptr, join.ordinal)
return this
}
/**
* Returns the filled equivalent of the stroked path.
*
......@@ -549,26 +436,13 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setShader(value)
}
/**
* @param shader how geometry is filled with color; if null, color is used instead
*
* @see [https://fiddle.skia.org/c/@Color_Filter_Methods](https://fiddle.skia.org/c/@Color_Filter_Methods)
*
* @see [https://fiddle.skia.org/c/@Paint_setShader](https://fiddle.skia.org/c/@Paint_setShader)
*/
fun setShader(shader: Shader?): Paint {
return try {
set(value) = try {
Stats.onNativeCall()
_nSetShader(_ptr, getPtr(shader))
this
_nSetShader(_ptr, getPtr(value))
} finally {
reachabilityBarrier(shader)
reachabilityBarrier(value)
reachabilityBarrier(this)
}
}
/**
* @param colorFilter [ColorFilter] to apply to subsequent draw
......@@ -588,29 +462,16 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setColorFilter(value)
}
/**
* @param colorFilter [ColorFilter] to apply to subsequent draw
*
* @see [https://fiddle.skia.org/c/@Blend_Mode_Methods](https://fiddle.skia.org/c/@Blend_Mode_Methods)
*
* @see [https://fiddle.skia.org/c/@Paint_setColorFilter](https://fiddle.skia.org/c/@Paint_setColorFilter)
*/
fun setColorFilter(colorFilter: ColorFilter?): Paint {
return try {
set(value) = try {
Stats.onNativeCall()
_nSetColorFilter(
_ptr,
getPtr(colorFilter)
getPtr(value)
)
this
} finally {
reachabilityBarrier(colorFilter)
reachabilityBarrier(this)
reachabilityBarrier(value)
}
}
/**
* Sets SkBlendMode to mode. Does not check for valid input.
......@@ -627,22 +488,13 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setBlendMode(value)
set(value) = try {
Stats.onNativeCall()
_nSetBlendMode(_ptr, value.ordinal)
} finally {
reachabilityBarrier(this)
}
/**
* Sets SkBlendMode to mode. Does not check for valid input.
*
* @param mode BlendMode used to combine source color and destination
* @return this
*/
fun setBlendMode(mode: BlendMode): Paint {
Stats.onNativeCall()
_nSetBlendMode(_ptr, mode.ordinal)
return this
}
/**
* @return true if BlendMode is BlendMode.SRC_OVER, the default.
*/
......@@ -667,27 +519,13 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setPathEffect(value)
}
/**
* @param p replace [Path] with a modification when drawn
*
* @see [https://fiddle.skia.org/c/@Mask_Filter_Methods](https://fiddle.skia.org/c/@Mask_Filter_Methods)
*
* @see [https://fiddle.skia.org/c/@Paint_setPathEffect](https://fiddle.skia.org/c/@Paint_setPathEffect)
*/
fun setPathEffect(p: PathEffect?): Paint {
return try {
set(value) = try {
Stats.onNativeCall()
_nSetPathEffect(_ptr, getPtr(p))
this
_nSetPathEffect(_ptr, getPtr(value))
} finally {
reachabilityBarrier(p)
reachabilityBarrier(this)
reachabilityBarrier(value)
}
}
/**
* maskFilter modifies clipping mask generated from drawn geometry
......@@ -707,30 +545,16 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setMaskFilter(value)
}
/**
* @param maskFilter modifies clipping mask generated from drawn geometry
* @return this
*
* @see [https://fiddle.skia.org/c/@Paint_setMaskFilter](https://fiddle.skia.org/c/@Paint_setMaskFilter)
*
* @see [https://fiddle.skia.org/c/@Typeface_Methods](https://fiddle.skia.org/c/@Typeface_Methods)
*/
fun setMaskFilter(maskFilter: MaskFilter?): Paint {
return try {
set(value) = try {
Stats.onNativeCall()
_nSetMaskFilter(
_ptr,
getPtr(maskFilter)
getPtr(value)
)
this
} finally {
reachabilityBarrier(maskFilter)
reachabilityBarrier(this)
reachabilityBarrier(value)
}
}
/**
* imageFilter how SkImage is sampled when transformed
......@@ -750,29 +574,16 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setImageFilter(value)
}
/**
* @param imageFilter how SkImage is sampled when transformed
*
* @see [https://fiddle.skia.org/c/@Draw_Looper_Methods](https://fiddle.skia.org/c/@Draw_Looper_Methods)
*
* @see [https://fiddle.skia.org/c/@Paint_setImageFilter](https://fiddle.skia.org/c/@Paint_setImageFilter)
*/
fun setImageFilter(imageFilter: ImageFilter?): Paint {
return try {
set(value) = try {
Stats.onNativeCall()
_nSetImageFilter(
_ptr,
getPtr(imageFilter)
getPtr(value)
)
this
} finally {
reachabilityBarrier(imageFilter)
reachabilityBarrier(this)
reachabilityBarrier(value)
}
}
/**
*
......@@ -797,7 +608,6 @@ class Paint : Managed {
}
}
@ExternalSymbolName("org_jetbrains_skia_Paint__1nGetFinalizer")
private external fun Paint_nGetFinalizer(): NativePointer
......
......@@ -224,7 +224,7 @@ class Path internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol
* @param other Path to compare
* @return true if this and Path are equivalent
*/
override fun _nativeEquals(other: Native?): Boolean {
override fun _nativeEquals(other: Native?): Boolean {
return try {
Path_nEquals(_ptr, getPtr(other))
} finally {
......@@ -309,15 +309,12 @@ class Path internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol
} finally {
reachabilityBarrier(this)
}
set(value) {
setFillMode(value)
set(value) = try {
Stats.onNativeCall()
_nSetFillMode(_ptr, value.ordinal)
} finally {
reachabilityBarrier(this)
}
fun setFillMode(fillMode: PathFillMode): Path {
Stats.onNativeCall()
_nSetFillMode(_ptr, fillMode.ordinal)
return this
}
/**
* Returns true if the path is convex. If necessary, it will first compute the convexity.
......@@ -482,9 +479,11 @@ class Path internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol
} finally {
reachabilityBarrier(this)
}
set(value) {
set(value) = try {
Stats.onNativeCall()
Path_nSetVolatile(_ptr, value)
} finally {
reachabilityBarrier(this)
}
/**
......@@ -1919,13 +1918,16 @@ class Path internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol
*
* @see [https://fiddle.skia.org/c/@Path_getLastPt](https://fiddle.skia.org/c/@Path_getLastPt)
*/
val lastPt: Point
var lastPt: Point
get() = try {
Stats.onNativeCall()
_nGetLastPt(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setLastPt(value.x, value.y)
}
/**
* Sets last point to (x, y). If Point array is empty, append [PathVerb.MOVE] to
......@@ -1943,17 +1945,6 @@ class Path internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol
return this
}
/**
* Sets the last point on the path. If Point array is empty, append [PathVerb.MOVE] to
* verb array and append p to Point array.
*
* @param p set value of last point
* @return this
*/
fun setLastPt(p: Point): Path {
return setLastPt(p.x, p.y)
}
/**
*
* Returns a mask, where each set bit corresponds to a SegmentMask constant
......
......@@ -34,19 +34,13 @@ class ParagraphStyle : Managed(ParagraphStyle_nMake(), _FinalizerHolder.PTR) {
} finally {
reachabilityBarrier(this)
}
set(value) {
setStrutStyle(value)
}
fun setStrutStyle(s: StrutStyle?): ParagraphStyle {
return try {
set(value) = try {
Stats.onNativeCall()
_nSetStrutStyle(_ptr, getPtr(s))
this
_nSetStrutStyle(_ptr, getPtr(value))
} finally {
reachabilityBarrier(s)
reachabilityBarrier(this)
reachabilityBarrier(value)
}
}
var textStyle: TextStyle
get() = try {
......@@ -55,19 +49,13 @@ class ParagraphStyle : Managed(ParagraphStyle_nMake(), _FinalizerHolder.PTR) {
} finally {
reachabilityBarrier(this)
}
set(value) {
setTextStyle(value)
}
fun setTextStyle(style: TextStyle?): ParagraphStyle {
return try {
set(value) = try {
Stats.onNativeCall()
_nSetTextStyle(_ptr, getPtr(style))
this
_nSetTextStyle(_ptr, getPtr(value))
} finally {
reachabilityBarrier(style)
reachabilityBarrier(value)
reachabilityBarrier(this)
}
}
var direction: Direction
get() = try {
......@@ -76,15 +64,13 @@ class ParagraphStyle : Managed(ParagraphStyle_nMake(), _FinalizerHolder.PTR) {
} finally {
reachabilityBarrier(this)
}
set(value) {
setDirection(value)
set(value) = try {
Stats.onNativeCall()
_nSetDirection(_ptr, value.ordinal)
} finally {
reachabilityBarrier(this)
}
fun setDirection(style: Direction): ParagraphStyle {
Stats.onNativeCall()
_nSetDirection(_ptr, style.ordinal)
return this
}
var alignment: Alignment
get() = try {
......@@ -93,16 +79,13 @@ class ParagraphStyle : Managed(ParagraphStyle_nMake(), _FinalizerHolder.PTR) {
} finally {
reachabilityBarrier(this)
}
set(value) {
setAlignment(value)
set(value) = try {
Stats.onNativeCall()
_nSetAlignment(_ptr, value.ordinal)
} finally {
reachabilityBarrier(this)
}
fun setAlignment(alignment: Alignment): ParagraphStyle {
Stats.onNativeCall()
_nSetAlignment(_ptr, alignment.ordinal)
return this
}
var maxLinesCount: Int
get() = try {
Stats.onNativeCall()
......@@ -110,16 +93,13 @@ class ParagraphStyle : Managed(ParagraphStyle_nMake(), _FinalizerHolder.PTR) {
} finally {
reachabilityBarrier(this)
}
set(value) {
setMaxLinesCount(value)
set(value) = try {
Stats.onNativeCall()
_nSetMaxLinesCount(_ptr, value)
} finally {
reachabilityBarrier(this)
}
fun setMaxLinesCount(count: Int): ParagraphStyle {
Stats.onNativeCall()
_nSetMaxLinesCount(_ptr, count)
return this
}
var ellipsis: String
get() = try {
Stats.onNativeCall()
......@@ -127,16 +107,13 @@ class ParagraphStyle : Managed(ParagraphStyle_nMake(), _FinalizerHolder.PTR) {
} finally {
reachabilityBarrier(this)
}
set(value) {
setEllipsis(value)
set(value) = try {
Stats.onNativeCall()
_nSetEllipsis(_ptr, value)
} finally {
reachabilityBarrier(this)
}
fun setEllipsis(ellipsis: String?): ParagraphStyle {
Stats.onNativeCall()
_nSetEllipsis(_ptr, ellipsis)
return this
}
var height: Float
get() = try {
Stats.onNativeCall()
......@@ -144,15 +121,13 @@ class ParagraphStyle : Managed(ParagraphStyle_nMake(), _FinalizerHolder.PTR) {
} finally {
reachabilityBarrier(this)
}
set(value) {
setHeight(value)
set(value) = try {
Stats.onNativeCall()
_nSetHeight(_ptr, value)
} finally {
reachabilityBarrier(this)
}
fun setHeight(height: Float): ParagraphStyle {
Stats.onNativeCall()
_nSetHeight(_ptr, height)
return this
}
var heightMode: HeightMode
get() = try {
......@@ -161,16 +136,13 @@ class ParagraphStyle : Managed(ParagraphStyle_nMake(), _FinalizerHolder.PTR) {
} finally {
reachabilityBarrier(this)
}
set(value) {
setHeightMode(value)
set(value) = try {
Stats.onNativeCall()
_nSetHeightMode(_ptr, value.ordinal)
} finally {
reachabilityBarrier(this)
}
fun setHeightMode(behavior: HeightMode): ParagraphStyle {
Stats.onNativeCall()
_nSetHeightMode(_ptr, behavior.ordinal)
return this
}
val effectiveAlignment: Alignment
get() = try {
Stats.onNativeCall()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment