Move from using Double to Float.
This change makes it easier to migrate from Klutter to Crane
as we are going to use Float values rather than Doubles.
Test: ran all existing tests and UI demos
Change-Id: Idb1a7b3c392413a1eafd4843ba636052c6c879b8
diff --git a/samples/UiPortDemos/src/main/java/com/example/ui/port/RowsAndColumnsActivity.kt b/samples/UiPortDemos/src/main/java/com/example/ui/port/RowsAndColumnsActivity.kt
index 4509111..a7ff1b4 100644
--- a/samples/UiPortDemos/src/main/java/com/example/ui/port/RowsAndColumnsActivity.kt
+++ b/samples/UiPortDemos/src/main/java/com/example/ui/port/RowsAndColumnsActivity.kt
@@ -54,8 +54,8 @@
RawImage(
key = Key.createKey("image $columnIndex $rowIndex"),
image = Image(bitmap),
- width = 100.0,
- height = 100.0
+ width = 100.0f,
+ height = 100.0f
)
}
Column(key = Key.createKey("column $columnIndex"), children = images)
diff --git a/samples/UiPortDemos/src/main/java/com/example/ui/port/WoodPeckerDemo.kt b/samples/UiPortDemos/src/main/java/com/example/ui/port/WoodPeckerDemo.kt
index d39a693..c59b5b7 100644
--- a/samples/UiPortDemos/src/main/java/com/example/ui/port/WoodPeckerDemo.kt
+++ b/samples/UiPortDemos/src/main/java/com/example/ui/port/WoodPeckerDemo.kt
@@ -65,9 +65,9 @@
private val metaData: MetaData
) : State<Gestures2App>(widget) {
- var xTranslation = 0.0
- var yTranslation = 0.0
- var scale = 1.0
+ var xTranslation = 0.0f
+ var yTranslation = 0.0f
+ var scale = 1.0f
override fun build(context: BuildContext): Widget {
val bitmap: Bitmap =
@@ -84,7 +84,7 @@
),
dragCallback = object : DragGestureRecognizerCallback {
override fun canDrag(direction: Direction) = true
- override fun drag(dx: Double, dy: Double): Offset {
+ override fun drag(dx: Float, dy: Float): Offset {
setState {
this@Gestures2AppState.xTranslation += dx
this@Gestures2AppState.yTranslation += dy
@@ -94,13 +94,13 @@
},
>
setState {
- this@Gestures2AppState.scale = 1.0
- this@Gestures2AppState.xTranslation = 0.0
- this@Gestures2AppState.yTranslation = 0.0
+ this@Gestures2AppState.scale = 1.0f
+ this@Gestures2AppState.xTranslation = 0.0f
+ this@Gestures2AppState.yTranslation = 0.0f
}
},
scaleCallback = object : ScaleGestureRecognizerCallback {
- override fun onScaleRatio(ratio: Double): Double {
+ override fun onScaleRatio(ratio: Float): Float {
setState {
this@Gestures2AppState.scale *= ratio
}
@@ -119,12 +119,12 @@
)
}
- private fun Bitmap.mod(dx: Double, dy: Double, scaleRatio: Double): Bitmap {
+ private fun Bitmap.mod(dx: Float, dy: Float, scaleRatio: Float): Bitmap {
val m = Matrix().apply {
- preTranslate(-dx.toFloat(), -dy.toFloat())
+ preTranslate(-dx, -dy)
preScale(
- scaleRatio.toFloat(),
- scaleRatio.toFloat(),
+ scaleRatio,
+ scaleRatio,
width.toFloat() / 2,
height.toFloat() / 2)
}
diff --git a/ui-r4a/src/main/java/androidx/r4a/CraneRects.kt b/ui-r4a/src/main/java/androidx/r4a/CraneRects.kt
index 446c6ac..0776fc6 100644
--- a/ui-r4a/src/main/java/androidx/r4a/CraneRects.kt
+++ b/ui-r4a/src/main/java/androidx/r4a/CraneRects.kt
@@ -100,15 +100,14 @@
@Composable
fun DrawImage(bitmap: Bitmap) {
- val context = composer.composer.context
val onPaint: (Canvas, PixelSize) -> Unit = { canvas, parentSize ->
val paint = Paint()
canvas.save()
- val width = parentSize.width.toDouble()
- val height = parentSize.height.toDouble()
- val scale = min(width/bitmap.width.toDouble(), height/bitmap.height.toDouble())
+ val width = parentSize.width
+ val height = parentSize.height
+ val scale = min(width/bitmap.width.toFloat(), height/bitmap.height.toFloat())
canvas.scale(scale, scale)
- canvas.drawImage(Image(bitmap), Offset(0.0, 0.0), paint)
+ canvas.drawImage(Image(bitmap), Offset(0.0f, 0.0f), paint)
canvas.restore()
}
<Draw onPaint />
@@ -116,13 +115,12 @@
@Composable
fun DrawRectangle(color: Color) {
- val context = composer.composer.context
val paint = Paint()
paint.color = color
val onPaint: (Canvas, PixelSize) -> Unit = { canvas, parentSize ->
- val widthPx = parentSize.width.toDouble()
- val heightPx = parentSize.height.toDouble()
- canvas.drawRect(Rect(0.0, 0.0, widthPx, heightPx), paint)
+ val widthPx = parentSize.width
+ val heightPx = parentSize.height
+ canvas.drawRect(Rect(0.0f, 0.0f, widthPx, heightPx), paint)
}
<Draw onPaint />
}
diff --git a/ui-r4a/src/main/java/androidx/r4a/CraneTextActivity.kt b/ui-r4a/src/main/java/androidx/r4a/CraneTextActivity.kt
index 63a457b..bac8646 100644
--- a/ui-r4a/src/main/java/androidx/r4a/CraneTextActivity.kt
+++ b/ui-r4a/src/main/java/androidx/r4a/CraneTextActivity.kt
@@ -27,7 +27,7 @@
style = TextStyle(
fontFamily = FontFamily("sans-serif"),
color = Color(0xFFFF0000.toInt()),
- fontSize = 100.0,
+ fontSize = 100.0f,
fontWeight = FontWeight.w700
)
)
@@ -35,7 +35,7 @@
textDirection=TextDirection.LTR
softWrap=true
overflow=TextOverflow.FADE
- textScaleFactor=2.3
+ textScaleFactor=2.3f
maxLines=3 />
</CraneWrapper>
</ScrollView>
diff --git a/ui/core/src/androidTest/java/androidx/ui/core/ContainingViewTest.kt b/ui/core/src/androidTest/java/androidx/ui/core/ContainingViewTest.kt
index fa6acb7..689ce77 100644
--- a/ui/core/src/androidTest/java/androidx/ui/core/ContainingViewTest.kt
+++ b/ui/core/src/androidTest/java/androidx/ui/core/ContainingViewTest.kt
@@ -96,8 +96,8 @@
val background : (Canvas, PixelSize) -> Unit = { canvas, parentSize ->
val paint = Paint()
paint.color = Color(0xFFFFFF00.toInt())
- canvas.drawRect(Rect(0.0, 0.0,
- parentSize.width.toDouble(), parentSize.height.toDouble()), paint)
+ canvas.drawRect(Rect(0.0f, 0.0f,
+ parentSize.width, parentSize.height), paint)
}
// Component constructor parameters over-memoize, so use a property instead
<Draw >
@@ -107,10 +107,10 @@
drawLatch.countDown()
val paint = Paint()
paint.color = Color(0xFF0000FF.toInt())
- val width = parentSize.width.toDouble()
- val height = parentSize.height.toDouble()
+ val width = parentSize.width
+ val height = parentSize.height
canvas.drawRect(
- Rect(0.0, 0.0, width, height),
+ Rect(0.0f, 0.0f, width, height),
paint
)
}
diff --git a/ui/core/src/main/java/androidx/ui/core/Draw.kt b/ui/core/src/main/java/androidx/ui/core/Draw.kt
index 9d819f4..24365ed 100644
--- a/ui/core/src/main/java/androidx/ui/core/Draw.kt
+++ b/ui/core/src/main/java/androidx/ui/core/Draw.kt
@@ -26,7 +26,7 @@
* <Draw> canvas, parentSize ->
* val paint = Paint()
* paint.color = Color(0xFF000000.toInt())
- * canvas.drawRect(Rect(0.0, 0.0, parentSize.width, parentSize.height, paint)
+ * canvas.drawRect(Rect(0.0f, 0.0f, parentSize.width, parentSize.height, paint)
* </Draw>
*/
class Draw() : Component() {
diff --git a/ui/core/src/main/java/androidx/ui/core/Text.kt b/ui/core/src/main/java/androidx/ui/core/Text.kt
index fa06816..9e0b89d 100644
--- a/ui/core/src/main/java/androidx/ui/core/Text.kt
+++ b/ui/core/src/main/java/androidx/ui/core/Text.kt
@@ -52,7 +52,7 @@
/** How visual overflow should be handled. */
var overflow: TextOverflow = TextOverflow.CLIP
/** The number of font pixels for each logical pixel. */
- var textScaleFactor: Double = 1.0
+ var textScaleFactor: Float = 1.0f
/**
* An optional maximum number of lines for the text to span, wrapping if necessary.
* If the text exceeds the given number of lines, it will be truncated according to [overflow]
@@ -80,14 +80,14 @@
attachContextToFont(text, context)
val boxConstraints = BoxConstraints(
- constraints.minWidth.toPx(context).toDouble(),
- constraints.maxWidth.toPx(context).toDouble(),
- constraints.minHeight.toPx(context).toDouble(),
- constraints.maxHeight.toPx(context).toDouble())
+ constraints.minWidth.toPx(context),
+ constraints.maxWidth.toPx(context),
+ constraints.minHeight.toPx(context),
+ constraints.maxHeight.toPx(context))
renderParagraph.layoutTextWithConstraints(boxConstraints)
measureOperations.collect {
<Draw> canvas, parent ->
- renderParagraph.paint(canvas, Offset(0.0, 0.0))
+ renderParagraph.paint(canvas, Offset(0.0f, 0.0f))
</Draw>
}
measureOperations.layout(
diff --git a/ui/port/src/androidTest/java/androidx/ui/port/engine/text/ParagraphTest.kt b/ui/port/src/androidTest/java/androidx/ui/port/engine/text/ParagraphTest.kt
index a18f95a..3655be9 100644
--- a/ui/port/src/androidTest/java/androidx/ui/port/engine/text/ParagraphTest.kt
+++ b/ui/port/src/androidTest/java/androidx/ui/port/engine/text/ParagraphTest.kt
@@ -68,45 +68,45 @@
@Test
fun empty_string() {
- val fontSize = 50.0
+ val fontSize = 50.0f
val text = StringBuilder("")
val paragraph = simpleParagraph(text = text, fontSize = fontSize)
- paragraph.layout(ParagraphConstraints(width = 100.0))
+ paragraph.layout(ParagraphConstraints(width = 100.0f))
- assertThat(paragraph.width, equalTo(100.0))
+ assertThat(paragraph.width, equalTo(100.0f))
assertThat(paragraph.height, equalTo(fontSize))
// defined in sample_font
- assertThat(paragraph.alphabeticBaseline, equalTo(fontSize * 0.8))
- assertThat(paragraph.maxIntrinsicWidth, equalTo(0.0))
- assertThat(paragraph.minIntrinsicWidth, equalTo(0.0))
- assertThat(paragraph.ideographicBaseline, equalTo(Double.MAX_VALUE))
+ assertThat(paragraph.alphabeticBaseline, equalTo(fontSize * 0.8f))
+ assertThat(paragraph.maxIntrinsicWidth, equalTo(0.0f))
+ assertThat(paragraph.minIntrinsicWidth, equalTo(0.0f))
+ assertThat(paragraph.ideographicBaseline, equalTo(Float.MAX_VALUE))
// TODO(Migration/siyamed): no baseline query per line?
// TODO(Migration/siyamed): no line count?
}
@Test
fun single_line_default_values() {
- val fontSize = 50.0
+ val fontSize = 50.0f
for (text in arrayOf("xyz", "\u05D0\u05D1\u05D2")) {
val paragraph = simpleParagraph(text = text, fontSize = fontSize)
// width greater than text width - 150
- paragraph.layout(ParagraphConstraints(width = 200.0))
+ paragraph.layout(ParagraphConstraints(width = 200.0f))
- assertThat(text, paragraph.width, equalTo(200.0))
+ assertThat(text, paragraph.width, equalTo(200.0f))
assertThat(text, paragraph.height, equalTo(fontSize))
// defined in sample_font
- assertThat(text, paragraph.alphabeticBaseline, equalTo(fontSize * 0.8))
+ assertThat(text, paragraph.alphabeticBaseline, equalTo(fontSize * 0.8f))
assertThat(text, paragraph.maxIntrinsicWidth, equalTo(fontSize * text.length))
- assertThat(text, paragraph.minIntrinsicWidth, equalTo(0.0))
- assertThat(text, paragraph.ideographicBaseline, equalTo(Double.MAX_VALUE))
+ assertThat(text, paragraph.minIntrinsicWidth, equalTo(0.0f))
+ assertThat(text, paragraph.ideographicBaseline, equalTo(Float.MAX_VALUE))
}
}
@Test
fun line_break_default_values() {
- val fontSize = 50.0
+ val fontSize = 50.0f
for (text in arrayOf("abcdef", "\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5")) {
val paragraph = simpleParagraph(text = text, fontSize = fontSize)
@@ -116,18 +116,18 @@
// 3 chars
assertThat(text, paragraph.width, equalTo(3 * fontSize))
// 2 lines, 1 line gap
- assertThat(text, paragraph.height, equalTo(2 * fontSize + fontSize / 5.0))
+ assertThat(text, paragraph.height, equalTo(2 * fontSize + fontSize / 5.0f))
// defined in sample_font
- assertThat(text, paragraph.alphabeticBaseline, equalTo(fontSize * 0.8))
+ assertThat(text, paragraph.alphabeticBaseline, equalTo(fontSize * 0.8f))
assertThat(text, paragraph.maxIntrinsicWidth, equalTo(fontSize * text.length))
- assertThat(text, paragraph.minIntrinsicWidth, equalTo(0.0))
- assertThat(text, paragraph.ideographicBaseline, equalTo(Double.MAX_VALUE))
+ assertThat(text, paragraph.minIntrinsicWidth, equalTo(0.0f))
+ assertThat(text, paragraph.ideographicBaseline, equalTo(Float.MAX_VALUE))
}
}
@Test
fun newline_default_values() {
- val fontSize = 50.0
+ val fontSize = 50.0f
for (text in arrayOf("abc\ndef", "\u05D0\u05D1\u05D2\n\u05D3\u05D4\u05D5")) {
val paragraph = simpleParagraph(text = text, fontSize = fontSize)
@@ -137,18 +137,18 @@
// 3 chars
assertThat(text, paragraph.width, equalTo(3 * fontSize))
// 2 lines, 1 line gap
- assertThat(text, paragraph.height, equalTo(2 * fontSize + fontSize / 5.0))
+ assertThat(text, paragraph.height, equalTo(2 * fontSize + fontSize / 5.0f))
// defined in sample_font
- assertThat(text, paragraph.alphabeticBaseline, equalTo(fontSize * 0.8))
+ assertThat(text, paragraph.alphabeticBaseline, equalTo(fontSize * 0.8f))
assertThat(text, paragraph.maxIntrinsicWidth, equalTo(fontSize * text.indexOf("\n")))
- assertThat(text, paragraph.minIntrinsicWidth, equalTo(0.0))
- assertThat(text, paragraph.ideographicBaseline, equalTo(Double.MAX_VALUE))
+ assertThat(text, paragraph.minIntrinsicWidth, equalTo(0.0f))
+ assertThat(text, paragraph.ideographicBaseline, equalTo(Float.MAX_VALUE))
}
}
@Test
fun newline_and_line_break_default_values() {
- val fontSize = 50.0
+ val fontSize = 50.0f
for (text in arrayOf("abc\ndef", "\u05D0\u05D1\u05D2\n\u05D3\u05D4\u05D5")) {
val paragraph = simpleParagraph(text = text, fontSize = fontSize)
@@ -158,19 +158,19 @@
// 2 chars
assertThat(text, paragraph.width, equalTo(2 * fontSize))
// 4 lines, 3 line gaps
- assertThat(text, paragraph.height, equalTo(4 * fontSize + 3 * fontSize / 5.0))
+ assertThat(text, paragraph.height, equalTo(4 * fontSize + 3 * fontSize / 5.0f))
// defined in sample_font
- assertThat(text, paragraph.alphabeticBaseline, equalTo(fontSize * 0.8))
+ assertThat(text, paragraph.alphabeticBaseline, equalTo(fontSize * 0.8f))
assertThat(text, paragraph.maxIntrinsicWidth, equalTo(fontSize * text.indexOf("\n")))
- assertThat(text, paragraph.minIntrinsicWidth, equalTo(0.0))
- assertThat(text, paragraph.ideographicBaseline, equalTo(Double.MAX_VALUE))
+ assertThat(text, paragraph.minIntrinsicWidth, equalTo(0.0f))
+ assertThat(text, paragraph.ideographicBaseline, equalTo(Float.MAX_VALUE))
}
}
@Test
fun getPositionForOffset_ltr() {
val text = "abc"
- val fontSize = 50.0
+ val fontSize = 50.0f
val paragraph = simpleParagraph(text = text, fontSize = fontSize)
paragraph.layout(ParagraphConstraints(width = text.length * fontSize))
@@ -189,7 +189,7 @@
@Test
fun getPositionForOffset_rtl() {
val text = "\u05D0\u05D1\u05D2"
- val fontSize = 50.0
+ val fontSize = 50.0f
val paragraph = simpleParagraph(text = text, fontSize = fontSize)
paragraph.layout(ParagraphConstraints(width = text.length * fontSize))
@@ -211,7 +211,7 @@
val firstLine = "abc"
val secondLine = "def"
val text = firstLine + secondLine
- val fontSize = 50.0
+ val fontSize = 50.0f
val paragraph = simpleParagraph(text = text, fontSize = fontSize)
paragraph.layout(ParagraphConstraints(width = firstLine.length * fontSize))
@@ -219,7 +219,7 @@
// test positions are 1, fontSize+1, 2fontSize+1 and always on the second line
// which maps to chars 3, 4, 5
for (i in 0..secondLine.length) {
- val offset = Offset(i * fontSize + 1, fontSize * 1.5)
+ val offset = Offset(i * fontSize + 1, fontSize * 1.5f)
val position = paragraph.getPositionForOffset(offset)
assertThat(
"position at index $i, offset $offset, second line does not match",
@@ -234,7 +234,7 @@
val firstLine = "\u05D0\u05D1\u05D2"
val secondLine = "\u05D3\u05D4\u05D5"
val text = firstLine + secondLine
- val fontSize = 50.0
+ val fontSize = 50.0f
val paragraph = simpleParagraph(text = text, fontSize = fontSize)
paragraph.layout(ParagraphConstraints(width = text.length * fontSize))
@@ -255,7 +255,7 @@
@Test
fun getPositionForOffset_ltr_width_outOfBounds() {
val text = "abc"
- val fontSize = 50.0
+ val fontSize = 50.0f
val paragraph = simpleParagraph(text = text, fontSize = fontSize)
paragraph.layout(ParagraphConstraints(width = text.length * fontSize))
@@ -274,7 +274,7 @@
@Test
fun getPositionForOffset_ltr_height_outOfBounds() {
val text = "abc"
- val fontSize = 50.0
+ val fontSize = 50.0f
val paragraph = simpleParagraph(text = text, fontSize = fontSize)
paragraph.layout(ParagraphConstraints(width = text.length * fontSize))
@@ -293,7 +293,7 @@
@Test
fun locale_withCJK_shouldNotDrawSame() {
val text = "\u82B1"
- val fontSize = 10.0
+ val fontSize = 10.0f
val locales = arrayOf(
// duplicate ja is on purpose
Locale(_languageCode = "ja"),
@@ -334,7 +334,7 @@
paragraphStyle = ParagraphStyle()
)
- paragraph.layout(ParagraphConstraints(width = Double.MAX_VALUE))
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
assertThat(
paragraph.paragraphImpl.textLocale.toLanguageTag(),
@@ -354,7 +354,7 @@
)
)
- paragraph.layout(ParagraphConstraints(width = Double.MAX_VALUE))
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
assertThat(paragraph.paragraphImpl.textLocale.toLanguageTag(), equalTo("en-US"))
}
@@ -371,7 +371,7 @@
)
)
- paragraph.layout(ParagraphConstraints(width = Double.MAX_VALUE))
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
assertThat(paragraph.paragraphImpl.textLocale.toLanguageTag(), equalTo("ja-JP"))
}
@@ -388,7 +388,7 @@
)
)
- paragraph.layout(ParagraphConstraints(width = Double.MAX_VALUE))
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
assertThat(paragraph.paragraphImpl.textLocale.toLanguageTag(), equalTo("ja"))
}
@@ -399,7 +399,7 @@
val maxLines = text.lines().size - 1
val paragraph = simpleParagraph(text = text, maxLines = maxLines)
- paragraph.layout(ParagraphConstraints(width = Double.MAX_VALUE))
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
assertThat(paragraph.didExceedMaxLines, equalTo(true))
}
@@ -409,7 +409,7 @@
val maxLines = text.lines().size
val paragraph = simpleParagraph(text = text, maxLines = maxLines)
- paragraph.layout(ParagraphConstraints(width = Double.MAX_VALUE))
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
assertThat(paragraph.didExceedMaxLines, equalTo(false))
}
@@ -419,14 +419,14 @@
val maxLines = text.lines().size + 1
val paragraph = simpleParagraph(text = text, maxLines = maxLines)
- paragraph.layout(ParagraphConstraints(width = Double.MAX_VALUE))
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
assertThat(paragraph.didExceedMaxLines, equalTo(false))
}
@Test
fun didExceedMaxLines_withMaxLinesSmallerThanTextLines_withLineWrap_returnsTrue() {
val text = "aa"
- val fontSize = 50.0
+ val fontSize = 50.0f
val maxLines = 1
val paragraph = simpleParagraph(text = text, fontSize = fontSize, maxLines = maxLines)
@@ -438,11 +438,11 @@
@Test
fun didExceedMaxLines_withMaxLinesEqualToTextLines_withLineWrap_returnsFalse() {
val text = "a"
- val fontSize = 50.0
+ val fontSize = 50.0f
val maxLines = text.lines().size
val paragraph = simpleParagraph(text = text, fontSize = fontSize, maxLines = maxLines)
- paragraph.layout(ParagraphConstraints(width = Double.MAX_VALUE))
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
assertThat(paragraph.didExceedMaxLines, equalTo(false))
}
@@ -450,7 +450,7 @@
fun didExceedMaxLines_withMaxLinesGreaterThanTextLines_withLineWrap_returnsFalse() {
val text = "aa"
val maxLines = 3
- val fontSize = 50.0
+ val fontSize = 50.0f
val paragraph = simpleParagraph(text = text, fontSize = fontSize, maxLines = maxLines)
// One line can only contain 1 character
@@ -462,7 +462,7 @@
fun textAlign_defaultValue_alignsStart() {
val textLTR = "aa"
val textRTL = "\u05D0\u05D0"
- val fontSize = 20.0
+ val fontSize = 20.0f
val paragraphLTR = simpleParagraph(
text = textLTR,
@@ -479,14 +479,14 @@
paragraphRTL.layout(ParagraphConstraints(width = layoutRTLWidth))
// When textAlign is TextAlign.start, LTR aligns to left, RTL aligns to right.
- assertThat(paragraphLTR.paragraphImpl.getLineLeft(0), equalTo(0.0))
+ assertThat(paragraphLTR.paragraphImpl.getLineLeft(0), equalTo(0.0f))
assertThat(paragraphRTL.paragraphImpl.getLineRight(0), equalTo(layoutRTLWidth))
}
@Test
fun textAlign_whenAlignLeft_returnsZeroForGetLineLeft() {
val texts = listOf("aa", "\u05D0\u05D0")
- val fontSize = 20.0
+ val fontSize = 20.0f
texts.map { text ->
val paragraph = simpleParagraph(
@@ -497,14 +497,14 @@
val layoutWidth = (text.length + 2) * fontSize
paragraph.layout(ParagraphConstraints(width = layoutWidth))
val paragraphImpl = paragraph.paragraphImpl
- assertThat(paragraphImpl.getLineLeft(0), equalTo(0.0))
+ assertThat(paragraphImpl.getLineLeft(0), equalTo(0.0f))
}
}
@Test
fun textAlign_whenAlignRight_returnsLayoutWidthForGetLineRight() {
val texts = listOf("aa", "\u05D0\u05D0")
- val fontSize = 20.0
+ val fontSize = 20.0f
texts.map { text ->
val paragraph = simpleParagraph(
@@ -522,7 +522,7 @@
@Test
fun textAlign_whenAlignCenter_textIsCentered() {
val texts = listOf("aa", "\u05D0\u05D0")
- val fontSize = 20.0
+ val fontSize = 20.0f
texts.map { text ->
val paragraph = simpleParagraph(
@@ -544,7 +544,7 @@
@Test
fun textAlign_whenAlignStart_withLTR_returnsZeroForGetLineLeft() {
val text = "aa"
- val fontSize = 20.0
+ val fontSize = 20.0f
val layoutWidth = (text.length + 2) * fontSize
val paragraph = simpleParagraph(
@@ -554,13 +554,13 @@
)
paragraph.layout(ParagraphConstraints(width = layoutWidth))
val paragraphImpl = paragraph.paragraphImpl
- assertThat(paragraphImpl.getLineLeft(0), equalTo(0.0))
+ assertThat(paragraphImpl.getLineLeft(0), equalTo(0.0f))
}
@Test
fun textAlign_whenAlignEnd_withLTR_returnsLayoutWidthForGetLineRight() {
val text = "aa"
- val fontSize = 20.0
+ val fontSize = 20.0f
val layoutWidth = (text.length + 2) * fontSize
val paragraph = simpleParagraph(
@@ -576,7 +576,7 @@
@Test
fun textAlign_whenAlignStart_withRTL_returnsLayoutWidthForGetLineRight() {
val text = "\u05D0\u05D0"
- val fontSize = 20.0
+ val fontSize = 20.0f
val layoutWidth = (text.length + 2) * fontSize
val paragraph = simpleParagraph(
@@ -592,7 +592,7 @@
@Test
fun textAlign_whenAlignEnd_withRTL_returnsZeroForGetLineLeft() {
val text = "\u05D0\u05D0"
- val fontSize = 20.0
+ val fontSize = 20.0f
val layoutWidth = (text.length + 2) * fontSize
val paragraph = simpleParagraph(
@@ -602,7 +602,7 @@
)
paragraph.layout(ParagraphConstraints(width = layoutWidth))
val paragraphImpl = paragraph.paragraphImpl
- assertThat(paragraphImpl.getLineLeft(0), equalTo(0.0))
+ assertThat(paragraphImpl.getLineLeft(0), equalTo(0.0f))
}
@Test
@@ -611,7 +611,7 @@
// before API 28 may have an extra space at the end of line.
fun textAlign_whenAlignJustify_justifies() {
val text = "a a a"
- val fontSize = 20.0
+ val fontSize = 20.0f
val layoutWidth = ("a a".length + 1) * fontSize
val paragraph = simpleParagraph(
@@ -621,16 +621,16 @@
)
paragraph.layout(ParagraphConstraints(width = layoutWidth))
val paragraphImpl = paragraph.paragraphImpl
- assertThat(paragraphImpl.getLineLeft(0), equalTo(0.0))
+ assertThat(paragraphImpl.getLineLeft(0), equalTo(0.0f))
assertThat(paragraphImpl.getLineRight(0), equalTo(layoutWidth))
// Last line should align start
- assertThat(paragraphImpl.getLineLeft(1), equalTo(0.0))
+ assertThat(paragraphImpl.getLineLeft(1), equalTo(0.0f))
}
@Test
fun textDirection_whenLTR_dotIsOnRight() {
val text = "a.."
- val fontSize = 20.0
+ val fontSize = 20.0f
val layoutWidth = text.length * fontSize
val paragraph = simpleParagraph(
@@ -648,7 +648,7 @@
@Test
fun textDirection_whenRTL_dotIsOnLeft() {
val text = "a.."
- val fontSize = 20.0
+ val fontSize = 20.0f
val layoutWidth = text.length * fontSize
val paragraph = simpleParagraph(
@@ -666,7 +666,7 @@
@Test
fun textDirection_whenDefault_withoutStrongChar_directionIsLTR() {
val text = "..."
- val fontSize = 20.0
+ val fontSize = 20.0f
val layoutWidth = text.length * fontSize
val paragraph = simpleParagraph(
@@ -685,7 +685,7 @@
@Test
fun textDirection_whenDefault_withFirstStrongCharLTR_directionIsLTR() {
val text = "a\u05D0."
- val fontSize = 20.0
+ val fontSize = 20.0f
val layoutWidth = text.length * fontSize
val paragraph = simpleParagraph(
@@ -704,7 +704,7 @@
@Test
fun textDirection_whenDefault_withFirstStrongCharRTL_directionIsRTL() {
val text = "\u05D0a."
- val fontSize = 20.0
+ val fontSize = 20.0f
val layoutWidth = text.length * fontSize
val paragraph = simpleParagraph(
@@ -721,10 +721,10 @@
@Test
fun lineHeight_returnsSameAsGiven() {
val text = "abcdefgh"
- val fontSize = 20.0
+ val fontSize = 20.0f
// Make the layout 4 lines
val layoutWidth = text.length * fontSize / 4
- val lineHeight = 1.5
+ val lineHeight = 1.5f
val paragraph = simpleParagraph(
text = text,
@@ -740,17 +740,17 @@
for (i in 1 until paragraphImpl.lineCount - 1) {
val actualHeight = paragraphImpl.getLineHeight(i)
// In the sample_font.ttf, the height of the line should be
- // fontSize + 0.2 * fontSize(line gap)
- assertThat("line number $i", actualHeight, equalTo(1.2 * fontSize * lineHeight))
+ // fontSize + 0.2f * fontSize(line gap)
+ assertThat("line number $i", actualHeight, equalTo(1.2f * fontSize * lineHeight))
}
}
@Test
fun lineHeight_hasNoEffectOnLastLine() {
val text = "abc"
- val fontSize = 20.0
+ val fontSize = 20.0f
val layoutWidth = (text.length - 1) * fontSize
- val lineHeight = 1.5
+ val lineHeight = 1.5f
val paragraph = simpleParagraph(
text = text,
@@ -763,7 +763,7 @@
val lastLine = paragraphImpl.lineCount - 1
// In the sample_font.ttf, the height of the line should be
// fontSize + 0.2 * fontSize(line gap)
- assertThat(paragraphImpl.getLineHeight(lastLine), equalTo(1.2 * fontSize))
+ assertThat(paragraphImpl.getLineHeight(lastLine), equalTo(1.2f * fontSize))
}
@Test(expected = IllegalArgumentException::class)
@@ -772,7 +772,7 @@
text = StringBuilder(""),
textStyles = listOf(),
paragraphStyle = ParagraphStyle(
- lineHeight = -1.0
+ lineHeight = -1.0f
)
)
}
@@ -780,7 +780,7 @@
@Test
fun textStyle_setFontSizeOnWholeText() {
val text = "abcde"
- val fontSize = 20.0
+ val fontSize = 20.0f
val textStyle = TextStyle(fontSize = fontSize)
val paragraphWidth = fontSize * text.length
@@ -800,8 +800,8 @@
@Test
fun textStyle_setFontSizeOnPartOfText() {
val text = "abcde"
- val fontSize = 20.0
- val textStyleFontSize = 30.0
+ val fontSize = 20.0f
+ val textStyleFontSize = 30.0f
val textStyle = TextStyle(fontSize = textStyleFontSize)
val paragraphWidth = textStyleFontSize * text.length
@@ -823,10 +823,10 @@
@Test
fun textStyle_seFontSizeTwice_lastOneOverwrite() {
val text = "abcde"
- val fontSize = 20.0
+ val fontSize = 20.0f
val textStyle = TextStyle(fontSize = fontSize)
- val fontSizeOverwrite = 30.0
+ val fontSizeOverwrite = 30.0f
val textStyleOverwrite = TextStyle(fontSize = fontSizeOverwrite)
val paragraphWidth = fontSizeOverwrite * text.length
@@ -850,8 +850,8 @@
@Test
fun textStyle_setLetterSpacingOnWholeText() {
val text = "abcde"
- val fontSize = 20.0
- val letterSpacing = 5.0
+ val fontSize = 20.0f
+ val letterSpacing = 5.0f
val textStyle = TextStyle(letterSpacing = letterSpacing)
val paragraphWidth = fontSize * (1 + letterSpacing) * text.length
@@ -875,8 +875,8 @@
@Test
fun textStyle_setLetterSpacingOnPartText() {
val text = "abcde"
- val fontSize = 20.0
- val letterSpacing = 5.0
+ val fontSize = 20.0f
+ val letterSpacing = 5.0f
val textStyle = TextStyle(letterSpacing = letterSpacing)
val paragraphWidth = fontSize * (1 + letterSpacing) * text.length
@@ -898,12 +898,12 @@
@Test
fun textStyle_setLetterSpacingTwice_lastOneOverwrite() {
val text = "abcde"
- val fontSize = 20.0
+ val fontSize = 20.0f
- val letterSpacing = 5.0
+ val letterSpacing = 5.0f
val textStyle = TextStyle(letterSpacing = letterSpacing)
- val letterSpacingOverwrite = 10.0
+ val letterSpacingOverwrite = 10.0f
val textStyleOverwrite = TextStyle(letterSpacing = letterSpacingOverwrite)
val paragraphWidth = fontSize * (1 + letterSpacingOverwrite) * text.length
@@ -929,7 +929,7 @@
@Test
fun textStyle_fontFamily_changesMeasurement() {
val text = "ad"
- val fontSize = 20.0
+ val fontSize = 20.0f
// custom 100 regular font has b as the wide glyph
// custom 200 regular font has d as the wide glyph
val textStyle = TextStyle(fontFamily = fontFamilyCustom200)
@@ -945,7 +945,7 @@
fontSize = fontSize,
fontFamily = fontFamilyCustom100
)
- paragraph.layout(ParagraphConstraints(width = Double.MAX_VALUE))
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
val paragraphImpl = paragraph.paragraphImpl
assertThat(paragraphImpl.lineCount, equalTo(1))
@@ -961,9 +961,9 @@
text: CharSequence = "",
textAlign: TextAlign? = null,
textDirection: TextDirection? = null,
- fontSize: Double? = null,
+ fontSize: Float? = null,
maxLines: Int? = null,
- lineHeight: Double? = null,
+ lineHeight: Float? = null,
textStyles: List<ParagraphBuilder.TextStyleIndex> = listOf(),
fontFamily: FontFamily = fontFamilyMeasureFont
): Paragraph {
@@ -980,4 +980,4 @@
)
)
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/androidTest/java/androidx/ui/port/engine/text/TextTestExtensions.kt b/ui/port/src/androidTest/java/androidx/ui/port/engine/text/TextTestExtensions.kt
index c297f8d..3eccf98 100644
--- a/ui/port/src/androidTest/java/androidx/ui/port/engine/text/TextTestExtensions.kt
+++ b/ui/port/src/androidTest/java/androidx/ui/port/engine/text/TextTestExtensions.kt
@@ -27,6 +27,6 @@
ceil(this.height).toInt(),
Bitmap.Config.ARGB_8888
)
- this.paint(androidx.ui.painting.Canvas(Canvas(bitmap)), 0.0, 0.0)
+ this.paint(androidx.ui.painting.Canvas(Canvas(bitmap)), 0.0f, 0.0f)
return bitmap
}
\ No newline at end of file
diff --git a/ui/port/src/androidTest/java/androidx/ui/port/engine/text/platform/ParagraphAndroidTest.kt b/ui/port/src/androidTest/java/androidx/ui/port/engine/text/platform/ParagraphAndroidTest.kt
index bf927ef..6b0c6b2 100644
--- a/ui/port/src/androidTest/java/androidx/ui/port/engine/text/platform/ParagraphAndroidTest.kt
+++ b/ui/port/src/androidTest/java/androidx/ui/port/engine/text/platform/ParagraphAndroidTest.kt
@@ -65,7 +65,7 @@
@Test
fun draw_with_newline_and_line_break_default_values() {
- val fontSize = 50.0
+ val fontSize = 50.0f
for (text in arrayOf("abc\ndef", "\u05D0\u05D1\u05D2\n\u05D3\u05D4\u05D5")) {
val paragraphAndroid = simpleParagraph(
text = StringBuilder(text),
@@ -77,7 +77,7 @@
paragraphAndroid.layout(width = 2 * fontSize)
val textPaint = TextPaint(Paint.ANTI_ALIAS_FLAG)
- textPaint.textSize = fontSize.toFloat()
+ textPaint.textSize = fontSize
textPaint.typeface = TypefaceAdapter().create(fontFamily)
val staticLayout = StaticLayoutCompat.Builder(
@@ -100,7 +100,7 @@
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, text.length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText, hasSpan(ForegroundColorSpan::class, 0, text.length))
}
@@ -114,7 +114,7 @@
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, "abc".length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText, hasSpan(ForegroundColorSpan::class, 0, "abc".length))
}
@@ -132,7 +132,7 @@
ParagraphBuilder.TextStyleIndex(textStyleOverwrite, 0, "abc".length)
)
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText, hasSpan(ForegroundColorSpan::class, 0, text.length))
assertThat(paragraph.underlyingText, hasSpan(ForegroundColorSpan::class, 0, "abc".length))
@@ -151,7 +151,7 @@
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, text.length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(paragraph.underlyingText, hasSpan(StrikethroughSpan::class, 0, text.length))
@@ -166,7 +166,7 @@
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, text.length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(paragraph.underlyingText, hasSpan(UnderlineSpan::class, 0, text.length))
@@ -181,7 +181,7 @@
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, "abc".length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(paragraph.underlyingText, hasSpan(StrikethroughSpan::class, 0, "abc".length))
@@ -196,7 +196,7 @@
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, "abc".length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(paragraph.underlyingText, hasSpan(UnderlineSpan::class, 0, "abc".length))
@@ -215,7 +215,7 @@
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, "abc".length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(paragraph.underlyingText, hasSpan(UnderlineSpan::class, 0, "abc".length))
@@ -225,7 +225,7 @@
@Test
fun textStyle_setFontSizeOnWholeText() {
val text = "abcde"
- val fontSize = 20.0
+ val fontSize = 20.0f
val paragraphWidth = text.length * fontSize
val textStyle = TextStyle(fontSize = fontSize)
@@ -241,7 +241,7 @@
@Test
fun textStyle_setFontSizeOnPartText() {
val text = "abcde"
- val fontSize = 20.0
+ val fontSize = 20.0f
val paragraphWidth = text.length * fontSize
val textStyle = TextStyle(fontSize = fontSize)
@@ -257,8 +257,8 @@
@Test
fun textStyle_setFontSizeTwice_lastOneOverwrite() {
val text = "abcde"
- val fontSize = 20.0
- val fontSizeOverwrite = 30.0
+ val fontSize = 20.0f
+ val fontSizeOverwrite = 30.0f
val paragraphWidth = text.length * fontSizeOverwrite
val textStyle = TextStyle(fontSize = fontSize)
val textStyleOverwrite = TextStyle(fontSize = fontSizeOverwrite)
@@ -283,14 +283,14 @@
@Test
fun textStyle_setLetterSpacingOnWholeText() {
val text = "abcde"
- val letterSpacing = 2.0
+ val letterSpacing = 2.0f
val textStyle = TextStyle(letterSpacing = letterSpacing)
val paragraph = simpleParagraph(
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, text.length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(paragraph.underlyingText, hasSpan(LetterSpacingSpan::class, 0, text.length))
}
@@ -298,13 +298,13 @@
@Test
fun textStyle_setLetterSpacingOnPartText() {
val text = "abcde"
- val textStyle = TextStyle(letterSpacing = 2.0)
+ val textStyle = TextStyle(letterSpacing = 2.0f)
val paragraph = simpleParagraph(
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, "abc".length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(paragraph.underlyingText, hasSpan(LetterSpacingSpan::class, 0, "abc".length))
}
@@ -312,8 +312,8 @@
@Test
fun textStyle_setLetterSpacingTwice_lastOneOverwrite() {
val text = "abcde"
- val textStyle = TextStyle(letterSpacing = 2.0)
- val textStyleOverwrite = TextStyle(letterSpacing = 3.0)
+ val textStyle = TextStyle(letterSpacing = 2.0f)
+ val textStyleOverwrite = TextStyle(letterSpacing = 3.0f)
val paragraph = simpleParagraph(
text = text,
@@ -322,7 +322,7 @@
ParagraphBuilder.TextStyleIndex(textStyleOverwrite, 0, "abc".length)
)
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(paragraph.underlyingText, hasSpan(LetterSpacingSpan::class, 0, text.length))
assertThat(paragraph.underlyingText, hasSpan(LetterSpacingSpan::class, 0, "abc".length))
@@ -342,7 +342,7 @@
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, text.length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(paragraph.underlyingText,
@@ -362,7 +362,7 @@
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, "abc".length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(paragraph.underlyingText,
@@ -387,7 +387,7 @@
ParagraphBuilder.TextStyleIndex(textStyleOverwrite, 0, "abc".length)
)
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(paragraph.underlyingText,
@@ -418,7 +418,7 @@
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, text.length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText, hasSpan(LocaleSpan::class, 0, text.length))
}
@@ -433,7 +433,7 @@
text = text,
textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, "abc".length))
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText, hasSpan(LocaleSpan::class, 0, "abc".length))
}
@@ -451,7 +451,7 @@
ParagraphBuilder.TextStyleIndex(textStyleOverwrite, 0, "abc".length)
)
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText, hasSpan(LocaleSpan::class, 0, text.length))
assertThat(paragraph.underlyingText, hasSpan(LocaleSpan::class, 0, "abc".length))
@@ -487,7 +487,7 @@
)
)
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(
@@ -525,7 +525,7 @@
)
)
)
- paragraph.layout(100.0)
+ paragraph.layout(100.0f)
assertThat(paragraph.underlyingText.toString(), equalTo(text))
assertThat(
@@ -542,7 +542,7 @@
text = "abc",
typefaceAdapter = typefaceAdapter
)
- paragraph.layout(Double.MAX_VALUE)
+ paragraph.layout(Float.MAX_VALUE)
verify(typefaceAdapter, never()).create(
fontFamily = any(),
@@ -563,7 +563,7 @@
fontWeight = FontWeight.bold,
typefaceAdapter = typefaceAdapter
)
- paragraph.layout(Double.MAX_VALUE)
+ paragraph.layout(Float.MAX_VALUE)
verify(typefaceAdapter, times(1)).create(
fontFamily = eq(null),
@@ -587,7 +587,7 @@
fontStyle = FontStyle.italic,
typefaceAdapter = typefaceAdapter
)
- paragraph.layout(Double.MAX_VALUE)
+ paragraph.layout(Float.MAX_VALUE)
verify(typefaceAdapter, times(1)).create(
fontFamily = eq(null),
@@ -612,7 +612,7 @@
fontFamily = fontFamily,
typefaceAdapter = typefaceAdapter
)
- paragraph.layout(Double.MAX_VALUE)
+ paragraph.layout(Float.MAX_VALUE)
verify(typefaceAdapter, times(1)).create(
fontFamily = eq(fontFamily),
@@ -635,7 +635,7 @@
fontFamily = fontFamily,
typefaceAdapter = typefaceAdapter
)
- paragraph.layout(Double.MAX_VALUE)
+ paragraph.layout(Float.MAX_VALUE)
verify(typefaceAdapter, times(1)).create(
fontFamily = eq(fontFamily),
@@ -652,7 +652,7 @@
text: CharSequence = "",
textStyles: List<ParagraphBuilder.TextStyleIndex> = listOf(),
textAlign: TextAlign? = null,
- fontSize: Double? = null,
+ fontSize: Float? = null,
maxLines: Int? = null,
fontFamily: FontFamily? = null,
fontWeight: FontWeight? = null,
@@ -673,4 +673,4 @@
)
)
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/androidTest/java/androidx/ui/port/engine/text/platform/TextTestExtensions.kt b/ui/port/src/androidTest/java/androidx/ui/port/engine/text/platform/TextTestExtensions.kt
index 28e937f..de2c864 100644
--- a/ui/port/src/androidTest/java/androidx/ui/port/engine/text/platform/TextTestExtensions.kt
+++ b/ui/port/src/androidTest/java/androidx/ui/port/engine/text/platform/TextTestExtensions.kt
@@ -31,7 +31,7 @@
ceil(this.height).toInt(),
Bitmap.Config.ARGB_8888
)
- this.paint(androidx.ui.painting.Canvas(Canvas(bitmap)), 0.0, 0.0)
+ this.paint(androidx.ui.painting.Canvas(Canvas(bitmap)), 0.0f, 0.0f)
return bitmap
}
@@ -58,7 +58,7 @@
val layout = TextLayout(
charSequence = text,
textPaint = paint,
- width = text.length * fontSize * 1.5
+ width = text.length * fontSize * 1.5f
)
return layout.layout.bitmap()
}
\ No newline at end of file
diff --git a/ui/port/src/androidTest/java/androidx/ui/port/integration/ContainingViewTest.kt b/ui/port/src/androidTest/java/androidx/ui/port/integration/ContainingViewTest.kt
index 1048372..59c24ab 100644
--- a/ui/port/src/androidTest/java/androidx/ui/port/integration/ContainingViewTest.kt
+++ b/ui/port/src/androidTest/java/androidx/ui/port/integration/ContainingViewTest.kt
@@ -100,7 +100,7 @@
var didLayout = false
val layout = LayoutNode { _, _ ->
didLayout = true
- Size(9.0, 10.0)
+ Size(9.0f, 10.0f)
}
val view = setContainingView(layout)
@@ -138,13 +138,13 @@
position(child, (width - child.width) / 2, (height - child.height) / 2)
}
}
- Size(width.toDouble(), height.toDouble())
+ Size(width.toFloat(), height.toFloat())
}
val squareLayout = LayoutNode { constraints, _ ->
- Size(10.0, 10.0)
+ Size(10.0f, 10.0f)
}
val rectLayout = LayoutNode { constraints, _ ->
- Size(20.0, 8.0)
+ Size(20.0f, 8.0f)
}
outerLayout.add(0, squareLayout)
@@ -199,12 +199,12 @@
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return
}
- val layout = LayoutNode { _, _ -> Size(10.0, 10.0) }
+ val layout = LayoutNode { _, _ -> Size(10.0f, 10.0f) }
val drawLatch = CountDownLatch(1)
val draw = DrawNode { canvas ->
drawLatch.countDown()
drawFill(canvas, 0xFF0000FF.toInt()) { c, paint ->
- c.drawRect(Rect(0.0, 0.0, 10.0, 10.0), paint)
+ c.drawRect(Rect(0.0f, 0.0f, 10.0f, 10.0f), paint)
}
}
draw.invalidate()
@@ -212,7 +212,7 @@
val view = setContainingView(layout)
assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
- val bitmap = waitAndScreenShot(Rect(0.0, 0.0, 10.0, 10.0), view)
+ val bitmap = waitAndScreenShot(Rect(0.0f, 0.0f, 10.0f, 10.0f), view)
assertEquals(0xFF0000FF.toInt(), bitmap.getPixel(0, 0))
assertEquals(0xFF0000FF.toInt(), bitmap.getPixel(9, 9))
assertEquals(0xFF0000FF.toInt(), bitmap.getPixel(0, 9))
@@ -227,18 +227,18 @@
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return
}
- val layout = LayoutNode { _, _ -> Size(10.0, 10.0) }
+ val layout = LayoutNode { _, _ -> Size(10.0f, 10.0f) }
val drawLatch = CountDownLatch(1)
val square = DrawNode { canvas ->
drawLatch.countDown()
drawFill(canvas, 0xFF0000FF.toInt()) { c, paint ->
- c.drawRect(Rect(0.0, 0.0, 10.0, 10.0), paint)
+ c.drawRect(Rect(0.0f, 0.0f, 10.0f, 10.0f), paint)
}
}
layout.add(0, square)
val circle = DrawNode { canvas ->
drawFill(canvas, 0xFF00FF00.toInt()) { c, paint ->
- c.drawOval(Rect(0.0, 0.0, 10.0, 10.0), paint)
+ c.drawOval(Rect(0.0f, 0.0f, 10.0f, 10.0f), paint)
}
}
layout.add(1, circle)
@@ -246,7 +246,7 @@
val view = setContainingView(layout)
assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
- val bitmap = waitAndScreenShot(Rect(0.0, 0.0, 10.0, 10.0), view)
+ val bitmap = waitAndScreenShot(Rect(0.0f, 0.0f, 10.0f, 10.0f), view)
// Square is drawn to the corners
assertEquals(0xFF0000FF.toInt(), bitmap.getPixel(0, 0))
assertEquals(0xFF0000FF.toInt(), bitmap.getPixel(9, 9))
@@ -276,20 +276,20 @@
measure(second, c, false)
position(first, 0, 0)
position(second, 10, 10)
- Size(20.0, 20.0)
+ Size(20.0f, 20.0f)
}
- val subLayout1 = LayoutNode { _, _ -> Size(10.0, 10.0) }
- val subLayout2 = LayoutNode { _, _ -> Size(10.0, 10.0) }
+ val subLayout1 = LayoutNode { _, _ -> Size(10.0f, 10.0f) }
+ val subLayout2 = LayoutNode { _, _ -> Size(10.0f, 10.0f) }
val redRect = DrawNode { canvas ->
drawFill(canvas, 0xFFFF0000.toInt()) { c, paint ->
- c.drawRect(Rect(0.0, 0.0, 10.0, 10.0), paint)
+ c.drawRect(Rect(0.0f, 0.0f, 10.0f, 10.0f), paint)
}
}
val drawLatch = CountDownLatch(1)
val blueRect = DrawNode { canvas ->
drawLatch.countDown()
drawFill(canvas, 0xFF0000FF.toInt()) { c, paint ->
- c.drawRect(Rect(0.0, 0.0, 10.0, 10.0), paint)
+ c.drawRect(Rect(0.0f, 0.0f, 10.0f, 10.0f), paint)
}
}
subLayout1.add(0, redRect)
@@ -300,7 +300,7 @@
val view = setContainingView(layout)
assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
- val bitmap = waitAndScreenShot(Rect(0.0, 0.0, 20.0, 20.0), view)
+ val bitmap = waitAndScreenShot(Rect(0.0f, 0.0f, 20.0f, 20.0f), view)
// top-left square is red
assertEquals(0xFFFF0000.toInt(), bitmap.getPixel(5, 5))
@@ -321,27 +321,27 @@
val first = layoutChildren[children[1]]!!
measure(first, c, false)
position(first, 0, 0)
- Size(20.0, 20.0)
+ Size(20.0f, 20.0f)
}
val drawLatch = CountDownLatch(1)
val draw1 = DrawNode { canvas ->
drawFill(canvas, android.graphics.Color.BLUE) { c, paint ->
- c.drawRect(Rect(0.0, 0.0, 20.0, 20.0), paint)
+ c.drawRect(Rect(0.0f, 0.0f, 20.0f, 20.0f), paint)
}
drawLatch.countDown()
}
val draw2 = DrawNode { canvas ->
drawFill(canvas, android.graphics.Color.BLACK) { c, paint ->
- c.drawOval(Rect(0.0, 0.0, 20.0, 20.0), paint)
+ c.drawOval(Rect(0.0f, 0.0f, 20.0f, 20.0f), paint)
}
}
val draw3 = DrawNode { canvas ->
drawFill(canvas, android.graphics.Color.WHITE) { c, paint ->
- c.drawRect(Rect(5.0, 5.0, 15.0, 15.0), paint)
+ c.drawRect(Rect(5.0f, 5.0f, 15.0f, 15.0f), paint)
}
}
layout.add(0, draw1)
- val child1 = LayoutNode { _, _ -> Size(20.0, 20.0) }
+ val child1 = LayoutNode { _, _ -> Size(20.0f, 20.0f) }
layout.add(1, child1)
child1.add(0, draw2)
layout.add(2, draw3)
@@ -349,7 +349,7 @@
val view = setContainingView(layout)
assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
- val bitmap = waitAndScreenShot(Rect(0.0, 0.0, 20.0, 20.0), view)
+ val bitmap = waitAndScreenShot(Rect(0.0f, 0.0f, 20.0f, 20.0f), view)
// outer corners should be draw1's blue
assertEquals(android.graphics.Color.BLUE, bitmap.getPixel(0, 0))
@@ -385,11 +385,11 @@
max(firstSize.height, secondSize.height)
)
}
- var size1 = 10.0
+ var size1 = 10.0f
val layout1 = LayoutNode { _, _ -> Size(size1, size1) }
outer.add(0, layout1)
- val layout2 = LayoutNode { _, _ -> Size(10.0, 10.0) }
+ val layout2 = LayoutNode { _, _ -> Size(10.0f, 10.0f) }
outer.add(1, layout2)
val view = setContainingView(outer)
@@ -401,7 +401,7 @@
assertEquals(10, view.height)
}
- size1 = 20.0
+ size1 = 20.0f
layout1.dirtyLayout()
assertTrue(layoutLatch2.await(1, TimeUnit.SECONDS))
diff --git a/ui/port/src/androidTest/java/androidx/ui/port/painting/TextPainterTest.kt b/ui/port/src/androidTest/java/androidx/ui/port/painting/TextPainterTest.kt
index d1728cf..6328ec6 100644
--- a/ui/port/src/androidTest/java/androidx/ui/port/painting/TextPainterTest.kt
+++ b/ui/port/src/androidTest/java/androidx/ui/port/painting/TextPainterTest.kt
@@ -47,8 +47,8 @@
@Test
fun preferredLineHeight_style_set() {
- val fontSize = 20.0
- val scaleFactor = 3.0
+ val fontSize = 20.0f
+ val scaleFactor = 3.0f
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = "Hello", style = textStyle)
val textPainter = TextPainter(text = textSpan, textScaleFactor = scaleFactor)
@@ -73,7 +73,7 @@
@Test
fun minIntrinsicWidth_getter() {
- val fontSize = 20.0
+ val fontSize = 20.0f
val text = "Hello"
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = text, style = textStyle)
@@ -81,12 +81,12 @@
textPainter.layout()
- assertThat(textPainter.minIntrinsicWidth).isEqualTo(0.0)
+ assertThat(textPainter.minIntrinsicWidth).isEqualTo(0.0f)
}
@Test
fun maxIntrinsicWidth_getter() {
- val fontSize = 20.0
+ val fontSize = 20.0f
val text = "Hello"
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = text, style = textStyle)
@@ -99,20 +99,20 @@
@Test
fun width_getter() {
- val fontSize = 20.0
+ val fontSize = 20.0f
val text = "Hello"
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = text, style = textStyle)
val textPainter = TextPainter(text = textSpan, textDirection = TextDirection.RTL)
- textPainter.layout(0.0, 200.0)
+ textPainter.layout(0.0f, 200.0f)
assertThat(textPainter.width).isEqualTo(fontSize * text.length)
}
@Test
fun height_getter() {
- val fontSize = 20.0
+ val fontSize = 20.0f
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = "Hello", style = textStyle)
val textPainter = TextPainter(text = textSpan, textDirection = TextDirection.RTL)
@@ -124,7 +124,7 @@
@Test
fun size_getter() {
- val fontSize = 20.0
+ val fontSize = 20.0f
val text = "Hello"
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = text, style = textStyle)
@@ -168,7 +168,7 @@
val textPainter =
TextPainter(text = textSpan, textDirection = TextDirection.RTL, maxLines = 2)
- textPainter.layout(0.0, 200.0)
+ textPainter.layout(0.0f, 200.0f)
assertThat(textPainter.didExceedMaxLines).isTrue()
}
@@ -180,7 +180,7 @@
val textPainter =
TextPainter(text = textSpan, textDirection = TextDirection.RTL, maxLines = 2)
- textPainter.layout(0.0, 200.0)
+ textPainter.layout(0.0f, 200.0f)
assertThat(textPainter.didExceedMaxLines).isFalse()
}
@@ -190,7 +190,7 @@
val textPainter =
TextPainter(text = TextSpan(text = "Hello"), textDirection = TextDirection.LTR)
- textPainter.layout(0.0, 20.0)
+ textPainter.layout(0.0f, 20.0f)
assertThat(textPainter.paragraph).isNotNull()
}
diff --git a/ui/port/src/androidTest/java/androidx/ui/port/rendering/RenderParagraphTest.kt b/ui/port/src/androidTest/java/androidx/ui/port/rendering/RenderParagraphTest.kt
index 195b608..fe6e2e3 100644
--- a/ui/port/src/androidTest/java/androidx/ui/port/rendering/RenderParagraphTest.kt
+++ b/ui/port/src/androidTest/java/androidx/ui/port/rendering/RenderParagraphTest.kt
@@ -47,34 +47,34 @@
@Test
fun computeMinIntrinsicWidth_returnMinWidth() {
- val fontSize = 20.0
+ val fontSize = 20.0f
val text = "Hello"
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = text, style = textStyle)
val paragraph = RenderParagraph(text = textSpan, textDirection = TextDirection.LTR)
- assertThat(paragraph.computeMinIntrinsicWidth(0.0)).isEqualTo(0.0)
+ assertThat(paragraph.computeMinIntrinsicWidth(0.0f)).isEqualTo(0.0f)
}
@Test
fun computeMaxIntrinsicWidth_returnParagraphWidth() {
- val fontSize = 20.0
+ val fontSize = 20.0f
val text = "Hello"
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = text, style = textStyle)
val paragraph = RenderParagraph(text = textSpan, textDirection = TextDirection.LTR)
- assertThat(paragraph.computeMaxIntrinsicWidth(0.0)).isEqualTo(fontSize * text.length)
+ assertThat(paragraph.computeMaxIntrinsicWidth(0.0f)).isEqualTo(fontSize * text.length)
}
@Test
fun computeIntrinsicHeight_wrap() {
- val fontSize = 16.8
+ val fontSize = 16.8f
val text = "Hello"
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = text, style = textStyle)
val paragraph = RenderParagraph(text = textSpan, textDirection = TextDirection.LTR)
- val maxWidth = 38.0
+ val maxWidth = 38.0f
val charPerLine = floor(maxWidth / fontSize)
val numberOfLines = ceil(text.length / charPerLine)
@@ -89,20 +89,20 @@
@Test
fun computeIntrinsicHeight_not_wrap() {
- val fontSize = 20.0
+ val fontSize = 20.0f
val text = "Hello"
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = text, style = textStyle)
val paragraph =
RenderParagraph(text = textSpan, textDirection = TextDirection.LTR, softWrap = false)
- val maxWidth = 38.0
+ val maxWidth = 38.0f
assertThat(paragraph.computeIntrinsicHeight(maxWidth)).isEqualTo(fontSize)
}
@Test
fun textSizeGetter() {
- val fontSize = 20.0
+ val fontSize = 20.0f
val text = "Hello"
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = text, style = textStyle)
@@ -116,7 +116,7 @@
@Test
fun textWidthGetter() {
- val fontSize = 20.0
+ val fontSize = 20.0f
val text = "Hello"
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = text, style = textStyle)
@@ -129,7 +129,7 @@
@Test
fun textHeightGetter() {
- val fontSize = 20.0
+ val fontSize = 20.0f
val text = "Hello"
val textStyle = TextStyle(fontSize = fontSize, fontFamily = fontFamily)
val textSpan = TextSpan(text = text, style = textStyle)
diff --git a/ui/port/src/main/java/androidx/ui/CraneView.kt b/ui/port/src/main/java/androidx/ui/CraneView.kt
index 46d3d63..77a8e15 100644
--- a/ui/port/src/main/java/androidx/ui/CraneView.kt
+++ b/ui/port/src/main/java/androidx/ui/CraneView.kt
@@ -110,8 +110,8 @@
private fun processInput(event: MotionEvent, pointerIndex: Int, change: PointerChange) {
val pointerDataPacket = PointerDataPacket()
val id = event.getPointerId(pointerIndex)
- val x = event.getX(pointerIndex).toDouble()
- val y = event.getY(pointerIndex).toDouble()
+ val x = event.getX(pointerIndex)
+ val y = event.getY(pointerIndex)
pointerDataPacket.data.add(
PointerData(
timeStamp = Duration.create(milliseconds = event.eventTime),
@@ -127,10 +127,10 @@
}
private fun updateMetrics() {
- val devicePixelRatio = resources.displayMetrics.density.toDouble()
- val size = Size(measuredWidth.toDouble(), measuredHeight.toDouble())
- val padding = WindowPadding(paddingLeft.toDouble(), paddingTop.toDouble(),
- paddingRight.toDouble(), paddingBottom.toDouble())
+ val devicePixelRatio = resources.displayMetrics.density
+ val size = Size(measuredWidth.toFloat(), measuredHeight.toFloat())
+ val padding = WindowPadding(paddingLeft.toFloat(), paddingTop.toFloat(),
+ paddingRight.toFloat(), paddingBottom.toFloat())
if (window.devicePixelRatio != devicePixelRatio ||
window.physicalSize != size ||
window.padding != padding) {
@@ -142,10 +142,10 @@
paddingRight = padding.right,
paddingBottom = padding.bottom,
paddingLeft = padding.left,
- viewInsetTop = 0.0,
- viewInsetRight = 0.0,
- viewInsetBottom = 0.0,
- viewInsetLeft = 0.0
+ viewInsetTop = 0.0f,
+ viewInsetRight = 0.0f,
+ viewInsetBottom = 0.0f,
+ viewInsetLeft = 0.0f
)
}
}
diff --git a/ui/port/src/main/java/androidx/ui/Helpers.kt b/ui/port/src/main/java/androidx/ui/Helpers.kt
index 3ffb376..d5352c5 100644
--- a/ui/port/src/main/java/androidx/ui/Helpers.kt
+++ b/ui/port/src/main/java/androidx/ui/Helpers.kt
@@ -1,29 +1,31 @@
package androidx.ui
import android.os.Looper
+import kotlin.math.max
+import kotlin.math.min
import kotlin.math.truncate
// These are purely Crane helpers for flutter migration. Feel free to add more.
// Copied from Dart
-fun lerpDouble(a: Double, b: Double, t: Double): Double {
+fun lerpFloat(a: Float, b: Float, t: Float): Float {
return a + (b - a) * t
}
-fun lerpInt(a: Int, b: Int, t: Double): Double {
+fun lerpInt(a: Int, b: Int, t: Float): Float {
return a + (b - a) * t
}
// Copied from Dart
-fun Double.toStringAsFixed(digits: Int) = java.lang.String.format("%.${digits}f", this)!!
+fun Float.toStringAsFixed(digits: Int) = java.lang.String.format("%.${digits}f", this)!!
// Copied from Dart
-fun Double.truncDiv(other: Double) = truncate(this / other).toInt()
+fun Float.truncDiv(other: Float) = truncate(this / other).toInt()
// Dart spec: If both operands are ints then a ~/ b performs the truncating integer division.
fun Int.truncDiv(other: Int) = this / other
-fun Double.clamp(min: Double, max: Double) = Math.max(min, Math.min(max, this))
+fun Float.clamp(min: Float, max: Float) = coerceIn(min, max)
fun Int.clamp(min: Int, max: Int) = Math.max(min, Math.min(max, this))
diff --git a/ui/port/src/main/java/androidx/ui/Hooks.kt b/ui/port/src/main/java/androidx/ui/Hooks.kt
index cff5e70..7a79ec7 100644
--- a/ui/port/src/main/java/androidx/ui/Hooks.kt
+++ b/ui/port/src/main/java/androidx/ui/Hooks.kt
@@ -37,17 +37,17 @@
import androidx.ui.engine.window.WindowPadding
fun Window.updateWindowMetrics(
- devicePixelRatio: Double,
- width: Double,
- height: Double,
- paddingTop: Double,
- paddingRight: Double,
- paddingBottom: Double,
- paddingLeft: Double,
- viewInsetTop: Double,
- viewInsetRight: Double,
- viewInsetBottom: Double,
- viewInsetLeft: Double
+ devicePixelRatio: Float,
+ width: Float,
+ height: Float,
+ paddingTop: Float,
+ paddingRight: Float,
+ paddingBottom: Float,
+ paddingLeft: Float,
+ viewInsetTop: Float,
+ viewInsetRight: Float,
+ viewInsetBottom: Float,
+ viewInsetLeft: Float
) {
this.devicePixelRatio = devicePixelRatio
this.physicalSize = Size(width, height)
diff --git a/ui/port/src/main/java/androidx/ui/Vertices.kt b/ui/port/src/main/java/androidx/ui/Vertices.kt
index 9db7294..6c48368 100644
--- a/ui/port/src/main/java/androidx/ui/Vertices.kt
+++ b/ui/port/src/main/java/androidx/ui/Vertices.kt
@@ -62,9 +62,9 @@
val pointIndex = i / 2
val point = points[pointIndex]
if (i % 2 == 0) {
- point.dx.toFloat()
+ point.dx
} else {
- point.dy.toFloat()
+ point.dy
}
}
}
diff --git a/ui/port/src/main/java/androidx/ui/animation/Animatable.kt b/ui/port/src/main/java/androidx/ui/animation/Animatable.kt
index 8820517..722243f 100644
--- a/ui/port/src/main/java/androidx/ui/animation/Animatable.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/Animatable.kt
@@ -29,13 +29,13 @@
abstract class Animatable<T> {
/** The current value of this object for the given animation. */
- abstract fun evaluate(animation: Animation<Double>): T
+ abstract fun evaluate(animation: Animation<Float>): T
/**
* Returns a new Animation that is driven by the given animation but that
* takes on values determined by this object.
*/
- fun animate(parent: Animation<Double>): Animation<T> {
+ fun animate(parent: Animation<Float>): Animation<T> {
return AnimatedEvaluation(parent, this)
}
@@ -43,13 +43,13 @@
* Returns a new Animatable whose value is determined by first evaluating
* the given parent and then evaluating this object.
*/
- fun chain(parent: Animatable<Double>): Animatable<T> {
+ fun chain(parent: Animatable<Float>): Animatable<T> {
return ChainedEvaluation(parent, this)
}
}
private class AnimatedEvaluation<T>(
- parent: Animation<Double>,
+ parent: Animation<Float>,
private val evaluatable: Animatable<T>
) : AnimationWithParentMixin<T>(parent) {
@@ -61,14 +61,14 @@
}
private class ChainedEvaluation<T>(
- private val parent: Animatable<Double>,
+ private val parent: Animatable<Float>,
private val evaluatable: Animatable<T>
) : Animatable<T>() {
- override fun evaluate(animation: Animation<Double>): T {
+ override fun evaluate(animation: Animation<Float>): T {
val value = parent.evaluate(animation)
return evaluatable.evaluate(AlwaysStoppedAnimation(value))
}
override fun toString() = "$parent\u27A9$evaluatable"
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/animation/AnimationController.kt b/ui/port/src/main/java/androidx/ui/animation/AnimationController.kt
index a61e765..33eed6f 100644
--- a/ui/port/src/main/java/androidx/ui/animation/AnimationController.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/AnimationController.kt
@@ -21,7 +21,7 @@
import androidx.ui.clamp
import androidx.ui.core.Duration
import androidx.ui.foundation.assertions.FlutterError
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.physics.Simulation
import androidx.ui.runtimeType
import androidx.ui.scheduler.ticker.Ticker
@@ -98,7 +98,7 @@
* * [value] is the initial value of the animation. If defaults to the lower
* bound.
*/
- value: Double? = null,
+ value: Float? = null,
/** * [duration] is the length of time this animation should last. */
var duration: Duration? = null,
/**
@@ -111,20 +111,20 @@
* value at which this animation is deemed to be DISMISSED. It cannot be
* null.
*/
- private val lowerBound: Double = 0.0,
+ private val lowerBound: Float = 0.0f,
/**
* * [upperBound] is the largest value this animation can obtain and the
* value at which this animation is deemed to be completed. It cannot be
* null.
*/
- private val upperBound: Double = 1.0,
+ private val upperBound: Float = 1.0f,
/**
* * `vsync` is the [TickerProvider] for the current context. It can be
* changed by calling [resync]. It is required and must not be null. See
* [TickerProvider] for advice on obtaining a ticker provider.
*/
vsync: TickerProvider
-) : AnimationEagerListenerMixin<Double>() {
+) : AnimationEagerListenerMixin<Float>() {
private var ticker: Ticker?
@@ -142,7 +142,7 @@
* running; if this happens, it also notifies all the status
* listeners.
*/
- private var _value: Double = 0.0
+ private var _value: Float = 0.0f
set(value) {
field = value.clamp(lowerBound, upperBound)
_status = if (field == lowerBound) {
@@ -176,7 +176,7 @@
* * [forward], [reverse], [animateTo], [animateWith], [fling], and [repeat],
* which start the animation controller.
*/
- override var value: Double
+ override var value: Float
get() = _value
set(newValue) {
stop()
@@ -193,11 +193,11 @@
}
/**
- * Returns an [Animation<double>] for this animation controller, so that a
+ * Returns an [Animation<Float>] for this animation controller, so that a
* pointer to this object can be passed around without allowing users of that
* pointer to mutate the [AnimationController] state.
*/
- val view: Animation<Double> = this
+ val view: Animation<Float> = this
/** Recreates the [Ticker] with the new [TickerProvider]. */
fun resync(vsync: TickerProvider) {
@@ -233,12 +233,12 @@
* If [isAnimating] is false, then [value] is not changing and the rate of
* change is zero.
*/
- val velocity: Double
+ val velocity: Float
get() {
if (!isAnimating)
- return 0.0
+ return 0.0f
return simulation!!.dx(
- lastElapsedDuration!!.inMicroseconds.toDouble() /
+ lastElapsedDuration!!.inMicroseconds.toFloat() /
Duration.microsecondsPerSecond
)
}
@@ -278,7 +278,7 @@
* which switches to [AnimationStatus.COMPLETED] when [upperBound] is
* reached at the end of the animation.
*/
- fun forward(from: Double? = null): TickerFuture {
+ fun forward(from: Float? = null): TickerFuture {
assert {
if (duration == null) {
throw FlutterError(
@@ -308,7 +308,7 @@
* which switches to [AnimationStatus.DISMISSED] when [lowerBound] is
* reached at the end of the animation.
*/
- fun reverse(from: Double? = null): TickerFuture {
+ fun reverse(from: Float? = null): TickerFuture {
assert {
if (duration == null) {
throw FlutterError(
@@ -340,7 +340,7 @@
* [AnimationStatus.COMPLETED].
*/
fun animateTo(
- target: Double,
+ target: Float,
duration: Duration? = null,
curve: Curve = Curves.linear
): TickerFuture {
@@ -349,7 +349,7 @@
}
private fun animateToInternal(
- target: Double,
+ target: Float,
duration: Duration? = null,
curve: Curve = Curves.linear
): TickerFuture {
@@ -369,7 +369,7 @@
}
val range = upperBound - lowerBound
val remainingFraction =
- if (range.isFinite()) (target - _value).absoluteValue / range else 1.0
+ if (range.isFinite()) (target - _value).absoluteValue / range else 1.0f
simulationDuration = this.duration!! * remainingFraction.toInt()
} else if (target == value) {
// Already at target, don't animate.
@@ -412,7 +412,7 @@
* canceled, meaning the future never completes and its [TickerFuture.orCancel]
* derivative future completes with a [TickerCanceled] error.
*/
- fun repeat(min: Double? = null, max: Double? = null, period: Duration? = null): TickerFuture {
+ fun repeat(min: Float? = null, max: Float? = null, period: Duration? = null): TickerFuture {
val finalMin = min ?: lowerBound
val finalMax = max ?: upperBound
val finalPeriod = period ?: duration
@@ -444,7 +444,7 @@
* canceled, meaning the future never completes and its [TickerFuture.orCancel]
* derivative future completes with a [TickerCanceled] error.
*/
- fun fling(velocity: Double = 1.0): TickerFuture {
+ fun fling(velocity: Float = 1.0f): TickerFuture {
TODO("Migration|Andrey. Needs SpringSimulation")
// direction = if (velocity < 0.0) AnimationDirection.REVERSE else AnimationDirection.FORWARD
// val target = if (velocity < 0.0) lowerBound - _kFlingTolerance.distance
@@ -473,7 +473,7 @@
assert(!isAnimating)
this.simulation = simulation
lastElapsedDuration = Duration.zero
- _value = simulation.x(0.0).clamp(lowerBound, upperBound)
+ _value = simulation.x(0.0f).clamp(lowerBound, upperBound)
val result = ticker!!.start()
_status = if (direction == AnimationDirection.FORWARD)
AnimationStatus.FORWARD else
@@ -544,8 +544,8 @@
private fun tick(elapsed: Duration) {
lastElapsedDuration = elapsed
- val elapsedInSeconds = elapsed.inMicroseconds.toDouble() / Duration.microsecondsPerSecond
- assert(elapsedInSeconds >= 0.0)
+ val elapsedInSeconds = elapsed.inMicroseconds.toFloat() / Duration.microsecondsPerSecond
+ assert(elapsedInSeconds >= 0.0f)
val sim = simulation!!
_value = sim.x(elapsedInSeconds).clamp(lowerBound, upperBound)
if (sim.isDone(elapsedInSeconds)) {
@@ -588,7 +588,7 @@
* pre-determined bounds.
*/
fun unbounded(
- value: Double = 0.0,
+ value: Float = 0.0f,
duration: Duration? = null,
debugLabel: String? = null,
vsync: TickerProvider
@@ -598,16 +598,16 @@
duration = duration,
debugLabel = debugLabel,
vsync = vsync,
- lowerBound = Double.NEGATIVE_INFINITY,
- upperBound = Double.POSITIVE_INFINITY
+ lowerBound = Float.NEGATIVE_INFINITY,
+ upperBound = Float.POSITIVE_INFINITY
)
}
}
}
private class InterpolationSimulation(
- private val begin: Double,
- private val end: Double,
+ private val begin: Float,
+ private val end: Float,
duration: Duration,
private val curve: Curve
) : Simulation() {
@@ -617,46 +617,46 @@
}
private val durationInSeconds =
- duration.inMicroseconds.toDouble() / Duration.microsecondsPerSecond
+ duration.inMicroseconds.toFloat() / Duration.microsecondsPerSecond
- override fun x(timeInSeconds: Double): Double {
- val t = (timeInSeconds / durationInSeconds).clamp(0.0, 1.0)
+ override fun x(timeInSeconds: Float): Float {
+ val t = (timeInSeconds / durationInSeconds).clamp(0.0f, 1.0f)
return when (t) {
- 0.0 -> begin
- 1.0 -> end
+ 0.0f -> begin
+ 1.0f -> end
else -> begin + (end - begin) * curve.transform(t)
}
}
- override fun dx(timeInSeconds: Double): Double {
+ override fun dx(timeInSeconds: Float): Float {
val epsilon = tolerance.time
return (x(timeInSeconds + epsilon) -
x(timeInSeconds - epsilon)) / (2 * epsilon)
}
- override fun isDone(timeInSeconds: Double) = timeInSeconds >= durationInSeconds
+ override fun isDone(timeInSeconds: Float) = timeInSeconds >= durationInSeconds
}
private class RepeatingSimulation(
- private val min: Double,
- private val max: Double,
+ private val min: Float,
+ private val max: Float,
period: Duration
) : Simulation() {
private val periodInSeconds =
- period.inMicroseconds.toDouble() / Duration.microsecondsPerSecond
+ period.inMicroseconds.toFloat() / Duration.microsecondsPerSecond
init {
- assert(periodInSeconds > 0.0)
+ assert(periodInSeconds > 0.0f)
}
- override fun x(timeInSeconds: Double): Double {
- assert(timeInSeconds >= 0.0)
- val t = (timeInSeconds / periodInSeconds) % 1.0
- return lerpDouble(min, max, t)
+ override fun x(timeInSeconds: Float): Float {
+ assert(timeInSeconds >= 0.0f)
+ val t = (timeInSeconds / periodInSeconds) % 1.0f
+ return lerpFloat(min, max, t)
}
- override fun dx(timeInSeconds: Double): Double = (max - min) / periodInSeconds
+ override fun dx(timeInSeconds: Float): Float = (max - min) / periodInSeconds
- override fun isDone(timeInSeconds: Double) = false
+ override fun isDone(timeInSeconds: Float) = false
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/animation/Curves.kt b/ui/port/src/main/java/androidx/ui/animation/Curves.kt
index e0a278f..196618c 100644
--- a/ui/port/src/main/java/androidx/ui/animation/Curves.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/Curves.kt
@@ -19,7 +19,10 @@
import androidx.ui.clamp
import androidx.ui.runtimeType
import androidx.ui.toStringAsFixed
+import androidx.ui.vectormath64.PI
import kotlin.math.absoluteValue
+import kotlin.math.pow
+import kotlin.math.sin
import kotlin.math.truncate
/**
@@ -39,7 +42,7 @@
*
* A curve must map t=0.0 to 0.0 and t=1.0 to 1.0.
*/
- abstract fun transform(t: Double): Double
+ abstract fun transform(t: Float): Float
/**
* Returns a new curve that is the reversed inversion of this one.
@@ -65,7 +68,7 @@
* See [Curves.linear] for an instance of this class.
*/
private class Linear : Curve() {
- override fun transform(t: Double) = t
+ override fun transform(t: Float) = t
}
/**
@@ -81,10 +84,10 @@
private val count: Int
) : Curve() {
- override fun transform(t: Double): Double {
+ override fun transform(t: Float): Float {
assert(t in 0.0..1.0)
- if (t == 1.0)
- return 1.0
+ if (t == 1.0f)
+ return 1.0f
val newT = t * count
return newT - truncate(newT)
}
@@ -109,28 +112,28 @@
*
* From t=0.0 to t=`begin`, the interval's value is 0.0.
*/
- private val begin: Double,
+ private val begin: Float,
/**
* The smallest value for which this interval is 1.0.
*
* From t=`end` to t=1.0, the interval's value is 1.0.
*/
- private val end: Double,
+ private val end: Float,
/** The curve to apply between [begin] and [end]. */
private val curve: Curve = Curves.linear
) : Curve() {
- override fun transform(t: Double): Double {
+ override fun transform(t: Float): Float {
assert(t in 0.0..1.0)
assert(begin >= 0.0)
assert(begin <= 1.0)
assert(end >= 0.0)
assert(end <= 1.0)
assert(end >= begin)
- if (t == 0.0 || t == 1.0)
+ if (t == 0.0f || t == 1.0f)
return t
- val newT = ((t - begin) / (end - begin)).clamp(0.0, 1.0)
- if (newT == 0.0 || newT == 1.0)
+ val newT = ((t - begin) / (end - begin)).clamp(0.0f, 1.0f)
+ if (newT == 0.0f || newT == 1.0f)
return newT
return curve.transform(newT)
}
@@ -155,20 +158,20 @@
*
* When t is exactly [threshold], the curve has the value 1.0.
*/
- private val threshold: Double
+ private val threshold: Float
) : Curve() {
- override fun transform(t: Double): Double {
+ override fun transform(t: Float): Float {
assert(t in 0.0..1.0)
assert(threshold >= 0.0)
assert(threshold <= 1.0)
- if (t == 0.0 || t == 1.0)
+ if (t == 0.0f || t == 1.0f)
return t
- return if (t < threshold) 0.0 else 1.0
+ return if (t < threshold) 0.0f else 1.0f
}
}
-private const val CUBIC_ERROR_BOUND: Double = 0.001
+private const val CUBIC_ERROR_BOUND: Float = 0.001f
/**
* A cubic polynomial mapPIng of the unit interval.
@@ -197,40 +200,40 @@
* The line through the point (0, 0) and the first control point is tangent
* to the curve at the point (0, 0).
*/
- private val a: Double,
+ private val a: Float,
/**
* The y coordinate of the first control point.
*
* The line through the point (0, 0) and the first control point is tangent
* to the curve at the point (0, 0).
*/
- private val b: Double,
+ private val b: Float,
/**
* The x coordinate of the second control point.
*
* The line through the point (1, 1) and the second control point is tangent
* to the curve at the point (1, 1).
*/
- private val c: Double,
+ private val c: Float,
/**
* The y coordinate of the second control point.
*
* The line through the point (1, 1) and the second control point is tangent
* to the curve at the point (1, 1).
*/
- private val d: Double
+ private val d: Float
) : Curve() {
- private fun evaluateCubic(a: Double, b: Double, m: Double): Double {
+ private fun evaluateCubic(a: Float, b: Float, m: Float): Float {
return 3 * a * (1 - m) * (1 - m) * m +
3 * b * (1 - m) * /* */ m * m +
/* */ m * m * m
}
- override fun transform(t: Double): Double {
- assert(t in 0.0..1.0)
- var start = 0.0
- var end = 1.0
+ override fun transform(t: Float): Float {
+ assert(t in 0.0f..1.0f)
+ var start = 0.0f
+ var end = 1.0f
while (true) {
val midpoint = (start + end) / 2
val estimate = evaluateCubic(a, c, midpoint)
@@ -267,7 +270,7 @@
private val curve: Curve
) : Curve() {
- override fun transform(t: Double) = 1.0 - curve.transform(1.0 - t)
+ override fun transform(t: Float) = 1.0f - curve.transform(1.0f - t)
override fun toString() = "${runtimeType()}($curve)"
}
@@ -283,32 +286,32 @@
*/
private class DecelerateCurve : Curve() {
- override fun transform(t: Double): Double {
- assert(t in 0.0..1.0)
+ override fun transform(t: Float): Float {
+ assert(t in 0.0f..1.0f)
// Intended to match the behavior of:
// https://android.googlesource.com/platform/frameworks/base/+/master/core/
// java/android/view/animation/DecelerateInterpolator.java
// ...as of December 2016.
- val newT = 1.0 - t
- return 1.0 - newT * newT
+ val newT = 1.0f - t
+ return 1.0f - newT * newT
}
}
// BOUNCE CURVES
-internal fun bounce(origT: Double): Double {
+internal fun bounce(origT: Float): Float {
var t = origT
- if (t < 1.0 / 2.75) {
- return 7.5625 * t * t
- } else if (t < 2 / 2.75) {
- t -= 1.5 / 2.75
- return 7.5625 * t * t + 0.75
+ if (t < 1.0f / 2.75f) {
+ return 7.5625f * t * t
+ } else if (t < 2f / 2.75f) {
+ t -= 1.5f / 2.75f
+ return 7.5625f * t * t + 0.75f
} else if (t < 2.5 / 2.75) {
- t -= 2.25 / 2.75
- return 7.5625 * t * t + 0.9375
+ t -= 2.25f / 2.75f
+ return 7.5625f * t * t + 0.9375f
}
- t -= 2.625 / 2.75
- return 7.5625 * t * t + 0.984375
+ t -= 2.625f / 2.75f
+ return 7.5625f * t * t + 0.984375f
}
/**
@@ -318,9 +321,9 @@
*/
private class BounceInCurve : Curve() {
- override fun transform(t: Double): Double {
+ override fun transform(t: Float): Float {
assert(t in 0.0..1.0)
- return 1.0 - bounce(1.0 - t)
+ return 1.0f - bounce(1.0f - t)
}
}
@@ -331,7 +334,7 @@
*/
private class BounceOutCurve : Curve() {
- override fun transform(t: Double): Double {
+ override fun transform(t: Float): Float {
assert(t in 0.0..1.0)
return bounce(t)
}
@@ -344,12 +347,12 @@
*/
private class BounceInOutCurve : Curve() {
- override fun transform(t: Double): Double {
- assert(t in 0.0..1.0)
- return if (t < 0.5)
- (1.0 - bounce(1.0 - t)) * 0.5
+ override fun transform(t: Float): Float {
+ assert(t in 0.0f..1.0f)
+ return if (t < 0.5f)
+ (1.0f - bounce(1.0f - t)) * 0.5f
else
- bounce(t * 2.0 - 1.0) * 0.5 + 0.5
+ bounce(t * 2.0f - 1.0f) * 0.5f + 0.5f
}
}
@@ -367,14 +370,14 @@
*/
class ElasticInCurve(
/** The duration of the oscillation. */
- private val period: Double = 0.4
+ private val period: Float = 0.4f
) : Curve() {
- override fun transform(t: Double): Double {
- assert(t in 0.0..1.0)
- val s = period / 4.0
- val newT = t - 1.0
- return -Math.pow(2.0, 10.0 * newT) * Math.sin((newT - s) * (Math.PI * 2.0) / period)
+ override fun transform(t: Float): Float {
+ assert(t in 0.0f..1.0f)
+ val s = period / 4.0f
+ val newT = t - 1.0f
+ return (-(2.0f.pow(10.0f * newT)) * sin((newT - s) * (PI * 2.0f) / period))
}
override fun toString() = "${runtimeType()}($period)"
@@ -392,13 +395,13 @@
*/
class ElasticOutCurve(
/** The duration of the oscillation. */
- private val period: Double = 0.4
+ private val period: Float = 0.4f
) : Curve() {
- override fun transform(t: Double): Double {
- assert(t in 0.0..1.0)
- val s = period / 4.0
- return Math.pow(2.0, -10 * t) * Math.sin((t - s) * (Math.PI * 2.0) / period) + 1.0
+ override fun transform(t: Float): Float {
+ assert(t in 0.0f..1.0f)
+ val s = period / 4.0f
+ return (2f.pow(-10f * t) * sin((t - s) * (PI * 2f) / period) + 1f)
}
override fun toString() = "${runtimeType()}($period)"
@@ -417,20 +420,18 @@
*/
class ElasticInOutCurve(
/** The duration of the oscillation. */
- private val period: Double = 0.4
+ private val period: Float = 0.4f
) : Curve() {
- override fun transform(t: Double): Double {
+ override fun transform(t: Float): Float {
assert(t in 0.0..1.0)
- val s = period / 4.0
- val newT = 2.0 * t - 1.0
- return if (newT < 0.0)
- -0.5 * Math.pow(2.0, 10.0 * newT) * Math.sin((newT - s) * (Math.PI * 2.0) / period)
+ val s = period / 4.0f
+ val newT = 2.0f * t - 1.0f
+ return if (newT < 0.0f)
+ (-0.5f * 2.0f.pow(10.0f * newT) * sin((newT - s) * (PI * 2.0f) / period))
else
- Math.pow(
- 2.0,
- -10.0 * newT
- ) * Math.sin((newT - s) * (Math.PI * 2.0) / period) * 0.5 + 1.0
+ (2.0f.pow(-10.0f * newT) *
+ sin((newT - s) * (PI * 2.0f) / period) * 0.5f + 1.0f)
}
override fun toString() = "${runtimeType()}($period)"
@@ -490,28 +491,28 @@
*
* ![](https://flutter.github.io/assets-for-aPI-docs/assets/animation/curve_ease.png)
*/
- val ease = Cubic(0.25, 0.1, 0.25, 1.0)
+ val ease = Cubic(0.25f, 0.1f, 0.25f, 1.0f)
/**
* A cubic animation curve that starts slowly and ends quickly.
*
* ![](https://flutter.github.io/assets-for-aPI-docs/assets/animation/curve_ease_in.png)
*/
- val easeIn = Cubic(0.42, 0.0, 1.0, 1.0)
+ val easeIn = Cubic(0.42f, 0.0f, 1.0f, 1.0f)
/**
* A cubic animation curve that starts quickly and ends slowly.
*
* ![](https://flutter.github.io/assets-for-aPI-docs/assets/animation/curve_ease_out.png)
*/
- val easeOut = Cubic(0.0, 0.0, 0.58, 1.0)
+ val easeOut = Cubic(0.0f, 0.0f, 0.58f, 1.0f)
/**
* A cubic animation curve that starts slowly, speeds up, and then and ends slowly.
*
* ![](https://flutter.github.io/assets-for-aPI-docs/assets/animation/curve_ease_in_out.png)
*/
- val easeInOut = Cubic(0.42, 0.0, 0.58, 1.0)
+ val easeInOut = Cubic(0.42f, 0.0f, 0.58f, 1.0f)
/**
* A curve that starts quickly and eases into its val position.
@@ -522,7 +523,7 @@
*
* ![](https://flutter.github.io/assets-for-aPI-docs/assets/animation/curve_fast_out_slow_in.png)
*/
- val fastOutSlowIn = Cubic(0.4, 0.0, 0.2, 1.0)
+ val fastOutSlowIn = Cubic(0.4f, 0.0f, 0.2f, 1.0f)
/**
* An oscillating curve that grows in magnitude.
@@ -566,4 +567,4 @@
*/
val elasticInOut = ElasticInOutCurve()
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/animation/Tween.kt b/ui/port/src/main/java/androidx/ui/animation/Tween.kt
index efdad36..00c64d0 100644
--- a/ui/port/src/main/java/androidx/ui/animation/Tween.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/Tween.kt
@@ -82,7 +82,7 @@
* operators on `T`. The [begin] and [end] properties must therefore be
* non-null by the time this method is called.
*/
- fun lerp(t: Double): T {
+ fun lerp(t: Float): T {
assert(begin != null)
assert(end != null)
return evaluator.invoke(begin!!, end!!, t)
@@ -101,11 +101,11 @@
* properties may be null when this is called. It varies from subclass to
* subclass.
*/
- override fun evaluate(animation: Animation<Double>): T {
+ override fun evaluate(animation: Animation<Float>): T {
val t = animation.value
- if (t == 0.0)
+ if (t == 0.0f)
return begin!!
- if (t == 1.0)
+ if (t == 1.0f)
return end!!
return lerp(t)
}
diff --git a/ui/port/src/main/java/androidx/ui/animation/TweenEvaluator.kt b/ui/port/src/main/java/androidx/ui/animation/TweenEvaluator.kt
index 40771e4..e724072 100644
--- a/ui/port/src/main/java/androidx/ui/animation/TweenEvaluator.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/TweenEvaluator.kt
@@ -28,7 +28,7 @@
/**
* Provides "begin + (end - begin) * t" implementation for type T
*/
-typealias TweenEvaluator<T> = (begin: T, end: T, t: Double) -> T
+typealias TweenEvaluator<T> = (begin: T, end: T, t: Float) -> T
fun Tween(begin: Float? = null, end: Float? = null) = Tween(begin, end, FloatTweenEvaluator)
@@ -48,49 +48,49 @@
Tween(begin, end, ShapeBorderEvaluator)
private object FloatTweenEvaluator : TweenEvaluator<Float> {
- override fun invoke(begin: Float, end: Float, t: Double): Float {
- return begin + ((end - begin) * t).toFloat()
+ override fun invoke(begin: Float, end: Float, t: Float): Float {
+ return begin + ((end - begin) * t)
}
}
private object DoubleTweenEvaluator : TweenEvaluator<Double> {
- override fun invoke(begin: Double, end: Double, t: Double): Double {
+ override fun invoke(begin: Double, end: Double, t: Float): Double {
return begin + (end - begin) * t
}
}
private object IntTweenEvaluator : TweenEvaluator<Int> {
- override fun invoke(begin: Int, end: Int, t: Double): Int {
+ override fun invoke(begin: Int, end: Int, t: Float): Int {
return begin + ((end - begin) * t).toInt()
}
}
private object LongTweenEvaluator : TweenEvaluator<Long> {
- override fun invoke(begin: Long, end: Long, t: Double): Long {
+ override fun invoke(begin: Long, end: Long, t: Float): Long {
return begin + ((end - begin) * t).toLong()
}
}
private object ColorTweenEvaluator : TweenEvaluator<Color> {
- override fun invoke(begin: Color, end: Color, t: Double): Color {
+ override fun invoke(begin: Color, end: Color, t: Float): Color {
return Color.lerp(begin, end, t)!!
}
}
private object SizeTweenEvaluator : TweenEvaluator<Size> {
- override fun invoke(begin: Size, end: Size, t: Double): Size {
+ override fun invoke(begin: Size, end: Size, t: Float): Size {
return Size.lerp(begin, end, t)!!
}
}
private object RectTweenEvaluator : TweenEvaluator<Rect> {
- override fun invoke(begin: Rect, end: Rect, t: Double): Rect {
+ override fun invoke(begin: Rect, end: Rect, t: Float): Rect {
return Rect.lerp(begin, end, t)!!
}
}
private object ShapeBorderEvaluator : TweenEvaluator<ShapeBorder> {
- override fun invoke(begin: ShapeBorder, end: ShapeBorder, t: Double): ShapeBorder {
+ override fun invoke(begin: ShapeBorder, end: ShapeBorder, t: Float): ShapeBorder {
return lerp(begin, end, t)!!
}
}
diff --git a/ui/port/src/main/java/androidx/ui/animation/animations/AlwaysCompleteAnimation.kt b/ui/port/src/main/java/androidx/ui/animation/animations/AlwaysCompleteAnimation.kt
index fcb8697..74bc214 100644
--- a/ui/port/src/main/java/androidx/ui/animation/animations/AlwaysCompleteAnimation.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/animations/AlwaysCompleteAnimation.kt
@@ -28,7 +28,7 @@
* [AnimationController] with an initial value of 1.0. This is useful when an
* API expects an animation but you don't actually want to animate anything.
*/
-object AlwaysCompleteAnimation : Animation<Double>() {
+object AlwaysCompleteAnimation : Animation<Float>() {
override fun addListener(listener: VoidCallback) {}
@@ -40,7 +40,7 @@
override val status = AnimationStatus.COMPLETED
- override val value = 1.0
+ override val value = 1.0f
override fun toString() = "AlwaysCompleteAnimation"
}
diff --git a/ui/port/src/main/java/androidx/ui/animation/animations/AlwaysDismissedAnimation.kt b/ui/port/src/main/java/androidx/ui/animation/animations/AlwaysDismissedAnimation.kt
index 8a4c406..8728484 100644
--- a/ui/port/src/main/java/androidx/ui/animation/animations/AlwaysDismissedAnimation.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/animations/AlwaysDismissedAnimation.kt
@@ -28,7 +28,7 @@
* [AnimationController] with an initial value of 0.0. This is useful when an
* API expects an animation but you don't actually want to animate anything.
*/
-object AlwaysDismissedAnimation : Animation<Double>() {
+object AlwaysDismissedAnimation : Animation<Float>() {
override fun addListener(listener: VoidCallback) {}
@@ -40,7 +40,7 @@
override val status = AnimationStatus.DISMISSED
- override val value = 0.0
+ override val value = 0.0f
override fun toString() = "AlwaysDismissedAnimation"
}
diff --git a/ui/port/src/main/java/androidx/ui/animation/animations/AnimationMax.kt b/ui/port/src/main/java/androidx/ui/animation/animations/AnimationMax.kt
index fad628c..bc75dd0 100644
--- a/ui/port/src/main/java/androidx/ui/animation/animations/AnimationMax.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/animations/AnimationMax.kt
@@ -25,9 +25,9 @@
* [first] and [next].
*/
class AnimationMax(
- first: Animation<Double>,
- next: Animation<Double>
-) : CompoundAnimation<Double>(first, next) {
+ first: Animation<Float>,
+ next: Animation<Float>
+) : CompoundAnimation<Float>(first, next) {
override val value = Math.max(first.value, next.value)
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/animation/animations/AnimationMean.kt b/ui/port/src/main/java/androidx/ui/animation/animations/AnimationMean.kt
index 0a8f15b..23ff781 100644
--- a/ui/port/src/main/java/androidx/ui/animation/animations/AnimationMean.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/animations/AnimationMean.kt
@@ -19,18 +19,18 @@
import androidx.ui.animation.Animation
/**
- * An animation of [double]s that tracks the mean of two other animations.
+ * An animation of [Float]s that tracks the mean of two other animations.
*
* The [status] of this animation is the status of the `right` animation if it is
* moving, and the `left` animation otherwise.
*
- * The [value] of this animation is the [double] that represents the mean value
+ * The [value] of this animation is the [Float] that represents the mean value
* of the values of the `left` and `right` animations.
*/
class AnimationMean(
- left: Animation<Double>,
- right: Animation<Double>
-) : CompoundAnimation<Double>(left, right) {
+ left: Animation<Float>,
+ right: Animation<Float>
+) : CompoundAnimation<Float>(left, right) {
- override val value = (left.value + right.value) / 2.0
+ override val value = (left.value + right.value) / 2.0f
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/animation/animations/AnimationMin.kt b/ui/port/src/main/java/androidx/ui/animation/animations/AnimationMin.kt
index de48568..b4d2ecd 100644
--- a/ui/port/src/main/java/androidx/ui/animation/animations/AnimationMin.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/animations/AnimationMin.kt
@@ -25,9 +25,9 @@
* [first] and [next].
*/
class AnimationMin(
- first: Animation<Double>,
- next: Animation<Double>
-) : CompoundAnimation<Double>(first, next) {
+ first: Animation<Float>,
+ next: Animation<Float>
+) : CompoundAnimation<Float>(first, next) {
override val value = Math.min(first.value, next.value)
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/animation/animations/AnimationWithParentMixin.kt b/ui/port/src/main/java/androidx/ui/animation/animations/AnimationWithParentMixin.kt
index 1db94cc..15c3405 100644
--- a/ui/port/src/main/java/androidx/ui/animation/animations/AnimationWithParentMixin.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/animations/AnimationWithParentMixin.kt
@@ -39,7 +39,7 @@
* you wish to proxy a different animation at different times, consider using
* [ProxyAnimation].
*/
- protected val parent: Animation<Double>
+ protected val parent: Animation<Float>
) : Animation<T>() {
// keep these next five dartdocs in sync with the dartdocs in Animation<T>
diff --git a/ui/port/src/main/java/androidx/ui/animation/animations/CurvedAnimation.kt b/ui/port/src/main/java/androidx/ui/animation/animations/CurvedAnimation.kt
index a534029..5908d9c 100644
--- a/ui/port/src/main/java/androidx/ui/animation/animations/CurvedAnimation.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/animations/CurvedAnimation.kt
@@ -48,7 +48,7 @@
*/
class CurvedAnimation(
/** The animation to which this animation applies a curve. */
- parent: Animation<Double>,
+ parent: Animation<Float>,
/** The curve to use in the forward direction. */
private val curve: Curve,
/**
@@ -67,7 +67,7 @@
* If this field is null, uses [curve] in both directions.
*/
private val reverseCurve: Curve? = null
-) : AnimationWithParentMixin<Double>(parent) {
+) : AnimationWithParentMixin<Float>(parent) {
/**
* The direction used to select the current curve.
@@ -102,20 +102,20 @@
get() = reverseCurve == null ||
(curveDirection ?: parent.status) != AnimationStatus.REVERSE
- override val value: Double
+ override val value: Float
get() {
val activeCurve = if (useForwardCurve) curve else reverseCurve
val t = parent.value
- if (t == Double.NaN) {
+ if (t == Float.NaN) {
toString()
}
if (activeCurve == null)
return t
- if (t == 0.0 || t == 1.0) {
+ if (t == 0.0f || t == 1.0f) {
assert {
val transformedValue = activeCurve.transform(t)
- val roundedTransformedValue = transformedValue.roundToInt().toDouble()
+ val roundedTransformedValue = transformedValue.roundToInt().toFloat()
if (roundedTransformedValue != t) {
throw FlutterError(
"Invalid curve endpoint at $t.\n" +
diff --git a/ui/port/src/main/java/androidx/ui/animation/animations/ProxyAnimation.kt b/ui/port/src/main/java/androidx/ui/animation/animations/ProxyAnimation.kt
index 13aa462..96fa19c 100644
--- a/ui/port/src/main/java/androidx/ui/animation/animations/ProxyAnimation.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/animations/ProxyAnimation.kt
@@ -35,17 +35,17 @@
* If the animation argument is omitted, the proxy animation will have the
* status [AnimationStatus.DISMISSED] and a value of 0
*/
- animation: Animation<Double>? = null
-) : AnimationLazyListenerMixin<Double>() {
+ animation: Animation<Float>? = null
+) : AnimationLazyListenerMixin<Float>() {
- private var _parent: Animation<Double>?
+ private var _parent: Animation<Float>?
/**
* The animation whose value this animation will proxy.
*
* This value is mutable. When mutated, the listeners on the proxy animation
* will be transparently updated to be listening to the new parent animation.
*/
- var parent: Animation<Double>?
+ var parent: Animation<Float>?
get() = _parent
set(newParent) {
val oldParent = _parent
@@ -78,15 +78,15 @@
override val status: AnimationStatus
get() = _parent?.status ?: _status!!
- private var _value: Double? = null
- override val value: Double
+ private var _value: Float? = null
+ override val value: Float
get() = _parent?.value ?: _value!!
init {
_parent = animation
if (_parent == null) {
_status = AnimationStatus.DISMISSED
- _value = 0.0
+ _value = 0.0f
}
}
diff --git a/ui/port/src/main/java/androidx/ui/animation/animations/ReverseAnimation.kt b/ui/port/src/main/java/androidx/ui/animation/animations/ReverseAnimation.kt
index ddcd010..d2503b0 100644
--- a/ui/port/src/main/java/androidx/ui/animation/animations/ReverseAnimation.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/animations/ReverseAnimation.kt
@@ -34,8 +34,8 @@
*/
class ReverseAnimation(
/** The animation whose value and direction this animation is reversing. */
- private val parent: Animation<Double>
-) : AnimationLazyListenerMixin<Double>() {
+ private val parent: Animation<Float>
+) : AnimationLazyListenerMixin<Float>() {
override val status: AnimationStatus
get() = when (parent.status) {
@@ -45,8 +45,8 @@
AnimationStatus.DISMISSED -> AnimationStatus.COMPLETED
}
- override val value: Double
- get() = 1.0 - parent.value
+ override val value: Float
+ get() = 1.0f - parent.value
override fun didStartListening() {
parent.addStatusListener(statusChangeHandler)
diff --git a/ui/port/src/main/java/androidx/ui/animation/animations/TrainHoppingAnimation.kt b/ui/port/src/main/java/androidx/ui/animation/animations/TrainHoppingAnimation.kt
index 1894d68..7de00f5 100644
--- a/ui/port/src/main/java/androidx/ui/animation/animations/TrainHoppingAnimation.kt
+++ b/ui/port/src/main/java/androidx/ui/animation/animations/TrainHoppingAnimation.kt
@@ -41,13 +41,13 @@
*/
class TrainHoppingAnimation(
/** The animation that is current driving this animation. */
- currentTrain: Animation<Double>,
- private var nextTrain: Animation<Double>?,
+ currentTrain: Animation<Float>,
+ private var nextTrain: Animation<Float>?,
/** Called when this animation switches to be driven by a different animation. */
private val onSwitchedTrain: VoidCallback? = null
-) : AnimationEagerListenerMixin<Double>() {
+) : AnimationEagerListenerMixin<Float>() {
- var currentTrain: Animation<Double> = currentTrain
+ var currentTrain: Animation<Float> = currentTrain
private set
private var mode: TrainHoppingMode? = null
@@ -61,7 +61,7 @@
assert(lastStatus != null)
}
- private var lastValue: Double? = null
+ private var lastValue: Float? = null
private val valueChangeHandler = { onValueChanged() }
private fun onValueChanged() {
@@ -113,7 +113,7 @@
override val status: AnimationStatus
get() = currentTrain.status
- override val value: Double
+ override val value: Float
get() = currentTrain.value
/**
diff --git a/ui/port/src/main/java/androidx/ui/compositing/SceneBuilder.kt b/ui/port/src/main/java/androidx/ui/compositing/SceneBuilder.kt
index 09845cc..b9caa46 100644
--- a/ui/port/src/main/java/androidx/ui/compositing/SceneBuilder.kt
+++ b/ui/port/src/main/java/androidx/ui/compositing/SceneBuilder.kt
@@ -57,10 +57,10 @@
}
private fun _pushClipRect(
- left: Double,
- right: Double,
- top: Double,
- bottom: Double
+ left: Float,
+ right: Float,
+ top: Float,
+ bottom: Float
) {
TODO()
// layer_builder_->PushClipRect(SkRect::MakeLTRB(left, top, right, bottom),
@@ -161,10 +161,10 @@
private fun _pushShaderMask(
shader: Shader,
- maskRectLeft: Double,
- maskRectRight: Double,
- maskRectTop: Double,
- maskRectBottom: Double,
+ maskRectLeft: Float,
+ maskRectRight: Float,
+ maskRectTop: Float,
+ maskRectBottom: Float,
blendMode: Int
) {
TODO()
@@ -188,7 +188,7 @@
*/
fun pushPhysicalShape(
path: Path,
- elevation: Double = 0.0,
+ elevation: Float = 0.0f,
color: Color,
shadowColor: Color? = null
) {
@@ -199,7 +199,7 @@
)
}
- private fun _pushPhysicalShape(path: Path, elevation: Double, color: Int, shadowColor: Int) {
+ private fun _pushPhysicalShape(path: Path, elevation: Float, color: Int, shadowColor: Int) {
TODO()
// layer_builder_->PushPhysicalShape(
// path->path(), //
@@ -258,10 +258,10 @@
private fun _addPerformanceOverlay(
enabledOptions: Int,
- left: Double,
- right: Double,
- top: Double,
- bottom: Double
+ left: Float,
+ right: Float,
+ top: Float,
+ bottom: Float
) {
TODO()
// layer_builder_->PushPerformanceOverlay(
@@ -295,17 +295,17 @@
fun addTexture(
textureId: Int,
offset: Offset = Offset.zero,
- width: Double = 0.0,
- height: Double = 0.0
+ width: Float = 0.0f,
+ height: Float = 0.0f
) {
_addTexture(offset.dx, offset.dy, width, height, textureId)
}
private fun _addTexture(
- dx: Double,
- dy: Double,
- width: Double,
- height: Double,
+ dx: Float,
+ dy: Float,
+ width: Float,
+ height: Float,
textureId: Int
) {
TODO()
@@ -320,8 +320,8 @@
// TODO(Migration/Andrey) needs SceneHost
// fun addChildScene(
// offset: Offset = Offset.zero,
-// width: Double = 0.0,
-// height: Double = 0.0,
+// width: Double = 0.0f,
+// height: Double = 0.0f,
// sceneHost: SceneHost? = null,
// hitTestable : Boolean = true
// ) {
diff --git a/ui/port/src/main/java/androidx/ui/core/Dimension.kt b/ui/port/src/main/java/androidx/ui/core/Dimension.kt
index 245bce2..4384a90 100644
--- a/ui/port/src/main/java/androidx/ui/core/Dimension.kt
+++ b/ui/port/src/main/java/androidx/ui/core/Dimension.kt
@@ -70,83 +70,83 @@
*/
/*inline*/ val Float.dp: Dimension get() = Dimension(dp = this)
-inline operator fun Float.div(by: Dimension) =
+/*inline*/ operator fun Float.div(by: Dimension) =
DimensionInverse(this / by.dp)
-inline operator fun Double.div(by: Dimension) =
+/*inline*/ operator fun Double.div(by: Dimension) =
DimensionInverse(this.toFloat() / by.dp)
-inline operator fun Int.div(by: Dimension) =
+/*inline*/ operator fun Int.div(by: Dimension) =
DimensionInverse(this / by.dp)
-inline operator fun Float.times(by: Dimension) =
+/*inline*/ operator fun Float.times(by: Dimension) =
Dimension(this * by.dp)
-inline operator fun Double.times(by: Dimension) =
+/*inline*/ operator fun Double.times(by: Dimension) =
Dimension(this.toFloat() * by.dp)
-inline operator fun Int.times(by: Dimension) =
+/*inline*/ operator fun Int.times(by: Dimension) =
Dimension(this * by.dp)
/**
* Add two Dimensions together.
*/
-inline operator fun Dimension.plus(dimension: Dimension) =
+/*inline*/ operator fun Dimension.plus(dimension: Dimension) =
Dimension(dp = dp + dimension.dp)
/**
* Subtract a Dimension from another one.
*/
-inline operator fun Dimension.minus(dimension: Dimension) =
+/*inline*/ operator fun Dimension.minus(dimension: Dimension) =
Dimension(dp = dp - dimension.dp)
/**
* Divide a Dimension by a scalar.
*/
-inline operator fun Dimension.div(by: Float): Dimension =
+/*inline*/ operator fun Dimension.div(by: Float): Dimension =
Dimension(dp = dp / by)
-inline operator fun Dimension.div(by: Int): Dimension =
+/*inline*/ operator fun Dimension.div(by: Int): Dimension =
Dimension(dp = dp / by)
/**
* Divide by another Dimension to get a scalar.
*/
-inline operator fun Dimension.div(by: Dimension): Float = dp / by.dp
+/*inline*/ operator fun Dimension.div(by: Dimension): Float = dp / by.dp
/**
* Divide by [DimensionSquared] to get a [DimensionInverse].
*/
-inline operator fun Dimension.div(by: DimensionSquared): DimensionInverse =
+/*inline*/ operator fun Dimension.div(by: DimensionSquared): DimensionInverse =
DimensionInverse(idp = dp / by.dp2)
/**
* Multiply a Dimension by a scalar.
*/
-inline operator fun Dimension.times(by: Float): Dimension =
+/*inline*/ operator fun Dimension.times(by: Float): Dimension =
Dimension(dp = dp * by)
-inline operator fun Dimension.times(by: Int): Dimension =
+/*inline*/ operator fun Dimension.times(by: Int): Dimension =
Dimension(dp = dp * by)
/**
* Multiply by a Dimension to get a [DimensionSquared] result.
*/
-inline operator fun Dimension.times(by: Dimension): DimensionSquared =
+/*inline*/ operator fun Dimension.times(by: Dimension): DimensionSquared =
DimensionSquared(dp2 = dp * by.dp)
/**
* Multiply by a Dimension to get a [DimensionSquared] result.
*/
-inline operator fun Dimension.times(by: DimensionSquared): DimensionCubed =
+/*inline*/ operator fun Dimension.times(by: DimensionSquared): DimensionCubed =
DimensionCubed(dp3 = dp * by.dp2)
/**
* Support comparing Dimensions with comparison operators.
*/
-inline operator fun Dimension.compareTo(other: Dimension) = dp.compareTo(other.dp)
+/*inline*/ operator fun Dimension.compareTo(other: Dimension) = dp.compareTo(other.dp)
-inline fun min(dimension1: Dimension, dimension2: Dimension): Dimension {
+/*inline*/ fun min(dimension1: Dimension, dimension2: Dimension): Dimension {
return if (dimension1 < dimension2) {
dimension1
} else {
@@ -154,7 +154,7 @@
}
}
-inline fun max(dimension1: Dimension, dimension2: Dimension): Dimension {
+/*inline*/ fun max(dimension1: Dimension, dimension2: Dimension): Dimension {
return if (dimension1 > dimension2) {
dimension1
} else {
@@ -209,7 +209,8 @@
fun Dimension.toPx(context: Context): Float =
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.resources.displayMetrics)
-fun Double.toDp(context: Context): Dimension = (this / 1.dp.toPx(context)).dp
+/** Convert a [Float] pixel value to a Dimension */
+fun Float.toDp(context: Context): Dimension = (this / 1.dp.toPx(context)).dp
/**
* A two dimensional size using [Dimension] for units
@@ -236,54 +237,55 @@
/**
* Add two DimensionSquares together.
*/
-inline operator fun DimensionSquared.plus(dimension: DimensionSquared) =
+/*inline*/ operator fun DimensionSquared.plus(dimension: DimensionSquared) =
DimensionSquared(dp2 = dp2 + dimension.dp2)
/**
* Subtract a DimensionSquare from another one.
*/
-inline operator fun DimensionSquared.minus(dimension: DimensionSquared) =
+/*inline*/ operator fun DimensionSquared.minus(dimension: DimensionSquared) =
DimensionSquared(dp2 = dp2 - dimension.dp2)
/**
* Divide a DimensionSquare by a scalar.
*/
-inline operator fun DimensionSquared.div(by: Float): DimensionSquared =
+/*inline*/ operator fun DimensionSquared.div(by: Float): DimensionSquared =
DimensionSquared(dp2 = dp2 / by)
/**
* Divide by a [Dimension] to get a [Dimension] result.
*/
-inline operator fun DimensionSquared.div(by: Dimension): Dimension =
+/*inline*/ operator fun DimensionSquared.div(by: Dimension): Dimension =
Dimension(dp = dp2 / by.dp)
/**
* Divide by a DimensionSquared to get a scalar result.
*/
-inline operator fun DimensionSquared.div(by: DimensionSquared): Float = dp2 / by.dp2
+/*inline*/ operator fun DimensionSquared.div(by: DimensionSquared): Float = dp2 / by.dp2
/**
* Divide by a [DimensionCubed] to get a [DimensionInverse] result.
*/
-inline operator fun DimensionSquared.div(by: DimensionCubed): DimensionInverse =
+/*inline*/ operator fun DimensionSquared.div(by: DimensionCubed): DimensionInverse =
DimensionInverse(dp2 / by.dp3)
/**
* Multiply by a scalar to get a DimensionSquared result.
*/
-inline operator fun DimensionSquared.times(by: Float): DimensionSquared =
+/*inline*/ operator fun DimensionSquared.times(by: Float): DimensionSquared =
DimensionSquared(dp2 = dp2 * by)
/**
* Multiply by a scalar to get a DimensionSquared result.
*/
-inline operator fun DimensionSquared.times(by: Dimension): DimensionCubed =
+/*inline*/ operator fun DimensionSquared.times(by: Dimension): DimensionCubed =
DimensionCubed(dp3 = dp2 * by.dp)
/**
* Support comparing DimensionSquared with comparison operators.
*/
-inline operator fun DimensionSquared.compareTo(other: DimensionSquared) = dp2.compareTo(other.dp2)
+/*inline*/ operator fun DimensionSquared.compareTo(other: DimensionSquared) =
+ dp2.compareTo(other.dp2)
/**
* Holds a unit of cubed dimensions, such as `1.dp * 2.dp * 3.dp`. [DimensionSquared],
@@ -300,48 +302,48 @@
/**
* Add two DimensionCubed together.
*/
-inline operator fun DimensionCubed.plus(dimension: DimensionCubed) =
+/*inline*/ operator fun DimensionCubed.plus(dimension: DimensionCubed) =
DimensionCubed(dp3 = dp3 + dimension.dp3)
/**
* Subtract a DimensionCubed from another one.
*/
-inline operator fun DimensionCubed.minus(dimension: DimensionCubed) =
+/*inline*/ operator fun DimensionCubed.minus(dimension: DimensionCubed) =
DimensionCubed(dp3 = dp3 - dimension.dp3)
/**
* Divide a DimensionCubed by a scalar.
*/
-inline operator fun DimensionCubed.div(by: Float): DimensionCubed =
+/*inline*/ operator fun DimensionCubed.div(by: Float): DimensionCubed =
DimensionCubed(dp3 = dp3 / by)
/**
* Divide by a [Dimension] to get a [DimensionSquared] result.
*/
-inline operator fun DimensionCubed.div(by: Dimension): DimensionSquared =
+/*inline*/ operator fun DimensionCubed.div(by: Dimension): DimensionSquared =
DimensionSquared(dp2 = dp3 / by.dp)
/**
* Divide by a [DimensionSquared] to get a [Dimension] result.
*/
-inline operator fun DimensionCubed.div(by: DimensionSquared): Dimension =
+/*inline*/ operator fun DimensionCubed.div(by: DimensionSquared): Dimension =
Dimension(dp = dp3 / by.dp2)
/**
* Divide by a DimensionCubed to get a scalar result.
*/
-inline operator fun DimensionCubed.div(by: DimensionCubed): Float = dp3 / by.dp3
+/*inline*/ operator fun DimensionCubed.div(by: DimensionCubed): Float = dp3 / by.dp3
/**
* Multiply by a scalar to get a DimensionCubed result.
*/
-inline operator fun DimensionCubed.times(by: Float): DimensionCubed =
+/*inline*/ operator fun DimensionCubed.times(by: Float): DimensionCubed =
DimensionCubed(dp3 = dp3 * by)
/**
* Support comparing DimensionCubed with comparison operators.
*/
-inline operator fun DimensionCubed.compareTo(other: DimensionCubed) = dp3.compareTo(other.dp3)
+/*inline*/ operator fun DimensionCubed.compareTo(other: DimensionCubed) = dp3.compareTo(other.dp3)
/**
* Holds a unit of an inverse dimensions, such as `1.dp / (2.dp * 3.dp)`. [DimensionSquared],
@@ -358,48 +360,49 @@
/**
* Add two DimensionInverse together.
*/
-inline operator fun DimensionInverse.plus(dimension: DimensionInverse) =
+/*inline*/ operator fun DimensionInverse.plus(dimension: DimensionInverse) =
DimensionInverse(idp = idp + dimension.idp)
/**
* Subtract a DimensionInverse from another one.
*/
-inline operator fun DimensionInverse.minus(dimension: DimensionInverse) =
+/*inline*/ operator fun DimensionInverse.minus(dimension: DimensionInverse) =
DimensionInverse(idp = idp - dimension.idp)
/**
* Divide a DimensionInverse by a scalar.
*/
-inline operator fun DimensionInverse.div(by: Float): DimensionInverse =
+/*inline*/ operator fun DimensionInverse.div(by: Float): DimensionInverse =
DimensionInverse(idp = idp / by)
/**
* Multiply by a scalar to get a DimensionInverse result.
*/
-inline operator fun DimensionInverse.times(by: Float): DimensionInverse =
+/*inline*/ operator fun DimensionInverse.times(by: Float): DimensionInverse =
DimensionInverse(idp = idp * by)
/**
* Multiply by a [Dimension] to get a scalar result.
*/
-inline operator fun DimensionInverse.times(by: Dimension): Float = idp * by.dp
+/*inline*/ operator fun DimensionInverse.times(by: Dimension): Float = idp * by.dp
/**
* Multiply by a [DimensionSquared] to get a [Dimension] result.
*/
-inline operator fun DimensionInverse.times(by: DimensionSquared): Dimension =
+/*inline*/ operator fun DimensionInverse.times(by: DimensionSquared): Dimension =
Dimension(dp = idp * by.dp2)
/**
* Multiply by a [DimensionCubed] to get a [DimensionSquared] result.
*/
-inline operator fun DimensionInverse.times(by: DimensionCubed): DimensionSquared =
+/*inline*/ operator fun DimensionInverse.times(by: DimensionCubed): DimensionSquared =
DimensionSquared(dp2 = idp * by.dp3)
/**
* Support comparing DimensionInverse with comparison operators.
*/
-inline operator fun DimensionInverse.compareTo(other: DimensionInverse) = idp.compareTo(other.idp)
+/*inline*/ operator fun DimensionInverse.compareTo(other: DimensionInverse) =
+ idp.compareTo(other.idp)
/**
* A size in Pixels
diff --git a/ui/port/src/main/java/androidx/ui/engine/geometry/Offset.kt b/ui/port/src/main/java/androidx/ui/engine/geometry/Offset.kt
index ea38e95..950458a 100644
--- a/ui/port/src/main/java/androidx/ui/engine/geometry/Offset.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/geometry/Offset.kt
@@ -1,8 +1,10 @@
package androidx.ui.engine.geometry
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.toStringAsFixed
import androidx.ui.truncDiv
+import kotlin.math.atan2
+import kotlin.math.sqrt
/**
* An immutable 2D floating-point offset.
@@ -30,7 +32,7 @@
* Creates an offset. The first argument sets [dx], the horizontal component,
* and the second sets [dy], the vertical component.
*/
-data class Offset(override val dx: Double, override val dy: Double) : OffsetBase {
+data class Offset(override val dx: Float, override val dy: Float) : OffsetBase {
companion object {
/**
@@ -38,7 +40,7 @@
*
* This can be used to represent the origin of a coordinate space.
*/
- val zero = Offset(0.0, 0.0)
+ val zero = Offset(0.0f, 0.0f)
/**
* An offset with infinite x and y components.
@@ -49,7 +51,7 @@
* * [isFinite], which checks whether both components are finite.
*/
// This is included for completeness, because [Size.infinite] exists.
- val infinite = Offset(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY)
+ val infinite = Offset(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY)
/**
* Linearly interpolate between two offsets.
@@ -65,21 +67,21 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
- fun lerp(a: Offset, b: Offset, t: Double): Offset? {
+ fun lerp(a: Offset, b: Offset, t: Float): Offset? {
// if (a == null && b == null)
// return null
// if (a == null)
// return b * t
// if (b == null)
// return a * (1.0 - t)
- return Offset(lerpDouble(a.dx, b.dx, t), lerpDouble(a.dy, b.dy, t))
+ return Offset(lerpFloat(a.dx, b.dx, t), lerpFloat(a.dy, b.dy, t))
}
fun isValid(offset: Offset): Boolean {
- assert(Double.NaN != offset.dx && Double.NaN != offset.dy) {
+ assert(Float.NaN != offset.dx && Float.NaN != offset.dy) {
"Offset argument contained a NaN value."
}
return true
@@ -92,7 +94,7 @@
* If you need this value to compare it to another [Offset]'s distance,
* consider using [distanceSquared] instead, since it is cheaper to compute.
*/
- fun getDistance() = Math.sqrt(dx * dx + dy * dy)
+ fun getDistance() = sqrt(dx * dx + dy * dy)
/**
* The square of the magnitude of the offset.
@@ -130,7 +132,7 @@
* * [distance], to compute the magnitude of the vector.
* * [Canvas.rotate], which uses the same convention for its angle.
*/
- fun getDirection() = Math.atan2(dy, dx)
+ fun getDirection() = atan2(dy, dx)
/**
* Returns a new offset with the x component scaled by `scaleX` and the y
@@ -152,7 +154,7 @@
* Offset b = -a; // same as: a.scale(-1.0, -1.0)
* ```
*/
- fun scale(scaleX: Double, scaleY: Double): Offset = Offset(dx * scaleX, dy * scaleY)
+ fun scale(scaleX: Float, scaleY: Float): Offset = Offset(dx * scaleX, dy * scaleY)
/**
* Returns a new offset with translateX added to the x component and
@@ -168,7 +170,7 @@
* Offset d = a - b; // same as: a.translate(-b.dx, -b.dy)
* ```
*/
- fun translate(translateX: Double, translateY: Double): Offset =
+ fun translate(translateX: Float, translateY: Float): Offset =
Offset(dx + translateX, dy + translateY)
/**
@@ -208,42 +210,42 @@
*
* Returns an offset whose coordinates are the coordinates of the
* left-hand-side operand (an Offset) multiplied by the scalar
- * right-hand-side operand (a double).
+ * right-hand-side operand (a Float).
*
* See also [scale].
*/
- operator fun times(operand: Double): Offset = Offset(dx * operand, dy * operand)
+ operator fun times(operand: Float): Offset = Offset(dx * operand, dy * operand)
/**
* Division operator.
*
* Returns an offset whose coordinates are the coordinates of the
* left-hand-side operand (an Offset) divided by the scalar right-hand-side
- * operand (a double).
+ * operand (a Float).
*
* See also [scale].
*/
- operator fun div(operand: Double): Offset = Offset(dx / operand, dy / operand)
+ operator fun div(operand: Float): Offset = Offset(dx / operand, dy / operand)
/**
* Integer (truncating) division operator.
*
* Returns an offset whose coordinates are the coordinates of the
* left-hand-side operand (an Offset) divided by the scalar right-hand-side
- * operand (a double), rounded towards zero.
+ * operand (a Float), rounded towards zero.
*/
// TODO(Migration/Filip): Original operator ~/ could not be overriden in Kotlin
- fun truncDiv(operand: Double) =
- Offset((dx.truncDiv(operand)).toDouble(), (dy.truncDiv(operand)).toDouble())
+ fun truncDiv(operand: Float) =
+ Offset((dx.truncDiv(operand)).toFloat(), (dy.truncDiv(operand)).toFloat())
/**
* Modulo (remainder) operator.
*
* Returns an offset whose coordinates are the remainder of dividing the
* coordinates of the left-hand-side operand (an Offset) by the scalar
- * right-hand-side operand (a double).
+ * right-hand-side operand (a Float).
*/
- operator fun rem(operand: Double) = Offset(dx % operand, dy % operand)
+ operator fun rem(operand: Float) = Offset(dx % operand, dy % operand)
/**
* Rectangle constructor operator.
@@ -283,4 +285,4 @@
result = 31 * result + dy.hashCode()
return result
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/engine/geometry/OffsetBase.kt b/ui/port/src/main/java/androidx/ui/engine/geometry/OffsetBase.kt
index a9be7a9..74dc929 100644
--- a/ui/port/src/main/java/androidx/ui/engine/geometry/OffsetBase.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/geometry/OffsetBase.kt
@@ -13,22 +13,22 @@
// TODO(Migration/Filip): Made OffsetBase to be an interface so we can have ancestors as data classes.
interface OffsetBase {
- val dx: Double
- val dy: Double
+ val dx: Float
+ val dy: Float
/**
- * Returns true if either component is [double.infinity], and false if both
+ * Returns true if either component is [Float.POSITIVE_INFINITY], and false if both
* are finite (or negative infinity, or NaN).
*
* This is different than comparing for equality with an instance that has
- * _both_ components set to [double.infinity].
+ * _both_ components set to [Float.POSITIVE_INFINITY].
*
* See also:
*
* * [isFinite], which is true if both components are finite (and not NaN).
*/
// TODO(Migration/Filip): Verify that this is valid in java world.
- fun isInfinite() = dx >= Double.POSITIVE_INFINITY || dy >= Double.POSITIVE_INFINITY
+ fun isInfinite() = dx >= Float.POSITIVE_INFINITY || dy >= Float.POSITIVE_INFINITY
/**
* Whether both components are finite (neither infinite nor NaN).
diff --git a/ui/port/src/main/java/androidx/ui/engine/geometry/RRect.kt b/ui/port/src/main/java/androidx/ui/engine/geometry/RRect.kt
index 720dae6..89fd0cb 100644
--- a/ui/port/src/main/java/androidx/ui/engine/geometry/RRect.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/geometry/RRect.kt
@@ -1,6 +1,6 @@
package androidx.ui.engine.geometry
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.toStringAsFixed
import kotlin.math.absoluteValue
@@ -9,29 +9,29 @@
*/
data class RRect(
/** The offset of the left edge of this rectangle from the x axis */
- val left: Double,
+ val left: Float,
/** The offset of the top edge of this rectangle from the y axis */
- val top: Double,
+ val top: Float,
/** The offset of the right edge of this rectangle from the x axis */
- val right: Double,
+ val right: Float,
/** The offset of the bottom edge of this rectangle from the y axis */
- val bottom: Double,
+ val bottom: Float,
/** The top-left horizontal radius */
- val topLeftRadiusX: Double,
+ val topLeftRadiusX: Float,
/** The top-left vertical radius */
- val topLeftRadiusY: Double,
+ val topLeftRadiusY: Float,
/** The top-right horizontal radius */
- val topRightRadiusX: Double,
+ val topRightRadiusX: Float,
/** The top-right vertical radius */
- val topRightRadiusY: Double,
+ val topRightRadiusY: Float,
/** The bottom-right horizontal radius */
- val bottomRightRadiusX: Double,
+ val bottomRightRadiusX: Float,
/** The bottom-right vertical radius */
- val bottomRightRadiusY: Double,
+ val bottomRightRadiusY: Float,
/** The bottom-left horizontal radius */
- val bottomLeftRadiusX: Double,
+ val bottomLeftRadiusX: Float,
/** The bottom-left vertical radius */
- val bottomLeftRadiusY: Double
+ val bottomLeftRadiusY: Float
) {
/** The distance between the left and right edges of this rectangle. */
val width = right - left
@@ -53,7 +53,7 @@
* Inspired from: https://github.com/google/skia/blob/master/src/core/SkRRect.cpp#L164
*/
private fun scaledRadiiRect(): RRect = _scaledRadiiRect ?: run {
- var scale = 1.0
+ var scale = 1.0f
scale = minRadius(scale, bottomLeftRadiusY, topLeftRadiusY, height)
scale = minRadius(scale, topLeftRadiusX, topRightRadiusX, width)
scale = minRadius(scale, topRightRadiusY, bottomRightRadiusY, height)
@@ -82,9 +82,9 @@
* Returns the minimum between min and scale to which radius1 and radius2
* should be scaled with in order not to exceed the limit.
*/
- private fun minRadius(min: Double, radius1: Double, radius2: Double, limit: Double): Double {
+ private fun minRadius(min: Float, radius1: Float, radius2: Float, limit: Float): Float {
val sum = radius1 + radius2
- return if (sum > limit && sum != 0.0) {
+ return if (sum > limit && sum != 0.0f) {
Math.min(min, limit / sum)
} else {
min
@@ -107,10 +107,10 @@
val scaled = scaledRadiiRect()
- val x: Double
- val y: Double
- val radiusX: Double
- val radiusY: Double
+ val x: Float
+ val y: Float
+ val radiusX: Float
+ val radiusY: Float
// check whether point is in one of the rounded corner areas
// x, y -> translate to ellipse center
if (point.dx < left + scaled.topLeftRadiusX &&
@@ -149,7 +149,7 @@
val newY = y / radiusY
// check if the point is inside the unit circle
- return newX * newX + newY * newY <= 1.0
+ return newX * newX + newY * newY <= 1.0f
}
// Kept this with a deprecated annotation to facilitate porting other code that uses
@@ -159,7 +159,7 @@
replaceWith = ReplaceWith("grow(delta)", "androidx.ui.engine.geometry.grow"),
level = DeprecationLevel.ERROR
)
- fun inflate(delta: Double): RRect = grow(delta)
+ fun inflate(delta: Float): RRect = grow(delta)
// Kept this with a deprecated annotation to facilitate porting other code that uses
// the function's old name/location
@@ -168,7 +168,7 @@
replaceWith = ReplaceWith("shrink(delta)", "androidx.ui.engine.geometry.shrink"),
level = DeprecationLevel.ERROR
)
- fun deflate(delta: Double): RRect = shrink(delta)
+ fun deflate(delta: Float): RRect = shrink(delta)
override fun toString(): String {
val tlRadius = topLeftRadius()
@@ -201,7 +201,7 @@
companion object {
/** A rounded rectangle with all the values set to zero. */
@JvmStatic
- val Zero = RRect(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
+ val Zero = RRect(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f)
}
}
@@ -210,12 +210,12 @@
* and the same radii along its horizontal axis and its vertical axis.
*/
fun RRect(
- left: Double,
- top: Double,
- right: Double,
- bottom: Double,
- radiusX: Double,
- radiusY: Double
+ left: Float,
+ top: Float,
+ right: Float,
+ bottom: Float,
+ radiusX: Float,
+ radiusY: Float
) = RRect(
left = left,
top = top,
@@ -236,10 +236,10 @@
* and the same radius in each corner.
*/
fun RRect(
- left: Double,
- top: Double,
- right: Double,
- bottom: Double,
+ left: Float,
+ top: Float,
+ right: Float,
+ bottom: Float,
radius: Radius
) = RRect(
left,
@@ -256,8 +256,8 @@
*/
fun RRect(
rect: Rect,
- radiusX: Double,
- radiusY: Double
+ radiusX: Float,
+ radiusY: Float
): RRect = RRect(
left = rect.left,
top = rect.top,
@@ -287,10 +287,10 @@
* The corner radii default to [Radius.zero], i.e. right-angled corners.
*/
fun RRect(
- left: Double,
- top: Double,
- right: Double,
- bottom: Double,
+ left: Float,
+ top: Float,
+ right: Float,
+ bottom: Float,
topLeft: Radius = Radius.zero,
topRight: Radius = Radius.zero,
bottomRight: Radius = Radius.zero,
@@ -365,7 +365,7 @@
* Returns a new [RRect] with edges and radii moved outwards by the given
* delta.
*/
-fun RRect.grow(delta: Double): RRect = RRect(
+fun RRect.grow(delta: Float): RRect = RRect(
left = left - delta,
top = top - delta,
right = right + delta,
@@ -377,7 +377,7 @@
)
/** Returns a new [RRect] with edges and radii moved inwards by the given delta. */
-fun RRect.shrink(delta: Double): RRect = grow(-delta)
+fun RRect.shrink(delta: Float): RRect = grow(-delta)
/** The bounding box of this rounded rectangle (the rectangle with no rounded corners). */
fun RRect.outerRect(): Rect = Rect.fromLTRB(left, top, right, bottom)
@@ -389,7 +389,7 @@
* respective quadrant bisector.
*/
fun RRect.safeInnerRect(): Rect {
- val insetFactor = 0.29289321881; // 1-cos(pi/4)
+ val insetFactor = 0.29289321881f; // 1-cos(pi/4)
val leftRadius = Math.max(bottomLeftRadiusX, topLeftRadiusX)
val topRadius = Math.max(topLeftRadiusY, topRightRadiusY)
@@ -473,10 +473,10 @@
* Whether this rounded rectangle is a simple rectangle with zero
* corner radii.
*/
-val RRect.isRect get(): Boolean = (topLeftRadiusX == 0.0 || topLeftRadiusY == 0.0) &&
- (topRightRadiusX == 0.0 || topRightRadiusY == 0.0) &&
- (bottomLeftRadiusX == 0.0 || bottomLeftRadiusY == 0.0) &&
- (bottomRightRadiusX == 0.0 || bottomRightRadiusY == 0.0)
+val RRect.isRect get(): Boolean = (topLeftRadiusX == 0.0f || topLeftRadiusY == 0.0f) &&
+ (topRightRadiusX == 0.0f || topRightRadiusY == 0.0f) &&
+ (bottomLeftRadiusX == 0.0f || bottomLeftRadiusY == 0.0f) &&
+ (bottomRightRadiusX == 0.0f || bottomRightRadiusY == 0.0f)
/** Whether this rounded rectangle has a side with no straight section. */
val RRect.isStadium get(): Boolean =
@@ -500,19 +500,19 @@
* The lesser of the magnitudes of the [width] and the [height] of this
* rounded rectangle.
*/
-val RRect.shortestSide get(): Double = Math.min(width.absoluteValue, height.absoluteValue)
+val RRect.shortestSide get(): Float = Math.min(width.absoluteValue, height.absoluteValue)
/**
* The greater of the magnitudes of the [width] and the [height] of this
* rounded rectangle.
*/
-val RRect.longestSide get(): Double = Math.max(width.absoluteValue, height.absoluteValue)
+val RRect.longestSide get(): Float = Math.max(width.absoluteValue, height.absoluteValue)
/**
* The offset to the point halfway between the left and right and the top and
* bottom edges of this rectangle.
*/
-fun RRect.center(): Offset = Offset(left + width / 2.0, top + height / 2.0)
+fun RRect.center(): Offset = Offset((left + width / 2.0f), (top + height / 2.0f))
/**
* Linearly interpolate between two rounded rectangles.
@@ -528,10 +528,10 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
-fun lerp(a: RRect?, b: RRect?, t: Double): RRect? = when {
+fun lerp(a: RRect?, b: RRect?, t: Float): RRect? = when {
a == null && b == null -> null
a == null -> {
b!! // Force the smart cast below; if it were null it would have tripped the case above
@@ -551,7 +551,7 @@
)
}
b == null -> {
- val k = 1.0 - t
+ val k = 1.0f - t
RRect(
left = a.left * k,
top = a.top * k,
@@ -568,17 +568,17 @@
)
}
else -> RRect(
- left = lerpDouble(a.left, b.left, t),
- top = lerpDouble(a.top, b.top, t),
- right = lerpDouble(a.right, b.right, t),
- bottom = lerpDouble(a.bottom, b.bottom, t),
- topLeftRadiusX = lerpDouble(a.topLeftRadiusX, b.topLeftRadiusX, t),
- topLeftRadiusY = lerpDouble(a.topLeftRadiusY, b.topLeftRadiusY, t),
- topRightRadiusX = lerpDouble(a.topRightRadiusX, b.topRightRadiusX, t),
- topRightRadiusY = lerpDouble(a.topRightRadiusY, b.topRightRadiusY, t),
- bottomRightRadiusX = lerpDouble(a.bottomRightRadiusX, b.bottomRightRadiusX, t),
- bottomRightRadiusY = lerpDouble(a.bottomRightRadiusY, b.bottomRightRadiusY, t),
- bottomLeftRadiusX = lerpDouble(a.bottomLeftRadiusX, b.bottomLeftRadiusX, t),
- bottomLeftRadiusY = lerpDouble(a.bottomLeftRadiusY, b.bottomLeftRadiusY, t)
+ left = lerpFloat(a.left, b.left, t),
+ top = lerpFloat(a.top, b.top, t),
+ right = lerpFloat(a.right, b.right, t),
+ bottom = lerpFloat(a.bottom, b.bottom, t),
+ topLeftRadiusX = lerpFloat(a.topLeftRadiusX, b.topLeftRadiusX, t),
+ topLeftRadiusY = lerpFloat(a.topLeftRadiusY, b.topLeftRadiusY, t),
+ topRightRadiusX = lerpFloat(a.topRightRadiusX, b.topRightRadiusX, t),
+ topRightRadiusY = lerpFloat(a.topRightRadiusY, b.topRightRadiusY, t),
+ bottomRightRadiusX = lerpFloat(a.bottomRightRadiusX, b.bottomRightRadiusX, t),
+ bottomRightRadiusY = lerpFloat(a.bottomRightRadiusY, b.bottomRightRadiusY, t),
+ bottomLeftRadiusX = lerpFloat(a.bottomLeftRadiusX, b.bottomLeftRadiusX, t),
+ bottomLeftRadiusY = lerpFloat(a.bottomLeftRadiusY, b.bottomLeftRadiusY, t)
)
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/engine/geometry/RSTransform.kt b/ui/port/src/main/java/androidx/ui/engine/geometry/RSTransform.kt
index b68ca4d..8ad9ec9 100644
--- a/ui/port/src/main/java/androidx/ui/engine/geometry/RSTransform.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/geometry/RSTransform.kt
@@ -1,5 +1,8 @@
package androidx.ui.engine.geometry
+import kotlin.math.cos
+import kotlin.math.sin
+
/**
* A transform consisting of a translation, a rotation, and a uniform scale.
*
@@ -36,34 +39,34 @@
*/
data class RSTransform(
// The cosine of the rotation multiplied by the scale factor.
- val scos: Double,
+ val scos: Float,
/** The sine of the rotation multiplied by that same scale factor. */
- val ssin: Double,
+ val ssin: Float,
/**
* The x coordinate of the translation, minus [scos] multiplied by the
* x-coordinate of the rotation point, plus [ssin] multiplied by the
* y-coordinate of the rotation point.
*/
- val tx: Double,
+ val tx: Float,
/**
* The y coordinate of the translation, minus [ssin] multiplied by the
* x-coordinate of the rotation point, minus [scos] multiplied by the
* y-coordinate of the rotation point.
*/
- val ty: Double
+ val ty: Float
) {
companion object {
fun fromComponents(
- rotation: Double,
- scale: Double,
- anchorX: Double,
- anchorY: Double,
- translateX: Double,
- translateY: Double
+ rotation: Float,
+ scale: Float,
+ anchorX: Float,
+ anchorY: Float,
+ translateX: Float,
+ translateY: Float
): RSTransform {
- val scos = Math.cos(rotation) * scale
- val ssin = Math.sin(rotation) * scale
+ val scos = cos(rotation) * scale
+ val ssin = sin(rotation) * scale
val tx = translateX + -scos * anchorX + ssin * anchorY
val ty = translateY + -ssin * anchorX - scos * anchorY
return RSTransform(scos, ssin, tx, ty)
diff --git a/ui/port/src/main/java/androidx/ui/engine/geometry/Radius.kt b/ui/port/src/main/java/androidx/ui/engine/geometry/Radius.kt
index 5b38b43..809732e 100644
--- a/ui/port/src/main/java/androidx/ui/engine/geometry/Radius.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/geometry/Radius.kt
@@ -1,25 +1,25 @@
package androidx.ui.engine.geometry
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.toStringAsFixed
import androidx.ui.truncDiv
/** A radius for either circular or elliptical shapes. */
data class Radius(
/** The radius value on the horizontal axis. */
- val x: Double,
+ val x: Float,
/** The radius value on the vertical axis. */
- val y: Double
+ val y: Float
) {
companion object {
/** Constructs a circular radius. [x] and [y] will have the same radius value. */
- fun circular(radius: Double): Radius {
+ fun circular(radius: Float): Radius {
return Radius(radius, radius)
}
/** Constructs an elliptical radius with the given radii. */
- fun elliptical(x: Double, y: Double): Radius {
+ fun elliptical(x: Float, y: Float): Radius {
return Radius(x, y)
}
@@ -28,7 +28,7 @@
*
* You can use [Radius.zero] with [RRect] to have right-angle corners.
*/
- val zero: Radius = circular(0.0)
+ val zero: Radius = circular(0.0f)
}
/**
@@ -66,37 +66,37 @@
*
* Returns a radius whose coordinates are the coordinates of the
* left-hand-side operand (a radius) multiplied by the scalar
- * right-hand-side operand (a double).
+ * right-hand-side operand (a Float).
*/
- operator fun times(operand: Double) = elliptical(x * operand, y * operand)
+ operator fun times(operand: Float) = elliptical(x * operand, y * operand)
/**
* Division operator.
*
* Returns a radius whose coordinates are the coordinates of the
* left-hand-side operand (a radius) divided by the scalar right-hand-side
- * operand (a double).
+ * operand (a Float).
*/
- operator fun div(operand: Double) = elliptical(x / operand, y / operand)
+ operator fun div(operand: Float) = elliptical(x / operand, y / operand)
/**
* Integer (truncating) division operator.
*
* Returns a radius whose coordinates are the coordinates of the
* left-hand-side operand (a radius) divided by the scalar right-hand-side
- * operand (a double), rounded towards zero.
+ * operand (a Float), rounded towards zero.
*/
- fun truncDiv(operand: Double): Radius =
- elliptical((x.truncDiv(operand)).toDouble(), y.truncDiv(operand).toDouble())
+ fun truncDiv(operand: Float): Radius =
+ elliptical((x.truncDiv(operand).toFloat()), y.truncDiv(operand).toFloat())
/**
* Modulo (remainder) operator.
*
* Returns a radius whose coordinates are the remainder of dividing the
* coordinates of the left-hand-side operand (a radius) by the scalar
- * right-hand-side operand (a double).
+ * right-hand-side operand (a Float).
*/
- operator fun rem(operand: Double) = elliptical(x % operand, y % operand)
+ operator fun rem(operand: Float) = elliptical(x % operand, y % operand)
/**
* Linearly interpolate between two radii.
@@ -112,10 +112,10 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
- fun lerp(a: Radius, b: Radius, t: Double): Radius? {
+ fun lerp(a: Radius, b: Radius, t: Float): Radius? {
// assert(t != null)
// if (a == null && b == null)
// return null
@@ -125,7 +125,7 @@
// val k: Double = 1.0 - t
// return elliptical(a.x * k, a.y * k)
// }
- return elliptical(lerpDouble(a.x, b.x, t), lerpDouble(a.y, b.y, t))
+ return elliptical(lerpFloat(a.x, b.x, t), lerpFloat(a.y, b.y, t))
}
override fun toString(): String {
@@ -165,18 +165,18 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
-fun lerp(a: Radius, b: Radius, t: Double): Radius? {
+fun lerp(a: Radius, b: Radius, t: Float): Radius? {
assert(t != null)
if (a == null && b == null)
return null
if (a == null)
return Radius.elliptical(b.x * t, b.y * t)
if (b == null) {
- val k: Double = 1.0 - t
+ val k: Float = 1.0f - t
return Radius.elliptical(a.x * k, a.y * k)
}
- return Radius.elliptical(lerpDouble(a.x, b.x, t), lerpDouble(a.y, b.y, t))
+ return Radius.elliptical(lerpFloat(a.x, b.x, t), lerpFloat(a.y, b.y, t))
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/engine/geometry/Rect.kt b/ui/port/src/main/java/androidx/ui/engine/geometry/Rect.kt
index 2724ded..ba850dd 100644
--- a/ui/port/src/main/java/androidx/ui/engine/geometry/Rect.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/geometry/Rect.kt
@@ -1,6 +1,6 @@
package androidx.ui.engine.geometry
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.toStringAsFixed
import kotlin.math.absoluteValue
@@ -17,18 +17,18 @@
*/
data class Rect(
// The offset of the left edge of this rectangle from the x axis.
- val left: Double,
+ val left: Float,
// The offset of the top edge of this rectangle from the y axis.
- val top: Double,
+ val top: Float,
// The offset of the right edge of this rectangle from the x axis.
- val right: Double,
+ val right: Float,
// The offset of the bottom edge of this rectangle from the y axis.
- val bottom: Double
+ val bottom: Float
) {
companion object {
/** Construct a rectangle from its left, top, right, and bottom edges. */
- fun fromLTRB(left: Double, top: Double, right: Double, bottom: Double): Rect {
+ fun fromLTRB(left: Float, top: Float, right: Float, bottom: Float): Rect {
return Rect(left, top, right, bottom)
}
@@ -39,7 +39,7 @@
* To construct a [Rect] from an [Offset] and a [Size], you can use the
* rectangle constructor operator `&`. See [Offset.&].
*/
- fun fromLTWH(left: Double, top: Double, width: Double, height: Double): Rect {
+ fun fromLTWH(left: Float, top: Float, width: Float, height: Float): Rect {
return Rect(left, top, left + width, top + height)
}
@@ -48,7 +48,7 @@
*
* The `center` argument is assumed to be an offset from the origin.
*/
- fun fromCircle(center: Offset, radius: Double): Rect {
+ fun fromCircle(center: Offset, radius: Float): Rect {
return Rect(
center.dx - radius,
center.dy - radius,
@@ -71,14 +71,14 @@
}
/** A rectangle with left, top, right, and bottom edges all at zero. */
- val zero: Rect = Rect(0.0, 0.0, 0.0, 0.0)
+ val zero: Rect = Rect(0.0f, 0.0f, 0.0f, 0.0f)
- val _giantScalar: Double = 1.0E+9 // matches kGiantRect from default_layer_builder.cc
+ val _giantScalar: Float = 1e7f // matches kGiantRect from default_layer_builder.cc
/**
* A rectangle that covers the entire coordinate space.
*
- * This covers the space from -1e9,-1e9 to 1e9,1e9.
+ * This covers the space from -1e7,-1e7 to 1e7, 1e7.
* This is the space over which graphics operations are valid.
*/
val largest: Rect = fromLTRB(-_giantScalar, -_giantScalar, _giantScalar, _giantScalar)
@@ -97,23 +97,23 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
- fun lerp(a: Rect?, b: Rect?, t: Double): Rect? {
+ fun lerp(a: Rect?, b: Rect?, t: Float): Rect? {
if (a == null && b == null)
return null
if (a == null)
return fromLTRB(b!!.left * t, b.top * t, b.right * t, b.bottom * t)
if (b == null) {
- val k = 1.0 - t
+ val k = 1.0f - t
return fromLTRB(a.left * k, a.top * k, a.right * k, a.bottom * k)
}
return fromLTRB(
- lerpDouble(a.left, b.left, t),
- lerpDouble(a.top, b.top, t),
- lerpDouble(a.right, b.right, t),
- lerpDouble(a.bottom, b.bottom, t)
+ lerpFloat(a.left, b.left, t),
+ lerpFloat(a.top, b.top, t),
+ lerpFloat(a.right, b.right, t),
+ lerpFloat(a.bottom, b.bottom, t)
)
}
}
@@ -142,10 +142,10 @@
/** Whether any of the coordinates of this rectangle are equal to positive infinity. */
// included for consistency with Offset and Size
fun isInfinite(): Boolean {
- return left >= Double.POSITIVE_INFINITY ||
- top >= Double.POSITIVE_INFINITY ||
- right >= Double.POSITIVE_INFINITY ||
- bottom >= Double.POSITIVE_INFINITY
+ return left >= Float.POSITIVE_INFINITY ||
+ top >= Float.POSITIVE_INFINITY ||
+ right >= Float.POSITIVE_INFINITY ||
+ bottom >= Float.POSITIVE_INFINITY
}
/** Whether all coordinates of this rectangle are finite. */
@@ -178,7 +178,7 @@
* To translate a rectangle by an [Offset] rather than by separate x and y
* components, consider [shift].
*/
- fun translate(translateX: Double, translateY: Double): Rect {
+ fun translate(translateX: Float, translateY: Float): Rect {
return fromLTRB(
left + translateX,
top + translateY,
@@ -188,12 +188,12 @@
}
/** Returns a new rectangle with edges moved outwards by the given delta. */
- fun inflate(delta: Double): Rect {
+ fun inflate(delta: Float): Rect {
return fromLTRB(left - delta, top - delta, right + delta, bottom + delta)
}
/** Returns a new rectangle with edges moved inwards by the given delta. */
- fun deflate(delta: Double): Rect = inflate(-delta)
+ fun deflate(delta: Float): Rect = inflate(-delta)
/**
* Returns a new rectangle that is the intersection of the given
@@ -248,13 +248,13 @@
* The lesser of the magnitudes of the [width] and the [height] of this
* rectangle.
*/
- fun getShortestSide(): Double = Math.min(width.absoluteValue, height.absoluteValue)
+ fun getShortestSide(): Float = Math.min(width.absoluteValue, height.absoluteValue)
/**
* The greater of the magnitudes of the [width] and the [height] of this
* rectangle.
*/
- fun getLongestSide(): Double = Math.max(width.absoluteValue, height.absoluteValue)
+ fun getLongestSide(): Float = Math.max(width.absoluteValue, height.absoluteValue)
/**
* The offset to the intersection of the top and left edges of this rectangle.
@@ -268,7 +268,7 @@
*
* See also [Size.topCenter].
*/
- fun getTopCenter(): Offset = Offset(left + width / 2.0, top)
+ fun getTopCenter(): Offset = Offset(left + width / 2.0f, top)
/**
* The offset to the intersection of the top and right edges of this rectangle.
@@ -282,7 +282,7 @@
*
* See also [Size.centerLeft].
*/
- fun getCenterLeft(): Offset = Offset(left, top + height / 2.0)
+ fun getCenterLeft(): Offset = Offset(left, top + height / 2.0f)
/**
* The offset to the point halfway between the left and right and the top and
@@ -290,14 +290,14 @@
*
* See also [Size.center].
*/
- fun getCenter(): Offset = Offset(left + width / 2.0, top + height / 2.0)
+ fun getCenter(): Offset = Offset(left + width / 2.0f, top + height / 2.0f)
/**
* The offset to the center of the right edge of this rectangle.
*
* See also [Size.centerLeft].
*/
- fun getCenterRight(): Offset = Offset(right, top + height / 2.0)
+ fun getCenterRight(): Offset = Offset(right, top + height / 2.0f)
/**
* The offset to the intersection of the bottom and left edges of this rectangle.
@@ -311,7 +311,7 @@
*
* See also [Size.bottomLeft].
*/
- fun getBottomCenter(): Offset = Offset(left + width / 2.0, bottom)
+ fun getBottomCenter(): Offset = Offset(left + width / 2.0f, bottom)
/**
* The offset to the intersection of the bottom and right edges of this rectangle.
@@ -368,10 +368,10 @@
fun toFrameworkRectF(): android.graphics.RectF {
return android.graphics.RectF(
- left.toFloat(),
- top.toFloat(),
- right.toFloat(),
- bottom.toFloat()
+ left,
+ top,
+ right,
+ bottom
)
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/engine/geometry/Size.kt b/ui/port/src/main/java/androidx/ui/engine/geometry/Size.kt
index 45c29c3..12f793c 100644
--- a/ui/port/src/main/java/androidx/ui/engine/geometry/Size.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/geometry/Size.kt
@@ -1,6 +1,6 @@
package androidx.ui.engine.geometry
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.toStringAsFixed
import androidx.ui.truncDiv
import kotlin.math.absoluteValue
@@ -10,10 +10,10 @@
*
* You can think of this as an [Offset] from the origin.
*/
-open class Size(val width: Double, val height: Double) : OffsetBase {
+open class Size(val width: Float, val height: Float) : OffsetBase {
- override val dx: Double = width
- override val dy: Double = height
+ override val dx: Float = width
+ override val dy: Float = height
companion object {
/**
@@ -32,22 +32,22 @@
* * [new Size.fromRadius], which is more convenient when the available size
* is the radius of a circle.
*/
- fun square(dimension: Double): Size {
+ fun square(dimension: Float): Size {
return Size(dimension, dimension)
}
/**
* Creates a [Size] with the given [width] and an infinite [height].
*/
- fun fromWidth(width: Double): Size {
- return Size(width, Double.POSITIVE_INFINITY)
+ fun fromWidth(width: Float): Size {
+ return Size(width, Float.POSITIVE_INFINITY)
}
/**
* Creates a [Size] with the given [height] and an infinite [width].
*/
- fun fromHeight(height: Double): Size {
- return Size(Double.POSITIVE_INFINITY, height)
+ fun fromHeight(height: Float): Size {
+ return Size(Float.POSITIVE_INFINITY, height)
}
/**
@@ -60,14 +60,14 @@
*
* * [new Size.square], which creates a square with the given dimension.
*/
- fun fromRadius(radius: Double): Size {
- return Size(radius * 2.0, radius * 2.0)
+ fun fromRadius(radius: Float): Size {
+ return Size(radius * 2.0f, radius * 2.0f)
}
/**
* An empty size, one with a zero width and a zero height.
*/
- val zero = Size(0.0, 0.0)
+ val zero = Size(0.0f, 0.0f)
/**
* A size whose [width] and [height] are infinite.
@@ -77,7 +77,7 @@
* * [isInfinite], which checks whether either dimension is infinite.
* * [isFinite], which checks whether both dimensions are finite.
*/
- val infinite = Size(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY)
+ val infinite = Size(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY)
/**
* Linearly interpolate between two sizes
@@ -93,17 +93,17 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
- fun lerp(a: Size, b: Size, t: Double): Size? {
+ fun lerp(a: Size, b: Size, t: Float): Size? {
// if (a == null && b == null)
// return null
// if (a == null)
// return b * t
// if (b == null)
// return a * (1.0 - t)
- return Size(lerpDouble(a.width, b.width, t), lerpDouble(a.height, b.height, t))
+ return Size(lerpFloat(a.width, b.width, t), lerpFloat(a.height, b.height, t))
}
}
@@ -112,7 +112,7 @@
*
* Negative areas are considered empty.
*/
- fun isEmpty() = width <= 0.0 || height <= 0.0
+ fun isEmpty() = width <= 0.0f || height <= 0.0f
/**
* Binary subtraction operator for [Size].
@@ -156,47 +156,47 @@
*
* Returns a [Size] whose dimensions are the dimensions of the left-hand-side
* operand (a [Size]) multiplied by the scalar right-hand-side operand (a
- * [double]).
+ * [Float]).
*/
- operator fun times(operand: Double) = Size(width * operand, height * operand)
+ operator fun times(operand: Float) = Size(width * operand, height * operand)
/**
* Division operator.
*
* Returns a [Size] whose dimensions are the dimensions of the left-hand-side
* operand (a [Size]) divided by the scalar right-hand-side operand (a
- * [double]).
+ * [Float]).
*/
- operator fun div(operand: Double) = Size(width / operand, height / operand)
+ operator fun div(operand: Float) = Size(width / operand, height / operand)
/**
* Integer (truncating) division operator.
*
* Returns a [Size] whose dimensions are the dimensions of the left-hand-side
* operand (a [Size]) divided by the scalar right-hand-side operand (a
- * [double]), rounded towards zero.
+ * [Float]), rounded towards zero.
*/
- fun truncDiv(operand: Double) =
- Size((width.truncDiv(operand)).toDouble(), (height.truncDiv(operand)).toDouble())
+ fun truncDiv(operand: Float) =
+ Size((width.truncDiv(operand)).toFloat(), (height.truncDiv(operand)).toFloat())
/**
* Modulo (remainder) operator.
*
* Returns a [Size] whose dimensions are the remainder of dividing the
* left-hand-side operand (a [Size]) by the scalar right-hand-side operand (a
- * [double]).
+ * [Float]).
*/
- operator fun rem(operand: Double) = Size(width % operand, height % operand)
+ operator fun rem(operand: Float) = Size(width % operand, height % operand)
/**
* The lesser of the magnitudes of the [width] and the [height].
*/
- fun getShortestSide(): Double = Math.min(width.absoluteValue, height.absoluteValue)
+ fun getShortestSide(): Float = Math.min(width.absoluteValue, height.absoluteValue)
/**
* The greater of the magnitudes of the [width] and the [height].
*/
- fun getLongestSide(): Double = Math.max(width.absoluteValue, height.absoluteValue)
+ fun getLongestSide(): Float = Math.max(width.absoluteValue, height.absoluteValue)
// Convenience methods that do the equivalent of calling the similarly named
// methods on a Rect constructed from the given origin and this size.
@@ -216,7 +216,7 @@
*
* See also [Rect.topCenter].
*/
- fun topCenter(origin: Offset): Offset = Offset(origin.dx + width / 2.0, origin.dy)
+ fun topCenter(origin: Offset): Offset = Offset(origin.dx + width / 2.0f, origin.dy)
/**
* The offset to the intersection of the top and right edges of the rectangle
@@ -233,7 +233,7 @@
*
* See also [Rect.centerLeft].
*/
- fun centerLeft(origin: Offset): Offset = Offset(origin.dx, origin.dy + height / 2.0)
+ fun centerLeft(origin: Offset): Offset = Offset(origin.dx, origin.dy + height / 2.0f)
/**
* The offset to the point halfway between the left and right and the top and
@@ -242,7 +242,7 @@
*
* See also [Rect.center].
*/
- fun center(origin: Offset): Offset = Offset(origin.dx + width / 2.0, origin.dy + height / 2.0)
+ fun center(origin: Offset): Offset = Offset(origin.dx + width / 2.0f, origin.dy + height / 2.0f)
/**
* The offset to the center of the right edge of the rectangle described by the
@@ -250,7 +250,7 @@
*
* See also [Rect.centerLeft].
*/
- fun centerRight(origin: Offset): Offset = Offset(origin.dx + width, origin.dy + height / 2.0)
+ fun centerRight(origin: Offset): Offset = Offset(origin.dx + width, origin.dy + height / 2.0f)
/**
* The offset to the intersection of the bottom and left edges of the
@@ -268,7 +268,7 @@
*
* See also [Rect.bottomLeft].
*/
- fun bottomCenter(origin: Offset): Offset = Offset(origin.dx + width / 2.0, origin.dy + height)
+ fun bottomCenter(origin: Offset): Offset = Offset(origin.dx + width / 2.0f, origin.dy + height)
/**
* The offset to the intersection of the bottom and right edges of the
@@ -288,7 +288,7 @@
* right edges.
*/
fun contains(offset: Offset): Boolean {
- return offset.dx >= 0.0 && offset.dx < width && offset.dy >= 0.0 && offset.dy < height
+ return offset.dx >= 0.0f && offset.dx < width && offset.dy >= 0.0f && offset.dy < height
}
/**
@@ -311,4 +311,4 @@
result = 31 * result + dy.hashCode()
return result
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/engine/text/FontWeight.kt b/ui/port/src/main/java/androidx/ui/engine/text/FontWeight.kt
index a769e85..7735ba7 100644
--- a/ui/port/src/main/java/androidx/ui/engine/text/FontWeight.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/text/FontWeight.kt
@@ -72,10 +72,10 @@
// easily be generated by curves such as [Curves.elasticInOut]). The result
// is clamped to the range [w100]–[w900].
//
- // Values for `t` are usually obtained from an [Animation<double>], such as
+ // Values for `t` are usually obtained from an [Animation<Float>], such as
// an [AnimationController].
// TODO(Migration/siyamed): I did not like the variable naming.
- fun lerp(a: FontWeight?, b: FontWeight?, t: Double): FontWeight {
+ fun lerp(a: FontWeight?, b: FontWeight?, t: Float): FontWeight {
return values[lerpInt(
a?.index ?: normal.index,
b?.index ?: normal.index,
@@ -102,4 +102,4 @@
else -> "FontWeight.unknown"
}
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/engine/text/Paragraph.kt b/ui/port/src/main/java/androidx/ui/engine/text/Paragraph.kt
index 99de521..52d0326 100644
--- a/ui/port/src/main/java/androidx/ui/engine/text/Paragraph.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/text/Paragraph.kt
@@ -50,7 +50,7 @@
*
* Valid only after [layout] has been called.
*/
- val width: Double
+ val width: Float
get() = paragraphImpl.width
/**
@@ -58,7 +58,7 @@
*
* Valid only after [layout] has been called.
*/
- val height: Double
+ val height: Float
get() = paragraphImpl.height
/**
@@ -76,21 +76,21 @@
*
* Valid only after [layout] has been called.
*/
- val maxIntrinsicWidth: Double
+ val maxIntrinsicWidth: Float
get() = paragraphImpl.maxIntrinsicWidth
/**
* The distance from the top of the paragraph to the alphabetic
* baseline of the first line, in logical pixels.
*/
- val alphabeticBaseline: Double
+ val alphabeticBaseline: Float
get() = paragraphImpl.alphabeticBaseline
/**
* The distance from the top of the paragraph to the ideographic
* baseline of the first line, in logical pixels.
*/
- val ideographicBaseline: Double
+ val ideographicBaseline: Float
get() = paragraphImpl.ideographicBaseline
/**
@@ -105,7 +105,7 @@
get() = paragraphImpl.didExceedMaxLines
init {
- if (paragraphStyle.lineHeight != null && paragraphStyle.lineHeight < 0.0) {
+ if (paragraphStyle.lineHeight != null && paragraphStyle.lineHeight < 0.0f) {
throw IllegalArgumentException("lineHeight can't be negative")
}
paragraphImpl = ParagraphAndroid(text, paragraphStyle, textStyles)
@@ -130,7 +130,7 @@
_layout(constraints.width)
}
- private fun _layout(width: Double, force: Boolean = false) {
+ private fun _layout(width: Float, force: Boolean = false) {
// TODO(migration/siyamed) the comparison should be floor(width) since it is
// floored in paragraphImpl, or the comparison should be moved to there.
if (!needsLayout && this.width == width && !force) return
@@ -184,7 +184,7 @@
// Redirecting the paint function in this way solves some dependency problems
// in the C++ code. If we straighten out the C++ dependencies, we can remove
// this indirection.
- fun paint(canvas: Canvas, x: Double, y: Double) {
+ fun paint(canvas: Canvas, x: Float, y: Float) {
paragraphImpl.paint(canvas, x, y)
}
}
diff --git a/ui/port/src/main/java/androidx/ui/engine/text/ParagraphConstraints.kt b/ui/port/src/main/java/androidx/ui/engine/text/ParagraphConstraints.kt
index 6dd763f4..9abf412 100644
--- a/ui/port/src/main/java/androidx/ui/engine/text/ParagraphConstraints.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/text/ParagraphConstraints.kt
@@ -45,7 +45,7 @@
* alignment described in the [ParagraphStyle] used when building the
* [Paragraph] with a [ParagraphBuilder].
*/
-data class ParagraphConstraints(val width: Double) {
+data class ParagraphConstraints(val width: Float) {
override fun toString(): String {
return "ParagraphConstraints(width: $width)"
}
diff --git a/ui/port/src/main/java/androidx/ui/engine/text/ParagraphStyle.kt b/ui/port/src/main/java/androidx/ui/engine/text/ParagraphStyle.kt
index 711446d..7a4f8bc 100644
--- a/ui/port/src/main/java/androidx/ui/engine/text/ParagraphStyle.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/text/ParagraphStyle.kt
@@ -77,8 +77,8 @@
val fontStyle: FontStyle? = null,
val maxLines: Int? = null,
val fontFamily: FontFamily? = null,
- val fontSize: Double? = null,
- val lineHeight: Double? = null,
+ val fontSize: Float? = null,
+ val lineHeight: Float? = null,
// TODO(Migration/siyamed): pass to TextLayout
val ellipsis: String? = null,
val locale: Locale? = null,
diff --git a/ui/port/src/main/java/androidx/ui/engine/text/TextBox.kt b/ui/port/src/main/java/androidx/ui/engine/text/TextBox.kt
index 8204c7ca..cd1f5c9 100644
--- a/ui/port/src/main/java/androidx/ui/engine/text/TextBox.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/text/TextBox.kt
@@ -28,20 +28,16 @@
* The left edge of the text box, irrespective of direction.
* To get the leading edge (which may depend on the [direction]), consider [start].
*/
- val left: Double,
-
+ val left: Float,
/** The top edge of the text box. */
- val top: Double,
-
+ val top: Float,
/**
* The right edge of the text box, irrespective of direction.
* To get the trailing edge (which may depend on the [direction]), consider [end].
*/
- val right: Double,
-
+ val right: Float,
/** The bottom edge of the text box. */
- val bottom: Double,
-
+ val bottom: Float,
/** The direction in which text inside this box flows. */
val direction: TextDirection
) {
@@ -56,7 +52,7 @@
* See also:
* * [direction], which specifies the text direction.
*/
- fun start(): Double {
+ fun start(): Float {
return if ((direction == TextDirection.LTR)) left else right
}
@@ -65,7 +61,7 @@
* See also:
* * [direction], which specifies the text direction.
*/
- fun end(): Double {
+ fun end(): Float {
return if ((direction == TextDirection.LTR)) right else left
}
@@ -76,10 +72,10 @@
companion object {
fun fromLTRBD(
- left: Double,
- top: Double,
- right: Double,
- bottom: Double,
+ left: Float,
+ top: Float,
+ right: Float,
+ bottom: Float,
direction: TextDirection
): TextBox {
return TextBox(left, top, right, bottom, direction)
diff --git a/ui/port/src/main/java/androidx/ui/engine/text/TextDecorationStyle.kt b/ui/port/src/main/java/androidx/ui/engine/text/TextDecorationStyle.kt
index d8f3095..7835fc1 100644
--- a/ui/port/src/main/java/androidx/ui/engine/text/TextDecorationStyle.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/text/TextDecorationStyle.kt
@@ -31,4 +31,4 @@
/** Draw a sinusoidal line */
wavy
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/engine/text/TextStyle.kt b/ui/port/src/main/java/androidx/ui/engine/text/TextStyle.kt
index 9c8ee94..4eddf4e 100644
--- a/ui/port/src/main/java/androidx/ui/engine/text/TextStyle.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/text/TextStyle.kt
@@ -55,10 +55,10 @@
val fontStyle: FontStyle? = null,
val textBaseline: TextBaseline? = null,
val fontFamily: FontFamily? = null,
- val fontSize: Double? = null,
- val letterSpacing: Double? = null,
- val wordSpacing: Double? = null,
- val height: Double? = null,
+ val fontSize: Float? = null,
+ val letterSpacing: Float? = null,
+ val wordSpacing: Float? = null,
+ val height: Float? = null,
val locale: Locale? = null,
// TODO(Migration/haoyuchang): background is changed to color from paint.
val background: Color? = null,
diff --git a/ui/port/src/main/java/androidx/ui/engine/text/platform/ParagraphAndroid.kt b/ui/port/src/main/java/androidx/ui/engine/text/platform/ParagraphAndroid.kt
index de75388..5725820 100644
--- a/ui/port/src/main/java/androidx/ui/engine/text/platform/ParagraphAndroid.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/text/platform/ParagraphAndroid.kt
@@ -71,27 +71,27 @@
// TODO(Migration/siyamed): width having -1 but others having 0 as default value is counter
// intuitive
- var width: Double = -1.0
- get() = layout?.let { field } ?: -1.0
+ var width: Float = -1.0f
+ get() = layout?.let { field } ?: -1.0f
- val height: Double
- get() = layout?.let { it.layout.height.toDouble() } ?: 0.0
+ val height: Float
+ get() = layout?.let { it.layout.height.toFloat() } ?: 0.0f
// TODO(Migration/siyamed): we do not have this concept. they limit to the max word size.
// it didn't make sense to me. I believe we might be able to do it. if we can use
// wordbreaker.
- val minIntrinsicWidth: Double
- get() = 0.0
+ val minIntrinsicWidth: Float
+ get() = 0.0f
- val maxIntrinsicWidth: Double
- get() = layout?.let { it.maxIntrinsicWidth } ?: 0.0
+ val maxIntrinsicWidth: Float
+ get() = layout?.let { it.maxIntrinsicWidth } ?: 0.0f
- val alphabeticBaseline: Double
- get() = layout?.let { it.layout.getLineBaseline(0).toDouble() } ?: Double.MAX_VALUE
+ val alphabeticBaseline: Float
+ get() = layout?.let { it.layout.getLineBaseline(0).toFloat() } ?: Float.MAX_VALUE
// TODO(Migration/siyamed): (metrics.fUnderlinePosition - metrics.fAscent) * style.height;
- val ideographicBaseline: Double
- get() = Double.MAX_VALUE
+ val ideographicBaseline: Float
+ get() = Float.MAX_VALUE
val didExceedMaxLines: Boolean
get() = layout?.let { it.didExceedMaxLines } ?: false
@@ -114,11 +114,11 @@
val underlyingText: CharSequence
get() = ensureLayout.text
- fun layout(width: Double, force: Boolean = false) {
+ fun layout(width: Float, force: Boolean = false) {
val floorWidth = floor(width)
paragraphStyle.fontSize?.let {
- textPaint.textSize = it.toFloat()
+ textPaint.textSize = it
}
// TODO: This default values are problem here. If the user just gives a single font
@@ -164,7 +164,7 @@
}
val lineSpacingMultiplier =
- paragraphStyle.lineHeight ?: DEFAULT_LINESPACING_MULTIPLIER.toDouble()
+ paragraphStyle.lineHeight ?: DEFAULT_LINESPACING_MULTIPLIER
layout = TextLayout(
charSequence = charSequence,
@@ -182,21 +182,21 @@
fun getPositionForOffset(offset: Offset): TextPosition {
val line = ensureLayout.layout.getLineForVertical(offset.dy.toInt())
return TextPosition(
- offset = ensureLayout.layout.getOffsetForHorizontal(line, offset.dx.toFloat()),
+ offset = ensureLayout.layout.getOffsetForHorizontal(line, offset.dx),
// TODO(Migration/siyamed): we provide a default value
affinity = TextAffinity.upstream
)
}
- fun getLineLeft(index: Int): Double = ensureLayout.getLineLeft(index)
+ fun getLineLeft(index: Int): Float = ensureLayout.getLineLeft(index)
- fun getLineRight(index: Int): Double = ensureLayout.getLineRight(index)
+ fun getLineRight(index: Int): Float = ensureLayout.getLineRight(index)
- fun getLineHeight(index: Int): Double = ensureLayout.getLineHeight(index)
+ fun getLineHeight(index: Int): Float = ensureLayout.getLineHeight(index)
- fun getLineWidth(index: Int): Double = ensureLayout.getLineWidth(index)
+ fun getLineWidth(index: Int): Float = ensureLayout.getLineWidth(index)
- fun paint(canvas: Canvas, x: Double, y: Double) {
+ fun paint(canvas: Canvas, x: Float, y: Float) {
val tmpLayout = layout ?: throw IllegalStateException("paint cannot be " +
"called before layout() is called")
canvas.translate(x, y)
@@ -275,7 +275,7 @@
// TODO(Migration/haoyuchang): support letter spacing with pixel.
style.letterSpacing?.let {
spannableString.setSpan(
- LetterSpacingSpan(it.toFloat()),
+ LetterSpacingSpan(it),
start,
end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
diff --git a/ui/port/src/main/java/androidx/ui/engine/window/Window.kt b/ui/port/src/main/java/androidx/ui/engine/window/Window.kt
index 8b339a9..110a902 100644
--- a/ui/port/src/main/java/androidx/ui/engine/window/Window.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/window/Window.kt
@@ -45,7 +45,7 @@
* * [WidgetsBindingObserver], for a mechanism at the widgets layer to
* observe when this value changes.
*/
- var devicePixelRatio: Double = 1.0
+ var devicePixelRatio: Float = 1.0f
internal set
/**
@@ -172,7 +172,7 @@
* * [WidgetsBindingObserver], for a mechanism at the widgets layer to
* observe when this value changes.
*/
- var textScaleFactor: Double = 1.0
+ var textScaleFactor: Float = 1.0f
internal set
/**
diff --git a/ui/port/src/main/java/androidx/ui/engine/window/WindowPadding.kt b/ui/port/src/main/java/androidx/ui/engine/window/WindowPadding.kt
index 7c97155..96e3fcb 100644
--- a/ui/port/src/main/java/androidx/ui/engine/window/WindowPadding.kt
+++ b/ui/port/src/main/java/androidx/ui/engine/window/WindowPadding.kt
@@ -20,17 +20,17 @@
*/
data class WindowPadding(
// The distance from the left edge to the first unpadded pixel, in physical pixels.
- val left: Double,
+ val left: Float,
// The distance from the top edge to the first unpadded pixel, in physical pixels.
- val top: Double,
+ val top: Float,
// The distance from the right edge to the first unpadded pixel, in physical pixels.
- val right: Double,
+ val right: Float,
// The distance from the bottom edge to the first unpadded pixel, in physical pixels.
- val bottom: Double
+ val bottom: Float
) {
companion object {
/** A window padding that has zeros for each edge. */
- val zero = WindowPadding(0.0, 0.0, 0.0, 0.0)
+ val zero = WindowPadding(0.0f, 0.0f, 0.0f, 0.0f)
}
}
diff --git a/ui/port/src/main/java/androidx/ui/flow/layers/DefaultLayerBuilder.kt b/ui/port/src/main/java/androidx/ui/flow/layers/DefaultLayerBuilder.kt
index 1d998c6..8bb3d6d 100644
--- a/ui/port/src/main/java/androidx/ui/flow/layers/DefaultLayerBuilder.kt
+++ b/ui/port/src/main/java/androidx/ui/flow/layers/DefaultLayerBuilder.kt
@@ -26,7 +26,7 @@
companion object {
- val kGiantRect: Rect = Rect.fromLTRB(-1E9, -1E9, 1E9, 1E9)
+ val kGiantRect: Rect = Rect.fromLTRB(-1E7f, -1E7f, 1E7f, 1E7f)
}
override fun PushTransform(matrix: SkMatrix) {
@@ -238,4 +238,4 @@
current_layer_!!.Add(layer)
current_layer_ = layer
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/flow/layers/LayerBuilder.kt b/ui/port/src/main/java/androidx/ui/flow/layers/LayerBuilder.kt
index b8bb399..9835c7d 100644
--- a/ui/port/src/main/java/androidx/ui/flow/layers/LayerBuilder.kt
+++ b/ui/port/src/main/java/androidx/ui/flow/layers/LayerBuilder.kt
@@ -86,4 +86,4 @@
abstract fun Pop()
abstract fun TakeLayer(): Layer?
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/foundation/AndroidOwner.kt b/ui/port/src/main/java/androidx/ui/foundation/AndroidOwner.kt
index ecbf141..1f6419e 100644
--- a/ui/port/src/main/java/androidx/ui/foundation/AndroidOwner.kt
+++ b/ui/port/src/main/java/androidx/ui/foundation/AndroidOwner.kt
@@ -61,7 +61,7 @@
System.out.println("Measuring $child")
measure(child, constraints, true)
System.out.println("Child's size is ${child.width} x ${child.height}")
- Size(child.width.toDouble(), child.height.toDouble())
+ Size(child.width.toFloat(), child.height.toFloat())
}
}
@@ -266,17 +266,17 @@
private fun convertMeasureSpec(measureSpec: Int): ConstraintRange {
val mode = MeasureSpec.getMode(measureSpec)
- val size = MeasureSpec.getSize(measureSpec).toDouble()
+ val size = MeasureSpec.getSize(measureSpec).toFloat()
return when (mode) {
MeasureSpec.EXACTLY -> ConstraintRange(size, size)
- MeasureSpec.UNSPECIFIED -> ConstraintRange(0.0, Double.POSITIVE_INFINITY)
- MeasureSpec.AT_MOST -> ConstraintRange(0.0, size)
+ MeasureSpec.UNSPECIFIED -> ConstraintRange(0.0f, Float.POSITIVE_INFINITY)
+ MeasureSpec.AT_MOST -> ConstraintRange(0.0f, size)
else -> throw IllegalStateException()
}
}
}
-private class ConstraintRange(val min: Double, val max: Double)
+private class ConstraintRange(val min: Float, val max: Float)
/**
* Defines a View used to keep RenderNode information on LayoutNodes and DrawNodes.
diff --git a/ui/port/src/main/java/androidx/ui/foundation/ComponentNodes.kt b/ui/port/src/main/java/androidx/ui/foundation/ComponentNodes.kt
index 19dbf11..8f49185 100644
--- a/ui/port/src/main/java/androidx/ui/foundation/ComponentNodes.kt
+++ b/ui/port/src/main/java/androidx/ui/foundation/ComponentNodes.kt
@@ -308,7 +308,7 @@
/**
* The constraints used the last time [layout] was called.
*/
- var constraints: Constraints = BoxConstraints.tight(Size(0.0, 0.0))
+ var constraints: Constraints = BoxConstraints.tight(Size(0.0f, 0.0f))
/**
* The `parentUsesSize` from the last time [layout] was called.
@@ -494,7 +494,7 @@
}
}
- return Size(child.width.toDouble(), child.height.toDouble())
+ return Size(child.width.toFloat(), child.height.toFloat())
}
}
}
diff --git a/ui/port/src/main/java/androidx/ui/foundation/diagnostics/Diagnosticable.kt b/ui/port/src/main/java/androidx/ui/foundation/diagnostics/Diagnosticable.kt
index a5ebf0a..8eea022 100644
--- a/ui/port/src/main/java/androidx/ui/foundation/diagnostics/Diagnosticable.kt
+++ b/ui/port/src/main/java/androidx/ui/foundation/diagnostics/Diagnosticable.kt
@@ -112,9 +112,9 @@
*
* * [StringProperty], which supports automatically enclosing a [String]
* value in quotes.
- * * [DoubleProperty], which supports specifying a unit of measurement for
- * a [double] value.
- * * [PercentProperty], which clamps a [double] to between 0 and 1 and
+ * * [FloatProperty], which supports specifying a unit of measurement for
+ * a [Float] value.
+ * * [PercentProperty], which clamps a [Float] to between 0 and 1 and
* formats it as a percentage.
* * [IntProperty], which supports specifying a unit of measurement for an
* [int] value.
@@ -161,18 +161,18 @@
* // as it would just add visual noise.
* properties.add(new StringProperty('message', message, showName: false));
*
- * properties.add(new DoubleProperty('stepWidth', stepWidth));
+ * properties.add(new FloatProperty('stepWidth', stepWidth));
*
* // A scale of 1.0 does nothing so should be hidden.
- * properties.add(new DoubleProperty('scale', scale, defaultValue: 1.0));
+ * properties.add(new FloatProperty('scale', scale, defaultValue: 1.0));
*
* // If the hitTestExtent matches the paintExtent, it is just set to its
* // default value so is not relevant.
- * properties.add(new DoubleProperty('hitTestExtent', hitTestExtent, defaultValue: paintExtent));
+ * properties.add(new FloatProperty('hitTestExtent', hitTestExtent, defaultValue: paintExtent));
*
- * // maxWidth of double.infinity indicates the width is unconstrained and
+ * // maxWidth of Float.POSITIVE_INFINITY indicates the width is unconstrained and
* // so maxWidth has no impact.,
- * properties.add(new DoubleProperty('maxWidth', maxWidth, defaultValue: double.infinity));
+ * properties.add(new FloatProperty('maxWidth', maxWidth, defaultValue: Float.POSITIVE_INFINITY));
*
* // Progress is a value between 0 and 1 or null. Showing it as a
* // percentage makes the meaning clear enough that the name can be
@@ -194,7 +194,7 @@
* // Tooltip is used instead of unit for this case as a unit should be a
* // terse description appropriate to display directly after a number
* // without a space.
- * properties.add(new DoubleProperty(
+ * properties.add(new FloatProperty(
* 'device pixel ratio',
* ui.window.devicePixelRatio,
* tooltip: 'physical pixels per logical pixel',
diff --git a/ui/port/src/main/java/androidx/ui/foundation/diagnostics/DoubleProperty.kt b/ui/port/src/main/java/androidx/ui/foundation/diagnostics/FloatProperty.kt
similarity index 83%
rename from ui/port/src/main/java/androidx/ui/foundation/diagnostics/DoubleProperty.kt
rename to ui/port/src/main/java/androidx/ui/foundation/diagnostics/FloatProperty.kt
index ac85677..2d001f4 100644
--- a/ui/port/src/main/java/androidx/ui/foundation/diagnostics/DoubleProperty.kt
+++ b/ui/port/src/main/java/androidx/ui/foundation/diagnostics/FloatProperty.kt
@@ -3,21 +3,21 @@
import androidx.ui.toStringAsFixed
/**
- * Property describing a [double] [value] with an optional [unit] of measurement.
+ * Property describing a [Float] [value] with an optional [unit] of measurement.
*
* Numeric formatting is optimized for debug message readability.
*/
-open class DoubleProperty protected constructor(
+open class FloatProperty protected constructor(
name: String,
- value: Double? = null,
- computeValue: ComputePropertyValueCallback<Double?>? = null,
+ value: Float? = null,
+ computeValue: ComputePropertyValueCallback<Float?>? = null,
ifNull: String? = null,
unit: String? = null,
showName: Boolean = true,
defaultValue: Any? = kNoDefaultValue,
tooltip: String? = null,
level: DiagnosticLevel = DiagnosticLevel.info
-) : _NumProperty<Double>(
+) : _NumProperty<Float>(
name = name,
value = value,
computeValue = computeValue,
@@ -38,15 +38,15 @@
*/
fun create(
name: String,
- value: Double? = null,
+ value: Float? = null,
ifNull: String? = null,
unit: String? = null,
showName: Boolean = true,
defaultValue: Any? = kNoDefaultValue,
tooltip: String? = null,
level: DiagnosticLevel = DiagnosticLevel.info
- ): DoubleProperty {
- return DoubleProperty(
+ ): FloatProperty {
+ return FloatProperty(
name = name,
value = value,
ifNull = ifNull,
@@ -68,15 +68,15 @@
*/
fun createLazy(
name: String,
- computeValue: ComputePropertyValueCallback<Double?>,
+ computeValue: ComputePropertyValueCallback<Float?>,
ifNull: String? = null,
unit: String? = null,
showName: Boolean = true,
defaultValue: Any = kNoDefaultValue,
tooltip: String? = null,
level: DiagnosticLevel = DiagnosticLevel.info
- ): DoubleProperty {
- return DoubleProperty(
+ ): FloatProperty {
+ return FloatProperty(
name = name,
computeValue = computeValue,
ifNull = ifNull,
diff --git a/ui/port/src/main/java/androidx/ui/foundation/diagnostics/PercentProperty.kt b/ui/port/src/main/java/androidx/ui/foundation/diagnostics/PercentProperty.kt
index 94cd990..e866e4e 100644
--- a/ui/port/src/main/java/androidx/ui/foundation/diagnostics/PercentProperty.kt
+++ b/ui/port/src/main/java/androidx/ui/foundation/diagnostics/PercentProperty.kt
@@ -4,7 +4,7 @@
import androidx.ui.toStringAsFixed
/**
- * Property which clamps a [double] to between 0 and 1 and formats it as a
+ * Property which clamps a [Float] to between 0 and 1 and formats it as a
* percentage.
*
* Ctor comment:
@@ -19,13 +19,13 @@
*/
class PercentProperty(
name: String,
- fraction: Double?,
+ fraction: Float?,
ifNull: String? = null,
unit: String? = null,
showName: Boolean = true,
tooltip: String? = null,
level: DiagnosticLevel = DiagnosticLevel.info
-) : DoubleProperty(
+) : FloatProperty(
name = name,
value = fraction,
ifNull = ifNull,
@@ -44,6 +44,6 @@
override fun numberToString(): String {
if (getValue() == null)
return getValue().toString()
- return "${(getValue()!!.clamp(0.0, 1.0) * 100.0).toStringAsFixed(1)}%"
+ return "${(getValue()!!.clamp(0.0f, 1.0f) * 100.0f).toStringAsFixed(1)}%"
}
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/gestures/constants.kt b/ui/port/src/main/java/androidx/ui/gestures/constants.kt
index 981b528..8b46014 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/constants.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/constants.kt
@@ -43,7 +43,7 @@
* which TapGestureRecognizer inherits from, uses [kTouchSlop].)
*/
// TODO(ianh): Remove this or implement it correctly.
-const val kHoverTapSlop: Double = 20.0 // Logical pixels
+const val kHoverTapSlop: Float = 20.0f // Logical pixels
/** The time before a long press gesture attempts to win. */
val kLongPressTimeout: Duration = Duration.create(milliseconds = 500)
@@ -72,21 +72,21 @@
*/
// This value was empirically derived. We started at 8.0 and increased it to
// 18.0 after getting complaints that it was too difficult to hit targets.
-const val kTouchSlop: Double = 18.0 // Logical pixels
+const val kTouchSlop: Float = 18.0f // Logical pixels
/**
* The maximum distance that the first touch in a double-tap gesture can travel
* before deciding that it is not part of a double-tap gesture.
* DoubleTapGestureRecognizer also restricts the second touch to this distance.
*/
-const val kDoubleTapTouchSlop: Double = kTouchSlop // Logical pixels
+const val kDoubleTapTouchSlop: Float = kTouchSlop // Logical pixels
/**
* Distance between the initial position of the first touch and the start
* position of a potential second touch for the second touch to be considered
* the second touch of a double-tap gesture.
*/
-const val kDoubleTapSlop: Double = 100.0 // Logical pixels
+const val kDoubleTapSlop: Float = 100.0f // Logical pixels
/**
* The time for which zoom controls (e.g. in a map interface) are to be
@@ -101,38 +101,38 @@
*/
// TODO(ianh): Create variants of HorizontalDragGestureRecognizer et al for
// paging, which use this constant.
-const val kPagingTouchSlop: Double = kTouchSlop * 2.0 // Logical pixels
+const val kPagingTouchSlop: Float = kTouchSlop * 2.0f // Logical pixels
/**
* The distance a touch has to travel for the framework to be confident that
* the gesture is a panning gesture.
*/
-const val kPanSlop: Double = kTouchSlop * 2.0 // Logical pixels
+const val kPanSlop: Float = kTouchSlop * 2.0f // Logical pixels
/**
* The distance a touch has to travel for the framework to be confident that
* the gesture is a scale gesture.
*/
-const val kScaleSlop: Double = kTouchSlop // Logical pixels
+const val kScaleSlop: Float = kTouchSlop // Logical pixels
/**
* The margin around a dialog, popup menu, or other window-like widget inside
* which we do not consider a tap to dismiss the widget. (Not currently used.)
*/
// TODO(ianh): Make ModalBarrier support this.
-const val kWindowTouchSlop: Double = 16.0 // Logical pixels
+const val kWindowTouchSlop: Float = 16.0f // Logical pixels
/**
* The minimum velocity for a touch to consider that touch to trigger a fling
* gesture.
*/
// TODO(ianh): Make sure nobody has their own version of this.
-const val kMinFlingVelocity: Double = 50.0 // Logical pixels / second
+const val kMinFlingVelocity: Float = 50.0f // Logical pixels / second
// const Velocity kMinFlingVelocity = const Velocity(pixelsPerSecond: 50.0)
/** Drag gesture fling velocities are clipped to this value. */
// TODO(ianh): Make sure nobody has their own version of this.
-const val kMaxFlingVelocity: Double = 8000.0 // Logical pixels / second
+const val kMaxFlingVelocity: Float = 8000.0f // Logical pixels / second
/**
* The maximum time from the start of the first tap to the start of the second
diff --git a/ui/port/src/main/java/androidx/ui/gestures/drag_details/DragEndDetails.kt b/ui/port/src/main/java/androidx/ui/gestures/drag_details/DragEndDetails.kt
index 77594a0..e3ced76 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/drag_details/DragEndDetails.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/drag_details/DragEndDetails.kt
@@ -48,15 +48,14 @@
*
* Defaults to null if not specified in the constructor.
*/
- val primaryVelocity: Double? = null
+ val primaryVelocity: Float? = null
) {
init {
assert(
- primaryVelocity == null
- || primaryVelocity == velocity.pixelsPerSecond.dx
- || primaryVelocity == velocity.pixelsPerSecond.dy
+ primaryVelocity == null || primaryVelocity == velocity.pixelsPerSecond.dx ||
+ primaryVelocity == velocity.pixelsPerSecond.dy
)
}
- override fun toString() = "${runtimeType()}(${velocity})"
+ override fun toString() = "${runtimeType()}($velocity)"
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/gestures/drag_details/DragUpdateDetails.kt b/ui/port/src/main/java/androidx/ui/gestures/drag_details/DragUpdateDetails.kt
index 2f39bde..c8614ab 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/drag_details/DragUpdateDetails.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/drag_details/DragUpdateDetails.kt
@@ -63,19 +63,18 @@
* If non-null, then its value must match one of the coordinates of [delta] and the other
* coordinate must be zero.
*/
- val primaryDelta: Double? = null,
+ val primaryDelta: Float? = null,
/** The pointer's global position when it triggered this update. */
val globalPosition: Offset
) {
init {
assert(
- primaryDelta == null
- || (primaryDelta == delta.dx && delta.dy == 0.0)
- || (primaryDelta == delta.dy && delta.dx == 0.0)
+ primaryDelta == null || (primaryDelta == delta.dx && delta.dy == 0.0f) ||
+ (primaryDelta == delta.dy && delta.dx == 0.0f)
)
}
- override fun toString() = "${runtimeType()}(${delta})"
+ override fun toString() = "${runtimeType()}($delta)"
}
/**
diff --git a/ui/port/src/main/java/androidx/ui/gestures/events/PointerAddedEvent.kt b/ui/port/src/main/java/androidx/ui/gestures/events/PointerAddedEvent.kt
index 88e478b..b54f67c 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/events/PointerAddedEvent.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/events/PointerAddedEvent.kt
@@ -30,14 +30,14 @@
device: Int = 0,
position: Offset = Offset.zero,
obscured: Boolean = false,
- pressureMin: Double = 1.0,
- pressureMax: Double = 1.0,
- distance: Double = 0.0,
- distanceMax: Double = 0.0,
- radiusMin: Double = 0.0,
- radiusMax: Double = 0.0,
- orientation: Double = 0.0,
- tilt: Double = 0.0
+ pressureMin: Float = 1.0f,
+ pressureMax: Float = 1.0f,
+ distance: Float = 0.0f,
+ distanceMax: Float = 0.0f,
+ radiusMin: Float = 0.0f,
+ radiusMax: Float = 0.0f,
+ orientation: Float = 0.0f,
+ tilt: Float = 0.0f
) : PointerEvent(
timeStamp = timeStamp,
kind = kind,
diff --git a/ui/port/src/main/java/androidx/ui/gestures/events/PointerCancelEvent.kt b/ui/port/src/main/java/androidx/ui/gestures/events/PointerCancelEvent.kt
index 58b5e55..bb3bdf3 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/events/PointerCancelEvent.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/events/PointerCancelEvent.kt
@@ -29,14 +29,14 @@
position: Offset = Offset.zero,
buttons: Int = 0,
obscured: Boolean = false,
- pressureMin: Double = 1.0,
- pressureMax: Double = 1.0,
- distance: Double = 0.0,
- distanceMax: Double = 0.0,
- radiusMin: Double = 0.0,
- radiusMax: Double = 0.0,
- orientation: Double = 0.0,
- tilt: Double = 0.0
+ pressureMin: Float = 1.0f,
+ pressureMax: Float = 1.0f,
+ distance: Float = 0.0f,
+ distanceMax: Float = 0.0f,
+ radiusMin: Float = 0.0f,
+ radiusMax: Float = 0.0f,
+ orientation: Float = 0.0f,
+ tilt: Float = 0.0f
) : PointerEvent(
timeStamp = timeStamp,
pointer = pointer,
diff --git a/ui/port/src/main/java/androidx/ui/gestures/events/PointerDownEvent.kt b/ui/port/src/main/java/androidx/ui/gestures/events/PointerDownEvent.kt
index 56145a9..e790b15 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/events/PointerDownEvent.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/events/PointerDownEvent.kt
@@ -29,16 +29,16 @@
position: Offset = Offset.zero,
buttons: Int = 0,
obscured: Boolean = false,
- pressure: Double = 1.0,
- pressureMin: Double = 1.0,
- pressureMax: Double = 1.0,
- distanceMax: Double = 0.0,
- radiusMajor: Double = 0.0,
- radiusMinor: Double = 0.0,
- radiusMin: Double = 0.0,
- radiusMax: Double = 0.0,
- orientation: Double = 0.0,
- tilt: Double = 0.0
+ pressure: Float = 1.0f,
+ pressureMin: Float = 1.0f,
+ pressureMax: Float = 1.0f,
+ distanceMax: Float = 0.0f,
+ radiusMajor: Float = 0.0f,
+ radiusMinor: Float = 0.0f,
+ radiusMin: Float = 0.0f,
+ radiusMax: Float = 0.0f,
+ orientation: Float = 0.0f,
+ tilt: Float = 0.0f
) : PointerEvent(
timeStamp = timeStamp,
pointer = pointer,
@@ -51,7 +51,7 @@
pressure = pressure,
pressureMin = pressureMin,
pressureMax = pressureMax,
- distance = 0.0,
+ distance = 0.0f,
distanceMax = distanceMax,
radiusMajor = radiusMajor,
radiusMinor = radiusMinor,
diff --git a/ui/port/src/main/java/androidx/ui/gestures/events/PointerEvent.kt b/ui/port/src/main/java/androidx/ui/gestures/events/PointerEvent.kt
index 40bbc60..bf8e494 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/events/PointerEvent.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/events/PointerEvent.kt
@@ -73,34 +73,34 @@
// /// with no discernible pressure, to 1.0, indicating a touch with "normal"
// /// pressure, and possibly beyond, indicating a stronger touch. For devices
// /// that do not detect pressure (e.g. mice), returns 1.0.
- val pressure: Double = 1.0,
+ val pressure: Float = 1.0f,
// /// The minimum value that [pressure] can return for this pointer. For devices
// /// that do not detect pressure (e.g. mice), returns 1.0. This will always be
// /// a number less than or equal to 1.0.
- val pressureMin: Double = 1.0,
+ val pressureMin: Float = 1.0f,
// /// The maximum value that [pressure] can return for this pointer. For devices
// /// that do not detect pressure (e.g. mice), returns 1.0. This will always be
// /// a greater than or equal to 1.0.
- val pressureMax: Double = 1.0,
+ val pressureMax: Float = 1.0f,
// /// The distance of the detected object from the input surface (e.g. the
// /// distance of a stylus or finger from a touch screen), in arbitrary units on
// /// an arbitrary (not necessarily linear) scale. If the pointer is down, this
// /// is 0.0 by definition.
- val distance: Double = 0.0,
+ val distance: Float = 0.0f,
// /// The maximum value that a distance can return for this pointer. If this
// /// input device cannot detect "hover touch" input events, then this will be
// /// 0.0.
- val distanceMax: Double = 0.0,
+ val distanceMax: Float = 0.0f,
// /// The radius of the contact ellipse along the major axis, in logical pixels.
- val radiusMajor: Double = 0.0,
+ val radiusMajor: Float = 0.0f,
// /// The radius of the contact ellipse along the minor axis, in logical pixels.
- val radiusMinor: Double = 0.0,
+ val radiusMinor: Float = 0.0f,
// /// The minimum value that could be reported for radiusMajor and radiusMinor
// /// for this pointer, in logical pixels.
- val radiusMin: Double = 0.0,
+ val radiusMin: Float = 0.0f,
// /// The minimum value that could be reported for radiusMajor and radiusMinor
// /// for this pointer, in logical pixels.
- val radiusMax: Double = 0.0,
+ val radiusMax: Float = 0.0f,
// /// For PointerDeviceKind.touch events:
// ///
// /// The angle of the contact ellipse, in radius in the range:
@@ -126,7 +126,7 @@
// /// indicate that the stylus would go down in the negative y-axis direction;
// /// pi/4 would indicate that the stylus goes up and to the right, -pi/2 would
// /// indicate that the stylus goes to the left, etc).
- val orientation: Double = 0.0,
+ val orientation: Float = 0.0f,
// /// For PointerDeviceKind.stylus and PointerDeviceKind.invertedStylus events:
// ///
// /// The angle of the stylus, in radians in the range:
@@ -137,7 +137,7 @@
// /// perpendicular to the input surface (thus 0.0 indicates the stylus is
// /// orthogonal to the plane of the input surface, while pi/2 indicates that
// /// the stylus is flat on that surface).
- val tilt: Double = 0.0,
+ val tilt: Float = 0.0f,
// /// We occasionally synthesize PointerEvents that aren"t exact translations
// /// of [ui.PointerData] from the engine to cover small cross-OS discrepancies
// /// in pointer behaviors.
@@ -151,7 +151,7 @@
val synthesized: Boolean = false
) {
// /// The minimum value that a distance can return for this pointer (always 0.0).
- val distanceMin: Double = 0.0
+ val distanceMin: Float = 0.0f
override fun toString(): String = "${this.javaClass.canonicalName}($position)"
diff --git a/ui/port/src/main/java/androidx/ui/gestures/events/PointerHoverEvent.kt b/ui/port/src/main/java/androidx/ui/gestures/events/PointerHoverEvent.kt
index c47602f..ce7ad08 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/events/PointerHoverEvent.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/events/PointerHoverEvent.kt
@@ -35,16 +35,16 @@
delta: Offset = Offset.zero,
buttons: Int = 0,
obscured: Boolean = false,
- pressureMin: Double = 1.0,
- pressureMax: Double = 1.0,
- distance: Double = 0.0,
- distanceMax: Double = 0.0,
- radiusMajor: Double = 0.0,
- radiusMinor: Double = 0.0,
- radiusMin: Double = 0.0,
- radiusMax: Double = 0.0,
- orientation: Double = 0.0,
- tilt: Double = 0.0,
+ pressureMin: Float = 1.0f,
+ pressureMax: Float = 1.0f,
+ distance: Float = 0.0f,
+ distanceMax: Float = 0.0f,
+ radiusMajor: Float = 0.0f,
+ radiusMinor: Float = 0.0f,
+ radiusMin: Float = 0.0f,
+ radiusMax: Float = 0.0f,
+ orientation: Float = 0.0f,
+ tilt: Float = 0.0f,
synthesized: Boolean = false
) : PointerEvent(
timeStamp = timeStamp,
diff --git a/ui/port/src/main/java/androidx/ui/gestures/events/PointerMoveEvent.kt b/ui/port/src/main/java/androidx/ui/gestures/events/PointerMoveEvent.kt
index ce2b7f57..541ceca 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/events/PointerMoveEvent.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/events/PointerMoveEvent.kt
@@ -36,16 +36,16 @@
delta: Offset = Offset.zero,
buttons: Int = 0,
obscured: Boolean = false,
- pressure: Double = 1.0,
- pressureMin: Double = 1.0,
- pressureMax: Double = 1.0,
- distanceMax: Double = 0.0,
- radiusMajor: Double = 0.0,
- radiusMinor: Double = 0.0,
- radiusMin: Double = 0.0,
- radiusMax: Double = 0.0,
- orientation: Double = 0.0,
- tilt: Double = 0.0,
+ pressure: Float = 1.0f,
+ pressureMin: Float = 1.0f,
+ pressureMax: Float = 1.0f,
+ distanceMax: Float = 0.0f,
+ radiusMajor: Float = 0.0f,
+ radiusMinor: Float = 0.0f,
+ radiusMin: Float = 0.0f,
+ radiusMax: Float = 0.0f,
+ orientation: Float = 0.0f,
+ tilt: Float = 0.0f,
synthesized: Boolean = false
) : PointerEvent(
timeStamp = timeStamp,
@@ -60,7 +60,7 @@
pressure = pressure,
pressureMin = pressureMin,
pressureMax = pressureMax,
- distance = 0.0,
+ distance = 0.0f,
distanceMax = distanceMax,
radiusMajor = radiusMajor,
radiusMinor = radiusMinor,
diff --git a/ui/port/src/main/java/androidx/ui/gestures/events/PointerRemovedEvent.kt b/ui/port/src/main/java/androidx/ui/gestures/events/PointerRemovedEvent.kt
index d7a6b54..fe768a9 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/events/PointerRemovedEvent.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/events/PointerRemovedEvent.kt
@@ -28,11 +28,11 @@
kind: PointerDeviceKind = PointerDeviceKind.touch,
device: Int = 0,
obscured: Boolean = false,
- pressureMin: Double = 1.0,
- pressureMax: Double = 1.0,
- distanceMax: Double = 0.0,
- radiusMin: Double = 0.0,
- radiusMax: Double = 0.0
+ pressureMin: Float = 1.0f,
+ pressureMax: Float = 1.0f,
+ distanceMax: Float = 0.0f,
+ radiusMin: Float = 0.0f,
+ radiusMax: Float = 0.0f
) : PointerEvent(
timeStamp = timeStamp,
kind = kind,
diff --git a/ui/port/src/main/java/androidx/ui/gestures/events/PointerUpEvent.kt b/ui/port/src/main/java/androidx/ui/gestures/events/PointerUpEvent.kt
index dfb3b3a..c5cda751 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/events/PointerUpEvent.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/events/PointerUpEvent.kt
@@ -29,14 +29,14 @@
position: Offset = Offset.zero,
buttons: Int = 0,
obscured: Boolean = false,
- pressureMin: Double = 1.0,
- pressureMax: Double = 1.0,
- distance: Double = 0.0,
- distanceMax: Double = 0.0,
- radiusMin: Double = 0.0,
- radiusMax: Double = 0.0,
- orientation: Double = 0.0,
- tilt: Double = 0.0
+ pressureMin: Float = 1.0f,
+ pressureMax: Float = 1.0f,
+ distance: Float = 0.0f,
+ distanceMax: Float = 0.0f,
+ radiusMin: Float = 0.0f,
+ radiusMax: Float = 0.0f,
+ orientation: Float = 0.0f,
+ tilt: Float = 0.0f
) : PointerEvent(
timeStamp = timeStamp,
pointer = pointer,
diff --git a/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/LeastSquaresSolver.kt b/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/LeastSquaresSolver.kt
index 54e6567..2c2b21c 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/LeastSquaresSolver.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/LeastSquaresSolver.kt
@@ -19,11 +19,11 @@
/** Uses the least-squares algorithm to fit a polynomial to a set of data. */
class LeastSquaresSolver(
/** The x-coordinates of each data point. */
- val x: DoubleArray,
+ val x: FloatArray,
/** The y-coordinates of each data point. */
- val y: DoubleArray,
+ val y: FloatArray,
/** The weight to use for each data point. */
- val w: DoubleArray
+ val w: FloatArray
) {
/** Fits a polynomial of the given degree to the data points. */
@@ -58,24 +58,24 @@
q.set(j, h, a.get(j, h))
}
for (i in 0 until j) {
- val dot: Double = q.getRow(j) * q.getRow(i)
+ val dot: Float = q.getRow(j) * q.getRow(i)
for (h in 0 until m) {
q.set(j, h, q.get(j, h) - dot * q.get(i, h))
}
}
- val norm: Double = q.getRow(j).norm()
+ val norm: Float = q.getRow(j).norm()
if ((norm < 0.000001)) {
// Vectors are linearly dependent or zero so no solution.
return null
}
- val inverseNorm: Double = 1.0 / norm
+ val inverseNorm: Float = 1.0f / norm
for (h in 0 until m) {
q.set(j, h, q.get(j, h) * inverseNorm)
}
for (i in 0 until n) {
- r.set(j, i, if (i < j) 0.0 else q.getRow(j) * a.getRow(i))
+ r.set(j, i, if (i < j) 0.0f else q.getRow(j) * a.getRow(i))
}
}
@@ -98,17 +98,17 @@
// ...where sumSquaredError is the residual sum of squares (variance of the
// error), and sumSquaredTotal is the total sum of squares (variance of the
// data) where each has been weighted.
- var yMean = 0.0
+ var yMean = 0.0f
for (h in 0 until m) {
yMean += y[h]
}
yMean /= m
- var sumSquaredError = 0.0
- var sumSquaredTotal = 0.0
+ var sumSquaredError = 0.0f
+ var sumSquaredTotal = 0.0f
for (h in 0 until m) {
- var term = 1.0
- var err: Double = y[h] - result.coefficients[0]
+ var term = 1.0f
+ var err: Float = y[h] - result.coefficients[0]
for (i in 1 until n) {
term *= x[h]
err -= term * result.coefficients[i]
@@ -119,7 +119,7 @@
}
result.confidence =
- if (sumSquaredTotal <= 0.000001) 1.0 else 1.0 - (sumSquaredError / sumSquaredTotal)
+ if (sumSquaredTotal <= 0.000001f) 1f else 1f - (sumSquaredError / sumSquaredTotal)
return result
}
diff --git a/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/PolynomialFit.kt b/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/PolynomialFit.kt
index cf844c4..799e9c2 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/PolynomialFit.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/PolynomialFit.kt
@@ -39,12 +39,12 @@
class PolynomialFit(degree: Int) {
/** The polynomial coefficients of the fit. */
- val coefficients: Array<Double> = Array(degree + 1) { 0.0 }
+ val coefficients: Array<Float> = Array(degree + 1) { 0.0f }
/**
* An indicator of the quality of the fit.
*
* Larger values indicate greater quality.
*/
- var confidence: Double = 0.0
+ var confidence: Float = 0.0f
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/_Matrix.kt b/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/_Matrix.kt
index 5d38088..88ceac6 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/_Matrix.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/_Matrix.kt
@@ -19,13 +19,13 @@
// TODO(abarth): Consider using vector_math.
internal class _Matrix(rows: Int, cols: Int) {
private val _columns: Int = cols
- private val _elements: Array<Double> = Array(rows * cols) { 0.0 }
+ private val _elements: Array<Float> = Array(rows * cols) { 0.0f }
- fun get(row: Int, col: Int): Double {
+ fun get(row: Int, col: Int): Float {
return _elements[(row * _columns) + col]
}
- fun set(row: Int, col: Int, value: Double) {
+ fun set(row: Int, col: Int, value: Float) {
_elements[(row * _columns) + col] = value
}
diff --git a/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/_Vector.kt b/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/_Vector.kt
index 1bb0da4..923a6fd 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/_Vector.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/lsq_solver/_Vector.kt
@@ -22,27 +22,27 @@
internal class _Vector internal constructor(
val _length: Int,
val _offset: Int = 0,
- val _elements: Array<Double> = Array(_length) { 0.0 }
+ val _elements: Array<Float> = Array(_length) { 0.0f }
) {
operator fun get(i: Int) = _elements.get((i + _offset))
- operator fun set(i: Int, value: Double) {
+ operator fun set(i: Int, value: Float) {
_elements[(i + _offset)] = value
}
- operator fun times(a: _Vector): Double {
- var result = 0.0
+ operator fun times(a: _Vector): Float {
+ var result = 0.0f
for (i in 0 until _length) {
result += this[i] * a[i]
}
return result
}
- fun norm(): Double = sqrt(this * this)
+ fun norm(): Float = sqrt(this * this)
companion object {
- internal fun fromVOL(values: Array<Double>, offset: Int, length: Int) =
+ internal fun fromVOL(values: Array<Float>, offset: Int, length: Int) =
_Vector(length, offset, values)
}
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/gestures/monodrag/DragGestureRecognizer.kt b/ui/port/src/main/java/androidx/ui/gestures/monodrag/DragGestureRecognizer.kt
index b8efaac..3a7d5e2 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/monodrag/DragGestureRecognizer.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/monodrag/DragGestureRecognizer.kt
@@ -105,7 +105,7 @@
* This value is typically compared with the distance traveled along the
* scrolling axis. If null then [kTouchSlop] is used.
*/
- var minFlingDistance: Double? = null
+ var minFlingDistance: Float? = null
/**
* The minimum velocity for an input pointer drag to be considered fling.
@@ -114,14 +114,14 @@
* velocity along the scrolling axis. If null then [kMinFlingVelocity]
* is used.
*/
- var minFlingVelocity: Double? = null
+ var minFlingVelocity: Float? = null
/**
* Fling velocity magnitudes will be clamped to this value.
*
* If null then [kMaxFlingVelocity] is used.
*/
- var maxFlingVelocity: Double? = null
+ var maxFlingVelocity: Float? = null
private var _state: _DragState = _DragState.ready
private var _initialPosition: Offset? = null
@@ -132,7 +132,7 @@
internal abstract fun _getDeltaForDetails(delta: Offset): Offset
- internal abstract fun _getPrimaryValueFromOffset(value: Offset): Double?
+ internal abstract fun _getPrimaryValueFromOffset(value: Offset): Float?
internal abstract fun _hasSufficientPendingDragDeltaToAccept(): Boolean
@@ -269,7 +269,7 @@
onEnd(
DragEndDetails(
velocity = Velocity.zero,
- primaryVelocity = 0.0
+ primaryVelocity = 0.0f
)
)
}, debugReport = {
diff --git a/ui/port/src/main/java/androidx/ui/gestures/monodrag/HorizontalDragGestureRecognizer.kt b/ui/port/src/main/java/androidx/ui/gestures/monodrag/HorizontalDragGestureRecognizer.kt
index b5407fb..cd47daf 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/monodrag/HorizontalDragGestureRecognizer.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/monodrag/HorizontalDragGestureRecognizer.kt
@@ -47,7 +47,7 @@
override fun _hasSufficientPendingDragDeltaToAccept() =
(_pendingDragOffset!!.dx.absoluteValue) > kTouchSlop
- override fun _getDeltaForDetails(delta: Offset) = Offset(0.0, delta.dx)
+ override fun _getDeltaForDetails(delta: Offset) = Offset(0.0f, delta.dx)
override fun _getPrimaryValueFromOffset(value: Offset) = value.dx
diff --git a/ui/port/src/main/java/androidx/ui/gestures/monodrag/VerticalDragGestureRecognizer.kt b/ui/port/src/main/java/androidx/ui/gestures/monodrag/VerticalDragGestureRecognizer.kt
index 18438cc..d1dc258 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/monodrag/VerticalDragGestureRecognizer.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/monodrag/VerticalDragGestureRecognizer.kt
@@ -47,7 +47,7 @@
override fun _hasSufficientPendingDragDeltaToAccept() =
(_pendingDragOffset!!.dy.absoluteValue) > kTouchSlop
- override fun _getDeltaForDetails(delta: Offset) = Offset(0.0, delta.dy)
+ override fun _getDeltaForDetails(delta: Offset) = Offset(0.0f, delta.dy)
override fun _getPrimaryValueFromOffset(value: Offset) = value.dy
diff --git a/ui/port/src/main/java/androidx/ui/gestures/multitap/TapTracker.kt b/ui/port/src/main/java/androidx/ui/gestures/multitap/TapTracker.kt
index da9c66a..8540fdb 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/multitap/TapTracker.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/multitap/TapTracker.kt
@@ -62,7 +62,7 @@
}
}
- fun isWithinTolerance(event: PointerEvent, tolerance: Double): Boolean {
+ fun isWithinTolerance(event: PointerEvent, tolerance: Float): Boolean {
val offset: Offset = event.position - initialPosition
return (offset.getDistance() <= tolerance)
}
diff --git a/ui/port/src/main/java/androidx/ui/gestures/recognizer/PrimaryPointerGestureRecognizer.kt b/ui/port/src/main/java/androidx/ui/gestures/recognizer/PrimaryPointerGestureRecognizer.kt
index 571abf1..a69d4b4 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/recognizer/PrimaryPointerGestureRecognizer.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/recognizer/PrimaryPointerGestureRecognizer.kt
@@ -117,7 +117,7 @@
timer = null
}
- private fun _getDistance(event: PointerEvent): Double {
+ private fun _getDistance(event: PointerEvent): Float {
val offset: Offset = event.position - initialPosition!!
return offset.getDistance()
}
diff --git a/ui/port/src/main/java/androidx/ui/gestures/scale/Scale.kt b/ui/port/src/main/java/androidx/ui/gestures/scale/Scale.kt
index e7e9e8c..7c9a09b 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/scale/Scale.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/scale/Scale.kt
@@ -79,7 +79,7 @@
* The scale implied by the pointers in contact with the screen. A value
* greater than or equal to zero.
*/
- val scale: Double = 1.0
+ val scale: Float = 1.0f
) {
override fun toString() = "ScaleUpdateDetails(focalPoint: $focalPoint, scale: $scale)"
}
@@ -108,7 +108,7 @@
typealias GestureScaleEndCallback = (ScaleEndDetails) -> Unit
internal fun isFlingGesture(velocity: Velocity): Boolean {
- val speedSquared: Double = velocity.pixelsPerSecond.getDistanceSquared()
+ val speedSquared: Float = velocity.pixelsPerSecond.getDistanceSquared()
return (speedSquared > kMinFlingVelocity * kMinFlingVelocity)
}
@@ -142,20 +142,20 @@
private var initialFocalPoint: Offset? = null
private var currentFocalPoint: Offset? = null
- private var initialSpan: Double = 0.0
- private var currentSpan: Double = 0.0
+ private var initialSpan: Float = 0.0f
+ private var currentSpan: Float = 0.0f
private var pointerLocations: MutableMap<Int, Offset>? = null
private val velocityTrackers: MutableMap<Int, VelocityTracker> = mutableMapOf()
- private fun scaleFactor() = if (initialSpan > 0.0) currentSpan / initialSpan else 1.0
+ private fun scaleFactor() = if (initialSpan > 0.0f) currentSpan / initialSpan else 1.0f
override fun addPointer(event: PointerDownEvent) {
startTrackingPointer(event.pointer)
velocityTrackers[event.pointer] = VelocityTracker()
if (state == ScaleState.READY) {
state = ScaleState.POSSIBLE
- initialSpan = 0.0
- currentSpan = 0.0
+ initialSpan = 0.0f
+ currentSpan = 0.0f
pointerLocations = mutableMapOf()
}
}
@@ -197,14 +197,14 @@
focalPoint += it
}
- currentFocalPoint = if (count > 0) focalPoint / count.toDouble() else Offset.zero
+ currentFocalPoint = if (count > 0) focalPoint / count.toFloat() else Offset.zero
// Span is the average deviation from focal point
- var totalDeviation = 0.0
+ var totalDeviation = 0.0f
pointerLocations!!.values.forEach {
totalDeviation += (currentFocalPoint!! - it).getDistance()
}
- currentSpan = if (count > 0) totalDeviation / count else 0.0
+ currentSpan = if (count > 0) totalDeviation / count else 0.0f
}
private fun reconfigure(pointer: Int): Boolean {
diff --git a/ui/port/src/main/java/androidx/ui/gestures/velocity_tracker/Velocity.kt b/ui/port/src/main/java/androidx/ui/gestures/velocity_tracker/Velocity.kt
index d72a645..f9c12d4e 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/velocity_tracker/Velocity.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/velocity_tracker/Velocity.kt
@@ -48,10 +48,10 @@
* If the magnitude of this Velocity is within the specified bounds then
* just return this.
*/
- fun clampMagnitude(minValue: Double, maxValue: Double): Velocity {
- assert(minValue >= 0.0)
- assert((maxValue >= 0.0) && (maxValue >= minValue))
- val valueSquared: Double = pixelsPerSecond.getDistanceSquared()
+ fun clampMagnitude(minValue: Float, maxValue: Float): Velocity {
+ assert(minValue >= 0.0f)
+ assert((maxValue >= 0.0f) && (maxValue >= minValue))
+ val valueSquared: Float = pixelsPerSecond.getDistanceSquared()
if (valueSquared > maxValue * maxValue) {
return Velocity(
pixelsPerSecond = (pixelsPerSecond / pixelsPerSecond.getDistance()) * maxValue
diff --git a/ui/port/src/main/java/androidx/ui/gestures/velocity_tracker/VelocityEstimate.kt b/ui/port/src/main/java/androidx/ui/gestures/velocity_tracker/VelocityEstimate.kt
index 2324af2..35303c6 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/velocity_tracker/VelocityEstimate.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/velocity_tracker/VelocityEstimate.kt
@@ -44,7 +44,7 @@
*
* The value of this property is 1.0 for a perfect fit, 0.0 for a poor fit.
*/
- val confidence: Double,
+ val confidence: Float,
/**
* The time that elapsed between the first and last position sample used
* to compute [pixelsPerSecond].
@@ -61,4 +61,4 @@
"offset: $offset, " +
"duration: $duration, " +
"confidence: ${confidence.toStringAsFixed(1)})"
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/gestures/velocity_tracker/VelocityTracker.kt b/ui/port/src/main/java/androidx/ui/gestures/velocity_tracker/VelocityTracker.kt
index cd22789..d5106c6 100644
--- a/ui/port/src/main/java/androidx/ui/gestures/velocity_tracker/VelocityTracker.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures/velocity_tracker/VelocityTracker.kt
@@ -58,10 +58,10 @@
* Returns null if there is no data on which to base an estimate.
*/
open fun getVelocityEstimate(): VelocityEstimate? {
- val x: MutableList<Double> = mutableListOf()
- val y: MutableList<Double> = mutableListOf()
- val w: MutableList<Double> = mutableListOf()
- val time: MutableList<Double> = mutableListOf()
+ val x: MutableList<Float> = mutableListOf()
+ val y: MutableList<Float> = mutableListOf()
+ val w: MutableList<Float> = mutableListOf()
+ val time: MutableList<Float> = mutableListOf()
var sampleCount = 0
var index: Int = _index
@@ -75,9 +75,9 @@
do {
val sample: _PointAtTime = _samples[index] ?: break
- val age: Double = (newestSample.time - sample.time).inMilliseconds.toDouble()
- val delta: Double =
- (sample.time - previousSample.time).inMilliseconds.absoluteValue.toDouble()
+ val age: Float = (newestSample.time - sample.time).inMilliseconds.toFloat()
+ val delta: Float =
+ (sample.time - previousSample.time).inMilliseconds.absoluteValue.toFloat()
previousSample = sample
if (age > _kHorizonMilliseconds || delta > _kAssumePointerMoveStoppedMilliseconds) {
break
@@ -87,7 +87,7 @@
val position: Offset = sample.point
x.add(position.dx)
y.add(position.dy)
- w.add(1.0)
+ w.add(1.0f)
time.add(-age)
index = (if (index == 0) _kHistorySize else index) - 1
@@ -96,11 +96,11 @@
if (sampleCount >= _kMinSampleSize) {
val xSolver =
- LeastSquaresSolver(time.toDoubleArray(), x.toDoubleArray(), w.toDoubleArray())
+ LeastSquaresSolver(time.toFloatArray(), x.toFloatArray(), w.toFloatArray())
val xFit: PolynomialFit? = xSolver.solve(2)
if (xFit != null) {
val ySolver =
- LeastSquaresSolver(time.toDoubleArray(), y.toDoubleArray(), w.toDoubleArray())
+ LeastSquaresSolver(time.toFloatArray(), y.toFloatArray(), w.toFloatArray())
val yFit: PolynomialFit? = ySolver.solve(2)
if (yFit != null) {
@@ -121,7 +121,7 @@
// valid pointer position.
return VelocityEstimate(
pixelsPerSecond = Offset.zero,
- confidence = 1.0,
+ confidence = 1.0f,
duration = newestSample.time - oldestSample.time,
offset = newestSample.point - oldestSample.point
)
diff --git a/ui/port/src/main/java/androidx/ui/gestures2/DragGestureRecognizer2.kt b/ui/port/src/main/java/androidx/ui/gestures2/DragGestureRecognizer2.kt
index 43b356c..aa90ac8 100644
--- a/ui/port/src/main/java/androidx/ui/gestures2/DragGestureRecognizer2.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures2/DragGestureRecognizer2.kt
@@ -27,7 +27,7 @@
fun onDragStop() {}
fun onDragCancelled() {}
fun canDrag(direction: Direction) = false
- fun drag(dx: Double, dy: Double) = Offset(dx, dy)
+ fun drag(dx: Float, dy: Float) = Offset(dx, dy)
}
class DragGestureRecognizer2(
@@ -104,17 +104,17 @@
private fun dragAndConsume(
pointerEvent2: PointerEvent2,
- dx: Double,
- dy: Double
+ dx: Float,
+ dy: Float
): PointerEvent2 {
val (consumedDx, consumedDY) = callback.drag(dx, dy)
return pointerEvent2.consumePositionChange(consumedDx, consumedDY)
}
- private fun clampToZero(clampToZero: Boolean, value: Double) =
+ private fun clampToZero(clampToZero: Boolean, value: Float) =
if (clampToZero) 0.0 else value
- private fun clampToAbsLimit(limit: Double, value: Double): Double {
+ private fun clampToAbsLimit(limit: Float, value: Float): Float {
val absLimit = Math.abs(limit)
val absValue = Math.abs(value)
diff --git a/ui/port/src/main/java/androidx/ui/gestures2/PointerEvent2.kt b/ui/port/src/main/java/androidx/ui/gestures2/PointerEvent2.kt
index 1d7080e..202c6a0 100644
--- a/ui/port/src/main/java/androidx/ui/gestures2/PointerEvent2.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures2/PointerEvent2.kt
@@ -46,7 +46,7 @@
val offset =
if (previousPosition == null || currentPosition == null) {
- Offset(0.0, 0.0)
+ Offset(0.0f, 0.0f)
} else {
previousPosition - currentPosition
}
@@ -65,14 +65,14 @@
// Consumption querying functions
fun PointerEvent2.anyPositionChangeConsumed() =
- consumed.positionChange.dx != 0.0 || consumed.positionChange.dy != 0.0
+ consumed.positionChange.dx != 0.0f || consumed.positionChange.dy != 0.0f
// Consume functions
fun PointerEvent2.consumeDownChange() =
copy(consumed = this.consumed.copy(downChange = true))
-fun PointerEvent2.consumePositionChange(consumedDx: Double, consumedDy: Double): PointerEvent2 {
+fun PointerEvent2.consumePositionChange(consumedDx: Float, consumedDy: Float): PointerEvent2 {
val newConsumedDx = consumedDx + consumed.positionChange.dx
val newConsumedDy = consumedDy + consumed.positionChange.dy
// TODO(shepshapard): Handle error if over consumed
@@ -109,6 +109,6 @@
}
data class ConsumedData(
- val positionChange: Offset = Offset(0.0, 0.0),
+ val positionChange: Offset = Offset(0.0f, 0.0f),
val downChange: Boolean = false
)
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/gestures2/ScaleGestureRecognizer2.kt b/ui/port/src/main/java/androidx/ui/gestures2/ScaleGestureRecognizer2.kt
index dfbcd42..21c5a90 100644
--- a/ui/port/src/main/java/androidx/ui/gestures2/ScaleGestureRecognizer2.kt
+++ b/ui/port/src/main/java/androidx/ui/gestures2/ScaleGestureRecognizer2.kt
@@ -18,6 +18,7 @@
import androidx.ui.engine.geometry.Offset
import kotlin.math.absoluteValue
+import kotlin.math.hypot
enum class ScaleDirection {
EXPAND_X, CONTRACT_X, EXPAND_Y, CONTRACT_Y
@@ -28,7 +29,7 @@
fun onScaleStop() {}
fun onCanScale(direction: ScaleDirection) = false
fun onAveragePointMove(offset: Offset) = Offset.zero
- fun onScaleRatio(ratio: Double) = 0.0
+ fun onScaleRatio(ratio: Float) = 0.0f
}
class ScaleGestureRecognizer2(
@@ -37,11 +38,11 @@
private val callback: ScaleGestureRecognizerCallback
) : GestureRecognizer2 {
- var accumulatedAverageSpanDiff = 0.0
+ var accumulatedAverageSpanDiff = 0.0f
var passedSlop = false
var points = HashMap<Int, Offset>()
var averagePoint = Offset.zero
- var averageSpan = 0.0
+ var averageSpan = 0.0f
override fun handleEvent(event: PointerEvent2, pass: PointerEventPass): PointerEvent2 {
var pointerEvent = event
@@ -104,8 +105,8 @@
}
private fun averageOffset(offsets: Map<Int, Offset>, toIgnore: Int? = null): Offset {
- var totalX = 0.0
- var totalY = 0.0
+ var totalX = 0.0f
+ var totalY = 0.0f
offsets.forEach {
if (it.key != toIgnore) {
totalX += it.value.dx
@@ -122,10 +123,10 @@
offsets: Map<Int, Offset>,
focalPoint: Offset,
toIgnore: Int? = null
- ): Double {
+ ): Float {
// Determine average deviation from focal point
- var devSumX = 0.0
- var devSumY = 0.0
+ var devSumX = 0.0f
+ var devSumY = 0.0f
offsets.forEach {
if (it.key != toIgnore) {
// Convert the resulting diameter into a radius.
@@ -142,6 +143,6 @@
// the focal point.
val spanX = devX * 2
val spanY = devY * 2
- return Math.hypot(spanX, spanY)
+ return hypot(spanX, spanY)
}
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/material/InkRipple.kt b/ui/port/src/main/java/androidx/ui/material/InkRipple.kt
index 053a6b0..06c019e0 100644
--- a/ui/port/src/main/java/androidx/ui/material/InkRipple.kt
+++ b/ui/port/src/main/java/androidx/ui/material/InkRipple.kt
@@ -45,7 +45,7 @@
internal val CancelDuration = Duration.create(milliseconds = 75)
// The fade out begins 225ms after the _fadeOutController starts. See confirm().
-private val FadeOutIntervalStart = 225.0 / 375.0
+private val FadeOutIntervalStart = 225.0f / 375.0f
internal fun getRippleClipCallback(
referenceBox: RenderBox,
@@ -64,11 +64,11 @@
internal fun getRippleTargetRadius(
referenceBox: RenderBox,
rectCallback: RectCallback?
-): Double {
+): Float {
val size = rectCallback?.invoke()?.getSize() ?: referenceBox.size
val d1 = size.bottomRight(Offset.zero).getDistance()
val d2 = (size.topRight(Offset.zero) - size.bottomLeft(Offset.zero)).getDistance()
- return Math.max(d1, d2) / 2.0
+ return Math.max(d1, d2) / 2.0f
}
private class InkRippleFactory : InteractiveInkFeatureFactory() {
@@ -81,7 +81,7 @@
containedInkWell: Boolean,
rectCallback: RectCallback?,
borderRadius: BorderRadius?,
- radius: Double?,
+ radius: Float?,
onRemoved: VoidCallback?
): InteractiveInkFeature {
return InkRipple(
@@ -146,17 +146,17 @@
containedInkWell: Boolean = false,
rectCallback: RectCallback? = null,
borderRadius: BorderRadius? = null,
- radiusParam: Double? = null,
+ radiusParam: Float? = null,
onRemoved: VoidCallback? = null
) : InteractiveInkFeature(controller, referenceBox, color, onRemoved) {
private val borderRadius: BorderRadius = borderRadius ?: BorderRadius.Zero
- private val targetRadius: Double =
+ private val targetRadius: Float =
radiusParam ?: getRippleTargetRadius(referenceBox, rectCallback)
private val clipCallback: RectCallback? =
getRippleClipCallback(referenceBox, containedInkWell, rectCallback)
- private val radius: Animation<Double>
+ private val radius: Animation<Float>
private val radiusController: AnimationController
private val fadeIn: Animation<Int>
@@ -192,8 +192,8 @@
// Initial splash diameter is 60% of the target diameter, final
// diameter is 10dps larger than the target diameter.
radius = Tween(
- begin = targetRadius * 0.30,
- end = targetRadius + 5.0
+ begin = targetRadius * 0.30f,
+ end = targetRadius + 5.0f
).animate(
CurvedAnimation(
parent = radiusController,
@@ -217,7 +217,7 @@
).animate(
CurvedAnimation(
parent = fadeOutController,
- curve = Interval(FadeOutIntervalStart, 1.0)
+ curve = Interval(FadeOutIntervalStart, 1.0f)
)
)
@@ -229,7 +229,7 @@
radiusController.forward()
// This confirm may have been preceded by a cancel.
fadeInController.forward()
- fadeOutController.animateTo(1.0, duration = FadeOutDuration)
+ fadeOutController.animateTo(1.0f, duration = FadeOutDuration)
}
override fun cancel() {
@@ -237,10 +237,10 @@
// Watch out: setting _fadeOutController's value to 1.0 will
// trigger a call to _handleAlphaStatusChanged() which will
// dispose _fadeOutController.
- val fadeOutValue = 1.0 - fadeInController.value
+ val fadeOutValue = 1.0f - fadeInController.value
fadeOutController.value = fadeOutValue
- if (fadeOutValue < 1.0) {
- fadeOutController.animateTo(1.0, duration = CancelDuration)
+ if (fadeOutValue < 1.0f) {
+ fadeOutController.animateTo(1.0f, duration = CancelDuration)
}
}
diff --git a/ui/port/src/main/java/androidx/ui/material/InkSplash.kt b/ui/port/src/main/java/androidx/ui/material/InkSplash.kt
index bf3e114..f69de4d 100644
--- a/ui/port/src/main/java/androidx/ui/material/InkSplash.kt
+++ b/ui/port/src/main/java/androidx/ui/material/InkSplash.kt
@@ -43,8 +43,8 @@
internal val UnconfirmedSplashDuration = Duration.create(seconds = 1)
internal val SplashFadeDuration = Duration.create(milliseconds = 200)
-internal val SplashInitialSize = 0.0; // logical pixels
-internal val SplashConfirmedVelocity = 1.0; // logical pixels per millisecond
+internal val SplashInitialSize = 0.0f; // logical pixels
+internal val SplashConfirmedVelocity = 1.0f; // logical pixels per millisecond
internal fun getSplashClipCallback(
referenceBox: RenderBox,
@@ -65,7 +65,7 @@
containedInkWell: Boolean,
rectCallback: RectCallback?,
position: Offset
-): Double {
+): Float {
if (containedInkWell) {
val size = rectCallback?.invoke()?.getSize() ?: referenceBox.size
return getSplashRadiusForPositionInSize(size, position)
@@ -73,7 +73,7 @@
return DefaultSplashRadius
}
-private fun getSplashRadiusForPositionInSize(bounds: Size, position: Offset): Double {
+private fun getSplashRadiusForPositionInSize(bounds: Size, position: Offset): Float {
val d1 = (position - bounds.topLeft(Offset.zero)).getDistance()
val d2 = (position - bounds.topRight(Offset.zero)).getDistance()
val d3 = (position - bounds.bottomLeft(Offset.zero)).getDistance()
@@ -91,7 +91,7 @@
containedInkWell: Boolean,
rectCallback: RectCallback?,
borderRadius: BorderRadius?,
- radius: Double?,
+ radius: Float?,
onRemoved: VoidCallback?
): InteractiveInkFeature {
return InkSplash(
@@ -154,19 +154,19 @@
containedInkWell: Boolean = false,
rectCallback: RectCallback? = null,
borderRadius: BorderRadius? = null,
- radiusParam: Double? = null,
+ radiusParam: Float? = null,
onRemoved: VoidCallback? = null
// private val shape: BoxShape = BoxShape.RECTANGLE,
) : InteractiveInkFeature(controller, referenceBox, color, onRemoved) {
private val borderRadius: BorderRadius = borderRadius ?: BorderRadius.Zero
- private val targetRadius: Double =
+ private val targetRadius: Float =
radiusParam ?: getSplashTargetRadius(referenceBox, containedInkWell, rectCallback, position)
private val clipCallback: RectCallback? =
getSplashClipCallback(referenceBox, containedInkWell, rectCallback)
private val repositionToReferenceBox: Boolean = !containedInkWell
- private val radius: Animation<Double>
+ private val radius: Animation<Float>
private val radiusController: AnimationController
private val alpha: Animation<Int>
diff --git a/ui/port/src/main/java/androidx/ui/material/InkWell.kt b/ui/port/src/main/java/androidx/ui/material/InkWell.kt
index 33579cd..fad7b11 100644
--- a/ui/port/src/main/java/androidx/ui/material/InkWell.kt
+++ b/ui/port/src/main/java/androidx/ui/material/InkWell.kt
@@ -124,7 +124,7 @@
containedInkWell: Boolean = false,
rectCallback: RectCallback? = null,
borderRadius: BorderRadius? = null,
- radius: Double? = null,
+ radius: Float? = null,
onRemoved: VoidCallback? = null
): InteractiveInkFeature
}
@@ -288,7 +288,7 @@
* * [splashColor], the color of the splash.
* * [splashFactory], which defines the appearance of the splash.
*/
- val radius: Double? = null,
+ val radius: Float? = null,
/**
* The clipping radius of the containing rect.
*
@@ -664,7 +664,7 @@
highlightColor: Color? = null,
splashColor: Color? = null,
splashFactory: InteractiveInkFeatureFactory? = null,
- radius: Double? = null,
+ radius: Float? = null,
borderRadius: BorderRadius? = null,
enableFeedback: Boolean = true,
excludeFromSemantics: Boolean = false
diff --git a/ui/port/src/main/java/androidx/ui/material/material/Material.kt b/ui/port/src/main/java/androidx/ui/material/material/Material.kt
index ae4ce30..97f3f8f 100644
--- a/ui/port/src/main/java/androidx/ui/material/material/Material.kt
+++ b/ui/port/src/main/java/androidx/ui/material/material/Material.kt
@@ -31,7 +31,7 @@
import androidx.ui.foundation.Key
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
import androidx.ui.foundation.diagnostics.DiagnosticsProperty
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.foundation.diagnostics.EnumProperty
import androidx.ui.painting.Canvas
import androidx.ui.painting.Color
@@ -118,15 +118,15 @@
*/
val MaterialEdges = mapOf(
MaterialType.CANVAS to null,
- MaterialType.CARD to BorderRadius.circular(2.0),
+ MaterialType.CARD to BorderRadius.circular(2.0f),
MaterialType.CIRCLE to null,
- MaterialType.BUTTON to BorderRadius.circular(2.0),
+ MaterialType.BUTTON to BorderRadius.circular(2.0f),
MaterialType.TRANSPARENCY to null
)
/** The default radius of an ink splash in logical pixels. */
// TODO("Migration|Andrey: Defined in dps, but will actually be drawn as pixels! Solve it!")
-const val DefaultSplashRadius: Double = 35.0
+const val DefaultSplashRadius: Float = 35.0f
/**
* An interface for creating [InkSplash]s and [InkHighlight]s on a material.
@@ -255,7 +255,7 @@
* Defaults to 0. Changing this value will cause the shadow to animate over
* [animationDuration].
*/
- val elevation: Double = 0.0,
+ val elevation: Float = 0.0f,
/**
* The color to paint the material.
*
@@ -318,7 +318,7 @@
override fun debugFillProperties(properties: DiagnosticPropertiesBuilder) {
super.debugFillProperties(properties)
properties.add(EnumProperty("type", type))
- properties.add(DoubleProperty.create("elevation", elevation, defaultValue = 0.0))
+ properties.add(FloatProperty.create("elevation", elevation, defaultValue = 0.0f))
properties.add(DiagnosticsProperty.create("color", color, defaultValue = null))
properties.add(
DiagnosticsProperty.create(
@@ -526,7 +526,7 @@
*/
val shape: ShapeBorder,
/** The target z-coordinate at which to place this physical object. */
- val elevation: Double,
+ val elevation: Float,
/** The target background color. */
val color: Color,
/** The target shadow color. */
@@ -540,7 +540,7 @@
override fun debugFillProperties(properties: DiagnosticPropertiesBuilder) {
super.debugFillProperties(properties)
properties.add(DiagnosticsProperty.create("shape", shape))
- properties.add(DoubleProperty.create("elevation", elevation))
+ properties.add(FloatProperty.create("elevation", elevation))
properties.add(DiagnosticsProperty.create("color", color))
properties.add(DiagnosticsProperty.create("shadowColor", shadowColor))
}
@@ -549,12 +549,12 @@
class MaterialInteriorState(widget: MaterialInterior) :
AnimatedWidgetBaseState<MaterialInterior>(widget) {
- private var elevation: Tween<Double>? = null
+ private var elevation: Tween<Float>? = null
private var shadowColor: Tween<Color>? = null
private var border: Tween<ShapeBorder>? = null
override fun forEachTween(visitor: TweenVisitor) {
- elevation = visitor(elevation, widget.elevation) { value: Double -> Tween(begin = value) }
+ elevation = visitor(elevation, widget.elevation) { value: Float -> Tween(begin = value) }
shadowColor =
visitor(shadowColor, widget.shadowColor) { value: Color -> Tween(begin = value) }
border = visitor(border, widget.shape) { value: ShapeBorder -> Tween(begin = value) }
diff --git a/ui/port/src/main/java/androidx/ui/painting/BoxFit.kt b/ui/port/src/main/java/androidx/ui/painting/BoxFit.kt
index 14d4998..61dcc77d 100644
--- a/ui/port/src/main/java/androidx/ui/painting/BoxFit.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/BoxFit.kt
@@ -139,8 +139,8 @@
* provide access to [paintImage] at the widgets layer.
*/
fun applyBoxFit(fit: BoxFit, inputSize: Size, outputSize: Size): FittedSizes {
- if (inputSize.height <= 0.0 || inputSize.width <= 0.0 ||
- outputSize.height <= 0.0 || outputSize.width <= 0.0)
+ if (inputSize.height <= 0.0f || inputSize.width <= 0.0f ||
+ outputSize.height <= 0.0f || outputSize.width <= 0.0f)
return FittedSizes(Size.zero, Size.zero)
val sourceSize: Size
diff --git a/ui/port/src/main/java/androidx/ui/painting/Canvas.kt b/ui/port/src/main/java/androidx/ui/painting/Canvas.kt
index 58c2771..d948ef3 100644
--- a/ui/port/src/main/java/androidx/ui/painting/Canvas.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/Canvas.kt
@@ -10,6 +10,7 @@
import androidx.ui.painting.matrixutils.isIdentity
import androidx.ui.skia.SkMatrix
import androidx.ui.vectormath64.Matrix4
+import androidx.ui.vectormath64.degrees
// TODO(Migration/njawad): Copy the class here
/**
@@ -201,10 +202,10 @@
TODO("Migration/njawad framework does not have quivalent for saveLayerWithoutBounds")
} else {
internalCanvas.saveLayer(
- bounds.left.toFloat(),
- bounds.top.toFloat(),
- bounds.right.toFloat(),
- bounds.bottom.toFloat(),
+ bounds.left,
+ bounds.top,
+ bounds.right,
+ bounds.bottom,
paint.toFrameworkPaint(),
android.graphics.Canvas.ALL_SAVE_FLAG
)
@@ -248,8 +249,8 @@
* Add a translation to the current transform, shifting the coordinate space
* horizontally by the first argument and vertically by the second argument.
*/
- fun translate(dx: Double, dy: Double) {
- internalCanvas.translate(dx.toFloat(), dy.toFloat())
+ fun translate(dx: Float, dy: Float) {
+ internalCanvas.translate(dx, dy)
}
/**
@@ -260,13 +261,13 @@
* If [sy] is unspecified, [sx] will be used for the scale in both
* directions.
*/
- fun scale(sx: Double, sy: Double = sx) {
- internalCanvas.scale(sx.toFloat(), sy.toFloat())
+ fun scale(sx: Float, sy: Float = sx) {
+ internalCanvas.scale(sx, sy)
}
/** Add a rotation to the current transform. The argument is in radians clockwise. */
- fun rotate(radians: Double) {
- internalCanvas.rotate(Math.toDegrees(radians).toFloat())
+ fun rotate(radians: Float) {
+ internalCanvas.rotate(degrees(radians))
}
/**
@@ -275,8 +276,8 @@
* second argument being the vertical skew in radians clockwise around the
* origin.
*/
- fun skew(sx: Double, sy: Double) {
- internalCanvas.skew(sx.toFloat(), sy.toFloat())
+ fun skew(sx: Float, sy: Float) {
+ internalCanvas.skew(sx, sy)
}
/**
@@ -363,10 +364,10 @@
*/
fun drawLine(p1: Offset, p2: Offset, paint: Paint) {
internalCanvas.drawLine(
- p1.dx.toFloat(),
- p1.dy.toFloat(),
- p2.dx.toFloat(),
- p2.dy.toFloat(),
+ p1.dx,
+ p1.dy,
+ p2.dx,
+ p2.dy,
paint.toFrameworkPaint()
)
}
@@ -438,11 +439,11 @@
* the third argument. Whether the circle is filled or stroked (or both) is
* controlled by [Paint.style].
*/
- fun drawCircle(c: Offset, radius: Double, paint: Paint) {
+ fun drawCircle(c: Offset, radius: Float, paint: Paint) {
internalCanvas.drawCircle(
- c.dx.toFloat(),
- c.dy.toFloat(),
- radius.toFloat(),
+ c.dx,
+ c.dy,
+ radius,
paint.toFrameworkPaint()
)
}
@@ -461,16 +462,16 @@
*/
fun drawArc(
rect: Rect,
- startAngle: Double,
- sweepAngle: Double,
+ startAngle: Float,
+ sweepAngle: Float,
useCenter: Boolean,
paint: Paint
) {
internalRectF.set(rect.toFrameworkRect())
internalCanvas.drawArc(
internalRectF,
- Math.toDegrees(startAngle).toFloat(),
- Math.toDegrees(sweepAngle).toFloat(),
+ degrees(startAngle),
+ degrees(sweepAngle),
useCenter,
paint.toFrameworkPaint()
)
@@ -492,8 +493,8 @@
fun drawImage(image: Image, p: Offset, paint: Paint) {
internalCanvas.drawBitmap(
image.bitmap,
- p.dx.toFloat(),
- p.dy.toFloat(),
+ p.dx,
+ p.dy,
paint.toFrameworkPaint()
)
}
@@ -631,8 +632,8 @@
private fun drawPoints(points: List<Offset>, paint: Paint) {
for (point in points) {
- internalCanvas.drawPoint(point.dx.toFloat(),
- point.dy.toFloat(),
+ internalCanvas.drawPoint(point.dx,
+ point.dy,
paint.toFrameworkPaint())
}
}
@@ -655,10 +656,10 @@
val p1 = points[i]
val p2 = points[i + 1]
internalCanvas.drawLine(
- p1.dx.toFloat(),
- p1.dy.toFloat(),
- p2.dx.toFloat(),
- p2.dy.toFloat(),
+ p1.dx,
+ p1.dy,
+ p2.dx,
+ p2.dy,
paint.toFrameworkPaint()
)
}
@@ -883,4 +884,4 @@
// int color,
// double elevation,
// bool transparentOccluder) native 'Canvas_drawShadow';
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/painting/Color.kt b/ui/port/src/main/java/androidx/ui/painting/Color.kt
index 5ad399b..e133f24 100644
--- a/ui/port/src/main/java/androidx/ui/painting/Color.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/Color.kt
@@ -19,6 +19,7 @@
import androidx.ui.clamp
import androidx.ui.toRadixString
import androidx.ui.truncDiv
+import kotlin.math.pow
import kotlin.math.roundToInt
/**
@@ -112,17 +113,17 @@
* * `r` is [red], from 0 to 255.
* * `g` is [green], from 0 to 255.
* * `b` is [blue], from 0 to 255.
- * * `opacity` is alpha channel of this color as a double, with 0.0 being
+ * * `opacity` is alpha channel of this color as a Float, with 0.0 being
* transparent and 1.0 being fully opaque.
*
* Out of range values are brought into range using modulo 255.
*
* See also [fromARGB], which takes the opacity as an integer value.
*/
- fun fromRGBO(r: Int, g: Int, b: Int, opacity: Double): Color {
+ fun fromRGBO(r: Int, g: Int, b: Int, opacity: Float): Color {
return Color(
(
- ((((opacity * 0xff.toDouble()).truncDiv(1.toDouble())) and 0xff) shl 24) or
+ ((((opacity * 0xff.toFloat()).truncDiv(1f)) and 0xff) shl 24) or
((r and 0xff) shl 16) or
((g and 0xff) shl 8) or
((b and 0xff) shl 0)
@@ -130,10 +131,10 @@
}
// See <https://www.w3.org/TR/WCAG20/#relativeluminancedef>
- fun _linearizeColorComponent(component: Double): Double {
- if (component <= 0.03928)
- return component / 12.92
- return Math.pow((component + 0.055) / 1.055, 2.4)
+ fun _linearizeColorComponent(component: Float): Float {
+ if (component <= 0.03928f)
+ return component / 12.92f
+ return ((component + 0.055f) / 1.055f).pow(2.4f)
}
/**
@@ -157,17 +158,17 @@
* easily be generated by curves such as [Curves.elasticInOut]). Each channel
* will be clamped to the range 0 to 255.
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
- fun lerp(a: Color?, b: Color?, t: Double?): Color? {
+ fun lerp(a: Color?, b: Color?, t: Float?): Color? {
assert(t != null)
if (a == null && b == null)
return null
if (a == null)
return _scaleAlpha(b!!, t!!)
if (b == null)
- return _scaleAlpha(a, 1.0 - t!!)
+ return _scaleAlpha(a, 1.0f - t!!)
return blend(a, b, t!!.toFloat())
}
@@ -184,12 +185,12 @@
var endB = (endColor.blue and 0xff) / 255.0f
// convert from sRGB to linear
- startR = Math.pow(startR.toDouble(), 2.2).toFloat()
- startG = Math.pow(startG.toDouble(), 2.2).toFloat()
- startB = Math.pow(startB.toDouble(), 2.2).toFloat()
- endR = Math.pow(endR.toDouble(), 2.2).toFloat()
- endG = Math.pow(endG.toDouble(), 2.2).toFloat()
- endB = Math.pow(endB.toDouble(), 2.2).toFloat()
+ startR = startR.pow(2.2f)
+ startG = startG.pow(2.2f)
+ startB = startB.pow(2.2f)
+ endR = endR.pow(2.2f)
+ endG = endG.pow(2.2f)
+ endB = endB.pow(2.2f)
// compute the interpolated color in linear space
var a = startA + fraction * (endA - startA)
@@ -199,9 +200,9 @@
// convert back to sRGB in the [0..255] range
a *= 255f
- r = (Math.pow(r.toDouble(), 1.0 / 2.2) * 255.0f).toFloat()
- g = (Math.pow(g.toDouble(), 1.0 / 2.2) * 255.0f).toFloat()
- b = (Math.pow(b.toDouble(), 1.0 / 2.2) * 255.0f).toFloat()
+ r = r.pow(1.0f / 2.2f) * 255.0f
+ g = g.pow(1.0f / 2.2f) * 255.0f
+ b = b.pow(1.0f / 2.2f) * 255.0f
return Color.fromARGB(Math.round(a), Math.round(r), Math.round(g), Math.round(b))
}
@@ -253,12 +254,12 @@
val alpha get() = (0xff000000.toInt() and value) ushr 24
/**
- * The alpha channel of this color as a double.
+ * The alpha channel of this color as a Float.
*
* A value of 0.0 means this color is fully transparent. A value of 1.0 means
* this color is fully opaque.
*/
- val opacity: Double = alpha.toDouble() / 0xFF.toDouble()
+ val opacity: Float = alpha.toFloat() / 0xFF.toFloat()
/** The red channel of this color in an 8 bit value. */
val red = (0x00ff0000 and value) shr 16
@@ -285,8 +286,8 @@
*
* Out of range values will have unexpected effects.
*/
- fun withOpacity(opacity: Double): Color {
- assert(opacity >= 0.0 && opacity <= 1.0)
+ fun withOpacity(opacity: Float): Color {
+ assert(opacity >= 0.0f && opacity <= 1.0f)
return withAlpha((255.0 * opacity).roundToInt())
}
@@ -328,12 +329,12 @@
*
* See <https://en.wikipedia.org/wiki/Relative_luminance>.
*/
- fun computeLuminance(): Double {
+ fun computeLuminance(): Float {
// See <https://www.w3.org/TR/WCAG20/#relativeluminancedef>
- val R = _linearizeColorComponent(red / 0xFF.toDouble())
- val G = _linearizeColorComponent(green / 0xFF.toDouble())
- val B = _linearizeColorComponent(blue / 0xFF.toDouble())
- return 0.2126 * R + 0.7152 * G + 0.0722 * B
+ val R = _linearizeColorComponent(red / 0xFF.toFloat())
+ val G = _linearizeColorComponent(green / 0xFF.toFloat())
+ val B = _linearizeColorComponent(blue / 0xFF.toFloat())
+ return 0.2126f * R + 0.7152f * G + 0.0722f * B
}
// Autogenerated by AS
@@ -356,6 +357,6 @@
override fun toString() = "Color(0x${value.toRadixString(16).padStart(8, '0')})"
}
-fun _scaleAlpha(a: Color, factor: Double): Color {
+fun _scaleAlpha(a: Color, factor: Float): Color {
return a.withAlpha((a.alpha * factor).roundToInt().clamp(0, 255))
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/painting/DecorationImage.kt b/ui/port/src/main/java/androidx/ui/painting/DecorationImage.kt
index 567cd3a..48c82b6 100644
--- a/ui/port/src/main/java/androidx/ui/painting/DecorationImage.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/DecorationImage.kt
@@ -112,7 +112,7 @@
if (rect.isEmpty())
return
var outputSize = rect.getSize()
- var inputSize = Size(image.width.toDouble(), image.height.toDouble())
+ var inputSize = Size(image.width.toFloat(), image.height.toFloat())
val sliceBorder: Offset?
if (centerSlice != null) {
sliceBorder = Offset(
@@ -154,8 +154,8 @@
// to nearest-neighbor.
paint.filterQuality = FilterQuality.low
}
- val halfWidthDelta = (outputSize.width - destinationSize.width) / 2.0
- val halfHeightDelta = (outputSize.height - destinationSize.height) / 2.0
+ val halfWidthDelta = (outputSize.width - destinationSize.width) / 2.0f
+ val halfHeightDelta = (outputSize.height - destinationSize.height) / 2.0f
val dx = halfWidthDelta + (if (flipHorizontally) -alignment.x else alignment.x) * halfWidthDelta
val dy = halfHeightDelta + alignment.y * halfHeightDelta
val destinationPosition = rect.getTopLeft().translate(dx, dy)
@@ -166,10 +166,10 @@
if (resolvedRepeat != ImageRepeat.noRepeat)
canvas.clipRect(rect)
if (flipHorizontally) {
- val dx2 = -(rect.left + rect.width / 2.0)
- canvas.translate(-dx2, 0.0)
- canvas.scale(-1.0, 1.0)
- canvas.translate(dx2, 0.0)
+ val dx2 = -(rect.left + rect.width / 2.0f)
+ canvas.translate(-dx2, 0.0f)
+ canvas.scale(-1.0f, 1.0f)
+ canvas.translate(dx2, 0.0f)
}
if (centerSlice == null) {
val sourceRect = alignment.inscribe(fittedSizes.source, Offset.zero.and(inputSize))
diff --git a/ui/port/src/main/java/androidx/ui/painting/Gradient.kt b/ui/port/src/main/java/androidx/ui/painting/Gradient.kt
index f7ed1e7..ec8fdaf 100644
--- a/ui/port/src/main/java/androidx/ui/painting/Gradient.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/Gradient.kt
@@ -18,6 +18,7 @@
import androidx.ui.engine.geometry.Offset
import androidx.ui.vectormath64.Matrix4
+import androidx.ui.vectormath64.PI
// A shader (as used by [Paint.shader]) that renders a color gradient.
//
@@ -52,15 +53,15 @@
from: Offset,
to: Offset,
colors: List<Color>,
- colorStops: List<Double>? = null,
+ colorStops: List<Float>? = null,
tileMode: TileMode = TileMode.clamp
): Gradient {
_validateColorStops(colors, colorStops)
val linearGradient = android.graphics.LinearGradient(
- from.dx.toFloat(),
- from.dy.toFloat(),
- to.dx.toFloat(),
- to.dy.toFloat(),
+ from.dx,
+ from.dy,
+ to.dx,
+ to.dy,
toIntArray(colors),
toFloatArray(colorStops),
toFrameworkTileMode(tileMode)
@@ -104,23 +105,23 @@
@SuppressWarnings("SyntheticAccessor")
fun radial(
center: Offset,
- radius: Double,
+ radius: Float,
color: List<Color>,
- colorStops: List<Double>?,
+ colorStops: List<Float>?,
tileMode: TileMode = TileMode.clamp,
matrix4: Matrix4,
focal: Offset?,
- focalRadius: Double
+ focalRadius: Float
): Gradient {
_validateColorStops(color, colorStops)
- if (focal == null || (focal == center && focalRadius == 0.0)) {
+ if (focal == null || (focal == center && focalRadius == 0.0f)) {
TODO("Migration/njawad: add focal support to RadialGradient in framework")
} else {
// TODO(Migration/njawad use matrix parameter in creation of RadialGradient)
val radial = android.graphics.RadialGradient(
- center.dx.toFloat(),
- center.dy.toFloat(),
- radius.toFloat(),
+ center.dx,
+ center.dy,
+ radius,
toIntArray(color),
toFloatArray(colorStops),
toFrameworkTileMode(tileMode)
@@ -163,18 +164,18 @@
fun sweep(
center: Offset,
colors: List<Color>,
- colorStops: List<Double>,
+ colorStops: List<Float>,
tileMode: TileMode = TileMode.clamp,
- startAngle: Double,
- endAngle: Double = Math.PI * 2,
+ startAngle: Float,
+ endAngle: Float = PI * 2,
matrix4: Matrix4
): Gradient {
_validateColorStops(colors, colorStops)
// TODO(Migration/njawad framework SweepGradient does not support angle ranges/TileModes)
val sweep = android.graphics.SweepGradient(
- center.dx.toFloat(), center.dy.toFloat(),
- toIntArray(colors),
- toFloatArray(colorStops)
+ center.dx, center.dy,
+ toIntArray(colors),
+ toFloatArray(colorStops)
)
return Gradient(sweep)
}
@@ -187,10 +188,10 @@
}
}
- private fun toFloatArray(stops: List<Double>?): FloatArray? {
+ private fun toFloatArray(stops: List<Float>?): FloatArray? {
return if (stops != null) {
- FloatArray(stops.size) {
- i -> stops[i].toFloat()
+ FloatArray(stops.size) { i ->
+ stops[i]
}
} else {
return null
@@ -203,7 +204,7 @@
}
}
- private fun _validateColorStops(colors: List<Color>, colorStops: List<Double>?) {
+ private fun _validateColorStops(colors: List<Color>, colorStops: List<Float>?) {
if (colorStops == null && colors.size != 2) {
throw IllegalArgumentException("colors must have length 2 if colorStops " +
"is omitted.")
@@ -217,4 +218,4 @@
internal override fun toFrameworkShader(): android.graphics.Shader {
return shader
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/painting/MaskFilter.kt b/ui/port/src/main/java/androidx/ui/painting/MaskFilter.kt
index afcb691..d407816 100644
--- a/ui/port/src/main/java/androidx/ui/painting/MaskFilter.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/MaskFilter.kt
@@ -22,7 +22,7 @@
//
// Instances of this class are used with [Paint.maskFilter] on [Paint] objects.
// TODO(Migration/njawad: add support for framework's EmbossMaskFilter
-data class MaskFilter(val style: BlurStyle, val sigma: Double) {
+data class MaskFilter(val style: BlurStyle, val sigma: Float) {
// Creates a mask filter that takes the shape being drawn and blurs it.
//
// This is commonly used to approximate shadows.
diff --git a/ui/port/src/main/java/androidx/ui/painting/Paint.kt b/ui/port/src/main/java/androidx/ui/painting/Paint.kt
index 373d9c4..c861cf2 100644
--- a/ui/port/src/main/java/androidx/ui/painting/Paint.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/Paint.kt
@@ -203,10 +203,10 @@
// the direction orthogonal to the direction of the path.
//
// Defaults to 0.0, which correspond to a hairline width.
- var strokeWidth: Double
- get() = internalPaint.strokeWidth.toDouble()
+ var strokeWidth: Float
+ get() = internalPaint.strokeWidth
set(value) {
- internalPaint.strokeWidth = value.toFloat()
+ internalPaint.strokeWidth = value
}
// The kind of finish to place on the end of lines drawn when
@@ -264,10 +264,10 @@
//
// Defaults to 4.0. Using zero as a limit will cause a [StrokeJoin.bevel]
// join to be used all the time.
- var strokeMiterLimit: Double
- get() = internalPaint.strokeMiter.toDouble()
+ var strokeMiterLimit: Float
+ get() = internalPaint.strokeMiter
set(value) {
- internalPaint.strokeMiter = value.toFloat()
+ internalPaint.strokeMiter = value
}
// A mask filter (for example, a blur) to apply to a shape after it has been
@@ -283,7 +283,7 @@
android.graphics.BlurMaskFilter.Blur.INNER -> BlurStyle.inner
}
// sigma is equivalent to roughly half the radius: sigma = radius / 2
- return MaskFilter(style, blurRadius / 2.0)
+ return MaskFilter(style, blurRadius / 2.0f)
}
set(value) {
val blur = when (value.style) {
@@ -295,7 +295,7 @@
// radius is equivalent to roughly twice the sigma: radius = sigma * 2
// TODO(Migration/njawad: Add support for framework EmbossMaskFilter?)
- internalPaint.maskFilter = BlurMaskFilter((value.sigma * 2).toFloat(), blur)
+ internalPaint.maskFilter = BlurMaskFilter((value.sigma * 2), blur)
}
// Controls the performance vs quality trade-off to use when applying
diff --git a/ui/port/src/main/java/androidx/ui/painting/Path.kt b/ui/port/src/main/java/androidx/ui/painting/Path.kt
index acd8413..7e2819e 100644
--- a/ui/port/src/main/java/androidx/ui/painting/Path.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/Path.kt
@@ -62,29 +62,29 @@
}
/** Starts a new subpath at the given coordinate. */
- fun moveTo(dx: Double, dy: Double) {
- internalPath.moveTo(dx.toFloat(), dy.toFloat())
+ fun moveTo(dx: Float, dy: Float) {
+ internalPath.moveTo(dx, dy)
}
/** Starts a new subpath at the given offset from the current point. */
- fun relativeMoveTo(dx: Double, dy: Double) {
- internalPath.rMoveTo(dx.toFloat(), dy.toFloat())
+ fun relativeMoveTo(dx: Float, dy: Float) {
+ internalPath.rMoveTo(dx, dy)
}
/**
* Adds a straight line segment from the current point to the given
* point.
*/
- fun lineTo(dx: Double, dy: Double) {
- internalPath.lineTo(dx.toFloat(), dy.toFloat())
+ fun lineTo(dx: Float, dy: Float) {
+ internalPath.lineTo(dx, dy)
}
/**
* Adds a straight line segment from the current point to the point
* at the given offset from the current point.
*/
- fun relativeLineTo(dx: Double, dy: Double) {
- internalPath.rLineTo(dx.toFloat(), dy.toFloat())
+ fun relativeLineTo(dx: Float, dy: Float) {
+ internalPath.rLineTo(dx, dy)
}
/**
@@ -92,8 +92,8 @@
* point to the given point (x2,y2), using the control point
* (x1,y1).
*/
- fun quadraticBezierTo(x1: Double, y1: Double, x2: Double, y2: Double) {
- internalPath.quadTo(x1.toFloat(), y1.toFloat(), x2.toFloat(), y2.toFloat())
+ fun quadraticBezierTo(x1: Float, y1: Float, x2: Float, y2: Float) {
+ internalPath.quadTo(x1, y1, x2, y2)
}
/**
@@ -102,8 +102,8 @@
* using the control point at the offset (x1,y1) from the current
* point.
*/
- fun relativeQuadraticBezierTo(x1: Double, y1: Double, x2: Double, y2: Double) {
- internalPath.rQuadTo(x1.toFloat(), y1.toFloat(), x2.toFloat(), y2.toFloat())
+ fun relativeQuadraticBezierTo(x1: Float, y1: Float, x2: Float, y2: Float) {
+ internalPath.rQuadTo(x1, y1, x2, y2)
}
/**
@@ -111,11 +111,11 @@
* to the given point (x3,y3), using the control points (x1,y1) and
* (x2,y2).
*/
- fun cubicTo(x1: Double, y1: Double, x2: Double, y2: Double, x3: Double, y3: Double) {
+ fun cubicTo(x1: Float, y1: Float, x2: Float, y2: Float, x3: Float, y3: Float) {
internalPath.cubicTo(
- x1.toFloat(), y1.toFloat(),
- x2.toFloat(), y2.toFloat(),
- x3.toFloat(), y3.toFloat()
+ x1, y1,
+ x2, y2,
+ x3, y3
)
}
@@ -125,11 +125,11 @@
* the control points at the offsets (x1,y1) and (x2,y2) from the
* current point.
*/
- fun relativeCubicTo(x1: Double, y1: Double, x2: Double, y2: Double, x3: Double, y3: Double) {
+ fun relativeCubicTo(x1: Float, y1: Float, x2: Float, y2: Float, x3: Float, y3: Float) {
internalPath.rCubicTo(
- x1.toFloat(), y1.toFloat(),
- x2.toFloat(), y2.toFloat(),
- x3.toFloat(), y3.toFloat()
+ x1, y1,
+ x2, y2,
+ x3, y3
)
}
@@ -140,7 +140,7 @@
* hyperbola; if the weight equals 1, it's a parabola; and if it is
* less than 1, it is an ellipse.
*/
- fun conicTo(x1: Double, y1: Double, x2: Double, y2: Double, w: Double) {
+ fun conicTo(x1: Float, y1: Float, x2: Float, y2: Float, w: Float) {
// TODO(Migration/njawad) figure out how to handle unsupported framework Path operations
throw UnsupportedOperationException("conicTo not supported in framework Path")
}
@@ -153,7 +153,7 @@
* a hyperbola; if the weight equals 1, it's a parabola; and if it
* is less than 1, it is an ellipse.
*/
- fun relativeConicTo(x1: Double, y1: Double, x2: Double, y2: Double, w: Double) {
+ fun relativeConicTo(x1: Float, y1: Float, x2: Float, y2: Float, w: Float) {
// TODO(Migration/njawad) figure out how to handle unsupported framework Path operations
throw UnsupportedOperationException("relativeConicTo not supported in framework Path")
}
@@ -176,17 +176,17 @@
* The line segment added if `forceMoveTo` is false starts at the
* current point and ends at the start of the arc.
*/
- fun arcTo(rect: Rect, startAngle: Double, sweepAngle: Double, forceMoveTo: Boolean) {
- val left = rect.left.toFloat()
- val top = rect.top.toFloat()
- val right = rect.right.toFloat()
- val bottom = rect.bottom.toFloat()
+ fun arcTo(rect: Rect, startAngle: Float, sweepAngle: Float, forceMoveTo: Boolean) {
+ val left = rect.left
+ val top = rect.top
+ val right = rect.right
+ val bottom = rect.bottom
rectF.set(left, top, right, bottom)
internalPath.arcTo(
- rectF,
- startAngle.toFloat(),
- sweepAngle.toFloat(),
- forceMoveTo
+ rectF,
+ startAngle,
+ sweepAngle,
+ forceMoveTo
)
}
@@ -207,7 +207,7 @@
fun arcToPoint(
arcEnd: Offset,
radius: Radius = Radius.zero,
- rotation: Double = 0.0,
+ rotation: Float = 0.0f,
largeArc: Boolean = false,
clockwise: Boolean = true
) {
@@ -216,11 +216,11 @@
}
private fun _arcToPoint(
- arcEndX: Double,
- arcEndY: Double,
- radius: Double,
- radiusY: Double,
- rotation: Double,
+ arcEndX: Float,
+ arcEndY: Float,
+ radius: Float,
+ radiusY: Float,
+ rotation: Float,
largeArc: Boolean,
clockwise: Boolean
) {
@@ -249,7 +249,7 @@
fun relativeArcToPoint(
arcEndDelta: Offset,
radius: Radius = Radius.zero,
- rotation: Double = 0.0,
+ rotation: Float = 0.0f,
largeArc: Boolean = false,
clockwise: Boolean = true
) {
@@ -265,11 +265,11 @@
}
private fun _relativeArcToPoint(
- arcEndX: Double,
- arcEndY: Double,
- radius: Double,
- radiusY: Double,
- rotation: Double,
+ arcEndX: Float,
+ arcEndY: Float,
+ radius: Float,
+ radiusY: Float,
+ rotation: Float,
largeArc: Boolean,
clockwise: Boolean
) {
@@ -292,7 +292,7 @@
}
// Not necessary as wrapping platform Path
- fun _addRect(left: Double, top: Double, right: Double, bottom: Double) {
+ fun _addRect(left: Float, top: Float, right: Float, bottom: Float) {
TODO()
// Flutter calls into native Path logic here
// native 'Path_addRect';
@@ -314,7 +314,7 @@
}
// Not necessary as wrapping platform Path
- private fun _addOval(left: Double, top: Double, right: Double, bottom: Double) {
+ private fun _addOval(left: Float, top: Float, right: Float, bottom: Float) {
TODO()
// Flutter calls into native Path logic here
// native 'Path_addOval';
@@ -330,14 +330,14 @@
* rectangle and with positive angles going clockwise around the
* oval.
*/
- fun addArc(oval: Rect, startAngle: Double, sweepAngle: Double) {
+ fun addArc(oval: Rect, startAngle: Float, sweepAngle: Float) {
assert(_rectIsValid(oval))
rectF.set(oval.toFrameworkRect())
- internalPath.addArc(rectF, startAngle.toFloat(), sweepAngle.toFloat())
+ internalPath.addArc(rectF, startAngle, sweepAngle)
}
// Not necessary as wrapping platform Path
- private fun _addArc(left: Double, top: Double, right: Double, bottom: Double) {
+ private fun _addArc(left: Float, top: Float, right: Float, bottom: Float) {
TODO()
// Flutter calls into native Path logic here
// native 'Path_addArc'
@@ -365,19 +365,18 @@
}
fun addRRect(rrect: RRect) {
- rectF.set(rrect.left.toFloat(), rrect.top.toFloat(), rrect.right.toFloat(),
- rrect.bottom.toFloat())
- radii[0] = rrect.topLeftRadiusX.toFloat()
- radii[1] = rrect.topLeftRadiusY.toFloat()
+ rectF.set(rrect.left, rrect.top, rrect.right, rrect.bottom)
+ radii[0] = rrect.topLeftRadiusX
+ radii[1] = rrect.topLeftRadiusY
- radii[2] = rrect.topRightRadiusX.toFloat()
- radii[3] = rrect.topRightRadiusY.toFloat()
+ radii[2] = rrect.topRightRadiusX
+ radii[3] = rrect.topRightRadiusY
- radii[4] = rrect.bottomRightRadiusX.toFloat()
- radii[5] = rrect.bottomRightRadiusY.toFloat()
+ radii[4] = rrect.bottomRightRadiusX
+ radii[5] = rrect.bottomRightRadiusY
- radii[6] = rrect.bottomLeftRadiusX.toFloat()
- radii[7] = rrect.bottomLeftRadiusY.toFloat()
+ radii[6] = rrect.bottomLeftRadiusX
+ radii[7] = rrect.bottomLeftRadiusY
internalPath.addRoundRect(rectF, radii, android.graphics.Path.Direction.CCW)
}
@@ -403,19 +402,19 @@
TODO("Refactor to convert Matrix4 to framework Matrix when Matrix4 is ported")
// internalPath.addPath(path.toFrameworkPath(), matrix);
} else {
- internalPath.addPath(path.toFrameworkPath(), offset.dx.toFloat(), offset.dy.toFloat())
+ internalPath.addPath(path.toFrameworkPath(), offset.dx, offset.dy)
}
}
// Not necessary as wrapping platform Path
- private fun _addPath(path: Path, dx: Double, dy: Double) {
+ private fun _addPath(path: Path, dx: Float, dy: Float) {
TODO()
// Flutter calls into native Path logic here
// native 'Path_addPath';
}
// Not necessary as wrapping platform Path
- private fun _addPathWithMatrix(path: Path, dx: Double, dy: Double, matrix4: Matrix4) {
+ private fun _addPathWithMatrix(path: Path, dx: Float, dy: Float, matrix4: Matrix4) {
TODO()
// Flutter calls into native Path logic here
// native 'Path_addPathWithMatrix';
@@ -431,14 +430,14 @@
// }
}
- private fun _extendWithPath(path: Path, dx: Double, dy: Double) {
+ private fun _extendWithPath(path: Path, dx: Float, dy: Float) {
// TODO(Migration/njawad: figure out how to handle unsupported framework Path operations)
TODO()
// Flutter calls into native Path logic here
// native 'Path_extendWithPath';
}
- private fun _extendWithPathAndMatrix(path: Path, dx: Double, dy: Double, matrix: Matrix4) {
+ private fun _extendWithPathAndMatrix(path: Path, dx: Float, dy: Float, matrix: Matrix4) {
// TODO(Migration/njawad: figure out how to handle unsupported framework Path operations)
TODO()
// Flutter calls into native Path logic here
@@ -482,9 +481,13 @@
// TODO(Migration/Andrey: temporary non-efficient implementation)
val path = android.graphics.Path()
- path.addRect(offset.dx.toFloat() - 0.01f, offset.dy.toFloat() - 0.01f,
- offset.dx.toFloat() + 0.01f, offset.dy.toFloat() + 0.01f,
- android.graphics.Path.Direction.CW)
+ path.addRect(
+ offset.dx - 0.01f,
+ offset.dy - 0.01f,
+ offset.dx + 0.01f,
+ offset.dy + 0.01f,
+ android.graphics.Path.Direction.CW
+ )
if (path.op(internalPath, android.graphics.Path.Op.INTERSECT)) {
return !path.isEmpty
}
@@ -500,7 +503,7 @@
fun shift(offset: Offset): androidx.ui.painting.Path {
return clone().apply {
mMatrix.reset()
- mMatrix.setTranslate(offset.dx.toFloat(), offset.dy.toFloat())
+ mMatrix.setTranslate(offset.dx, offset.dy)
internalPath.transform(mMatrix)
}
}
@@ -543,10 +546,10 @@
fun getBounds(): Rect {
internalPath.computeBounds(rectF, true)
return Rect(
- rectF.left.toDouble(),
- rectF.top.toDouble(),
- rectF.right.toDouble(),
- rectF.bottom.toDouble()
+ rectF.left,
+ rectF.top,
+ rectF.right,
+ rectF.bottom
)
}
@@ -555,7 +558,7 @@
TODO()
// Flutter calls into native code here
// native 'Path_getBounds';
- return Rect(0.0, 0.0, 0.0, 0.0)
+ return Rect(0.0f, 0.0f, 0.0f, 0.0f)
}
companion object {
@@ -628,16 +631,16 @@
// }
private fun _rectIsValid(rect: Rect): Boolean {
- assert(Double.NaN != rect.left) {
+ assert(Float.NaN != rect.left) {
"Rect.left is NaN"
}
- assert(Double.NaN != rect.top) {
+ assert(Float.NaN != rect.top) {
"Rect.top is NaN"
}
- assert(Double.NaN != rect.right) {
+ assert(Float.NaN != rect.right) {
"Rect.right is NaN"
}
- assert(Double.NaN != rect.bottom) {
+ assert(Float.NaN != rect.bottom) {
"Rect.bottom is NaN"
}
return true
@@ -646,4 +649,4 @@
private fun _matrixIsValid(matrix: Matrix4): Boolean {
return true
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/painting/Picture.kt b/ui/port/src/main/java/androidx/ui/painting/Picture.kt
index 37aea03..f5c55dd 100644
--- a/ui/port/src/main/java/androidx/ui/painting/Picture.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/Picture.kt
@@ -39,9 +39,9 @@
}
fun cullRect(): Rect {
- return Rect(0.0,
- 0.0,
- frameworkPicture.width.toDouble(),
- frameworkPicture.height.toDouble())
+ return Rect(0.0f,
+ 0.0f,
+ frameworkPicture.width.toFloat(),
+ frameworkPicture.height.toFloat())
}
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/painting/TextPainter.kt b/ui/port/src/main/java/androidx/ui/painting/TextPainter.kt
index 22bc600..4f0d6ba 100644
--- a/ui/port/src/main/java/androidx/ui/painting/TextPainter.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/TextPainter.kt
@@ -42,7 +42,7 @@
* fractional pixel values up to the nearest whole pixel value. The right long-term fix is to do
* layout using fixed precision arithmetic.
*/
-fun applyFloatingPointHack(layoutValue: Double): Double {
+fun applyFloatingPointHack(layoutValue: Float): Float {
return ceil(layoutValue)
}
@@ -98,7 +98,7 @@
text: TextSpan? = null,
textAlign: TextAlign = TextAlign.START,
textDirection: TextDirection? = null,
- textScaleFactor: Double = 1.0,
+ textScaleFactor: Float = 1.0f,
maxLines: Int? = null,
// TODO(Migration/qqd): We won't be able to use customized ellipsis, but lets leave it here for
// now. Maybe remove it later.
@@ -139,7 +139,7 @@
needsLayout = true
}
- var textScaleFactor: Double = textScaleFactor
+ var textScaleFactor: Float = textScaleFactor
set(value) {
if (field == value) return
field = value
@@ -210,7 +210,7 @@
* the [preferredLineHeight]. If [text] is null or if it specifies no styles, the default
* [TextStyle] values are used (a 10 pixel sans-serif font).
*/
- val preferredLineHeight: Double
+ val preferredLineHeight: Float
get() {
if (layoutTemplate == null) {
val builder = ParagraphBuilder(
@@ -222,7 +222,7 @@
}
builder.addText(" ")
layoutTemplate = builder.build()
- layoutTemplate?.layout(ParagraphConstraints(width = Double.POSITIVE_INFINITY))
+ layoutTemplate?.layout(ParagraphConstraints(width = Float.POSITIVE_INFINITY))
}
return layoutTemplate!!.height
}
@@ -239,7 +239,7 @@
*
* Valid only after [layout] has been called.
*/
- val minIntrinsicWidth: Double
+ val minIntrinsicWidth: Float
get() {
assertNeedsLayout("minIntrinsicWidth")
return applyFloatingPointHack(paragraph!!.minIntrinsicWidth)
@@ -250,7 +250,7 @@
*
* Valid only after [layout] has been called.
*/
- val maxIntrinsicWidth: Double
+ val maxIntrinsicWidth: Float
get() {
assertNeedsLayout("maxIntrinsicWidth")
return applyFloatingPointHack(paragraph!!.maxIntrinsicWidth)
@@ -261,7 +261,7 @@
*
* Valid only after [layout] has been called.
*/
- val width: Double
+ val width: Float
get() {
assertNeedsLayout("width")
return applyFloatingPointHack(paragraph!!.width)
@@ -272,7 +272,7 @@
*
* Valid only after [layout] has been called.
*/
- val height: Double
+ val height: Float
get() {
assertNeedsLayout("height")
return applyFloatingPointHack(paragraph!!.height)
@@ -294,7 +294,7 @@
*
* Valid only after [layout] has been called.
*/
- fun computeDistanceToActualBaseline(baseline: TextBaseline): Double {
+ fun computeDistanceToActualBaseline(baseline: TextBaseline): Float {
assertNeedsLayout("computeDistanceToActualBaseline")
return when (baseline) {
TextBaseline.alphabetic -> paragraph!!.alphabeticBaseline
@@ -319,8 +319,8 @@
return paragraph!!.didExceedMaxLines
}
- private var lastMinWidth: Double = 0.0
- private var lastMaxWidth: Double = 0.0
+ private var lastMinWidth: Float = 0.0f
+ private var lastMaxWidth: Float = 0.0f
/**
* Computes the visual position of the glyphs for painting the text.
@@ -330,7 +330,7 @@
*
* The [text] and [textDirection] properties must be non-null before this is called.
*/
- fun layout(minWidth: Double = 0.0, maxWidth: Double = Double.POSITIVE_INFINITY) {
+ fun layout(minWidth: Float = 0.0f, maxWidth: Float = Float.POSITIVE_INFINITY) {
assert(text != null) {
"TextPainter.text must be set to a non-null value before using the TextPainter."
}
@@ -437,7 +437,7 @@
}
// TODO(Migration/qqd): Implement _emptyOffset.
- var _emptyOffset: Offset = Offset(0.0, 0.0)
+ var _emptyOffset: Offset = Offset(0.0f, 0.0f)
get() {
TODO()
// assert(!_needsLayout); // implies textDirection is non-null
diff --git a/ui/port/src/main/java/androidx/ui/painting/TextSpan.kt b/ui/port/src/main/java/androidx/ui/painting/TextSpan.kt
index 66678dd..6400770 100644
--- a/ui/port/src/main/java/androidx/ui/painting/TextSpan.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/TextSpan.kt
@@ -65,7 +65,7 @@
* Rather than using this directly, it's simpler to use the [TextPainter] class to paint
* [TextSpan] objects onto [Canvas] objects.
*/
- fun build(builder: ParagraphBuilder, textScaleFactor: Double = 1.0) {
+ fun build(builder: ParagraphBuilder, textScaleFactor: Float = 1.0f) {
val hasStyle: Boolean = style != null
if (hasStyle) {
builder.pushStyle(style!!.getTextStyle(textScaleFactor))
diff --git a/ui/port/src/main/java/androidx/ui/painting/TextStyle.kt b/ui/port/src/main/java/androidx/ui/painting/TextStyle.kt
index 5f4dc54..b59c034 100644
--- a/ui/port/src/main/java/androidx/ui/painting/TextStyle.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/TextStyle.kt
@@ -35,19 +35,19 @@
import androidx.ui.foundation.diagnostics.Diagnosticable
import androidx.ui.foundation.diagnostics.DiagnosticsNode
import androidx.ui.foundation.diagnostics.DiagnosticsProperty
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.foundation.diagnostics.EnumProperty
import androidx.ui.foundation.diagnostics.MessageProperty
import androidx.ui.foundation.diagnostics.StringProperty
import androidx.ui.foundation.diagnostics.describeIdentity
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.painting.basictypes.RenderComparison
import androidx.ui.toStringAsFixed
private const val _kDefaultDebugLabel: String = "unknown"
/** The default font size if none is specified. */
-private const val _defaultFontSize: Double = 14.0
+private const val _defaultFontSize: Float = 14.0f
/**
* An opaque object that determines the size, position, and rendering of text.
@@ -76,14 +76,14 @@
data class TextStyle(
val inherit: Boolean? = true,
val color: Color? = null,
- val fontSize: Double? = null,
+ val fontSize: Float? = null,
val fontWeight: FontWeight? = null,
val fontStyle: FontStyle? = null,
val fontSynthesis: FontSynthesis? = null,
- val letterSpacing: Double? = null,
- val wordSpacing: Double? = null,
+ val letterSpacing: Float? = null,
+ val wordSpacing: Float? = null,
val textBaseline: TextBaseline? = null,
- val height: Double? = null,
+ val height: Float? = null,
val locale: Locale? = null,
// TODO(Migration/haoyuchang): Changed from Paint to Color.
val background: Color? = null,
@@ -129,20 +129,20 @@
decorationColor: Color? = null,
decorationStyle: TextDecorationStyle? = null,
fontFamily: FontFamily? = null,
- fontSizeFactor: Double = 1.0,
- fontSizeDelta: Double = 0.0,
+ fontSizeFactor: Float = 1.0f,
+ fontSizeDelta: Float = 0.0f,
fontWeightDelta: Int = 0,
- letterSpacingFactor: Double = 1.0,
- letterSpacingDelta: Double = 0.0,
- wordSpacingFactor: Double = 1.0,
- wordSpacingDelta: Double = 0.0,
- heightFactor: Double = 1.0,
- heightDelta: Double = 0.0
+ letterSpacingFactor: Float = 1.0f,
+ letterSpacingDelta: Float = 0.0f,
+ wordSpacingFactor: Float = 1.0f,
+ wordSpacingDelta: Float = 0.0f,
+ heightFactor: Float = 1.0f,
+ heightDelta: Float = 0.0f
): TextStyle {
- assert(fontSize != null || (fontSizeFactor == 1.0 && fontSizeDelta == 0.0))
+ assert(fontSize != null || (fontSizeFactor == 1.0f && fontSizeDelta == 0.0f))
assert(fontWeight != null || fontWeightDelta == 0)
- assert(letterSpacing != null || (letterSpacingFactor == 1.0 && letterSpacingDelta == 0.0))
- assert(wordSpacing != null || (wordSpacingFactor == 1.0 && wordSpacingDelta == 0.0))
+ assert(letterSpacing != null || (letterSpacingFactor == 1.0f && letterSpacingDelta == 0.0f))
+ assert(wordSpacing != null || (wordSpacingFactor == 1.0f && wordSpacingDelta == 0.0f))
var modifiedDebugLabel = ""
@@ -241,11 +241,11 @@
* values greater than 1.0 are valid (and can easily be generated by curves such as
* [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as an
+ * Values for `t` are usually obtained from an [Animation<Float>], such as an
* [AnimationController].
*/
companion object {
- fun lerp(a: TextStyle? = null, b: TextStyle? = null, t: Double): TextStyle? {
+ fun lerp(a: TextStyle? = null, b: TextStyle? = null, t: Float): TextStyle? {
val aIsNull = a == null
val bIsNull = b == null
val inheritEqual = a?.inherit == b?.inherit
@@ -346,28 +346,28 @@
// TODO(Migration/qqd): Currently [fontSize], [letterSpacing], [wordSpacing] and
// [height] of textstyles a and b cannot be null if both a and b are not null, because
- // [lerpDouble(Double, Double, Double)] API cannot take null parameters. We could have a
+ // [lerpFloat(Float, Float, Float)] API cannot take null parameters. We could have a
// workaround by using 0.0, but for now let's keep it this way.
return TextStyle(
inherit = b.inherit,
color = Color.lerp(a.color, b.color, t),
fontFamily = if (t < 0.5) a.fontFamily else b.fontFamily,
- fontSize = lerpDouble(a.fontSize ?: b.fontSize!!, b.fontSize ?: a.fontSize!!, t),
+ fontSize = lerpFloat(a.fontSize ?: b.fontSize!!, b.fontSize ?: a.fontSize!!, t),
fontWeight = FontWeight.lerp(a.fontWeight, b.fontWeight, t),
fontStyle = if (t < 0.5) a.fontStyle else b.fontStyle,
fontSynthesis = if (t < 0.5) a.fontSynthesis else b.fontSynthesis,
- letterSpacing = lerpDouble(
+ letterSpacing = lerpFloat(
a.letterSpacing ?: b.letterSpacing!!,
b.letterSpacing ?: a.letterSpacing!!,
t
),
- wordSpacing = lerpDouble(
+ wordSpacing = lerpFloat(
a.wordSpacing ?: b.wordSpacing!!,
b.wordSpacing ?: a.wordSpacing!!,
t
),
textBaseline = if (t < 0.5) a.textBaseline else b.textBaseline,
- height = lerpDouble(a.height ?: b.height!!, b.height ?: a.height!!, t),
+ height = lerpFloat(a.height ?: b.height!!, b.height ?: a.height!!, t),
locale = if (t < 0.5) a.locale else b.locale,
background = if (t < 0.5) a.background else b.background,
decoration = if (t < 0.5) a.decoration else b.decoration,
@@ -379,7 +379,7 @@
}
/** The style information for text runs, encoded for use by ui. */
- fun getTextStyle(textScaleFactor: Double = 1.0): androidx.ui.engine.text.TextStyle {
+ fun getTextStyle(textScaleFactor: Float = 1.0f): androidx.ui.engine.text.TextStyle {
return androidx.ui.engine.text.TextStyle(
color = color,
decoration = decoration,
@@ -411,7 +411,7 @@
fun getParagraphStyle(
textAlign: TextAlign? = null,
textDirection: TextDirection? = null,
- textScaleFactor: Double = 1.0,
+ textScaleFactor: Float = 1.0f,
ellipsis: String? = null,
maxLines: Int? = null,
locale: Locale? = null
@@ -486,7 +486,7 @@
quoted = false
)
)
- styles.add(DoubleProperty.create("size", fontSize, defaultValue = null))
+ styles.add(FloatProperty.create("size", fontSize, defaultValue = null))
var weightDescription = ""
if (fontWeight != null) {
when (fontWeight) {
@@ -514,10 +514,10 @@
)
styles.add(EnumProperty<FontStyle>("style", fontStyle, defaultValue = null))
styles.add(StringProperty("fontSynthesis", fontSynthesis?.toString(), defaultValue = null))
- styles.add(DoubleProperty.create("letterSpacing", letterSpacing, defaultValue = null))
- styles.add(DoubleProperty.create("wordSpacing", wordSpacing, defaultValue = null))
+ styles.add(FloatProperty.create("letterSpacing", letterSpacing, defaultValue = null))
+ styles.add(FloatProperty.create("wordSpacing", wordSpacing, defaultValue = null))
styles.add(EnumProperty<TextBaseline>("baseline", textBaseline, defaultValue = null))
- styles.add(DoubleProperty.create("height", height, unit = "x", defaultValue = null))
+ styles.add(FloatProperty.create("height", height, unit = "x", defaultValue = null))
styles.add(
StringProperty(
"locale",
diff --git a/ui/port/src/main/java/androidx/ui/painting/alignment/Alignment.kt b/ui/port/src/main/java/androidx/ui/painting/alignment/Alignment.kt
index 0f55bef..2b968ea 100644
--- a/ui/port/src/main/java/androidx/ui/painting/alignment/Alignment.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/alignment/Alignment.kt
@@ -3,7 +3,7 @@
import androidx.ui.engine.geometry.Offset
import androidx.ui.engine.geometry.Rect
import androidx.ui.engine.geometry.Size
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.engine.text.TextDirection
import androidx.ui.toStringAsFixed
import androidx.ui.truncDiv
@@ -52,7 +52,7 @@
* and values greater than 1.0 represent positions to the right of the right
* edge.
*/
- val x: Double,
+ val x: Float,
/**
* The distance fraction in the vertical direction.
*
@@ -61,36 +61,36 @@
* values less than -1.0 represent positions above the top, and values
* greater than 1.0 represent positions below the bottom.
*/
- val y: Double
+ val y: Float
) : AlignmentGeometry() {
companion object {
/** The top left corner. */
- val topLeft = Alignment(-1.0, -1.0)
+ val topLeft = Alignment(-1.0f, -1.0f)
/** The center point along the top edge. */
- val topCenter = Alignment(0.0, -1.0)
+ val topCenter = Alignment(0.0f, -1.0f)
/** The top right corner. */
- val topRight = Alignment(1.0, -1.0)
+ val topRight = Alignment(1.0f, -1.0f)
/** The center point along the left edge. */
- val centerLeft = Alignment(-1.0, 0.0)
+ val centerLeft = Alignment(-1.0f, 0.0f)
/** The center point, both horizontally and vertically. */
- val center = Alignment(0.0, 0.0)
+ val center = Alignment(0.0f, 0.0f)
/** The center point along the right edge. */
- val centerRight = Alignment(1.0, 0.0)
+ val centerRight = Alignment(1.0f, 0.0f)
/** The bottom left corner. */
- val bottomLeft = Alignment(-1.0, 1.0)
+ val bottomLeft = Alignment(-1.0f, 1.0f)
/** The center point along the bottom edge. */
- val bottomCenter = Alignment(0.0, 1.0)
+ val bottomCenter = Alignment(0.0f, 1.0f)
/** The bottom right corner. */
- val bottomRight = Alignment(1.0, 1.0)
+ val bottomRight = Alignment(1.0f, 1.0f)
/**
* Linearly interpolate between two [Alignment]s.
@@ -106,48 +106,48 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
- fun lerp(a: Alignment?, b: Alignment?, t: Double): Alignment? {
+ fun lerp(a: Alignment?, b: Alignment?, t: Float): Alignment? {
if (a == null && b == null)
return null
if (a == null)
- return Alignment(lerpDouble(0.0, b!!.x, t), lerpDouble(0.0, b.y, t))
+ return Alignment(lerpFloat(0.0f, b!!.x, t), lerpFloat(0.0f, b.y, t))
if (b == null)
- return Alignment(lerpDouble(a.x, 0.0, t), lerpDouble(a.y, 0.0, t))
- return Alignment(lerpDouble(a.x, b.x, t), lerpDouble(a.y, b.y, t))
+ return Alignment(lerpFloat(a.x, 0.0f, t), lerpFloat(a.y, 0.0f, t))
+ return Alignment(lerpFloat(a.x, b.x, t), lerpFloat(a.y, b.y, t))
}
- internal fun _stringify(x: Double, y: Double): String {
- if (x == -1.0 && y == -1.0)
+ internal fun _stringify(x: Float, y: Float): String {
+ if (x == -1.0f && y == -1.0f)
return "topLeft"
- if (x == 0.0 && y == -1.0)
+ if (x == 0.0f && y == -1.0f)
return "topCenter"
- if (x == 1.0 && y == -1.0)
+ if (x == 1.0f && y == -1.0f)
return "topRight"
- if (x == -1.0 && y == 0.0)
+ if (x == -1.0f && y == 0.0f)
return "centerLeft"
- if (x == 0.0 && y == 0.0)
+ if (x == 0.0f && y == 0.0f)
return "center"
- if (x == 1.0 && y == 0.0)
+ if (x == 1.0f && y == 0.0f)
return "centerRight"
- if (x == -1.0 && y == 1.0)
+ if (x == -1.0f && y == 1.0f)
return "bottomLeft"
- if (x == 0.0 && y == 1.0)
+ if (x == 0.0f && y == 1.0f)
return "bottomCenter"
- if (x == 1.0 && y == 1.0)
+ if (x == 1.0f && y == 1.0f)
return "bottomRight"
return "Alignment(${x.toStringAsFixed(1)}, " +
"${y.toStringAsFixed(1)})"
}
}
- override val _x: Double = x
+ override val _x: Float = x
- override val _start: Double = 0.0
+ override val _start: Float = 0.0f
- override val _y: Double = y
+ override val _y: Float = y
override fun add(other: AlignmentGeometry): AlignmentGeometry {
if (other is Alignment)
@@ -171,43 +171,43 @@
}
/** Scales the [Alignment] in each dimension by the given factor. */
- override operator fun times(other: Double): Alignment {
+ override operator fun times(other: Float): Alignment {
return Alignment(x * other, y * other)
}
/** Divides the [Alignment] in each dimension by the given factor. */
- override operator fun div(other: Double): Alignment {
+ override operator fun div(other: Float): Alignment {
return Alignment(x / other, y / other)
}
/** Integer divides the [Alignment] in each dimension by the given factor. */
- override fun truncDiv(other: Double): Alignment {
- return Alignment(x.truncDiv(other).toDouble(), y.truncDiv(other).toDouble())
+ override fun truncDiv(other: Float): Alignment {
+ return Alignment(x.truncDiv(other).toFloat(), y.truncDiv(other).toFloat())
}
/** Computes the remainder in each dimension by the given factor. */
- override operator fun rem(other: Double): Alignment {
+ override operator fun rem(other: Float): Alignment {
return Alignment(x % other, y % other)
}
/** Returns the offset that is this fraction in the direction of the given offset. */
fun alongOffset(other: Offset): Offset {
- val centerX = other.dx / 2.0
- val centerY = other.dy / 2.0
+ val centerX = other.dx / 2.0f
+ val centerY = other.dy / 2.0f
return Offset(centerX + x * centerX, centerY + y * centerY)
}
/** Returns the offset that is this fraction within the given size. */
fun alongSize(other: Size): Offset {
- val centerX = other.width / 2.0
- val centerY = other.height / 2.0
+ val centerX = other.width / 2.0f
+ val centerY = other.height / 2.0f
return Offset(centerX + x * centerX, centerY + y * centerY)
}
/** Returns the point that is this fraction within the given rect. */
fun withinRect(rect: Rect): Offset {
- val halfWidth = rect.width / 2.0
- val halfHeight = rect.height / 2.0
+ val halfWidth = rect.width / 2.0f
+ val halfHeight = rect.height / 2.0f
return Offset(
rect.left + halfWidth + x * halfWidth,
rect.top + halfHeight + y * halfHeight
@@ -223,8 +223,8 @@
* the 200×200 rect.
*/
fun inscribe(size: Size, rect: Rect): Rect {
- val halfWidthDelta = (rect.width - size.width) / 2.0
- val halfHeightDelta = (rect.height - size.height) / 2.0
+ val halfWidthDelta = (rect.width - size.width) / 2.0f
+ val halfHeightDelta = (rect.height - size.height) / 2.0f
return Rect.fromLTWH(
rect.left + halfWidthDelta + x * halfWidthDelta,
rect.top + halfHeightDelta + y * halfHeightDelta,
diff --git a/ui/port/src/main/java/androidx/ui/painting/alignment/AlignmentDirectional.kt b/ui/port/src/main/java/androidx/ui/painting/alignment/AlignmentDirectional.kt
index 4110c42..58f327f 100644
--- a/ui/port/src/main/java/androidx/ui/painting/alignment/AlignmentDirectional.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/alignment/AlignmentDirectional.kt
@@ -16,7 +16,7 @@
package androidx.ui.painting.alignment
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.engine.text.TextDirection
import androidx.ui.toStringAsFixed
import androidx.ui.truncDiv
@@ -48,7 +48,7 @@
* This value is normalized into a [Alignment.x] value by the [resolve]
* method.
*/
- val start: Double,
+ val start: Float,
/**
* The distance fraction in the vertical direction.
*
@@ -60,19 +60,19 @@
* This value is passed through to [Alignment.y] unmodified by the
* [resolve] method.
*/
- val y: Double
+ val y: Float
) : AlignmentGeometry() {
- override val _x: Double = 0.0
+ override val _x: Float = 0.0f
- override val _start: Double = start
+ override val _start: Float = start
- override val _y: Double = y
+ override val _y: Float = y
companion object {
/** The top corner on the "start" side. */
- val topStart = AlignmentDirectional(-1.0, -1.0)
+ val topStart = AlignmentDirectional(-1.0f, -1.0f)
/**
* The center point along the top edge.
@@ -80,13 +80,13 @@
* Consider using [Alignment.topCenter] instead, as it does not need
* to be [resolve]d to be used.
*/
- val topCenter = AlignmentDirectional(0.0, -1.0)
+ val topCenter = AlignmentDirectional(0.0f, -1.0f)
/** The top corner on the "end" side. */
- val topEnd = AlignmentDirectional(1.0, -1.0)
+ val topEnd = AlignmentDirectional(1.0f, -1.0f)
/** The center point along the "start" edge. */
- val centerStart = AlignmentDirectional(-1.0, 0.0)
+ val centerStart = AlignmentDirectional(-1.0f, 0.0f)
/**
* The center point, both horizontally and vertically.
@@ -94,13 +94,13 @@
* Consider using [Alignment.center] instead, as it does not need to
* be [resolve]d to be used.
*/
- val center = AlignmentDirectional(0.0, 0.0)
+ val center = AlignmentDirectional(0.0f, 0.0f)
/** The center point along the "end" edge. */
- val centerEnd = AlignmentDirectional(1.0, 0.0)
+ val centerEnd = AlignmentDirectional(1.0f, 0.0f)
/** The bottom corner on the "start" side. */
- val bottomStart = AlignmentDirectional(-1.0, 1.0)
+ val bottomStart = AlignmentDirectional(-1.0f, 1.0f)
/**
* The center point along the bottom edge.
@@ -108,10 +108,10 @@
* Consider using [Alignment.bottomCenter] instead, as it does not
* need to be [resolve]d to be used.
*/
- val bottomCenter = AlignmentDirectional(0.0, 1.0)
+ val bottomCenter = AlignmentDirectional(0.0f, 1.0f)
/** The bottom corner on the "end" side. */
- val bottomEnd = AlignmentDirectional(1.0, 1.0)
+ val bottomEnd = AlignmentDirectional(1.0f, 1.0f)
/**
* Linearly interpolate between two [AlignmentDirectional]s.
@@ -127,41 +127,41 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
fun lerp(
a: AlignmentDirectional?,
b: AlignmentDirectional?,
- t: Double
+ t: Float
): AlignmentDirectional? {
if (a == null && b == null)
return null
if (a == null)
- return AlignmentDirectional(lerpDouble(0.0, b!!.start, t), lerpDouble(0.0, b.y, t))
+ return AlignmentDirectional(lerpFloat(0.0f, b!!.start, t), lerpFloat(0.0f, b.y, t))
if (b == null)
- return AlignmentDirectional(lerpDouble(a.start, 0.0, t), lerpDouble(a.y, 0.0, t))
- return AlignmentDirectional(lerpDouble(a.start, b.start, t), lerpDouble(a.y, b.y, t))
+ return AlignmentDirectional(lerpFloat(a.start, 0.0f, t), lerpFloat(a.y, 0.0f, t))
+ return AlignmentDirectional(lerpFloat(a.start, b.start, t), lerpFloat(a.y, b.y, t))
}
- fun _stringify(start: Double, y: Double): String {
- if (start == -1.0 && y == -1.0)
+ fun _stringify(start: Float, y: Float): String {
+ if (start == -1.0f && y == -1.0f)
return "AlignmentDirectional.topStart"
- if (start == 0.0 && y == -1.0)
+ if (start == 0.0f && y == -1.0f)
return "AlignmentDirectional.topCenter"
- if (start == 1.0 && y == -1.0)
+ if (start == 1.0f && y == -1.0f)
return "AlignmentDirectional.topEnd"
- if (start == -1.0 && y == 0.0)
+ if (start == -1.0f && y == 0.0f)
return "AlignmentDirectional.centerStart"
- if (start == 0.0 && y == 0.0)
+ if (start == 0.0f && y == 0.0f)
return "AlignmentDirectional.center"
- if (start == 1.0 && y == 0.0)
+ if (start == 1.0f && y == 0.0f)
return "AlignmentDirectional.centerEnd"
- if (start == -1.0 && y == 1.0)
+ if (start == -1.0f && y == 1.0f)
return "AlignmentDirectional.bottomStart"
- if (start == 0.0 && y == 1.0)
+ if (start == 0.0f && y == 1.0f)
return "AlignmentDirectional.bottomCenter"
- if (start == 1.0 && y == 1.0)
+ if (start == 1.0f && y == 1.0f)
return "AlignmentDirectional.bottomEnd"
return "AlignmentDirectional(${start.toStringAsFixed(1)}, " +
"${y.toStringAsFixed(1)})"
@@ -190,24 +190,24 @@
}
/** Scales the [AlignmentDirectional] in each dimension by the given factor. */
- override operator fun times(other: Double): AlignmentGeometry {
+ override operator fun times(other: Float): AlignmentGeometry {
return AlignmentDirectional(start * other, y * other)
}
/** Divides the [AlignmentDirectional] in each dimension by the given factor. */
- override operator fun div(other: Double): AlignmentGeometry {
+ override operator fun div(other: Float): AlignmentGeometry {
return AlignmentDirectional(start / other, y / other)
}
/** Integer divides the [AlignmentDirectional] in each dimension by the given factor. */
- override fun truncDiv(other: Double): AlignmentGeometry {
+ override fun truncDiv(other: Float): AlignmentGeometry {
return AlignmentDirectional(
- (start.truncDiv(other)).toDouble(),
- (y.truncDiv(other)).toDouble())
+ (start.truncDiv(other)).toFloat(),
+ (y.truncDiv(other)).toFloat())
}
/** Computes the remainder in each dimension by the given factor. */
- override operator fun rem(other: Double): AlignmentGeometry {
+ override operator fun rem(other: Float): AlignmentGeometry {
return AlignmentDirectional(start % other, y % other)
}
@@ -221,4 +221,4 @@
}
override fun toString() = _stringify(start, y)
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/painting/alignment/AlignmentGeometry.kt b/ui/port/src/main/java/androidx/ui/painting/alignment/AlignmentGeometry.kt
index e4111fb..3ed9c64 100644
--- a/ui/port/src/main/java/androidx/ui/painting/alignment/AlignmentGeometry.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/alignment/AlignmentGeometry.kt
@@ -16,7 +16,7 @@
package androidx.ui.painting.alignment
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.engine.text.TextDirection
/**
@@ -31,11 +31,11 @@
*/
abstract class AlignmentGeometry {
- abstract val _x: Double
+ abstract val _x: Float
- abstract val _start: Double
+ abstract val _start: Float
- abstract val _y: Double
+ abstract val _y: Float
/**
* Returns the sum of two [AlignmentGeometry] objects.
@@ -72,28 +72,28 @@
*
* This operator returns an object of the same type as the operand.
*/
- abstract operator fun times(other: Double): AlignmentGeometry
+ abstract operator fun times(other: Float): AlignmentGeometry
/**
* Divides the [AlignmentGeometry] object in each dimension by the given factor.
*
* This operator returns an object of the same type as the operand.
*/
- abstract operator fun div(other: Double): AlignmentGeometry
+ abstract operator fun div(other: Float): AlignmentGeometry
/**
* Integer divides the [AlignmentGeometry] object in each dimension by the given factor.
*
* This operator returns an object of the same type as the operand.
*/
- abstract fun truncDiv(other: Double): AlignmentGeometry
+ abstract fun truncDiv(other: Float): AlignmentGeometry
/**
* Computes the remainder in each dimension by the given factor.
*
* This operator returns an object of the same type as the operand.
*/
- abstract operator fun rem(other: Double): AlignmentGeometry
+ abstract operator fun rem(other: Float): AlignmentGeometry
companion object {
/**
@@ -108,33 +108,33 @@
* representing a combination of both is returned. That object can be turned
* into a concrete [Alignment] using [resolve].
*
- * The `t` argument represents position on the timeline, with 0.0 meaning
+ * The `t` argument represents position on the timeline, with 0.0f meaning
* that the interpolation has not started, returning `a` (or something
* equivalent to `a`), 1.0 meaning that the interpolation has finished,
* returning `b` (or something equivalent to `b`), and values in between
* meaning that the interpolation is at the relevant point on the timeline
- * between `a` and `b`. The interpolation can be extrapolated beyond 0.0 and
+ * between `a` and `b`. The interpolation can be extrapolated beyond 0.0f and
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
- fun lerp(a: AlignmentGeometry?, b: AlignmentGeometry?, t: Double): AlignmentGeometry? {
+ fun lerp(a: AlignmentGeometry?, b: AlignmentGeometry?, t: Float): AlignmentGeometry? {
if (a == null && b == null)
return null
if (a == null)
return b !! * t
if (b == null)
- return a * (1.0 - t)
+ return a * (1.0f - t)
if (a is Alignment && b is Alignment)
return Alignment.lerp(a, b, t)
if (a is AlignmentDirectional && b is AlignmentDirectional)
return AlignmentDirectional.lerp(a, b, t)
return _MixedAlignment(
- lerpDouble(a._x, b._x, t),
- lerpDouble(a._start, b._start, t),
- lerpDouble(a._y, b._y, t)
+ lerpFloat(a._x, b._x, t),
+ lerpFloat(a._start, b._start, t),
+ lerpFloat(a._y, b._y, t)
)
}
}
@@ -153,11 +153,11 @@
abstract fun resolve(direction: TextDirection?): Alignment
override fun toString(): String {
- if (_start == 0.0)
+ if (_start == 0.0f)
return Alignment._stringify(_x, _y)
- if (_x == 0.0)
+ if (_x == 0.0f)
return AlignmentDirectional._stringify(_start, _y)
- return Alignment._stringify(_x, _y) + " + " + AlignmentDirectional._stringify(_start, 0.0)
+ return Alignment._stringify(_x, _y) + " + " + AlignmentDirectional._stringify(_start, 0.0f)
}
// Auto-generated by Android Studio
diff --git a/ui/port/src/main/java/androidx/ui/painting/alignment/_MixedAlignment.kt b/ui/port/src/main/java/androidx/ui/painting/alignment/_MixedAlignment.kt
index c4bf56b..c8500af 100644
--- a/ui/port/src/main/java/androidx/ui/painting/alignment/_MixedAlignment.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/alignment/_MixedAlignment.kt
@@ -19,7 +19,7 @@
import androidx.ui.engine.text.TextDirection
import androidx.ui.truncDiv
-class _MixedAlignment(x: Double, start: Double, y: Double) : AlignmentGeometry() {
+class _MixedAlignment(x: Float, start: Float, y: Float) : AlignmentGeometry() {
override val _x = x
@@ -35,7 +35,7 @@
)
}
- override operator fun times(other: Double): _MixedAlignment {
+ override operator fun times(other: Float): _MixedAlignment {
return _MixedAlignment(
_x * other,
_start * other,
@@ -43,7 +43,7 @@
)
}
- override operator fun div(other: Double): _MixedAlignment {
+ override operator fun div(other: Float): _MixedAlignment {
return _MixedAlignment(
_x / other,
_start / other,
@@ -51,15 +51,15 @@
)
}
- override fun truncDiv(other: Double): _MixedAlignment {
+ override fun truncDiv(other: Float): _MixedAlignment {
return _MixedAlignment(
- (_x.truncDiv(other)).toDouble(),
- (_start.truncDiv(other)).toDouble(),
- (_y.truncDiv(other)).toDouble()
+ (_x.truncDiv(other)).toFloat(),
+ (_start.truncDiv(other)).toFloat(),
+ (_y.truncDiv(other)).toFloat()
)
}
- override operator fun rem(other: Double): _MixedAlignment {
+ override operator fun rem(other: Float): _MixedAlignment {
return _MixedAlignment(
_x % other,
_start % other,
diff --git a/ui/port/src/main/java/androidx/ui/painting/borderradius/BorderRadius.kt b/ui/port/src/main/java/androidx/ui/painting/borderradius/BorderRadius.kt
index 53261e2..e5bc2e6 100644
--- a/ui/port/src/main/java/androidx/ui/painting/borderradius/BorderRadius.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/borderradius/BorderRadius.kt
@@ -102,7 +102,7 @@
}
/** Scales each corner of the [BorderRadius] by the given factor. */
- override operator fun times(other: Double) = BorderRadius(
+ override operator fun times(other: Float) = BorderRadius(
topLeft = this.topLeft * other,
topRight = this.topRight * other,
bottomLeft = this.bottomLeft * other,
@@ -110,7 +110,7 @@
)
/** Divides each corner of the [BorderRadius] by the given factor. */
- override operator fun div(other: Double): BorderRadius {
+ override operator fun div(other: Float): BorderRadius {
return BorderRadius(
topLeft = this.topLeft / other,
topRight = this.topRight / other,
@@ -120,7 +120,7 @@
}
/** Integer divides each corner of the [BorderRadius] by the given factor. */
- override fun truncDiv(other: Double): BorderRadiusGeometry {
+ override fun truncDiv(other: Float): BorderRadiusGeometry {
return BorderRadius(
topLeft = topLeft.truncDiv(other),
topRight = topRight.truncDiv(other),
@@ -130,7 +130,7 @@
}
/** Computes the remainder of each corner by the given factor. */
- override operator fun rem(other: Double) = BorderRadius(
+ override operator fun rem(other: Float) = BorderRadius(
topLeft = this.topLeft % other,
topRight = this.topRight % other,
bottomLeft = this.bottomLeft % other,
@@ -155,7 +155,7 @@
)
/** Creates a border radius where all radii are [Radius.circular(radius)]. */
- fun circular(radius: Double) = all(
+ fun circular(radius: Float) = all(
Radius.circular(radius)
)
@@ -207,16 +207,16 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
-fun lerp(a: BorderRadius?, b: BorderRadius?, t: Double): BorderRadius? {
+fun lerp(a: BorderRadius?, b: BorderRadius?, t: Float): BorderRadius? {
if (a == null && b == null)
return null
if (a == null)
return b!! * t
if (b == null)
- return a * (1.0 - t)
+ return a * (1.0f - t)
return BorderRadius(
topLeft = lerp(a.topLeft, b.topLeft, t)!!,
topRight = lerp(a.topRight, b.topRight, t)!!,
diff --git a/ui/port/src/main/java/androidx/ui/painting/borderradius/BorderRadiusGeometry.kt b/ui/port/src/main/java/androidx/ui/painting/borderradius/BorderRadiusGeometry.kt
index 604e148..f50be07 100644
--- a/ui/port/src/main/java/androidx/ui/painting/borderradius/BorderRadiusGeometry.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/borderradius/BorderRadiusGeometry.kt
@@ -112,14 +112,14 @@
*
* This operator returns an object of the same type as the operand.
*/
- abstract operator fun times(other: Double): BorderRadiusGeometry
+ abstract operator fun times(other: Float): BorderRadiusGeometry
/**
* Divides the [BorderRadiusGeometry] object's corners by the given factor.
*
* This operator returns an object of the same type as the operand.
*/
- abstract operator fun div(other: Double): BorderRadiusGeometry
+ abstract operator fun div(other: Float): BorderRadiusGeometry
/**
* Integer divides the [BorderRadiusGeometry] object's corners by the given factor.
@@ -129,7 +129,7 @@
* This operator may have unexpected results when applied to a mixture of
* [BorderRadius] and [BorderRadiusDirectional] objects.
*/
- abstract fun truncDiv(other: Double): BorderRadiusGeometry
+ abstract fun truncDiv(other: Float): BorderRadiusGeometry
/**
* Computes the remainder of each corner by the given factor.
@@ -139,7 +139,7 @@
* This operator may have unexpected results when applied to a mixture of
* [BorderRadius] and [BorderRadiusDirectional] objects.
*/
- abstract operator fun rem(other: Double): BorderRadiusGeometry
+ abstract operator fun rem(other: Float): BorderRadiusGeometry
/**
* Convert this instance into a [BorderRadius], so that the radii are
@@ -300,10 +300,10 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
-fun lerp(a: BorderRadiusGeometry?, b: BorderRadiusGeometry?, t: Double): BorderRadiusGeometry? {
+fun lerp(a: BorderRadiusGeometry?, b: BorderRadiusGeometry?, t: Float): BorderRadiusGeometry? {
if (a == null && b == null)
return null
val a = a ?: BorderRadius.Zero
diff --git a/ui/port/src/main/java/androidx/ui/painting/borderradius/MixedBorderRadius.kt b/ui/port/src/main/java/androidx/ui/painting/borderradius/MixedBorderRadius.kt
index 0637d61..fbeed73 100644
--- a/ui/port/src/main/java/androidx/ui/painting/borderradius/MixedBorderRadius.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/borderradius/MixedBorderRadius.kt
@@ -44,7 +44,7 @@
}
/** Scales each corner of the [MixedBorderRadius] by the given factor. */
- override fun times(other: Double): MixedBorderRadius {
+ override fun times(other: Float): MixedBorderRadius {
return MixedBorderRadius(
topLeft * other,
topRight * other,
@@ -57,7 +57,7 @@
)
}
- override fun div(other: Double): MixedBorderRadius {
+ override fun div(other: Float): MixedBorderRadius {
return MixedBorderRadius(
topLeft / other,
topRight / other,
@@ -70,7 +70,7 @@
)
}
- override fun truncDiv(other: Double): MixedBorderRadius {
+ override fun truncDiv(other: Float): MixedBorderRadius {
return MixedBorderRadius(
topLeft.truncDiv(other),
topRight.truncDiv(other),
@@ -83,7 +83,7 @@
)
}
- override fun rem(other: Double): MixedBorderRadius {
+ override fun rem(other: Float): MixedBorderRadius {
return MixedBorderRadius(
topLeft % other,
topRight % other,
diff --git a/ui/port/src/main/java/androidx/ui/painting/borders/BorderSide.kt b/ui/port/src/main/java/androidx/ui/painting/borders/BorderSide.kt
index 0c7082f..025bed1 100644
--- a/ui/port/src/main/java/androidx/ui/painting/borders/BorderSide.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/borders/BorderSide.kt
@@ -16,12 +16,13 @@
package androidx.ui.painting.borders
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.painting.Color
import androidx.ui.painting.Paint
import androidx.ui.painting.PaintingStyle
import androidx.ui.runtimeType
import androidx.ui.toStringAsFixed
+import kotlin.math.max
/** The style of line to draw for a [BorderSide] in a [Border]. */
enum class BorderStyle {
@@ -78,7 +79,7 @@
* zero-width border is a hairline border. To omit the border
* entirely, set the [style] to [BorderStyle.NONE].
*/
- val width: Double = 1.0,
+ val width: Float = 1.0f,
/**
* The style of this side of the border.
*
@@ -108,14 +109,14 @@
* border at all, the zero factor is special-cased to instead change the
* style no [BorderStyle.NONE].
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
- fun scale(t: Double): BorderSide {
+ fun scale(t: Float): BorderSide {
return BorderSide(
color = color,
- width = Math.max(0.0, width * t),
- style = if (t <= 0.0) BorderStyle.NONE else style
+ width = max(0.0f, width * t),
+ style = if (t <= 0.0f) BorderStyle.NONE else style
)
}
@@ -136,7 +137,7 @@
}
BorderStyle.NONE -> Paint().apply {
color = Color(0x00000000)
- strokeWidth = 0.0
+ strokeWidth = 0.0f
style = PaintingStyle.stroke
}
}
@@ -148,7 +149,7 @@
/** A hairline black border that is not rendered. */
@JvmStatic
- val None = BorderSide(width = 0.0, style = BorderStyle.NONE)
+ val None = BorderSide(width = 0.0f, style = BorderStyle.NONE)
}
}
@@ -167,8 +168,8 @@
*/
fun merge(a: BorderSide, b: BorderSide): BorderSide {
assert(canMerge(a, b))
- val aIsNone = a.style == BorderStyle.NONE && a.width == 0.0
- val bIsNone = b.style == BorderStyle.NONE && b.width == 0.0
+ val aIsNone = a.style == BorderStyle.NONE && a.width == 0.0f
+ val bIsNone = b.style == BorderStyle.NONE && b.width == 0.0f
if (aIsNone && bIsNone)
return BorderSide.None
if (aIsNone)
@@ -192,8 +193,8 @@
* [BorderStyle.NONE], or if they both have the same color and style.
*/
fun canMerge(a: BorderSide, b: BorderSide): Boolean {
- if ((a.style == BorderStyle.NONE && a.width == 0.0) ||
- (b.style == BorderStyle.NONE && b.width == 0.0)
+ if ((a.style == BorderStyle.NONE && a.width == 0.0f) ||
+ (b.style == BorderStyle.NONE && b.width == 0.0f)
)
return true
return a.style == b.style &&
@@ -214,16 +215,16 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
-fun lerp(a: BorderSide, b: BorderSide, t: Double): BorderSide {
- if (t == 0.0)
+fun lerp(a: BorderSide, b: BorderSide, t: Float): BorderSide {
+ if (t == 0.0f)
return a
- if (t == 1.0)
+ if (t == 1.0f)
return b
- val width = lerpDouble(a.width, b.width, t)
- if (width < 0.0)
+ val width = lerpFloat(a.width, b.width, t)
+ if (width < 0.0f)
return BorderSide.None
if (a.style == b.style) {
return BorderSide(
diff --git a/ui/port/src/main/java/androidx/ui/painting/borders/CircleBorder.kt b/ui/port/src/main/java/androidx/ui/painting/borders/CircleBorder.kt
index 7e15d8b..50a3d06 100644
--- a/ui/port/src/main/java/androidx/ui/painting/borders/CircleBorder.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/borders/CircleBorder.kt
@@ -20,6 +20,7 @@
import androidx.ui.engine.text.TextDirection
import androidx.ui.painting.Canvas
import androidx.ui.painting.Path
+import kotlin.math.max
/**
* A border that fits a circle within the available space.
@@ -47,15 +48,15 @@
// return new EdgeInsets.all(side.width);
// }
- override fun scale(t: Double) = CircleBorder(side = side.scale(t))
+ override fun scale(t: Float) = CircleBorder(side = side.scale(t))
- override fun lerpFrom(a: ShapeBorder?, t: Double): ShapeBorder? {
+ override fun lerpFrom(a: ShapeBorder?, t: Float): ShapeBorder? {
if (a is CircleBorder)
return CircleBorder(side = lerp(a.side, side, t))
return super.lerpFrom(a, t)
}
- override fun lerpTo(b: ShapeBorder?, t: Double): ShapeBorder? {
+ override fun lerpTo(b: ShapeBorder?, t: Float): ShapeBorder? {
if (b is CircleBorder)
return CircleBorder(side = lerp(side, b.side, t))
return super.lerpTo(b, t)
@@ -66,7 +67,7 @@
addOval(
Rect.fromCircle(
center = rect.getCenter(),
- radius = Math.max(0.0, rect.getShortestSide() / 2.0 - side.width)
+ radius = max(0.0f, rect.getShortestSide() / 2.0f - side.width)
)
)
}
@@ -77,7 +78,7 @@
addOval(
Rect.fromCircle(
center = rect.getCenter(),
- radius = rect.getShortestSide() / 2.0
+ radius = rect.getShortestSide() / 2.0f
)
)
}
@@ -90,7 +91,7 @@
BorderStyle.SOLID ->
canvas.drawCircle(
rect.getCenter(),
- (rect.getShortestSide() - side.width) / 2.0,
+ (rect.getShortestSide() - side.width) / 2.0f,
side.toPaint()
)
}
diff --git a/ui/port/src/main/java/androidx/ui/painting/borders/RoundedRectangleBorder.kt b/ui/port/src/main/java/androidx/ui/painting/borders/RoundedRectangleBorder.kt
index f7cb10a..ac500b2 100644
--- a/ui/port/src/main/java/androidx/ui/painting/borders/RoundedRectangleBorder.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/borders/RoundedRectangleBorder.kt
@@ -19,7 +19,7 @@
import androidx.ui.engine.geometry.Rect
import androidx.ui.engine.geometry.shrink
import androidx.ui.engine.text.TextDirection
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.painting.Canvas
import androidx.ui.painting.Paint
import androidx.ui.painting.Path
@@ -54,14 +54,14 @@
// return new EdgeInsets.all(side.width);
// }
- override fun scale(t: Double): ShapeBorder {
+ override fun scale(t: Float): ShapeBorder {
return RoundedRectangleBorder(
side = side.scale(t),
borderRadius = borderRadius * t
)
}
- override fun lerpFrom(a: ShapeBorder?, t: Double): ShapeBorder? {
+ override fun lerpFrom(a: ShapeBorder?, t: Float): ShapeBorder? {
if (a is RoundedRectangleBorder) {
return RoundedRectangleBorder(
side = lerp(a.side, side, t),
@@ -72,13 +72,13 @@
return RoundedRectangleToCircleBorder(
side = lerp(a.side, side, t),
borderRadius = borderRadius,
- circleness = 1.0 - t
+ circleness = 1.0f - t
)
}
return super.lerpFrom(a, t)
}
- override fun lerpTo(b: ShapeBorder?, t: Double): ShapeBorder? {
+ override fun lerpTo(b: ShapeBorder?, t: Float): ShapeBorder? {
if (b is RoundedRectangleBorder) {
return RoundedRectangleBorder(
side = lerp(side, b.side, t),
@@ -113,7 +113,7 @@
}
BorderStyle.SOLID -> {
val width = side.width
- if (width == 0.0) {
+ if (width == 0.0f) {
canvas.drawRRect(
borderRadius.resolve(textDirection).toRRect(rect),
side.toPaint()
@@ -132,7 +132,7 @@
}
private data class RoundedRectangleToCircleBorder(
- val circleness: Double,
+ val circleness: Float,
val side: BorderSide = BorderSide.None,
val borderRadius: BorderRadius = BorderRadius.Zero
) : ShapeBorder() {
@@ -143,7 +143,7 @@
// return new EdgeInsets.all(side.width);
// }
- override fun scale(t: Double): ShapeBorder {
+ override fun scale(t: Float): ShapeBorder {
return RoundedRectangleToCircleBorder(
circleness = t,
side = side.scale(t),
@@ -151,7 +151,7 @@
)
}
- override fun lerpFrom(a: ShapeBorder?, t: Double): ShapeBorder? {
+ override fun lerpFrom(a: ShapeBorder?, t: Float): ShapeBorder? {
if (a is RoundedRectangleBorder) {
return RoundedRectangleToCircleBorder(
side = lerp(a.side, side, t),
@@ -163,49 +163,49 @@
return RoundedRectangleToCircleBorder(
side = lerp(a.side, side, t),
borderRadius = borderRadius,
- circleness = circleness + (1.0 - circleness) * (1.0 - t)
+ circleness = circleness + (1.0f - circleness) * (1.0f - t)
)
}
if (a is RoundedRectangleToCircleBorder) {
return RoundedRectangleToCircleBorder(
side = lerp(a.side, side, t),
borderRadius = lerp(a.borderRadius, borderRadius, t)!!,
- circleness = lerpDouble(a.circleness, circleness, t)
+ circleness = lerpFloat(a.circleness, circleness, t)
)
}
return super.lerpFrom(a, t)
}
- override fun lerpTo(b: ShapeBorder?, t: Double): ShapeBorder? {
+ override fun lerpTo(b: ShapeBorder?, t: Float): ShapeBorder? {
if (b is RoundedRectangleBorder) {
return RoundedRectangleToCircleBorder(
side = lerp(side, b.side, t),
borderRadius = lerp(borderRadius, b.borderRadius, t)!!,
- circleness = circleness * (1.0 - t)
+ circleness = circleness * (1.0f - t)
)
}
if (b is CircleBorder) {
return RoundedRectangleToCircleBorder(
side = lerp(side, b.side, t),
borderRadius = borderRadius,
- circleness = circleness + (1.0 - circleness) * t
+ circleness = circleness + (1.0f - circleness) * t
)
}
if (b is RoundedRectangleToCircleBorder) {
return RoundedRectangleToCircleBorder(
side = lerp(side, b.side, t),
borderRadius = lerp(borderRadius, b.borderRadius, t)!!,
- circleness = lerpDouble(circleness, b.circleness, t)
+ circleness = lerpFloat(circleness, b.circleness, t)
)
}
return super.lerpTo(b, t)
}
private fun adjustRect(rect: Rect): Rect {
- if (circleness == 0.0 || rect.width == rect.height)
+ if (circleness == 0.0f || rect.width == rect.height)
return rect
if (rect.width < rect.height) {
- val delta = circleness * (rect.height - rect.width) / 2.0
+ val delta = circleness * (rect.height - rect.width) / 2.0f
return Rect.fromLTRB(
rect.left,
rect.top + delta,
@@ -213,7 +213,7 @@
rect.bottom - delta
)
} else {
- val delta = circleness * (rect.width - rect.height) / 2.0
+ val delta = circleness * (rect.width - rect.height) / 2.0f
return Rect.fromLTRB(
rect.left + delta,
rect.top,
@@ -224,11 +224,11 @@
}
private fun adjustBorderRadius(rect: Rect): BorderRadius {
- if (circleness == 0.0)
+ if (circleness == 0.0f)
return borderRadius
return lerp(
borderRadius,
- BorderRadius.circular(rect.getShortestSide() / 2.0),
+ BorderRadius.circular(rect.getShortestSide() / 2.0f),
circleness
)!!
}
@@ -251,7 +251,7 @@
}
BorderStyle.SOLID -> {
val width = side.width
- if (width == 0.0) {
+ if (width == 0.0f) {
canvas.drawRRect(
adjustBorderRadius(rect).toRRect(adjustRect(rect)),
side.toPaint()
diff --git a/ui/port/src/main/java/androidx/ui/painting/borders/ShapeBorder.kt b/ui/port/src/main/java/androidx/ui/painting/borders/ShapeBorder.kt
index ac39011..87ca4de 100644
--- a/ui/port/src/main/java/androidx/ui/painting/borders/ShapeBorder.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/borders/ShapeBorder.kt
@@ -91,7 +91,7 @@
* (they correspond to extrapolating the interpolation from this object to
* nothing, and going beyond nothing)
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*
* See also:
@@ -99,7 +99,7 @@
* * [BorderSide.scale], which most [ShapeBorder] subclasses defer to for
* the actual computation.
*/
- abstract fun scale(t: Double): ShapeBorder
+ abstract fun scale(t: Float): ShapeBorder
/**
* Linearly interpolates from another [ShapeBorder] (possibly of another
@@ -122,12 +122,12 @@
* valid (and can easily be generated by curves such as
* [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*
* Instead of calling this directly, use [ShapeBorder.lerp].
*/
- open fun lerpFrom(a: ShapeBorder?, t: Double): ShapeBorder? {
+ open fun lerpFrom(a: ShapeBorder?, t: Float): ShapeBorder? {
if (a == null)
return scale(t)
return null
@@ -155,14 +155,14 @@
* and 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*
* Instead of calling this directly, use [ShapeBorder.lerp].
*/
- open fun lerpTo(b: ShapeBorder?, t: Double): ShapeBorder? {
+ open fun lerpTo(b: ShapeBorder?, t: Float): ShapeBorder? {
if (b == null)
- return scale(1.0 - t)
+ return scale(1.0f - t)
return null
}
@@ -240,10 +240,10 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
-fun lerp(a: ShapeBorder?, b: ShapeBorder?, t: Double): ShapeBorder? {
+fun lerp(a: ShapeBorder?, b: ShapeBorder?, t: Float): ShapeBorder? {
var result: ShapeBorder? = null
if (b != null)
result = b.lerpFrom(a, t)
diff --git a/ui/port/src/main/java/androidx/ui/painting/matrixutils/MatrixUtils.kt b/ui/port/src/main/java/androidx/ui/painting/matrixutils/MatrixUtils.kt
index 731c2ae..cf05365 100644
--- a/ui/port/src/main/java/androidx/ui/painting/matrixutils/MatrixUtils.kt
+++ b/ui/port/src/main/java/androidx/ui/painting/matrixutils/MatrixUtils.kt
@@ -30,50 +30,50 @@
fun Matrix4.getAsTranslation(): Offset? {
val values = m4storage
// Values are stored in column-major order.
- return if (values[0] == 1.0 && // col 1
- values[1] == 0.0 &&
- values[2] == 0.0 &&
- values[3] == 0.0 &&
- values[4] == 0.0 && // col 2
- values[5] == 1.0 &&
- values[6] == 0.0 &&
- values[7] == 0.0 &&
- values[8] == 0.0 && // col 3
- values[9] == 0.0 &&
- values[10] == 1.0 &&
- values[11] == 0.0 &&
- values[14] == 0.0 && // bottom of col 4 (values 12 and 13 are the x and y offsets)
+ return if (values[0] == 1.0f && // col 1
+ values[1] == 0.0f &&
+ values[2] == 0.0f &&
+ values[3] == 0.0f &&
+ values[4] == 0.0f && // col 2
+ values[5] == 1.0f &&
+ values[6] == 0.0f &&
+ values[7] == 0.0f &&
+ values[8] == 0.0f && // col 3
+ values[9] == 0.0f &&
+ values[10] == 1.0f &&
+ values[11] == 0.0f &&
+ values[14] == 0.0f && // bottom of col 4 (values 12 and 13 are the x and y offsets)
- values[15] == 1.0) {
+ values[15] == 1.0f) {
Offset(values[12], values[13])
} else null
}
/**
- * Returns the given [transform] matrix as a [double] describing a uniform
+ * Returns the given [transform] matrix as a [Float] describing a uniform
* scale, if the matrix is nothing but a symmetric 2D scale transform.
*
* Otherwise, returns null.
*/
-fun Matrix4.getAsScale(): Double? {
+fun Matrix4.getAsScale(): Float? {
val values = m4storage
// Values are stored in column-major order.
- return if (values[1] == 0.0 && // col 1 (value 0 is the scale)
- values[2] == 0.0 &&
- values[3] == 0.0 &&
- values[4] == 0.0 && // col 2 (value 5 is the scale)
- values[6] == 0.0 &&
- values[7] == 0.0 &&
- values[8] == 0.0 && // col 3
- values[9] == 0.0 &&
- values[10] == 1.0 &&
- values[11] == 0.0 &&
- values[12] == 0.0 && // col 4
- values[13] == 0.0 &&
- values[14] == 0.0 &&
- values[15] == 1.0 &&
+ return if (values[1] == 0.0f && // col 1 (value 0 is the scale)
+ values[2] == 0.0f &&
+ values[3] == 0.0f &&
+ values[4] == 0.0f && // col 2 (value 5 is the scale)
+ values[6] == 0.0f &&
+ values[7] == 0.0f &&
+ values[8] == 0.0f && // col 3
+ values[9] == 0.0f &&
+ values[10] == 1.0f &&
+ values[11] == 0.0f &&
+ values[12] == 0.0f && // col 4
+ values[13] == 0.0f &&
+ values[14] == 0.0f &&
+ values[15] == 1.0f &&
values[0] == values[5]) { // uniform scale
- values[0].toDouble()
+ values[0]
} else null
}
@@ -98,22 +98,22 @@
/** Whether the given matrix is the identity matrix. */
fun Matrix4.isIdentity(): Boolean {
val storage = m4storage
- return (storage[0] == 1.0 && // col 1
- storage[1] == 0.0 &&
- storage[2] == 0.0 &&
- storage[3] == 0.0 &&
- storage[4] == 0.0 && // col 2
- storage[5] == 1.0 &&
- storage[6] == 0.0 &&
- storage[7] == 0.0 &&
- storage[8] == 0.0 && // col 3
- storage[9] == 0.0 &&
- storage[10] == 1.0 &&
- storage[11] == 0.0 &&
- storage[12] == 0.0 && // col 4
- storage[13] == 0.0 &&
- storage[14] == 0.0 &&
- storage[15] == 1.0)
+ return (storage[0] == 1.0f && // col 1
+ storage[1] == 0.0f &&
+ storage[2] == 0.0f &&
+ storage[3] == 0.0f &&
+ storage[4] == 0.0f && // col 2
+ storage[5] == 1.0f &&
+ storage[6] == 0.0f &&
+ storage[7] == 0.0f &&
+ storage[8] == 0.0f && // col 3
+ storage[9] == 0.0f &&
+ storage[10] == 1.0f &&
+ storage[11] == 0.0f &&
+ storage[12] == 0.0f && // col 4
+ storage[13] == 0.0f &&
+ storage[14] == 0.0f &&
+ storage[15] == 1.0f)
}
/**
@@ -123,7 +123,7 @@
* z-coordinate of the result is ignored.
*/
fun Matrix4.transformPoint(point: Offset): Offset {
- val position3 = Vector3(point.dx, point.dy, 0.0)
+ val position3 = Vector3(point.dx, point.dy, 0.0f)
val transformed3 = perspectiveTransform(position3)
return Offset(transformed3.x, transformed3.y)
}
@@ -149,11 +149,11 @@
)
}
-fun _min4(a: Double, b: Double, c: Double, d: Double): Double {
+fun _min4(a: Float, b: Float, c: Float, d: Float): Float {
return minOf(a, minOf(b, minOf(c, d)))
}
-fun _max4(a: Double, b: Double, c: Double, d: Double): Double {
+fun _max4(a: Float, b: Float, c: Float, d: Float): Float {
return maxOf(a, maxOf(b, maxOf(c, d)))
}
@@ -166,7 +166,7 @@
* 0.0 before computing its bounding rect.
*/
fun inverseTransformRect(transform: Matrix4, rect: Rect): Rect {
- assert(transform.determinant != 0.0)
+ assert(transform.determinant != 0.0f)
if (transform.isIdentity())
return rect
val inverted = Matrix4(transform).apply { invert() }
@@ -208,9 +208,9 @@
* or the back side of the transformed plane before π / 2 when perspective > 0.
*/
fun createCylindricalProjectionTransform(
- radius: Double,
- angle: Double,
- perspective: Double = 0.001,
+ radius: Float,
+ angle: Float,
+ perspective: Float = 0.001f,
orientation: Axis = Axis.VERTICAL
): Matrix4 {
assert(perspective >= 0 && perspective <= 1.0)
@@ -235,7 +235,7 @@
val result = Matrix4.identity().apply {
set(2, 3, -perspective)
set(3, 2, -radius)
- set(3, 3, perspective * radius + 1.0)
+ set(3, 3, perspective * radius + 1.0f)
}
// Model matrix by first translating the object from the origin of the world
@@ -243,7 +243,7 @@
result *=
(if (orientation == Axis.HORIZONTAL)
Matrix4.rotationY(angle) else Matrix4.rotationX(angle)) *
- Matrix4.translationValues(0.0, 0.0, radius)
+ Matrix4.translationValues(0.0f, 0.0f, radius)
// Essentially perspective * view * model.
return result
diff --git a/ui/port/src/main/java/androidx/ui/physics/Simulation.kt b/ui/port/src/main/java/androidx/ui/physics/Simulation.kt
index 42d5419..1dd55d7 100644
--- a/ui/port/src/main/java/androidx/ui/physics/Simulation.kt
+++ b/ui/port/src/main/java/androidx/ui/physics/Simulation.kt
@@ -59,13 +59,13 @@
) {
/** The position of the object in the simulation at the given time. */
- abstract fun x(timeInSeconds: Double): Double
+ abstract fun x(timeInSeconds: Float): Float
/** The velocity of the object in the simulation at the given time. */
- abstract fun dx(timeInSeconds: Double): Double
+ abstract fun dx(timeInSeconds: Float): Float
/** Whether the simulation is "done" at the given time. */
- abstract fun isDone(timeInSeconds: Double): Boolean
+ abstract fun isDone(timeInSeconds: Float): Boolean
override fun toString() = runtimeType().toString()
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/physics/Tolerance.kt b/ui/port/src/main/java/androidx/ui/physics/Tolerance.kt
index 3339b3e..80dca3a 100644
--- a/ui/port/src/main/java/androidx/ui/physics/Tolerance.kt
+++ b/ui/port/src/main/java/androidx/ui/physics/Tolerance.kt
@@ -16,7 +16,7 @@
package androidx.ui.physics
-private const val EPSILON_DEFAULT: Double = 0.001
+private const val EPSILON_DEFAULT: Float = 0.001f
/**
* Structure that specifies maximum allowable magnitudes for distances,
@@ -37,7 +37,7 @@
* The units for the distance tolerance must be the same as the units used
* for the distances that are to be compared to this tolerance.
*/
- val distance: Double = EPSILON_DEFAULT,
+ val distance: Float = EPSILON_DEFAULT,
/**
* The magnitude of the maximum duration between two times for them to be
* considered within tolerance.
@@ -45,7 +45,7 @@
* The units for the time tolerance must be the same as the units used
* for the times that are to be compared to this tolerance.
*/
- val time: Double = EPSILON_DEFAULT,
+ val time: Float = EPSILON_DEFAULT,
/**
* The magnitude of the maximum difference between two velocities for them to
* be considered within tolerance.
@@ -53,7 +53,7 @@
* The units for the velocity tolerance must be the same as the units used
* for the velocities that are to be compared to this tolerance.
*/
- val velocity: Double = EPSILON_DEFAULT
+ val velocity: Float = EPSILON_DEFAULT
) {
diff --git a/ui/port/src/main/java/androidx/ui/rendering/RenderImage.kt b/ui/port/src/main/java/androidx/ui/rendering/RenderImage.kt
index 10c340a..5b80104 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/RenderImage.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/RenderImage.kt
@@ -21,7 +21,7 @@
import androidx.ui.engine.geometry.Size
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
import androidx.ui.foundation.diagnostics.DiagnosticsProperty
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.foundation.diagnostics.EnumProperty
import androidx.ui.foundation.diagnostics.FlagProperty
import androidx.ui.painting.BlendMode
@@ -56,9 +56,9 @@
*/
class RenderImage(
image: Image? = null,
- width: Double? = null,
- height: Double? = null,
- scale: Double = 1.0,
+ width: Float? = null,
+ height: Float? = null,
+ scale: Float = 1.0f,
color: Color? = null,
colorBlendMode: BlendMode? = null,
fit: BoxFit? = null,
@@ -120,7 +120,7 @@
* If null, the image will pick a size that best preserves its intrinsic
* aspect ratio.
*/
- var width: Double?
+ var width: Float?
get() = _width
set(value) = run {
if (value == _width)
@@ -135,7 +135,7 @@
* If null, the image will pick a size that best preserves its intrinsic
* aspect ratio.
*/
- var height: Double?
+ var height: Float?
get() = _height
set(value) = run {
if (value == _height)
@@ -149,7 +149,7 @@
*
* Used when determining the best display size for the image.
*/
- var scale: Double
+ var scale: Float
get() = _scale
set(value) = run {
if (value == _scale)
@@ -318,32 +318,32 @@
return cons.smallest
return cons.constrainSizeAndAttemptToPreserveAspectRatio(Size(
- _image!!.width.toDouble() / _scale,
- _image!!.height.toDouble() / _scale
+ _image!!.width / _scale,
+ _image!!.height / _scale
))
}
- override fun computeMinIntrinsicWidth(height: Double): Double {
- assert(height >= 0.0)
+ override fun computeMinIntrinsicWidth(height: Float): Float {
+ assert(height >= 0.0f)
if (_width == null && _height == null)
- return 0.0
+ return 0.0f
return _sizeForConstraints(BoxConstraints.tightForFinite(height = height)).width
}
- override fun computeMaxIntrinsicWidth(height: Double): Double {
- assert(height >= 0.0)
+ override fun computeMaxIntrinsicWidth(height: Float): Float {
+ assert(height >= 0.0f)
return _sizeForConstraints(BoxConstraints.tightForFinite(height = height)).width
}
- override fun computeMinIntrinsicHeight(width: Double): Double {
- assert(width >= 0.0)
+ override fun computeMinIntrinsicHeight(width: Float): Float {
+ assert(width >= 0.0f)
if (_width == null && _height == null)
- return 0.0
+ return 0.0f
return _sizeForConstraints(BoxConstraints.tightForFinite(width = width)).height
}
- override fun computeMaxIntrinsicHeight(width: Double): Double {
- assert(width >= 0.0)
+ override fun computeMaxIntrinsicHeight(width: Float): Float {
+ assert(width >= 0.0f)
return _sizeForConstraints(BoxConstraints.tightForFinite(width = width)).height
}
@@ -376,9 +376,9 @@
override fun debugFillProperties(properties: DiagnosticPropertiesBuilder) {
super.debugFillProperties(properties)
properties.add(DiagnosticsProperty.create("image", image))
- properties.add(DoubleProperty.create("width", width, defaultValue = null))
- properties.add(DoubleProperty.create("height", height, defaultValue = null))
- properties.add(DoubleProperty.create("scale", scale, defaultValue = 1.0))
+ properties.add(FloatProperty.create("width", width, defaultValue = null))
+ properties.add(FloatProperty.create("height", height, defaultValue = null))
+ properties.add(FloatProperty.create("scale", scale, defaultValue = 1.0f))
properties.add(DiagnosticsProperty.create("color", color, defaultValue = null))
properties.add(EnumProperty("colorBlendMode", colorBlendMode, defaultValue = null))
properties.add(EnumProperty("fit", fit, defaultValue = null))
diff --git a/ui/port/src/main/java/androidx/ui/rendering/binding/RendererBinding.kt b/ui/port/src/main/java/androidx/ui/rendering/binding/RendererBinding.kt
index 84c51b9..add1869 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/binding/RendererBinding.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/binding/RendererBinding.kt
@@ -207,7 +207,7 @@
* using `flutter run`.
*/
fun createViewConfiguration(): ViewConfiguration {
- val devicePixelRatio: Double = window.devicePixelRatio
+ val devicePixelRatio: Float = window.devicePixelRatio
// TODO(Migration/ njawad revisit window class as sizing is relative to CraneView
// dimensions not the window size of the device
return ViewConfiguration(
diff --git a/ui/port/src/main/java/androidx/ui/rendering/box/BoxConstraints.kt b/ui/port/src/main/java/androidx/ui/rendering/box/BoxConstraints.kt
index fb3ee67..6ccb4e7 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/box/BoxConstraints.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/box/BoxConstraints.kt
@@ -5,7 +5,7 @@
import androidx.ui.engine.geometry.Size
import androidx.ui.foundation.assertions.FlutterError
import androidx.ui.foundation.assertions.InformationCollector
-import androidx.ui.lerpDouble
+import androidx.ui.lerpFloat
import androidx.ui.rendering.obj.Constraints
import androidx.ui.toStringAsFixed
import androidx.ui.truncDiv
@@ -20,10 +20,10 @@
*
* The constraints themselves must satisfy these relations:
*
- * * 0.0 <= [minWidth] <= [maxWidth] <= [Double.POSITIVE_INFINITY]
- * * 0.0 <= [minHeight] <= [maxHeight] <= [Double.POSITIVE_INFINITY]
+ * * 0.0 <= [minWidth] <= [maxWidth] <= [Float.POSITIVE_INFINITY]
+ * * 0.0 <= [minHeight] <= [maxHeight] <= [Float.POSITIVE_INFINITY]
*
- * [Double.POSITIVE_INFINITY] is a legal value for each constraint.
+ * [Float.POSITIVE_INFINITY] is a legal value for each constraint.
*
* ## The box layout model
*
@@ -74,15 +74,15 @@
// Creates box constraints with the given constraints.
data class BoxConstraints(
// The minimum width that satisfies the constraints.
- val minWidth: Double = 0.0,
+ val minWidth: Float = 0.0f,
// The maximum width that satisfies the constraints.
- // Might be [Double.POSITIVE_INFINITY].
- val maxWidth: Double = Double.POSITIVE_INFINITY,
+ // Might be [Float.POSITIVE_INFINITY].
+ val maxWidth: Float = Float.POSITIVE_INFINITY,
// The minimum height that satisfies the constraints.
- val minHeight: Double = 0.0,
+ val minHeight: Float = 0.0f,
// The maximum height that satisfies the constraints.
- // Might be [Double.POSITIVE_INFINITY].
- val maxHeight: Double = Double.POSITIVE_INFINITY
+ // Might be [Float.POSITIVE_INFINITY].
+ val maxHeight: Float = Float.POSITIVE_INFINITY
) : Constraints() {
companion object {
@@ -100,11 +100,11 @@
* being tight if the value is non-null, is tight if the value is not
* infinite.
*/
- fun tightFor(width: Double? = null, height: Double? = null): BoxConstraints {
- return BoxConstraints(minWidth = width ?: 0.0,
- maxWidth = width ?: Double.POSITIVE_INFINITY,
- minHeight = height ?: 0.0,
- maxHeight = height ?: Double.POSITIVE_INFINITY
+ fun tightFor(width: Float? = null, height: Float? = null): BoxConstraints {
+ return BoxConstraints(minWidth = width ?: 0.0f,
+ maxWidth = width ?: Float.POSITIVE_INFINITY,
+ minHeight = height ?: 0.0f,
+ maxHeight = height ?: Float.POSITIVE_INFINITY
)
}
@@ -118,16 +118,16 @@
* tight if the value is not infinite, is tight if the value is non-null.
*/
fun tightForFinite(
- width: Double = Double.POSITIVE_INFINITY,
- height: Double = Double.POSITIVE_INFINITY
+ width: Float = Float.POSITIVE_INFINITY,
+ height: Float = Float.POSITIVE_INFINITY
): BoxConstraints {
- return BoxConstraints(minWidth = if (width != Double.POSITIVE_INFINITY) width else 0.0,
- maxWidth = if (width != Double.POSITIVE_INFINITY) width
- else Double.POSITIVE_INFINITY,
- minHeight = if (height != Double.POSITIVE_INFINITY) height
- else 0.0,
- maxHeight = if (height != Double.POSITIVE_INFINITY) height
- else Double.POSITIVE_INFINITY
+ return BoxConstraints(minWidth = if (width != Float.POSITIVE_INFINITY) width else 0.0f,
+ maxWidth = if (width != Float.POSITIVE_INFINITY) width
+ else Float.POSITIVE_INFINITY,
+ minHeight = if (height != Float.POSITIVE_INFINITY) height
+ else 0.0f,
+ maxHeight = if (height != Float.POSITIVE_INFINITY) height
+ else Float.POSITIVE_INFINITY
)
}
@@ -135,9 +135,9 @@
* Creates box constraints that forbid sizes larger than the given size.
*/
fun loose(size: Size): BoxConstraints {
- return BoxConstraints(minWidth = 0.0,
+ return BoxConstraints(minWidth = 0.0f,
maxWidth = size.width,
- minHeight = 0.0,
+ minHeight = 0.0f,
maxHeight = size.height)
}
@@ -147,11 +147,11 @@
* If width or height is given, the constraints will require exactly the
* given value in the given dimension.
*/
- fun expand(width: Double? = null, height: Double? = null): BoxConstraints {
- return BoxConstraints(minWidth = width ?: Double.POSITIVE_INFINITY,
- maxWidth = width ?: Double.POSITIVE_INFINITY,
- minHeight = height ?: Double.POSITIVE_INFINITY,
- maxHeight = height ?: Double.POSITIVE_INFINITY
+ fun expand(width: Float? = null, height: Float? = null): BoxConstraints {
+ return BoxConstraints(minWidth = width ?: Float.POSITIVE_INFINITY,
+ maxWidth = width ?: Float.POSITIVE_INFINITY,
+ minHeight = height ?: Float.POSITIVE_INFINITY,
+ maxHeight = height ?: Float.POSITIVE_INFINITY
)
}
@@ -170,43 +170,43 @@
* 1.0, so negative values and values greater than 1.0 are valid (and can
* easily be generated by curves such as [Curves.elasticInOut]).
*
- * Values for `t` are usually obtained from an [Animation<double>], such as
+ * Values for `t` are usually obtained from an [Animation<Float>], such as
* an [AnimationController].
*/
- fun lerp(a: BoxConstraints?, b: BoxConstraints?, t: Double): BoxConstraints? {
+ fun lerp(a: BoxConstraints?, b: BoxConstraints?, t: Float): BoxConstraints? {
if (a == null && b == null)
return null
if (a == null)
return b!! * t
if (b == null)
- return a * (1.0 - t)
+ return a * (1.0f - t)
assert(a.debugAssertIsValid())
assert(b.debugAssertIsValid())
assert((a.minWidth.isFinite() && b.minWidth.isFinite()) ||
- (a.minWidth == Double.POSITIVE_INFINITY &&
- b.minWidth == Double.POSITIVE_INFINITY)
+ (a.minWidth == Float.POSITIVE_INFINITY &&
+ b.minWidth == Float.POSITIVE_INFINITY)
) { "Cannot interpolate between finite constraints and unbounded constraints." }
assert((a.maxWidth.isFinite() && b.maxWidth.isFinite()) ||
- (a.maxWidth == Double.POSITIVE_INFINITY &&
- b.maxWidth == Double.POSITIVE_INFINITY)
+ (a.maxWidth == Float.POSITIVE_INFINITY &&
+ b.maxWidth == Float.POSITIVE_INFINITY)
) { "Cannot interpolate between finite constraints and unbounded constraints." }
assert((a.minHeight.isFinite() && b.minHeight.isFinite()) ||
- (a.minHeight == Double.POSITIVE_INFINITY &&
- b.minHeight == Double.POSITIVE_INFINITY)
+ (a.minHeight == Float.POSITIVE_INFINITY &&
+ b.minHeight == Float.POSITIVE_INFINITY)
) { "Cannot interpolate between finite constraints and unbounded constraints." }
assert((a.maxHeight.isFinite() && b.maxHeight.isFinite()) ||
- (a.maxHeight == Double.POSITIVE_INFINITY &&
- b.maxHeight == Double.POSITIVE_INFINITY)
+ (a.maxHeight == Float.POSITIVE_INFINITY &&
+ b.maxHeight == Float.POSITIVE_INFINITY)
) { "Cannot interpolate between finite constraints and unbounded constraints." }
return BoxConstraints(
- minWidth = if (a.minWidth.isFinite()) lerpDouble(a.minWidth, b.minWidth,
- t) else Double.POSITIVE_INFINITY,
- maxWidth = if (a.maxWidth.isFinite()) lerpDouble(a.maxWidth, b.maxWidth,
- t) else Double.POSITIVE_INFINITY,
- minHeight = if (a.minHeight.isFinite()) lerpDouble(a.minHeight, b.minHeight,
- t) else Double.POSITIVE_INFINITY,
- maxHeight = if (a.maxHeight.isFinite()) lerpDouble(a.maxHeight, b.maxHeight,
- t) else Double.POSITIVE_INFINITY
+ minWidth = if (a.minWidth.isFinite()) lerpFloat(a.minWidth, b.minWidth,
+ t) else Float.POSITIVE_INFINITY,
+ maxWidth = if (a.maxWidth.isFinite()) lerpFloat(a.maxWidth, b.maxWidth,
+ t) else Float.POSITIVE_INFINITY,
+ minHeight = if (a.minHeight.isFinite()) lerpFloat(a.minHeight, b.minHeight,
+ t) else Float.POSITIVE_INFINITY,
+ maxHeight = if (a.maxHeight.isFinite()) lerpFloat(a.maxHeight, b.maxHeight,
+ t) else Float.POSITIVE_INFINITY
)
}
}
@@ -215,10 +215,10 @@
* Creates a copy of this box constraints but with the given fields replaced with the new values.
*/
fun copyWith(
- minWidth: Double? = null,
- maxWidth: Double? = null,
- minHeight: Double? = null,
- maxHeight: Double? = null
+ minWidth: Float? = null,
+ maxWidth: Float? = null,
+ minHeight: Float? = null,
+ maxHeight: Float? = null
): BoxConstraints {
return BoxConstraints(
minWidth = minWidth ?: this.minWidth,
@@ -251,9 +251,9 @@
fun loosen(): BoxConstraints {
assert(debugAssertIsValid())
return BoxConstraints(
- minWidth = 0.0,
+ minWidth = 0.0f,
maxWidth = maxWidth,
- minHeight = 0.0,
+ minHeight = 0.0f,
maxHeight = maxHeight
)
}
@@ -276,7 +276,7 @@
* the given width and height as possible while still respecting the original
* box constraints.
*/
- fun tighten(width: Double? = null, height: Double? = null): BoxConstraints {
+ fun tighten(width: Float? = null, height: Float? = null): BoxConstraints {
return BoxConstraints(minWidth = width?.clamp(minWidth, maxWidth) ?: minWidth,
maxWidth = width?.clamp(minWidth, maxWidth) ?: maxWidth,
minHeight = height?.clamp(minHeight, maxHeight) ?: minHeight,
@@ -316,7 +316,7 @@
* Returns the width that both satisfies the constraints and is as close as
* possible to the given width.
*/
- fun constrainWidth(width: Double = Double.POSITIVE_INFINITY): Double {
+ fun constrainWidth(width: Float = Float.POSITIVE_INFINITY): Float {
assert(debugAssertIsValid())
return width.clamp(minWidth, maxWidth)
}
@@ -325,7 +325,7 @@
* Returns the height that both satisfies the constraints and is as close as
* possible to the given height.
*/
- fun constrainHeight(height: Double = Double.POSITIVE_INFINITY): Double {
+ fun constrainHeight(height: Float = Float.POSITIVE_INFINITY): Float {
assert(debugAssertIsValid())
return height.clamp(minHeight, maxHeight)
}
@@ -363,7 +363,7 @@
* When you already have a [Size], prefer [constrain], which applies the same
* algorithm to a [Size] directly.
*/
- fun constrainDimensions(width: Double, height: Double): Size {
+ fun constrainDimensions(width: Float, height: Float): Size {
return Size(constrainWidth(width), constrainHeight(height))
}
@@ -385,8 +385,8 @@
var width = size.width
var height = size.height
- assert(width > 0.0)
- assert(height > 0.0)
+ assert(width > 0.0f)
+ assert(height > 0.0f)
val aspectRatio = width / height
if (width > maxWidth) {
@@ -422,7 +422,7 @@
/**
* The smallest size that satisfies the constraints.
*/
- val smallest get() = Size(constrainWidth(0.0), constrainHeight(0.0))
+ val smallest get() = Size(constrainWidth(0.0f), constrainHeight(0.0f))
/**
* Whether there is exactly one width value that satisfies the constraints.
@@ -443,12 +443,12 @@
/**
* Whether there is an upper bound on the maximum width.
*/
- val hasBoundedWidth get() = maxWidth < Double.POSITIVE_INFINITY
+ val hasBoundedWidth get() = maxWidth < Float.POSITIVE_INFINITY
/**
* Whether there is an upper bound on the maximum height.
*/
- val hasBoundedHeight get() = maxHeight < Double.POSITIVE_INFINITY
+ val hasBoundedHeight get() = maxHeight < Float.POSITIVE_INFINITY
/**
* Whether the given size satisfies the constraints.
@@ -462,7 +462,7 @@
/**
* Scales each constraint parameter by the given factor.
*/
- operator fun times(factor: Double) = BoxConstraints(
+ operator fun times(factor: Float) = BoxConstraints(
minWidth = minWidth * factor,
maxWidth = maxWidth * factor,
minHeight = minHeight * factor,
@@ -472,7 +472,7 @@
/**
* Scales each constraint parameter by the inverse of the given factor.
*/
- operator fun div(factor: Double) = BoxConstraints(
+ operator fun div(factor: Float) = BoxConstraints(
minWidth = minWidth / factor,
maxWidth = maxWidth / factor,
minHeight = minHeight / factor,
@@ -483,17 +483,17 @@
* Scales each constraint parameter by the inverse of the given factor, rounded to the nearest integer.
*/
// TODO(Migration/Andrey): Original operator ~/ could not be overriden in Kotlin
- fun truncDiv(factor: Double) = BoxConstraints(
- minWidth = minWidth.truncDiv(factor).toDouble(),
- maxWidth = maxWidth.truncDiv(factor).toDouble(),
- minHeight = minHeight.truncDiv(factor).toDouble(),
- maxHeight = maxHeight.truncDiv(factor).toDouble()
+ fun truncDiv(factor: Float) = BoxConstraints(
+ minWidth = minWidth.truncDiv(factor).toFloat(),
+ maxWidth = maxWidth.truncDiv(factor).toFloat(),
+ minHeight = minHeight.truncDiv(factor).toFloat(),
+ maxHeight = maxHeight.truncDiv(factor).toFloat()
)
/**
* Computes the remainder of each constraint parameter by the given value.
*/
- operator fun rem(value: Double) = BoxConstraints(
+ operator fun rem(value: Float) = BoxConstraints(
minWidth = minWidth % value,
maxWidth = maxWidth % value,
minHeight = minHeight % value,
@@ -514,9 +514,9 @@
* are not normalized.
*/
override val isNormalized: Boolean
- get() = minWidth >= 0.0 &&
+ get() = minWidth >= 0.0f &&
minWidth <= maxWidth &&
- minHeight >= 0.0 &&
+ minHeight >= 0.0f &&
minHeight <= maxHeight
override fun debugAssertIsValid(
@@ -557,12 +557,12 @@
"BoxConstraints has ${(if (affectedFieldsList.size == 1) " a NaN value "
else " NaN values")} in $whichFields.")
}
- if (minWidth < 0.0 && minHeight < 0.0)
+ if (minWidth < 0.0f && minHeight < 0.0f)
throwError("BoxConstraints has both a negative minimum width " +
"and a negative minimum height.")
- if (minWidth < 0.0)
+ if (minWidth < 0.0f)
throwError("BoxConstraints has a negative minimum width.")
- if (minHeight < 0.0)
+ if (minHeight < 0.0f)
throwError("BoxConstraints has a negative minimum height.")
if (maxWidth < minWidth && maxHeight < minHeight)
throwError("BoxConstraints has both width and height constraints non-normalized.")
@@ -593,8 +593,8 @@
fun normalize(): BoxConstraints {
if (isNormalized)
return this
- val minWidth = if (this.minWidth >= 0.0) this.minWidth else 0.0
- val minHeight = if (this.minHeight >= 0.0) this.minHeight else 0.0
+ val minWidth = if (this.minWidth >= 0.0f) this.minWidth else 0.0f
+ val minHeight = if (this.minHeight >= 0.0f) this.minHeight else 0.0f
return BoxConstraints(
minWidth = minWidth,
maxWidth = if (minWidth > maxWidth) minWidth else maxWidth,
@@ -627,12 +627,12 @@
override fun toString(): String {
val annotation = if (isNormalized) "" else "; NOT NORMALIZED"
- if (minWidth == Double.POSITIVE_INFINITY && minHeight == Double.POSITIVE_INFINITY)
+ if (minWidth == Float.POSITIVE_INFINITY && minHeight == Float.POSITIVE_INFINITY)
return "BoxConstraints(biggest$annotation)"
- if (minWidth == 0.0 && maxWidth == Double.POSITIVE_INFINITY &&
- minHeight == 0.0 && maxHeight == Double.POSITIVE_INFINITY)
+ if (minWidth == 0.0f && maxWidth == Float.POSITIVE_INFINITY &&
+ minHeight == 0.0f && maxHeight == Float.POSITIVE_INFINITY)
return "BoxConstraints(unconstrained$annotation)"
- val describe: (Double, Double, String) -> String = { min, max, dim ->
+ val describe: (Float, Float, String) -> String = { min, max, dim ->
if (min == max)
"$dim=${min.toStringAsFixed(1)}"
else
@@ -642,4 +642,4 @@
val height = describe(minHeight, maxHeight, "h")
return "BoxConstraints($width, $height$annotation)"
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/rendering/box/RenderBox.kt b/ui/port/src/main/java/androidx/ui/rendering/box/RenderBox.kt
index 29f5441..d8370dd 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/box/RenderBox.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/box/RenderBox.kt
@@ -446,13 +446,13 @@
child.parentData = BoxParentData()
}
- var _cachedIntrinsicDimensions: MutableMap<_IntrinsicDimensionsCacheEntry, Double>? = null
+ var _cachedIntrinsicDimensions: MutableMap<_IntrinsicDimensionsCacheEntry, Float>? = null
fun _computeIntrinsicDimension(
dimension: _IntrinsicDimension,
- argument: Double,
- computer: (Double) -> Double
- ): Double {
+ argument: Float,
+ computer: (Float) -> Float
+ ): Float {
// performResize should not depend on anything except the incoming constraints
assert(RenderObject.debugCheckingIntrinsics || !debugDoingThisResize)
var shouldCache = true
@@ -493,22 +493,22 @@
* Do not override this method. Instead, implement [computeMinIntrinsicWidth].
*/
@CallSuper
- fun getMinIntrinsicWidth(height: Double?): Double {
+ fun getMinIntrinsicWidth(height: Float?): Float {
assert {
if (height == null) {
throw FlutterError(
"The height argument to getMinIntrinsicWidth was null.\n" +
"The argument to getMinIntrinsicWidth must not be " +
"negative or null. If you do not have a specific height in mind, " +
- "then pass double.infinity instead."
+ "then pass Float.POSITIVE_INFINITY instead."
)
}
- if (height < 0.0) {
+ if (height < 0.0f) {
throw FlutterError(
"The height argument to getMinIntrinsicWidth was negative.\n" +
"The argument to getMinIntrinsicWidth must not be negative or null. " +
"If you perform computations on another height before passing it to " +
- "getMinIntrinsicWidth, consider using math.max() or double.clamp() " +
+ "getMinIntrinsicWidth, consider using math.max() or Float.clamp() " +
"to force the value into the valid range."
)
}
@@ -614,8 +614,8 @@
* When the incoming argument is not finite, then they should return the
* actual intrinsic dimensions based on the contents, as any other box would.
*/
- protected open fun computeMinIntrinsicWidth(height: Double): Double {
- return 0.0
+ protected open fun computeMinIntrinsicWidth(height: Float): Float {
+ return 0.0f
}
/**
@@ -639,22 +639,22 @@
* [computeMaxIntrinsicWidth].
*/
@CallSuper
- fun getMaxIntrinsicWidth(height: Double?): Double {
+ fun getMaxIntrinsicWidth(height: Float?): Float {
assert {
if (height == null) {
throw FlutterError(
"The height argument to getMaxIntrinsicWidth was null.\n" +
"The argument to getMaxIntrinsicWidth must not be negative or null. " +
"If you do not have a specific height in mind, " +
- "then pass double.infinity instead."
+ "then pass Float.POSITIVE_INFINITY instead."
)
}
- if (height < 0.0) {
+ if (height < 0.0f) {
throw FlutterError(
"The height argument to getMaxIntrinsicWidth was negative.\n" +
"The argument to getMaxIntrinsicWidth must not be negative or null. " +
"If you perform computations on another height before passing it to " +
- "getMaxIntrinsicWidth, consider using math.max() or double.clamp() " +
+ "getMaxIntrinsicWidth, consider using max() or coerceIn() " +
"to force the value into the valid range."
)
}
@@ -698,8 +698,8 @@
*
* See also examples in the definition of [computeMinIntrinsicWidth].
*/
- protected open fun computeMaxIntrinsicWidth(height: Double): Double {
- return 0.0
+ protected open fun computeMaxIntrinsicWidth(height: Float): Float {
+ return 0.0f
}
/** Returns the minimum height that this box could be without failing to
@@ -721,22 +721,22 @@
* [computeMinIntrinsicHeight].
*/
@CallSuper
- fun getMinIntrinsicHeight(width: Double?): Double {
+ fun getMinIntrinsicHeight(width: Float?): Float {
assert {
if (width == null) {
throw FlutterError(
"The width argument to getMinIntrinsicHeight was null.\n" +
"The argument to getMinIntrinsicHeight must not be negative or null. " +
"If you do not have a specific width in mind, " +
- "then pass double.infinity instead."
+ "then pass Float.POSITIVE_INFINITY instead."
)
}
- if (width < 0.0) {
+ if (width < 0.0f) {
throw FlutterError(
"The width argument to getMinIntrinsicHeight was negative.\n" +
"The argument to getMinIntrinsicHeight must not be negative or null. " +
"If you perform computations on another width before passing it to " +
- "getMinIntrinsicHeight, consider using math.max() or double.clamp() " +
+ "getMinIntrinsicHeight, consider using math.max() or Float.clamp() " +
"to force the value into the valid range."
)
}
@@ -776,8 +776,8 @@
*
* See also examples in the definition of [computeMinIntrinsicWidth].
*/
- protected open fun computeMinIntrinsicHeight(width: Double): Double {
- return 0.0
+ protected open fun computeMinIntrinsicHeight(width: Float): Float {
+ return 0.0f
}
/**
@@ -801,22 +801,22 @@
* [computeMaxIntrinsicHeight].
*/
@CallSuper
- fun getMaxIntrinsicHeight(width: Double?): Double {
+ fun getMaxIntrinsicHeight(width: Float?): Float {
assert {
if (width == null) {
throw FlutterError(
"The width argument to getMaxIntrinsicHeight was null.\n" +
"The argument to getMaxIntrinsicHeight must not be negative or null. " +
"If you do not have a specific width in mind, " +
- "then pass double.infinity instead."
+ "then pass Float.POSITIVE_INFINITY instead."
)
}
- if (width < 0.0) {
+ if (width < 0.0f) {
throw FlutterError(
"The width argument to getMaxIntrinsicHeight was negative.\n" +
"The argument to getMaxIntrinsicHeight must not be negative or null. " +
"If you perform computations on another width before passing it to " +
- "getMaxIntrinsicHeight, consider using math.max() or double.clamp() " +
+ "getMaxIntrinsicHeight, consider using math.max() or Float.clamp() " +
"to force the value into the valid range."
)
}
@@ -860,8 +860,8 @@
*
* See also examples in the definition of [computeMinIntrinsicWidth].
*/
- protected open fun computeMaxIntrinsicHeight(width: Double): Double {
- return 0.0
+ protected open fun computeMaxIntrinsicHeight(width: Float): Float {
+ return 0.0f
}
// Whether this render object has undergone layout and has a [size].
@@ -1029,7 +1029,7 @@
size = size
}
- private var _cachedBaselines: MutableMap<TextBaseline, Double?>? = null
+ private var _cachedBaselines: MutableMap<TextBaseline, Float?>? = null
companion object {
var _debugDoingBaseline = false
@@ -1052,7 +1052,7 @@
* Only call this function after calling [layout] on this box. You are only allowed to call this
* from the parent of this box during that parent's [performLayout] or [paint] functions.
*/
- fun getDistanceToBaseline(baseline: TextBaseline, onlyReal: Boolean = false): Double? {
+ fun getDistanceToBaseline(baseline: TextBaseline, onlyReal: Boolean = false): Float? {
assert(!debugNeedsLayout)
assert(!_debugDoingBaseline)
assert {
@@ -1082,7 +1082,7 @@
* methods.
*/
@CallSuper
- protected fun getDistanceToActualBaseline(baseline: TextBaseline): Double? {
+ protected fun getDistanceToActualBaseline(baseline: TextBaseline): Float? {
assert(_debugDoingBaseline)
val cachedBaselinesTemp = _cachedBaselines ?: mutableMapOf()
cachedBaselinesTemp.getOrPut(baseline) { computeDistanceToActualBaseline(baseline) }
@@ -1101,7 +1101,7 @@
*
* Subclasses should override this method to supply the distances to their baselines.
*/
- protected open fun computeDistanceToActualBaseline(baseline: TextBaseline): Double? {
+ protected open fun computeDistanceToActualBaseline(baseline: TextBaseline): Float? {
assert(_debugDoingBaseline)
return null
}
@@ -1192,10 +1192,10 @@
var failureCount = 0
fun testIntrinsic(
- function: (Double) -> Double,
+ function: (Float) -> Float,
name: String,
- constraint: Double
- ): Double {
+ constraint: Float
+ ): Float {
val result = function(constraint)
if (result < 0) {
failures.appendln(
@@ -1213,10 +1213,10 @@
}
fun testIntrinsicsForValues(
- getMin: (Double) -> Double,
- getMax: (Double) -> Double,
+ getMin: (Float) -> Float,
+ getMax: (Float) -> Float,
name: String,
- constraint: Double
+ constraint: Float
) {
val min = testIntrinsic(getMin, "getMinIntrinsic$name", constraint)
val max = testIntrinsic(getMax, "getMaxIntrinsic$name", constraint)
@@ -1231,11 +1231,11 @@
testIntrinsicsForValues(
::getMinIntrinsicWidth, ::getMaxIntrinsicWidth, "Width",
- Double.POSITIVE_INFINITY
+ Float.POSITIVE_INFINITY
)
testIntrinsicsForValues(
::getMinIntrinsicHeight, ::getMaxIntrinsicHeight, "Height",
- Double.POSITIVE_INFINITY
+ Float.POSITIVE_INFINITY
)
if (constraints!!.hasBoundedWidth)
testIntrinsicsForValues(
@@ -1448,7 +1448,7 @@
fun globalToLocal(point: Offset, ancestor: RenderObject? = null): Offset {
val transform = getTransformTo(ancestor)
val det = transform.invert()
- if (det == 0.0)
+ if (det == 0.0f)
return Offset.zero
return transform.transformPoint(point)
}
@@ -1563,10 +1563,10 @@
assert {
val paint = Paint().apply {
style = PaintingStyle.stroke
- strokeWidth = 1.0
+ strokeWidth = 1.0f
color = Color(0xFF00FFFF.toInt())
}
- context.canvas.drawRect((offset.and(size)).deflate(0.5), paint)
+ context.canvas.drawRect((offset.and(size)).deflate(0.5f), paint)
true
}
}
diff --git a/ui/port/src/main/java/androidx/ui/rendering/box/_IntrinsicDimensionsCacheEntry.kt b/ui/port/src/main/java/androidx/ui/rendering/box/_IntrinsicDimensionsCacheEntry.kt
index ae0e5a5..885beee 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/box/_IntrinsicDimensionsCacheEntry.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/box/_IntrinsicDimensionsCacheEntry.kt
@@ -3,7 +3,7 @@
// TODO(Migration/xbhatnag): const constructor
data class _IntrinsicDimensionsCacheEntry(
val dimension: _IntrinsicDimension,
- val argument: Double
+ val argument: Float
) {
// override fun equals(other: Any?): Boolean {
// if (other !is _IntrinsicDimensionsCacheEntry)
diff --git a/ui/port/src/main/java/androidx/ui/rendering/editable/RenderEditable.kt b/ui/port/src/main/java/androidx/ui/rendering/editable/RenderEditable.kt
index 9025a25..187a261 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/editable/RenderEditable.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/editable/RenderEditable.kt
@@ -906,7 +906,7 @@
// return null;
// }
- fun _getMaxScrollExtent(contentSize: Size): Double {
+ fun _getMaxScrollExtent(contentSize: Size): Float {
TODO("Not yet implemented")
// assert(hasSize);
// switch (_viewportAxis) {
@@ -998,13 +998,13 @@
// return Rect.fromLTWH(0.0, 0.0, cursorWidth, preferredLineHeight).shift(caretOffset + _paintOffset);
}
- override fun computeMinIntrinsicWidth(height: Double): Double {
+ override fun computeMinIntrinsicWidth(height: Float): Float {
TODO("Not yet implemented")
// _layoutText(double.infinity);
// return _textPainter.minIntrinsicWidth;
}
- override fun computeMaxIntrinsicWidth(height: Double): Double {
+ override fun computeMaxIntrinsicWidth(height: Float): Float {
TODO("Not yet implemented")
// _layoutText(double.infinity);
// return _textPainter.maxIntrinsicWidth;
@@ -1016,7 +1016,7 @@
*/
// double get preferredLineHeight => _textPainter.preferredLineHeight;
- fun _preferredHeight(width: Double): Double {
+ fun _preferredHeight(width: Float): Float {
TODO("Not yet implemented")
// if (maxLines != null)
// return preferredLineHeight * maxLines;
@@ -1033,17 +1033,17 @@
// return math.max(preferredLineHeight, _textPainter.height);
}
- override fun computeMinIntrinsicHeight(width: Double): Double {
+ override fun computeMinIntrinsicHeight(width: Float): Float {
TODO("Not yet implemented")
// return _preferredHeight(width);
}
- override fun computeMaxIntrinsicHeight(width: Double): Double {
+ override fun computeMaxIntrinsicHeight(width: Float): Float {
TODO("Not yet implemented")
// return _preferredHeight(width);
}
- override fun computeDistanceToActualBaseline(baseline: TextBaseline): Double? {
+ override fun computeDistanceToActualBaseline(baseline: TextBaseline): Float? {
TODO("Not yet implemented")
// _layoutText(constraints.maxWidth);
// return _textPainter.computeDistanceToActualBaseline(baseline);
@@ -1194,7 +1194,7 @@
// Rect _caretPrototype;
- fun _layoutText(constraintWidth: Double) {
+ fun _layoutText(constraintWidth: Float) {
TODO("Not yet implemented")
// assert(constraintWidth != null);
// if (_textLayoutLastWidth == constraintWidth)
@@ -1298,7 +1298,7 @@
// properties.add(DiagnosticsProperty<ValueNotifier<bool>>('showCursor', showCursor));
// properties.add(IntProperty('maxLines', maxLines));
// properties.add(DiagnosticsProperty<Color>('selectionColor', selectionColor));
-// properties.add(DoubleProperty('textScaleFactor', textScaleFactor));
+// properties.add(FloatProperty('textScaleFactor', textScaleFactor));
// properties.add(DiagnosticsProperty<Locale>('locale', locale, defaultValue: null));
// properties.add(DiagnosticsProperty<TextSelection>('selection', selection));
// properties.add(DiagnosticsProperty<ViewportOffset>('offset', offset));
@@ -1313,4 +1313,4 @@
// ),
// ];
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/rendering/error/RenderErrorBox.kt b/ui/port/src/main/java/androidx/ui/rendering/error/RenderErrorBox.kt
index 1496564..aaf9586 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/error/RenderErrorBox.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/error/RenderErrorBox.kt
@@ -21,8 +21,8 @@
import androidx.ui.rendering.box.RenderBox
import androidx.ui.rendering.obj.PaintingContext
-const val _kMaxWidth: Double = 100000.0
-const val _kMaxHeight: Double = 100000.0
+const val _kMaxWidth: Float = 100000.0f
+const val _kMaxHeight: Float = 100000.0f
// Line length to fit small phones without dynamically checking size.
const val _kLine: String = "\n\n────────────────────\n\n"
@@ -92,11 +92,11 @@
// var _paragraph: ui.Paragraph? = null;
- override fun computeMaxIntrinsicWidth(height: Double): Double {
+ override fun computeMaxIntrinsicWidth(height: Float): Float {
return _kMaxWidth
}
- override fun computeMaxIntrinsicHeight(width: Double): Double {
+ override fun computeMaxIntrinsicHeight(width: Float): Float {
return _kMaxHeight
}
diff --git a/ui/port/src/main/java/androidx/ui/rendering/flex/RenderFlex.kt b/ui/port/src/main/java/androidx/ui/rendering/flex/RenderFlex.kt
index b3a3558..620620d 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/flex/RenderFlex.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/flex/RenderFlex.kt
@@ -38,7 +38,7 @@
import androidx.ui.runtimeType
import kotlin.math.max
-internal typealias ChildSizingFunction = (child: RenderBox, extent: Double) -> Double
+internal typealias ChildSizingFunction = (child: RenderBox, extent: Float) -> Float
internal fun startIsTopLeft(
direction: Axis,
@@ -310,7 +310,7 @@
// }
// Set during layout if overflow occurred on the main axis.
- private var overflow: Double = 0.0
+ private var overflow: Float = 0.0f
override fun setupParentData(child: RenderObject) {
if (child.parentData !is FlexParentData) {
@@ -320,16 +320,16 @@
internal fun getIntrinsicSize(
sizingDirection: Axis,
- extent: Double, // the extent in the direction that isn't the sizing direction
+ extent: Float, // the extent in the direction that isn't the sizing direction
childSize: ChildSizingFunction // a method to find the size in the sizing direction
- ): Double {
+ ): Float {
if (_direction == sizingDirection) {
// INTRINSIC MAIN SIZE
// Intrinsic main size is the smallest size the flex container can take
// while maintaining the min/max-content contributions of its flex items.
- var totalFlex = 0.0
- var inflexibleSpace = 0.0
- var maxFlexFractionSoFar = 0.0
+ var totalFlex = 0.0f
+ var inflexibleSpace = 0.0f
+ var maxFlexFractionSoFar = 0.0f
var child = firstChild
while (child != null) {
val flex = getFlex(child)
@@ -356,23 +356,23 @@
// Get inflexible space using the max intrinsic dimensions of fixed children in the main direction.
val availableMainSpace = extent
var totalFlex = 0
- var inflexibleSpace = 0.0
- var maxCrossSize = 0.0
+ var inflexibleSpace = 0.0f
+ var maxCrossSize = 0.0f
var child = firstChild
while (child != null) {
val flex = getFlex(child)
totalFlex += flex
- val mainSize: Double
- val crossSize: Double
+ val mainSize: Float
+ val crossSize: Float
if (flex == 0) {
when (_direction) {
Axis.HORIZONTAL -> {
- mainSize = child.getMaxIntrinsicWidth(Double.POSITIVE_INFINITY)
+ mainSize = child.getMaxIntrinsicWidth(Float.POSITIVE_INFINITY)
crossSize = childSize(child, mainSize)
}
Axis.VERTICAL -> {
mainSize = child
- .getMaxIntrinsicHeight(Double.POSITIVE_INFINITY)
+ .getMaxIntrinsicHeight(Float.POSITIVE_INFINITY)
crossSize = childSize(child, mainSize)
}
}
@@ -386,7 +386,7 @@
}
// Determine the spacePerFlex by allocating the remaining available space.
- val spacePerFlex = max(0.0, (availableMainSpace - inflexibleSpace) / totalFlex)
+ val spacePerFlex = max(0.0f, (availableMainSpace - inflexibleSpace) / totalFlex)
// Size remaining (flexible) items, find the maximum cross size.
child = firstChild
@@ -407,25 +407,25 @@
}
}
- override fun computeMinIntrinsicWidth(height: Double) = getIntrinsicSize(
+ override fun computeMinIntrinsicWidth(height: Float) = getIntrinsicSize(
sizingDirection = Axis.HORIZONTAL,
extent = height,
childSize = { child, extent -> child.getMinIntrinsicWidth(extent) }
)
- override fun computeMaxIntrinsicWidth(height: Double) = getIntrinsicSize(
+ override fun computeMaxIntrinsicWidth(height: Float) = getIntrinsicSize(
sizingDirection = Axis.HORIZONTAL,
extent = height,
childSize = { child, extent -> child.getMaxIntrinsicWidth(extent) }
)
- override fun computeMinIntrinsicHeight(width: Double) = getIntrinsicSize(
+ override fun computeMinIntrinsicHeight(width: Float) = getIntrinsicSize(
sizingDirection = Axis.VERTICAL,
extent = width,
childSize = { child, extent -> child.getMinIntrinsicHeight(extent) }
)
- override fun computeMaxIntrinsicHeight(width: Double) = getIntrinsicSize(
+ override fun computeMaxIntrinsicHeight(width: Float) = getIntrinsicSize(
sizingDirection = Axis.VERTICAL,
extent = width,
childSize = { child, extent -> child.getMaxIntrinsicHeight(extent) }
@@ -472,9 +472,9 @@
constraints!!.maxHeight
}
- val canFlex = maxMainSize < Double.POSITIVE_INFINITY
- var crossSize = 0.0
- var allocatedSize = 0.0; // Sum of the sizes of the non-flexible children.
+ val canFlex = maxMainSize < Float.POSITIVE_INFINITY
+ var crossSize = 0.0f
+ var allocatedSize = 0.0f // Sum of the sizes of the non-flexible children.
var child = firstChild
var lastFlexChild: RenderBox? = null
while (child != null) {
@@ -580,14 +580,14 @@
}
// Distribute free space to flexible children, and determine baseline.
- val freeSpace = max(0.0, (if (canFlex) maxMainSize else 0.0) - allocatedSize)
- var allocatedFlexSpace = 0.0
- var maxBaselineDistance = 0.0
+ val freeSpace = max(0.0f, (if (canFlex) maxMainSize else 0.0f) - allocatedSize)
+ var allocatedFlexSpace = 0.0f
+ var maxBaselineDistance = 0.0f
if (totalFlex > 0 || crossAxisAlignment == CrossAxisAlignment.BASELINE) {
val spacePerFlex = if (canFlex && totalFlex > 0) {
(freeSpace / totalFlex)
} else {
- Double.NaN
+ Float.NaN
}
child = firstChild
@@ -601,16 +601,16 @@
spacePerFlex * flex
}
} else {
- Double.POSITIVE_INFINITY
+ Float.POSITIVE_INFINITY
}
- val minChildExtent: Double
+ val minChildExtent: Float
when (getFit(child)) {
FlexFit.TIGHT -> {
- assert(maxChildExtent < Double.POSITIVE_INFINITY)
+ assert(maxChildExtent < Float.POSITIVE_INFINITY)
minChildExtent = maxChildExtent
}
FlexFit.LOOSE -> {
- minChildExtent = 0.0
+ minChildExtent = 0.0f
}
}
@@ -681,8 +681,8 @@
// Align items along the main axis.
val idealSize =
if (canFlex && mainAxisSize == MainAxisSize.MAX) maxMainSize else allocatedSize
- val actualSize: Double
- val actualSizeDelta: Double
+ val actualSize: Float
+ val actualSizeDelta: Float
when (_direction) {
Axis.HORIZONTAL -> {
size = constraints!!.constrain(Size(idealSize, crossSize))
@@ -696,11 +696,11 @@
}
}
actualSizeDelta = actualSize - allocatedSize
- overflow = max(0.0, -actualSizeDelta)
+ overflow = max(0.0f, -actualSizeDelta)
- val remainingSpace = max(0.0, actualSizeDelta)
- val leadingSpace: Double
- val betweenSpace: Double
+ val remainingSpace = max(0.0f, actualSizeDelta)
+ val leadingSpace: Float
+ val betweenSpace: Float
// flipMainAxis is used to decide whether to lay out left-to-right/top-to-bottom (false), or
// right-to-left/bottom-to-top (true). The _startIsTopLeft will return null if there's only
// one child and the relevant direction is null, in which case we arbitrarily decide not to
@@ -708,27 +708,27 @@
val flipMainAxis = !(startIsTopLeft(direction, textDirection, verticalDirection) ?: true)
when (_mainAxisAlignment) {
MainAxisAlignment.START -> {
- leadingSpace = 0.0
- betweenSpace = 0.0
+ leadingSpace = 0.0f
+ betweenSpace = 0.0f
}
MainAxisAlignment.END -> {
leadingSpace = remainingSpace
- betweenSpace = 0.0
+ betweenSpace = 0.0f
}
MainAxisAlignment.CENTER -> {
- leadingSpace = remainingSpace / 2.0
- betweenSpace = 0.0
+ leadingSpace = remainingSpace / 2.0f
+ betweenSpace = 0.0f
}
MainAxisAlignment.SPACE_BETWEEN -> {
- leadingSpace = 0.0
- betweenSpace = if (totalChildren > 1) remainingSpace / (totalChildren - 1) else 0.0
+ leadingSpace = 0.0f
+ betweenSpace = if (totalChildren > 1) remainingSpace / (totalChildren - 1) else 0.0f
}
MainAxisAlignment.SPACE_AROUND -> {
- betweenSpace = if (totalChildren > 0) remainingSpace / totalChildren else 0.0
- leadingSpace = betweenSpace / 2.0
+ betweenSpace = if (totalChildren > 0) remainingSpace / totalChildren else 0.0f
+ leadingSpace = betweenSpace / 2.0f
}
MainAxisAlignment.SPACE_EVENLY -> {
- betweenSpace = if (totalChildren > 0) remainingSpace / (totalChildren + 1) else 0.0
+ betweenSpace = if (totalChildren > 0) remainingSpace / (totalChildren + 1) else 0.0f
leadingSpace = betweenSpace
}
}
@@ -738,25 +738,25 @@
child = firstChild
while (child != null) {
val childParentData = child.parentData
- var childCrossPosition: Double
+ var childCrossPosition: Float
when (_crossAxisAlignment) {
CrossAxisAlignment.START, CrossAxisAlignment.END -> {
childCrossPosition = if (
startIsTopLeft(direction.flip(), textDirection, verticalDirection) ==
(_crossAxisAlignment == CrossAxisAlignment.START)) {
- 0.0
+ 0.0f
} else {
crossSize - getCrossSize(child)
}
}
CrossAxisAlignment.CENTER -> {
- childCrossPosition = crossSize / 2.0 - getCrossSize(child) / 2.0
+ childCrossPosition = crossSize / 2.0f - getCrossSize(child) / 2.0f
}
CrossAxisAlignment.STRETCH -> {
- childCrossPosition = 0.0
+ childCrossPosition = 0.0f
}
CrossAxisAlignment.BASELINE -> {
- childCrossPosition = 0.0
+ childCrossPosition = 0.0f
if (_direction == Axis.HORIZONTAL) {
assert(textBaseline != null)
TODO("Migration/Mihai: baselines")
@@ -831,11 +831,11 @@
when (_direction) {
Axis.HORIZONTAL -> {
overflowChildRect =
- Rect.fromLTWH(0.0, 0.0, size.width + overflow, 0.0)
+ Rect.fromLTWH(0.0f, 0.0f, size.width + overflow, 0.0f)
}
Axis.VERTICAL -> {
overflowChildRect =
- Rect.fromLTWH(0.0, 0.0, 0.0, size.height + overflow)
+ Rect.fromLTWH(0.0f, 0.0f, 0.0f, size.height + overflow)
}
}
// TODO(migration/Mihai): overflow indicator
@@ -865,4 +865,4 @@
properties.add(EnumProperty("verticalDirection", verticalDirection, defaultValue = null))
properties.add(EnumProperty("textBaseline", textBaseline, defaultValue = null))
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/rendering/layer/TransformLayer.kt b/ui/port/src/main/java/androidx/ui/rendering/layer/TransformLayer.kt
index ed54873d..17a0fea 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/layer/TransformLayer.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/layer/TransformLayer.kt
@@ -45,7 +45,7 @@
_lastEffectiveTransform!! *= Matrix4.translationValues(
totalOffset.dx,
totalOffset.dy,
- 0.0)
+ 0.0f)
}
builder.pushTransform(_lastEffectiveTransform!!)
addChildrenToScene(builder, Offset.zero)
diff --git a/ui/port/src/main/java/androidx/ui/rendering/obj/Constraints.kt b/ui/port/src/main/java/androidx/ui/rendering/obj/Constraints.kt
index f6c58a0..6984a145 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/obj/Constraints.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/obj/Constraints.kt
@@ -71,7 +71,7 @@
* This might involve checks more detailed than [isNormalized].
*
* For example, the [BoxConstraints] subclass verifies that the constraints
- * are not [double.nan].
+ * are not [Float.NaN].
*
* If the `isAppliedConstraint` argument is true, then even stricter rules
* are enforced. This argument is set to true when checking constraints that
diff --git a/ui/port/src/main/java/androidx/ui/rendering/obj/ContainerRenderObjectMixin.kt b/ui/port/src/main/java/androidx/ui/rendering/obj/ContainerRenderObjectMixin.kt
index c0e1379..5113606 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/obj/ContainerRenderObjectMixin.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/obj/ContainerRenderObjectMixin.kt
@@ -327,7 +327,7 @@
* Useful when the children are displayed vertically in the same order they
* appear in the child list.
*/
- fun defaultComputeDistanceToFirstActualBaseline(baseline: TextBaseline): Double {
+ fun defaultComputeDistanceToFirstActualBaseline(baseline: TextBaseline): Float {
TODO("Migration/Mihai: baselines")
// assert(!debugNeedsLayout);
// ChildType child = firstChild;
@@ -347,7 +347,7 @@
* Useful when the vertical position of the children isn't determined by the
* order in the child list.
*/
- fun defaultComputeDistanceToHighestActualBaseline(baseline: TextBaseline): Double {
+ fun defaultComputeDistanceToHighestActualBaseline(baseline: TextBaseline): Float {
TODO("Migration/Mihai: baselines")
// assert(!debugNeedsLayout);
// double result;
@@ -425,4 +425,4 @@
}
return result
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/rendering/paragraph/RenderParagraph.kt b/ui/port/src/main/java/androidx/ui/rendering/paragraph/RenderParagraph.kt
index 17291b8..85642f0 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/paragraph/RenderParagraph.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/paragraph/RenderParagraph.kt
@@ -29,14 +29,21 @@
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
import androidx.ui.foundation.diagnostics.DiagnosticsNode
import androidx.ui.foundation.diagnostics.DiagnosticsTreeStyle
-import androidx.ui.foundation.diagnostics.DoubleProperty
import androidx.ui.foundation.diagnostics.EnumProperty
import androidx.ui.foundation.diagnostics.FlagProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.foundation.diagnostics.IntProperty
-import androidx.ui.painting.*
-import androidx.ui.rendering.box.RenderBox
+import androidx.ui.painting.BlendMode
+import androidx.ui.painting.Canvas
+import androidx.ui.painting.Color
+import androidx.ui.painting.Gradient
+import androidx.ui.painting.Paint
+import androidx.ui.painting.Shader
+import androidx.ui.painting.TextPainter
+import androidx.ui.painting.TextSpan
import androidx.ui.painting.basictypes.RenderComparison
import androidx.ui.rendering.box.BoxConstraints
+import androidx.ui.rendering.box.RenderBox
import androidx.ui.rendering.debugRepaintTextRainbowEnabled
import androidx.ui.rendering.obj.PaintingContext
import androidx.ui.semantics.SemanticsConfiguration
@@ -85,7 +92,7 @@
textDirection: TextDirection,
softWrap: Boolean = true,
overflow: TextOverflow = TextOverflow.CLIP,
- textScaleFactor: Double = 1.0,
+ textScaleFactor: Float = 1.0f,
maxLines: Int? = null
) : RenderBox() {
@VisibleForTesting
@@ -161,7 +168,7 @@
markNeedsLayout()
}
- var textScaleFactor: Double
+ var textScaleFactor: Float
set(value) {
if (textPainter.textScaleFactor == value) return
textPainter.textScaleFactor = value
@@ -184,17 +191,17 @@
return textPainter.maxLines
}
- val width: Double
+ val width: Float
get() = textPainter.width
- val height: Double
+ val height: Float
get() = textPainter.height
- fun layoutText(minWidth: Double = 0.0, maxWidth: Double = Double.POSITIVE_INFINITY) {
+ fun layoutText(minWidth: Float = 0.0f, maxWidth: Float = Float.POSITIVE_INFINITY) {
val widthMatters = softWrap || overflow == TextOverflow.ELLIPSIS
textPainter.layout(
minWidth = minWidth, maxWidth =
- if (widthMatters) maxWidth else Double.POSITIVE_INFINITY
+ if (widthMatters) maxWidth else Float.POSITIVE_INFINITY
)
}
@@ -202,31 +209,31 @@
layoutText(minWidth = constraints.minWidth, maxWidth = constraints.maxWidth)
}
- public override fun computeMinIntrinsicWidth(height: Double): Double {
+ public override fun computeMinIntrinsicWidth(height: Float): Float {
layoutText()
return textPainter.minIntrinsicWidth
}
- public override fun computeMaxIntrinsicWidth(height: Double): Double {
+ public override fun computeMaxIntrinsicWidth(height: Float): Float {
layoutText()
return textPainter.maxIntrinsicWidth
}
@VisibleForTesting
- internal fun computeIntrinsicHeight(width: Double): Double {
+ internal fun computeIntrinsicHeight(width: Float): Float {
layoutText(minWidth = width, maxWidth = width)
return textPainter.height
}
- public override fun computeMinIntrinsicHeight(width: Double): Double {
+ public override fun computeMinIntrinsicHeight(width: Float): Float {
return computeIntrinsicHeight(width)
}
- public override fun computeMaxIntrinsicHeight(width: Double): Double {
+ public override fun computeMaxIntrinsicHeight(width: Float): Float {
return computeIntrinsicHeight(width)
}
- public override fun computeDistanceToActualBaseline(baseline: TextBaseline): Double {
+ public override fun computeDistanceToActualBaseline(baseline: TextBaseline): Float {
assert(!debugNeedsLayout)
// TODO(Migration/qqd): Need to figure out where this constraints come from and how to make
// it non-null.
@@ -292,11 +299,11 @@
)
fadeSizePainter.layout()
if (didOverflowWidth) {
- val fadeEnd: Double
- val fadeStart: Double
+ var fadeEnd: Float
+ var fadeStart: Float
when (textDirection) {
TextDirection.RTL -> {
- fadeEnd = 0.0
+ fadeEnd = 0.0f
fadeStart = fadeSizePainter.width
}
TextDirection.LTR -> {
@@ -305,16 +312,16 @@
}
}
overflowShader = Gradient.linear(
- Offset(fadeStart, 0.0),
- Offset(fadeEnd, 0.0),
- listOf(Color(0xFFFFFFFF.toInt()), Color(0x00FFFFFF.toInt()))
+ Offset(fadeStart, 0.0f),
+ Offset(fadeEnd, 0.0f),
+ listOf(Color(0xFFFFFFFF.toInt()), Color(0x00FFFFFF))
)
} else {
val fadeEnd = size.height
- val fadeStart = fadeEnd - fadeSizePainter.height / 2.0
+ val fadeStart = fadeEnd - fadeSizePainter.height / 2.0f
overflowShader = Gradient.linear(
- Offset(0.0, fadeStart),
- Offset(0.0, fadeEnd),
+ Offset(0.0f, fadeStart),
+ Offset(0.0f, fadeEnd),
listOf(Color(0xFFFFFFFF.toInt()), Color(0x00FFFFFF))
)
}
@@ -475,7 +482,7 @@
)
properties.add(EnumProperty<TextOverflow>("overflow", overflow))
properties.add(
- DoubleProperty.create(
+ FloatProperty.create(
"textScaleFactor",
textScaleFactor,
defaultValue = 1.0
diff --git a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderAspectRatio.kt b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderAspectRatio.kt
index c623a25..6f6e183 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderAspectRatio.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderAspectRatio.kt
@@ -22,7 +22,7 @@
import androidx.ui.rendering.box.BoxConstraints
import androidx.ui.rendering.box.RenderBox
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
// /// Attempts to size the child to a specific aspect ratio.
// ///
@@ -57,40 +57,40 @@
// /// The aspect ratio is expressed as a ratio of width to height. For example,
// /// a 16:9 width:height aspect ratio would have a value of 16.0/9.0. It must
// /// be a finite, positive value.
- aspectRatio: Double
+ aspectRatio: Float
) : RenderProxyBox(child) {
init {
- assert(aspectRatio > 0.0)
+ assert(aspectRatio > 0.0f)
assert(aspectRatio.isFinite())
}
- var aspectRatio: Double = aspectRatio
+ var aspectRatio: Float = aspectRatio
set(value) {
- assert(value > 0.0)
+ assert(value > 0.0f)
assert(value.isFinite())
if (field == value) return
field = value
markNeedsLayout()
}
- override fun computeMinIntrinsicWidth(height: Double): Double {
+ override fun computeMinIntrinsicWidth(height: Float): Float {
if (height.isFinite()) return height * aspectRatio
- return child?.getMinIntrinsicWidth(height) ?: 0.0
+ return child?.getMinIntrinsicWidth(height) ?: 0.0f
}
- override fun computeMaxIntrinsicWidth(height: Double): Double {
+ override fun computeMaxIntrinsicWidth(height: Float): Float {
if (height.isFinite()) return height * aspectRatio
- return child?.getMaxIntrinsicWidth(height) ?: 0.0
+ return child?.getMaxIntrinsicWidth(height) ?: 0.0f
}
- override fun computeMinIntrinsicHeight(width: Double): Double {
+ override fun computeMinIntrinsicHeight(width: Float): Float {
if (width.isFinite()) return width / aspectRatio
- return child?.getMinIntrinsicHeight(width) ?: 0.0
+ return child?.getMinIntrinsicHeight(width) ?: 0.0f
}
- override fun computeMaxIntrinsicHeight(width: Double): Double {
+ override fun computeMaxIntrinsicHeight(width: Float): Float {
if (width.isFinite()) return width / aspectRatio
- return child?.getMaxIntrinsicHeight(width) ?: 0.0
+ return child?.getMaxIntrinsicHeight(width) ?: 0.0f
}
private fun applyAspectRatio(constraints: BoxConstraints): Size {
@@ -111,8 +111,8 @@
if (constraints.isTight) return constraints.smallest
- var width: Double = constraints.maxWidth
- var height: Double
+ var width: Float = constraints.maxWidth
+ var height: Float
// We default to picking the height based on the width, but if the width
// would be infinite, that's not sensible so we try to infer the height
@@ -159,6 +159,6 @@
override fun debugFillProperties(properties: DiagnosticPropertiesBuilder) {
super.debugFillProperties(properties)
- properties.add(DoubleProperty.create("aspectRatio", aspectRatio))
+ properties.add(FloatProperty.create("aspectRatio", aspectRatio))
}
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderConstrainedBox.kt b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderConstrainedBox.kt
index 86e4502..0615d87 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderConstrainedBox.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderConstrainedBox.kt
@@ -64,7 +64,7 @@
markNeedsLayout()
}
- override fun computeMinIntrinsicWidth(height: Double): Double {
+ override fun computeMinIntrinsicWidth(height: Float): Float {
if (_additionalConstraints.hasBoundedWidth && _additionalConstraints.hasTightWidth)
return _additionalConstraints.minWidth
val width = super.computeMinIntrinsicWidth(height)
@@ -73,7 +73,7 @@
return width
}
- override fun computeMaxIntrinsicWidth(height: Double): Double {
+ override fun computeMaxIntrinsicWidth(height: Float): Float {
if (_additionalConstraints.hasBoundedWidth && _additionalConstraints.hasTightWidth)
return _additionalConstraints.minWidth
val width = super.computeMaxIntrinsicWidth(height)
@@ -82,7 +82,7 @@
return width
}
- override fun computeMinIntrinsicHeight(width: Double): Double {
+ override fun computeMinIntrinsicHeight(width: Float): Float {
if (_additionalConstraints.hasBoundedHeight && _additionalConstraints.hasTightHeight)
return _additionalConstraints.minHeight
val height = super.computeMinIntrinsicHeight(width)
@@ -91,7 +91,7 @@
return height
}
- override fun computeMaxIntrinsicHeight(width: Double): Double {
+ override fun computeMaxIntrinsicHeight(width: Float): Float {
if (_additionalConstraints.hasBoundedHeight && _additionalConstraints.hasTightHeight)
return _additionalConstraints.minHeight
val height = super.computeMaxIntrinsicHeight(width)
diff --git a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderCustomClip.kt b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderCustomClip.kt
index 38b81d0..15ced3f 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderCustomClip.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderCustomClip.kt
@@ -99,25 +99,25 @@
assert {
debugPaint = debugPaint ?: Paint().apply {
shader = Gradient.linear(
- Offset(0.0, 0.0),
- Offset(10.0, 10.0),
+ Offset(0.0f, 0.0f),
+ Offset(10.0f, 10.0f),
listOf(
Color(0x00000000),
Color(0xFFFF00FF.toInt()),
Color(0xFFFF00FF.toInt()),
Color(0x00000000)
),
- listOf(0.25, 0.25, 0.75, 0.75),
+ listOf(0.25f, 0.25f, 0.75f, 0.75f),
TileMode.repeated
)
- strokeWidth = 2.0
+ strokeWidth = 2.0f
style = PaintingStyle.stroke
debugText = debugText ?: TextPainter(
text = TextSpan(
text = "✂",
style = TextStyle(
color = Color(0xFFFF00FF.toInt()),
- fontSize = 14.0
+ fontSize = 14.0f
)
),
textDirection = TextDirection.RTL // doesn't matter, it's one character
diff --git a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderIntrinsicHeight.kt b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderIntrinsicHeight.kt
index e4596a0..2f43252 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderIntrinsicHeight.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderIntrinsicHeight.kt
@@ -35,27 +35,27 @@
) : RenderProxyBox(child) {
/** Creates a render object that sizes itself to its child's intrinsic height. */
- override fun computeMinIntrinsicWidth(height: Double): Double {
+ override fun computeMinIntrinsicWidth(height: Float): Float {
if (child == null)
- return 0.0
+ return 0.0f
var resultHeight = height
if (!resultHeight.isFinite())
- resultHeight = child!!.getMaxIntrinsicHeight(Double.POSITIVE_INFINITY)
+ resultHeight = child!!.getMaxIntrinsicHeight(Float.POSITIVE_INFINITY)
assert(resultHeight.isFinite())
return child!!.getMinIntrinsicWidth(resultHeight)
}
- override fun computeMaxIntrinsicWidth(height: Double): Double {
+ override fun computeMaxIntrinsicWidth(height: Float): Float {
if (child == null)
- return 0.0
+ return 0.0f
var resultHeight = height
if (!resultHeight.isFinite())
- resultHeight = child!!.getMaxIntrinsicHeight(Double.POSITIVE_INFINITY)
+ resultHeight = child!!.getMaxIntrinsicHeight(Float.POSITIVE_INFINITY)
assert(resultHeight.isFinite())
return child!!.getMaxIntrinsicWidth(resultHeight)
}
- override fun computeMinIntrinsicHeight(width: Double): Double {
+ override fun computeMinIntrinsicHeight(width: Float): Float {
return computeMaxIntrinsicHeight(width)
}
diff --git a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderIntrinsicWidth.kt b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderIntrinsicWidth.kt
index d8dc860..06d7e49 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderIntrinsicWidth.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderIntrinsicWidth.kt
@@ -17,9 +17,10 @@
package androidx.ui.rendering.proxybox
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.rendering.box.BoxConstraints
import androidx.ui.rendering.box.RenderBox
+import kotlin.math.ceil
/**
* Sizes its child to the child's intrinsic width.
@@ -39,14 +40,14 @@
* depth of the tree.
*/
class RenderIntrinsicWidth(
- private var _stepWidth: Double? = null,
- private var _stepHeight: Double? = null,
+ private var _stepWidth: Float? = null,
+ private var _stepHeight: Float? = null,
child: RenderBox? = null
) : RenderProxyBox(child) {
/** Creates a render object that sizes itself to its child's intrinsic width. */
/** If non-null, force the child's width to be a multiple of this value. */
- var stepWidth: Double?
+ var stepWidth: Float?
get() { return _stepWidth }
set(value) {
if (value == _stepWidth)
@@ -56,7 +57,7 @@
}
/** If non-null, force the child's height to be a multiple of this value. */
- var stepHeight: Double?
+ var stepHeight: Float?
get() { return _stepHeight }
set(value) {
if (value == _stepHeight)
@@ -66,40 +67,40 @@
}
companion object {
- internal fun _applyStep(input: Double, step: Double?): Double {
+ internal fun _applyStep(input: Float, step: Float?): Float {
assert(input.isFinite())
if (step == null)
return input
- return Math.ceil(input / step) * step
+ return ceil(input / step) * step
}
}
- override fun computeMinIntrinsicWidth(height: Double) = computeMaxIntrinsicWidth(height)
+ override fun computeMinIntrinsicWidth(height: Float) = computeMaxIntrinsicWidth(height)
- override fun computeMaxIntrinsicWidth(height: Double): Double {
+ override fun computeMaxIntrinsicWidth(height: Float): Float {
if (child == null)
- return 0.0
+ return 0.0f
val width = child!!.getMaxIntrinsicWidth(height)
return _applyStep(width, _stepWidth)
}
- override fun computeMinIntrinsicHeight(width: Double): Double {
+ override fun computeMinIntrinsicHeight(width: Float): Float {
var resultWidth = width
if (child == null)
- return 0.0
+ return 0.0f
if (!resultWidth.isFinite())
- resultWidth = computeMaxIntrinsicWidth(Double.POSITIVE_INFINITY)
+ resultWidth = computeMaxIntrinsicWidth(Float.POSITIVE_INFINITY)
assert(resultWidth.isFinite())
val height = child!!.getMinIntrinsicHeight(resultWidth)
return _applyStep(height, _stepHeight)
}
- override fun computeMaxIntrinsicHeight(width: Double): Double {
+ override fun computeMaxIntrinsicHeight(width: Float): Float {
var resultWidth = width
if (child == null)
- return 0.0
+ return 0.0f
if (!resultWidth.isFinite())
- resultWidth = computeMaxIntrinsicWidth(Double.POSITIVE_INFINITY)
+ resultWidth = computeMaxIntrinsicWidth(Float.POSITIVE_INFINITY)
assert(resultWidth.isFinite())
val height = child!!.getMaxIntrinsicHeight(resultWidth)
return _applyStep(height, _stepHeight)
@@ -128,7 +129,7 @@
override fun debugFillProperties(properties: DiagnosticPropertiesBuilder) {
super.debugFillProperties(properties)
- properties.add(DoubleProperty.create("stepWidth", stepWidth))
- properties.add(DoubleProperty.create("stepHeight", stepHeight))
+ properties.add(FloatProperty.create("stepWidth", stepWidth))
+ properties.add(FloatProperty.create("stepHeight", stepHeight))
}
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderPhysicalShape.kt b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderPhysicalShape.kt
index 86812e0..3c7cef4 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderPhysicalShape.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderPhysicalShape.kt
@@ -20,7 +20,7 @@
import androidx.ui.engine.geometry.Offset
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
import androidx.ui.foundation.diagnostics.DiagnosticsProperty
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.gestures.hit_test.HitTestResult
import androidx.ui.painting.Color
import androidx.ui.painting.Paint
@@ -48,7 +48,7 @@
class RenderPhysicalShape(
child: RenderBox? = null,
clipper: CustomClipper<Path>,
- elevation: Double,
+ elevation: Float,
color: Color,
shadowColor: Color = Color(0xFF000000.toInt())
) : RenderPhysicalModelBase<Path>(child, elevation, color, shadowColor, clipper) {
@@ -79,7 +79,7 @@
Paint().apply {
color = shadowColor
style = PaintingStyle.stroke
- strokeWidth = elevation * 2.0
+ strokeWidth = elevation * 2.0f
}
)
}
@@ -98,13 +98,13 @@
// context.pushLayer(physicalModel, super.paint, offset, childPaintBounds= offsetBounds);
} else {
val canvas = context.canvas
- if (elevation != 0.0 && paintShadows) {
+ if (elevation != 0.0f && paintShadows) {
// The drawShadow call doesn't add the region of the shadow to the
// picture's bounds, so we draw a hardcoded amount of extra space to
// account for the maximum potential area of the shadow.
// TODO(jsimmons): remove this when Skia does it for us.
canvas.drawRect(
- offsetBounds.inflate(20.0),
+ offsetBounds.inflate(20.0f),
transparentPaint
)
TODO("Migration|Andrey: Needs canvas.drawShadow")
@@ -145,7 +145,7 @@
*/
abstract class RenderPhysicalModelBase<T>(
child: RenderBox?,
- elevation: Double,
+ elevation: Float,
color: Color,
shadowColor: Color,
clipper: CustomClipper<T>?
@@ -157,7 +157,7 @@
* If [debugDisableShadows] is set, this value is ignored and no shadow is
* drawn (an outline is rendered instead).
*/
- var elevation: Double = elevation
+ var elevation: Float = elevation
set(value) {
if (field == value)
return
@@ -194,7 +194,7 @@
override fun debugFillProperties(properties: DiagnosticPropertiesBuilder) {
super.debugFillProperties(properties)
- properties.add(DoubleProperty.create("elevation", elevation))
+ properties.add(FloatProperty.create("elevation", elevation))
properties.add(DiagnosticsProperty.create("color", color))
properties.add(DiagnosticsProperty.create("shadowColor", color))
}
diff --git a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderProxyBoxMixin.kt b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderProxyBoxMixin.kt
index fc0ae9a..fdd6c09 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderProxyBoxMixin.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderProxyBoxMixin.kt
@@ -52,20 +52,20 @@
}
}
- override fun computeMinIntrinsicWidth(height: Double): Double {
- return child?.getMinIntrinsicWidth(height) ?: 0.0
+ override fun computeMinIntrinsicWidth(height: Float): Float {
+ return child?.getMinIntrinsicWidth(height) ?: 0.0f
}
- override fun computeMaxIntrinsicWidth(height: Double): Double {
- return child?.getMaxIntrinsicWidth(height) ?: 0.0
+ override fun computeMaxIntrinsicWidth(height: Float): Float {
+ return child?.getMaxIntrinsicWidth(height) ?: 0.0f
}
- override fun computeMinIntrinsicHeight(width: Double): Double {
- return child?.getMinIntrinsicHeight(width) ?: 0.0
+ override fun computeMinIntrinsicHeight(width: Float): Float {
+ return child?.getMinIntrinsicHeight(width) ?: 0.0f
}
- override fun computeMaxIntrinsicHeight(width: Double): Double {
- return child?.getMaxIntrinsicHeight(width) ?: 0.0
+ override fun computeMaxIntrinsicHeight(width: Float): Float {
+ return child?.getMaxIntrinsicHeight(width) ?: 0.0f
}
// TODO(Migration/Andrey): Needs TextBaseline
diff --git a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderSemanticsGestureHandler.kt b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderSemanticsGestureHandler.kt
index 920b0b3..e1e3ec2 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderSemanticsGestureHandler.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/proxybox/RenderSemanticsGestureHandler.kt
@@ -46,7 +46,7 @@
* accessibility system, it will translate into a 160 pixel
* leftwards drag.
*/
- val scrollFactor: Double = 0.8
+ val scrollFactor: Float = 0.8f
) : RenderProxyBox(
child
) {
@@ -142,7 +142,7 @@
var primaryDelta = size.width * -scrollFactor
it(
DragUpdateDetails(
- delta = Offset(dx = primaryDelta, dy = 0.0),
+ delta = Offset(dx = primaryDelta, dy = 0.0f),
primaryDelta = primaryDelta,
globalPosition = this.localToGlobal(size.center(Offset.zero))
)
@@ -155,7 +155,7 @@
var primaryDelta = size.width * scrollFactor
it(
DragUpdateDetails(
- delta = Offset(dx = primaryDelta, dy = 0.0),
+ delta = Offset(dx = primaryDelta, dy = 0.0f),
primaryDelta = primaryDelta,
globalPosition = this.localToGlobal(size.center(Offset.zero))
)
@@ -168,7 +168,7 @@
var primaryDelta = size.height * -scrollFactor
it(
DragUpdateDetails(
- delta = Offset(dx = 0.0, dy = primaryDelta),
+ delta = Offset(dx = 0.0f, dy = primaryDelta),
primaryDelta = primaryDelta,
globalPosition = this.localToGlobal(size.center(Offset.zero))
)
@@ -181,7 +181,7 @@
var primaryDelta = size.height * scrollFactor
it(
DragUpdateDetails(
- delta = Offset(dx = 0.0, dy = primaryDelta),
+ delta = Offset(dx = 0.0f, dy = primaryDelta),
primaryDelta = primaryDelta,
globalPosition = this.localToGlobal(size.center(Offset.zero))
)
diff --git a/ui/port/src/main/java/androidx/ui/rendering/shiftedbox/RenderPositionedBox.kt b/ui/port/src/main/java/androidx/ui/rendering/shiftedbox/RenderPositionedBox.kt
index ecf4eea..c12427a 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/shiftedbox/RenderPositionedBox.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/shiftedbox/RenderPositionedBox.kt
@@ -19,8 +19,9 @@
import androidx.ui.assert
import androidx.ui.engine.geometry.Offset
import androidx.ui.engine.geometry.Size
+import androidx.ui.engine.text.TextDirection
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.painting.Color
import androidx.ui.painting.Paint
import androidx.ui.painting.PaintingStyle
@@ -30,7 +31,7 @@
import androidx.ui.rendering.box.BoxParentData
import androidx.ui.rendering.box.RenderBox
import androidx.ui.rendering.obj.PaintingContext
-import androidx.ui.engine.text.TextDirection
+import kotlin.math.min
/**
* Positions its child using a [AlignmentGeometry].
@@ -46,8 +47,8 @@
*/
class RenderPositionedBox(
child: RenderBox? = null,
- widthFactor: Double? = null,
- heightFactor: Double? = null,
+ widthFactor: Float? = null,
+ heightFactor: Float? = null,
alignment: AlignmentGeometry = Alignment.center,
textDirection: TextDirection? = null
) : RenderAligningShiftedBox(
@@ -57,22 +58,22 @@
) {
init {
- assert(widthFactor == null || widthFactor >= 0.0)
- assert(heightFactor == null || heightFactor >= 0.0)
+ assert(widthFactor == null || widthFactor >= 0.0f)
+ assert(heightFactor == null || heightFactor >= 0.0f)
}
- var _widthFactor: Double? = widthFactor
- var _heightFactor: Double? = heightFactor
+ var _widthFactor: Float? = widthFactor
+ var _heightFactor: Float? = heightFactor
/**
* If non-null, sets its width to the child's width multiplied by this factor.
*
* Can be both greater and less than 1.0 but must be positive.
*/
- var widthFactor: Double?
+ var widthFactor: Float?
get() = _widthFactor
set(value) {
- assert(value == null || value >= 0.0)
+ assert(value == null || value >= 0.0f)
if (_widthFactor == value)
return
_widthFactor = value
@@ -84,10 +85,10 @@
*
* Can be both greater and less than 1.0 but must be positive.
*/
- var heightFactor: Double?
+ var heightFactor: Float?
get() = _heightFactor
set(value) {
- assert(value == null || value >= 0.0)
+ assert(value == null || value >= 0.0f)
if (_heightFactor == value)
return
_heightFactor = value
@@ -96,31 +97,31 @@
override fun performLayout() {
val shrinkWrapWidth = _widthFactor != null ||
- constraints!!.maxWidth == Double.POSITIVE_INFINITY
+ constraints!!.maxWidth == Float.POSITIVE_INFINITY
val shrinkWrapHeight = _heightFactor != null ||
- constraints!!.maxHeight == Double.POSITIVE_INFINITY
+ constraints!!.maxHeight == Float.POSITIVE_INFINITY
if (child != null) {
child!!.layout(constraints!!.loosen(), parentUsesSize = true)
size = constraints!!.constrain(
Size(
if (shrinkWrapWidth) {
- child!!.size.width * (_widthFactor ?: 1.0)
+ child!!.size.width * (_widthFactor ?: 1.0f)
} else {
- Double.POSITIVE_INFINITY
+ Float.POSITIVE_INFINITY
},
if (shrinkWrapHeight) {
- child!!.size.height * (_heightFactor ?: 1.0)
+ child!!.size.height * (_heightFactor ?: 1.0f)
} else {
- Double.POSITIVE_INFINITY
+ Float.POSITIVE_INFINITY
}
))
alignChild()
} else {
size = constraints!!.constrain(
Size(
- if (shrinkWrapWidth) 0.0 else Double.POSITIVE_INFINITY,
- if (shrinkWrapHeight) 0.0 else Double.POSITIVE_INFINITY
+ if (shrinkWrapWidth) 0.0f else Float.POSITIVE_INFINITY,
+ if (shrinkWrapHeight) 0.0f else Float.POSITIVE_INFINITY
))
}
}
@@ -132,16 +133,16 @@
if (child != null && !child!!.size.isEmpty()) {
paint = Paint().let {
it.style = PaintingStyle.stroke
- it.strokeWidth = 1.0
+ it.strokeWidth = 1.0f
it.color = Color(0xFFFFFF00.toInt())
it
}
var path = Path()
val childParentData = child!!.parentData as BoxParentData
- if (childParentData.offset.dy > 0.0) {
+ if (childParentData.offset.dy > 0.0f) {
// vertical alignment arrows
- val headSize: Double = Math.min(childParentData.offset.dy * 0.2, 10.0)
+ val headSize: Float = min(childParentData.offset.dy * 0.2f, 10.0f)
TODO("Migration/Filip: Wait for Path to be migrated")
// path
// ..moveTo(offset.dx + size.width / 2.0, offset.dy)
@@ -158,9 +159,9 @@
// ..relativeLineTo(headSize, 0.0);
context.canvas.drawPath(path, paint)
}
- if (childParentData.offset.dx > 0.0) {
+ if (childParentData.offset.dx > 0.0f) {
// horizontal alignment arrows
- val headSize: Double = Math.min(childParentData.offset.dx * 0.2, 10.0)
+ val headSize: Float = min(childParentData.offset.dx * 0.2f, 10.0f)
TODO("Migration/Filip: Wait for Path to be migrated")
// path
// ..moveTo(offset.dx, offset.dy + size.height / 2.0)
@@ -190,7 +191,7 @@
override fun debugFillProperties(properties: DiagnosticPropertiesBuilder) {
super.debugFillProperties(properties)
- properties.add(DoubleProperty.create("widthFactor", _widthFactor, ifNull = "expand"))
- properties.add(DoubleProperty.create("heightFactor", _heightFactor, ifNull = "expand"))
+ properties.add(FloatProperty.create("widthFactor", _widthFactor, ifNull = "expand"))
+ properties.add(FloatProperty.create("heightFactor", _heightFactor, ifNull = "expand"))
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/rendering/shiftedbox/RenderShiftedBox.kt b/ui/port/src/main/java/androidx/ui/rendering/shiftedbox/RenderShiftedBox.kt
index 73b92e9..5d91969 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/shiftedbox/RenderShiftedBox.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/shiftedbox/RenderShiftedBox.kt
@@ -35,28 +35,28 @@
markAsLayoutOnlyNode()
}
- override fun computeMinIntrinsicWidth(height: Double): Double {
+ override fun computeMinIntrinsicWidth(height: Float): Float {
if (child != null)
return child!!.getMinIntrinsicWidth(height)
- return 0.0
+ return 0.0f
}
- override fun computeMaxIntrinsicWidth(height: Double): Double {
+ override fun computeMaxIntrinsicWidth(height: Float): Float {
if (child != null)
return child!!.getMaxIntrinsicWidth(height)
- return 0.0
+ return 0.0f
}
- override fun computeMinIntrinsicHeight(width: Double): Double {
+ override fun computeMinIntrinsicHeight(width: Float): Float {
if (child != null)
return child!!.getMinIntrinsicHeight(width)
- return 0.0
+ return 0.0f
}
- override fun computeMaxIntrinsicHeight(width: Double): Double {
+ override fun computeMaxIntrinsicHeight(width: Float): Float {
if (child != null)
return child!!.getMaxIntrinsicHeight(width)
- return 0.0
+ return 0.0f
}
// @override
@@ -88,4 +88,4 @@
}
return false
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/rendering/view/RenderView.kt b/ui/port/src/main/java/androidx/ui/rendering/view/RenderView.kt
index 6fbe1eb..3d9673f 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/view/RenderView.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/view/RenderView.kt
@@ -12,7 +12,7 @@
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
import androidx.ui.foundation.diagnostics.DiagnosticsNode
import androidx.ui.foundation.diagnostics.DiagnosticsProperty
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.foundation.timelineWhitelistArguments
import androidx.ui.gestures.hit_test.HitTestEntry
import androidx.ui.gestures.hit_test.HitTestResult
@@ -198,7 +198,7 @@
}
properties.add(DiagnosticsProperty.create("window size",
window.physicalSize, tooltip = "in physical pixels"))
- properties.add(DoubleProperty.create("device pixel ratio",
+ properties.add(FloatProperty.create("device pixel ratio",
window.devicePixelRatio, tooltip = "physical pixels per logical pixel"))
properties.add(DiagnosticsProperty.create("configuration",
configuration, tooltip = "in logical pixels"))
diff --git a/ui/port/src/main/java/androidx/ui/rendering/view/ViewConfiguration.kt b/ui/port/src/main/java/androidx/ui/rendering/view/ViewConfiguration.kt
index 0a30c64..4751064 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/view/ViewConfiguration.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/view/ViewConfiguration.kt
@@ -10,14 +10,14 @@
// @immutable
data class ViewConfiguration(
val size: Size = Size.zero, // / The size of the output surface.
- val devicePixelRatio: Double = 1.0 // / The pixel density of the output surface.
+ val devicePixelRatio: Float = 1.0f // / The pixel density of the output surface.
) {
/** Creates a transformation matrix that applies the [devicePixelRatio]. */
fun toMatrix(): Matrix4 {
// TODO("Migration|Andrey: Flutter uses DPs for drawing on canvas, but we use pixels now")
-// return Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 1.0)
- return Matrix4.diagonal3Values(1.0, 1.0, 1.0)
+// return Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 1.0f)
+ return Matrix4.diagonal3Values(1.0f, 1.0f, 1.0f)
}
override fun toString(): String {
diff --git a/ui/port/src/main/java/androidx/ui/rendering/viewport_offset/FixedViewportOffset.kt b/ui/port/src/main/java/androidx/ui/rendering/viewport_offset/FixedViewportOffset.kt
index 074e1d7..d88b6d7 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/viewport_offset/FixedViewportOffset.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/viewport_offset/FixedViewportOffset.kt
@@ -24,33 +24,33 @@
/**
* A ViewportOffset implementation for the fixed pixel.
*/
-internal class FixedViewportOffset(pixels: Double) : ViewportOffset() {
+internal class FixedViewportOffset(pixels: Float) : ViewportOffset() {
companion object {
fun zero(): FixedViewportOffset {
- return FixedViewportOffset(0.0)
+ return FixedViewportOffset(0.0f)
}
}
- override var pixels: Double = pixels
+ override var pixels: Float = pixels
get() = field
- private set(pixels: Double) {
+ private set(pixels: Float) {
field = pixels
}
- override fun applyContentDimensions(minScrollExtent: Double, maxScrollExtent: Double): Boolean =
+ override fun applyContentDimensions(minScrollExtent: Float, maxScrollExtent: Float): Boolean =
true
- override fun applyViewportDimension(viewportDimension: Double): Boolean = true
+ override fun applyViewportDimension(viewportDimension: Float): Boolean = true
- override fun correctBy(correction: Double) {
+ override fun correctBy(correction: Float) {
pixels += correction
}
- override fun jumpTo(pixels: Double) {
+ override fun jumpTo(pixels: Float) {
// Do nothing, viewport is fixed.
}
- override fun animateTo(to: Double, duration: Duration?, curve: Curve?): Deferred<Unit> {
+ override fun animateTo(to: Float, duration: Duration?, curve: Curve?): Deferred<Unit> {
return CompletableDeferred(Unit)
}
diff --git a/ui/port/src/main/java/androidx/ui/rendering/viewport_offset/ViewportOffset.kt b/ui/port/src/main/java/androidx/ui/rendering/viewport_offset/ViewportOffset.kt
index 0383e8c..2060f72 100644
--- a/ui/port/src/main/java/androidx/ui/rendering/viewport_offset/ViewportOffset.kt
+++ b/ui/port/src/main/java/androidx/ui/rendering/viewport_offset/ViewportOffset.kt
@@ -51,7 +51,7 @@
*
* The [pixels] value does not change unless the viewport issues a correction.
*/
- fun fixed(value: Double): ViewportOffset {
+ fun fixed(value: Float): ViewportOffset {
return FixedViewportOffset(value)
}
@@ -76,7 +76,7 @@
* This object notifies its listeners when this value changes (except when the value changes due
* to [correctBy]).
*/
- abstract val pixels: Double
+ abstract val pixels: Float
/**
* Called when the viewport's extents are established.
@@ -101,7 +101,7 @@
* these viewport dimensions unconditionally?"; if the new dimensions change the
* [ViewportOffset]'s actual [pixels] value, then the viewport will need to be laid out again.)
*/
- abstract fun applyViewportDimension(viewportDimension: Double): Boolean
+ abstract fun applyViewportDimension(viewportDimension: Float): Boolean
/**
* Called when the viewport's content extents are established.
@@ -125,7 +125,7 @@
* returns false). This is always called after [applyViewportDimension], if that method is
* called.
*/
- abstract fun applyContentDimensions(minScrollExtent: Double, maxScrollExtent: Double): Boolean
+ abstract fun applyContentDimensions(minScrollExtent: Float, maxScrollExtent: Float): Boolean
/**
* Apply a layout-time correction to the scroll offset.
@@ -140,7 +140,7 @@
* * [jumpTo], for also changing the scroll position when not in layout.
* [jumpTo] applies the change immediately and notifies its listeners.
*/
- abstract fun correctBy(correction: Double)
+ abstract fun correctBy(correction: Float)
/**
* Jumps [pixels] from its current value to the given value, without animation, and without
@@ -151,7 +151,7 @@
* * [correctBy], for changing the current offset in the middle of layout and that defers the
* notification of its listeners until after layout.
*/
- abstract fun jumpTo(pixels: Double)
+ abstract fun jumpTo(pixels: Float)
/**
* Animates [pixels] from its current value to the given value.
@@ -162,7 +162,7 @@
* The duration must not be zero. To jump to a particular value without an animation, use
* [jumpTo].
*/
- abstract fun animateTo(to: Double, duration: Duration?, curve: Curve?): Deferred<Unit>
+ abstract fun animateTo(to: Float, duration: Duration?, curve: Curve?): Deferred<Unit>
/**
* Calls [jumpTo] if duration is null or [Duration.zero], otherwise [animateTo] is called.
@@ -172,7 +172,7 @@
* adjusting [to] to prevent over or underscroll.
*/
fun moveTo(
- to: Double,
+ to: Float,
duration: Duration? = null,
curve: Curve? = null,
clamp: Boolean? = null
diff --git a/ui/port/src/main/java/androidx/ui/semantics/OrdinalSortKey.kt b/ui/port/src/main/java/androidx/ui/semantics/OrdinalSortKey.kt
index 040dfc1..c68bed0 100644
--- a/ui/port/src/main/java/androidx/ui/semantics/OrdinalSortKey.kt
+++ b/ui/port/src/main/java/androidx/ui/semantics/OrdinalSortKey.kt
@@ -1,10 +1,10 @@
package androidx.ui.semantics
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
/**
- * A [SemanticsSortKey] that sorts simply based on the `Double` value it is
+ * A [SemanticsSortKey] that sorts simply based on the `Float` value it is
* given.
*
* The [OrdinalSortKey] compares itself with other [OrdinalSortKey]s
@@ -12,8 +12,8 @@
*
* The ordinal value `order` is typically a whole number, though it can be
* fractional, e.g. in order to fit between two other consecutive whole
- * numbers. The value must be finite (it cannot be [Double.nan],
- * [Double.infinity], or [Double.negativeInfinity]).
+ * numbers. The value must be finite (it cannot be [Float.NaN],
+ * [Float.POSITIVE_INFINITY], or [Float.negativeInfinity]).
*
* See also:
*
@@ -27,15 +27,15 @@
*
* Lower values will be traversed first.
*/
- val order: Double,
+ val order: Float,
name: String? = null
) : SemanticsSortKey(name) {
init {
assert(order != null)
- assert(order != Double.NaN)
- assert(order > Double.NEGATIVE_INFINITY)
- assert(order < Double.POSITIVE_INFINITY)
+ assert(order != Float.NaN)
+ assert(order > Float.NEGATIVE_INFINITY)
+ assert(order < Float.POSITIVE_INFINITY)
}
override fun doCompare(other: SemanticsSortKey): Int {
@@ -47,6 +47,6 @@
override fun debugFillProperties(properties: DiagnosticPropertiesBuilder) {
super.debugFillProperties(properties)
- properties.add(DoubleProperty.create("order", order, defaultValue = null))
+ properties.add(FloatProperty.create("order", order, defaultValue = null))
}
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/semantics/SemanticsConfiguration.kt b/ui/port/src/main/java/androidx/ui/semantics/SemanticsConfiguration.kt
index 74feb42..d45f877 100644
--- a/ui/port/src/main/java/androidx/ui/semantics/SemanticsConfiguration.kt
+++ b/ui/port/src/main/java/androidx/ui/semantics/SemanticsConfiguration.kt
@@ -811,7 +811,7 @@
*
* * [ScrollPosition.pixels], from where this value is usually taken.
*/
- var scrollPosition: Double? by NonNullAnnotationProperty(null)
+ var scrollPosition: Float? by NonNullAnnotationProperty(null)
/**
* Indicates the maximum in-range value for [scrollPosition] if the node is
@@ -823,7 +823,7 @@
*
* * [ScrollPosition.maxScrollExtent], from where this value is usually taken.
*/
- var scrollExtentMax: Double? by NonNullAnnotationProperty(null)
+ var scrollExtentMax: Float? by NonNullAnnotationProperty(null)
/**
* Indicates the minimum in-range value for [scrollPosition] if the node is
@@ -835,7 +835,7 @@
*
* * [ScrollPosition.minScrollExtent], from where this value is usually taken.
*/
- var scrollExtentMin: Double? by NonNullAnnotationProperty(null)
+ var scrollExtentMin: Float? by NonNullAnnotationProperty(null)
// TAGS
@@ -1024,4 +1024,4 @@
}
return copy
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/semantics/SemanticsData.kt b/ui/port/src/main/java/androidx/ui/semantics/SemanticsData.kt
index d686aef..e46bb18 100644
--- a/ui/port/src/main/java/androidx/ui/semantics/SemanticsData.kt
+++ b/ui/port/src/main/java/androidx/ui/semantics/SemanticsData.kt
@@ -5,7 +5,7 @@
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
import androidx.ui.foundation.diagnostics.Diagnosticable
import androidx.ui.foundation.diagnostics.DiagnosticsProperty
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.foundation.diagnostics.EnumProperty
import androidx.ui.foundation.diagnostics.IterableProperty
import androidx.ui.foundation.diagnostics.MessageProperty
@@ -101,7 +101,7 @@
*
* * [ScrollPosition.pixels], from where this value is usually taken.
*/
- val scrollPosition: Double?,
+ val scrollPosition: Float?,
/**
* Indicates the maximum in-range value for [scrollPosition] if the node is
@@ -113,7 +113,7 @@
*
* * [ScrollPosition.maxScrollExtent], from where this value is usually taken.
*/
- val scrollExtentMax: Double?,
+ val scrollExtentMax: Float?,
/**
* Indicates the minimum in-range value for [scrollPosition] if the node is
@@ -125,7 +125,7 @@
*
* * [ScrollPosition.minScrollExtent], from where this value is usually taken.
*/
- val scrollExtentMin: Double?,
+ val scrollExtentMin: Float?,
/** The set of [SemanticsTag]s associated with this node. */
val tags: Set<SemanticsTag>,
@@ -210,21 +210,21 @@
)
)
properties.add(
- DoubleProperty.create(
+ FloatProperty.create(
"scrollExtentMin",
scrollExtentMin,
defaultValue = null
)
)
properties.add(
- DoubleProperty.create(
+ FloatProperty.create(
"scrollPosition",
scrollPosition,
defaultValue = null
)
)
properties.add(
- DoubleProperty.create(
+ FloatProperty.create(
"scrollExtentMax",
scrollExtentMax,
defaultValue = null
diff --git a/ui/port/src/main/java/androidx/ui/semantics/SemanticsNode.kt b/ui/port/src/main/java/androidx/ui/semantics/SemanticsNode.kt
index 6fcec22..9d3b4fe 100644
--- a/ui/port/src/main/java/androidx/ui/semantics/SemanticsNode.kt
+++ b/ui/port/src/main/java/androidx/ui/semantics/SemanticsNode.kt
@@ -1,13 +1,13 @@
package androidx.ui.semantics
import android.annotation.SuppressLint
-import androidx.ui.Float64List
import androidx.ui.Int32List
import androidx.ui.VoidCallback
import androidx.ui.assert
import androidx.ui.describeEnum
import androidx.ui.engine.geometry.Offset
import androidx.ui.engine.geometry.Rect
+import androidx.ui.engine.text.TextDirection
import androidx.ui.foundation.AbstractNode
import androidx.ui.foundation.Key
import androidx.ui.foundation.assertions.FlutterError
@@ -17,9 +17,9 @@
import androidx.ui.foundation.diagnostics.DiagnosticsNode
import androidx.ui.foundation.diagnostics.DiagnosticsProperty
import androidx.ui.foundation.diagnostics.DiagnosticsTreeStyle
-import androidx.ui.foundation.diagnostics.DoubleProperty
import androidx.ui.foundation.diagnostics.EnumProperty
import androidx.ui.foundation.diagnostics.FlagProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.foundation.diagnostics.IterableProperty
import androidx.ui.foundation.diagnostics.MessageProperty
import androidx.ui.foundation.diagnostics.StringProperty
@@ -28,14 +28,13 @@
import androidx.ui.painting.matrixutils.isIdentity
import androidx.ui.painting.matrixutils.matrixEquals
import androidx.ui.runtimeType
-import androidx.ui.engine.text.TextDirection
import androidx.ui.services.text_editing.TextSelection
import androidx.ui.toStringAsFixed
import androidx.ui.vectormath64.Matrix4
import androidx.ui.vectormath64.Vector3
-fun _initIdentityTransform(): Float64List {
- return Matrix4.identity().m4storage.toDoubleArray()
+fun _initIdentityTransform(): FloatArray {
+ return Matrix4.identity().m4storage.toFloatArray()
}
private val _kEmptyChildList: Int32List = Int32List(0)
@@ -46,7 +45,7 @@
if (node.transform == null) {
return point
}
- val vector: Vector3 = Vector3(point.dx, point.dy, 0.0)
+ val vector: Vector3 = Vector3(point.dx, point.dy, 0.0f)
TODO("Needs Matrix4.transform3")
// node.transform.transform3(vector);
return Offset(vector.x, vector.y)
@@ -657,7 +656,7 @@
*
* * [ScrollPosition.pixels], from where this value is usually taken.
*/
- var scrollPosition: Double? = null
+ var scrollPosition: Float? = null
private set
/**
@@ -670,7 +669,7 @@
*
* * [ScrollPosition.maxScrollExtent], from where this value is usually taken.
*/
- var scrollExtentMax: Double? = null
+ var scrollExtentMax: Float? = null
private set
/**
@@ -683,7 +682,7 @@
*
* * [ScrollPosition.minScrollExtent] from where this value is usually taken.
*/
- var scrollExtentMin: Double? = null
+ var scrollExtentMin: Float? = null
private set
internal fun _canPerformAction(action: SemanticsAction) = _actions.containsKey(action)
@@ -872,10 +871,10 @@
} else {
-1
},
- scrollPosition = data.scrollPosition ?: Double.NaN,
- scrollExtentMax = data.scrollExtentMax ?: Double.NaN,
- scrollExtentMin = data.scrollExtentMin ?: Double.NaN,
- transform = data.transform?.m4storage?.toDoubleArray() ?: _kIdentityTransform,
+ scrollPosition = data.scrollPosition ?: Float.NaN,
+ scrollExtentMax = data.scrollExtentMax ?: Float.NaN,
+ scrollExtentMin = data.scrollExtentMin ?: Float.NaN,
+ transform = data.transform?.m4storage?.toFloatArray() ?: _kIdentityTransform,
childrenInTraversalOrder = childrenInTraversalOrder,
childrenInHitTestOrder = childrenInHitTestOrder
)
@@ -1091,13 +1090,13 @@
}
}
properties.add(
- DoubleProperty.create("scrollExtentMin", scrollExtentMin, defaultValue = null)
+ FloatProperty.create("scrollExtentMin", scrollExtentMin, defaultValue = null)
)
properties.add(
- DoubleProperty.create("scrollPosition", scrollPosition, defaultValue = null)
+ FloatProperty.create("scrollPosition", scrollPosition, defaultValue = null)
)
properties.add(
- DoubleProperty.create("scrollExtentMax", scrollExtentMax, defaultValue = null)
+ FloatProperty.create("scrollExtentMax", scrollExtentMax, defaultValue = null)
)
}
diff --git a/ui/port/src/main/java/androidx/ui/semantics/SemanticsOwner.kt b/ui/port/src/main/java/androidx/ui/semantics/SemanticsOwner.kt
index 0185609..4b1bb34 100644
--- a/ui/port/src/main/java/androidx/ui/semantics/SemanticsOwner.kt
+++ b/ui/port/src/main/java/androidx/ui/semantics/SemanticsOwner.kt
@@ -143,7 +143,7 @@
var position = position
node.transform?.let {
val inverse = Matrix4.identity()
- if (inverse.copyInverse(it) == 0.0)
+ if (inverse.copyInverse(it) == 0.0f)
return null
position = inverse.transformPoint(position)
}
diff --git a/ui/port/src/main/java/androidx/ui/semantics/SemanticsUpdateBuilder.kt b/ui/port/src/main/java/androidx/ui/semantics/SemanticsUpdateBuilder.kt
index ca660b3..12b53e9 100644
--- a/ui/port/src/main/java/androidx/ui/semantics/SemanticsUpdateBuilder.kt
+++ b/ui/port/src/main/java/androidx/ui/semantics/SemanticsUpdateBuilder.kt
@@ -16,7 +16,6 @@
package androidx.ui.semantics
-import androidx.ui.Float64List
import androidx.ui.Int32List
import androidx.ui.engine.geometry.Rect
import androidx.ui.engine.text.TextDirection
@@ -88,9 +87,9 @@
actions: Int,
textSelectionBase: Int,
textSelectionExtent: Int,
- scrollPosition: Double,
- scrollExtentMax: Double,
- scrollExtentMin: Double,
+ scrollPosition: Float,
+ scrollExtentMax: Float,
+ scrollExtentMin: Float,
rect: Rect,
label: String,
hint: String,
@@ -98,7 +97,7 @@
increasedValue: String,
decreasedValue: String,
textDirection: TextDirection?,
- transform: Float64List,
+ transform: FloatArray,
childrenInTraversalOrder: Int32List,
childrenInHitTestOrder: Int32List
) {
@@ -136,20 +135,20 @@
actions: Int,
textSelectionBase: Int,
textSelectionExtent: Int,
- scrollPosition: Double,
- scrollExtentMax: Double,
- scrollExtentMin: Double,
- left: Double,
- top: Double,
- right: Double,
- bottom: Double,
+ scrollPosition: Float,
+ scrollExtentMax: Float,
+ scrollExtentMin: Float,
+ left: Float,
+ top: Float,
+ right: Float,
+ bottom: Float,
label: String,
hInt: String,
value: String,
increasedValue: String,
decreasedValue: String,
textDirection: Int,
- transform: Float64List,
+ transform: FloatArray,
childrenIntraversalOrder: Int32List,
childrenInHitTestOrder: Int32List
) {
diff --git a/ui/port/src/main/java/androidx/ui/semantics/_BoxEdge.kt b/ui/port/src/main/java/androidx/ui/semantics/_BoxEdge.kt
index 6cc2320..a2decc3 100644
--- a/ui/port/src/main/java/androidx/ui/semantics/_BoxEdge.kt
+++ b/ui/port/src/main/java/androidx/ui/semantics/_BoxEdge.kt
@@ -30,7 +30,7 @@
* The offset from the start edge of the parent [SemanticsNode] in the
* direction of the traversal.
*/
- val offset: Double,
+ val offset: Float,
/** The node to whom this edge belongs. */
val node: SemanticsNode
diff --git a/ui/port/src/main/java/androidx/ui/semantics/_SemanticsSortGroup.kt b/ui/port/src/main/java/androidx/ui/semantics/_SemanticsSortGroup.kt
index 37ab21a..a9e521d 100644
--- a/ui/port/src/main/java/androidx/ui/semantics/_SemanticsSortGroup.kt
+++ b/ui/port/src/main/java/androidx/ui/semantics/_SemanticsSortGroup.kt
@@ -17,7 +17,7 @@
* This value is equal to the [_BoxEdge.offset] of the first node in the
* [nodes] list being considered.
*/
- val startOffset: Double,
+ val startOffset: Float,
val textDirection: TextDirection?
@@ -165,4 +165,4 @@
override fun hashCode(): Int {
return System.identityHashCode(this)
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/skia/SkMatrix.kt b/ui/port/src/main/java/androidx/ui/skia/SkMatrix.kt
index 164d408..7eb1e64 100644
--- a/ui/port/src/main/java/androidx/ui/skia/SkMatrix.kt
+++ b/ui/port/src/main/java/androidx/ui/skia/SkMatrix.kt
@@ -45,8 +45,8 @@
// 0, 4, 12,
// 1, 5, 13,
// 3, 7, 15,
- val array = matrix4.toDoubleArray()
- val map = { i: Int -> array[i].toFloat() }
+ val array = matrix4.toFloatArray()
+ val map = { i: Int -> array[i] }
setValues(floatArrayOf(
map(0), map(4), map(12),
map(1), map(5), map(13),
@@ -85,10 +85,10 @@
val dstF = RectF()
frameworkMatrix.mapRect(dstF, srcF)
return Rect(
- dstF.left.toDouble(),
- dstF.top.toDouble(),
- dstF.right.toDouble(),
- dstF.bottom.toDouble()
+ dstF.left,
+ dstF.top,
+ dstF.right,
+ dstF.bottom
)
}
}
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/ui/pointer/PointerData.kt b/ui/port/src/main/java/androidx/ui/ui/pointer/PointerData.kt
index ccab3dd..c044111 100644
--- a/ui/port/src/main/java/androidx/ui/ui/pointer/PointerData.kt
+++ b/ui/port/src/main/java/androidx/ui/ui/pointer/PointerData.kt
@@ -14,10 +14,10 @@
val device: Int = 0,
// /// X coordinate of the position of the pointer, in physical pixels in the
// /// global coordinate space.
- val physicalX: Double = 0.0,
+ val physicalX: Float = 0.0f,
// /// Y coordinate of the position of the pointer, in physical pixels in the
// /// global coordinate space.
- val physicalY: Double = 0.0,
+ val physicalY: Float = 0.0f,
// /// Bit field using the *Button constants (PRIMARY_MOUSE_BUTTON,
// /// SECONDARY_STYLUS_BUTTON, etc). For example, if this has the value 6 and the
// /// [kind] is [PointerDeviceKind.invertedStylus], then this indicates an
@@ -27,38 +27,38 @@
// /// obscuring this application's window. (Aspirational; not currently
// /// implemented.)
val obscured: Boolean = false,
- // /// The pressure of the touch as a number ranging from 0.0, indicating a touch
+ // /// The pressure of the touch as a number ranging from 0.0f, indicating a touch
// /// with no discernible pressure, to 1.0, indicating a touch with "normal"
// /// pressure, and possibly beyond, indicating a stronger touch. For devices
// /// that do not detect pressure (e.g. mice), returns 1.0.
- val pressure: Double = 0.0,
+ val pressure: Float = 0.0f,
// /// The minimum value that [pressure] can return for this pointer. For devices
// /// that do not detect pressure (e.g. mice), returns 1.0. This will always be
// /// a number less than or equal to 1.0.
- val pressureMin: Double = 0.0,
+ val pressureMin: Float = 0.0f,
// /// The maximum value that [pressure] can return for this pointer. For devices
// /// that do not detect pressure (e.g. mice), returns 1.0. This will always be
// /// a greater than or equal to 1.0.
- val pressureMax: Double = 0.0,
+ val pressureMax: Float = 0.0f,
// /// The distance of the detected object from the input surface (e.g. the
// /// distance of a stylus or finger from a touch screen), in arbitrary units on
// /// an arbitrary (not necessarily linear) scale. If the pointer is down, this
- // /// is 0.0 by definition.
- val distance: Double = 0.0,
+ // /// is 0.0f by definition.
+ val distance: Float = 0.0f,
// /// The maximum value that a distance can return for this pointer. If this
// /// input device cannot detect "hover touch" input events, then this will be
// /// 0.0.
- val distanceMax: Double = 0.0,
+ val distanceMax: Float = 0.0f,
// /// The radius of the contact ellipse along the major axis, in logical pixels.
- val radiusMajor: Double = 0.0,
+ val radiusMajor: Float = 0.0f,
// /// The radius of the contact ellipse along the minor axis, in logical pixels.
- val radiusMinor: Double = 0.0,
+ val radiusMinor: Float = 0.0f,
// /// The minimum value that could be reported for radiusMajor and radiusMinor
// /// for this pointer, in logical pixels.
- val radiusMin: Double = 0.0,
+ val radiusMin: Float = 0.0f,
// /// The minimum value that could be reported for radiusMajor and radiusMinor
// /// for this pointer, in logical pixels.
- val radiusMax: Double = 0.0,
+ val radiusMax: Float = 0.0f,
// /// For PointerDeviceKind.touch events:
// ///
// /// The angle of the contact ellipse, in radius in the range:
@@ -84,7 +84,7 @@
// /// indicate that the stylus would go down in the negative y-axis direction;
// /// pi/4 would indicate that the stylus goes up and to the right, -pi/2 would
// /// indicate that the stylus goes to the left, etc).
- val orientation: Double = 0.0,
+ val orientation: Float = 0.0f,
// /// For PointerDeviceKind.stylus and PointerDeviceKind.invertedStylus events:
// ///
// /// The angle of the stylus, in radians in the range:
@@ -95,11 +95,11 @@
// /// perpendicular to the input surface (thus 0.0 indicates the stylus is
// /// orthogonal to the plane of the input surface, while pi/2 indicates that
// /// the stylus is flat on that surface).
- val tilt: Double = 0.0,
+ val tilt: Float = 0.0f,
/**
* Unique identifier for the individual pointer being tracked. This will be consistent from
* the point a pointer goes down, till it goes up. Pointer IDs may be reused but all pointers
* down on the screen at the same time will have different pointer IDs.
*/
val pointerId: Int
-)
\ No newline at end of file
+)
diff --git a/ui/port/src/main/java/androidx/ui/vectormath64/Matrix2.kt b/ui/port/src/main/java/androidx/ui/vectormath64/Matrix2.kt
index 8ffd775..e94f66e 100644
--- a/ui/port/src/main/java/androidx/ui/vectormath64/Matrix2.kt
+++ b/ui/port/src/main/java/androidx/ui/vectormath64/Matrix2.kt
@@ -16,13 +16,13 @@
package androidx.ui.vectormath64
data class Matrix2(
- var x: Vector2 = Vector2(x = 1.0),
- var y: Vector2 = Vector2(y = 1.0)
+ var x: Vector2 = Vector2(x = 1.0f),
+ var y: Vector2 = Vector2(y = 1.0f)
) {
constructor(m: Matrix2) : this(m.x.copy(), m.y.copy())
companion object {
- fun of(vararg a: Double): Matrix2 {
+ fun of(vararg a: Float): Matrix2 {
require(a.size >= 4)
return Matrix2(
Vector2(a[0], a[2]),
@@ -33,7 +33,7 @@
fun identity() = Matrix2()
}
- inline val m2storage: List<Double>
+ inline val m2storage: List<Float>
get() = x.v2storage + y.v2storage
operator fun get(column: Int) = when (column) {
@@ -53,7 +53,7 @@
operator fun set(column: Int, v: Vector2) {
this[column].xy = v
}
- operator fun set(column: Int, row: Int, v: Double) {
+ operator fun set(column: Int, row: Int, v: Float) {
this[column][row] = v
}
@@ -67,10 +67,10 @@
--y
}
- operator fun plus(v: Double) = Matrix2(x + v, y + v)
- operator fun minus(v: Double) = Matrix2(x - v, y - v)
- operator fun times(v: Double) = Matrix2(x * v, y * v)
- operator fun div(v: Double) = Matrix2(x / v, y / v)
+ operator fun plus(v: Float) = Matrix2(x + v, y + v)
+ operator fun minus(v: Float) = Matrix2(x - v, y - v)
+ operator fun times(v: Float) = Matrix2(x * v, y * v)
+ operator fun div(v: Float) = Matrix2(x / v, y / v)
operator fun times(m: Matrix2): Matrix2 {
val t = transpose(this)
@@ -85,7 +85,7 @@
return Vector2(dot(t.x, v), dot(t.y, v))
}
- fun toDoubleArray() = doubleArrayOf(
+ fun toFloatArray() = floatArrayOf(
x.x, y.x,
x.y, y.y
)
diff --git a/ui/port/src/main/java/androidx/ui/vectormath64/Matrix3.kt b/ui/port/src/main/java/androidx/ui/vectormath64/Matrix3.kt
index 008edc9..eb3703b 100644
--- a/ui/port/src/main/java/androidx/ui/vectormath64/Matrix3.kt
+++ b/ui/port/src/main/java/androidx/ui/vectormath64/Matrix3.kt
@@ -16,14 +16,14 @@
package androidx.ui.vectormath64
data class Matrix3(
- var x: Vector3 = Vector3(x = 1.0),
- var y: Vector3 = Vector3(y = 1.0),
- var z: Vector3 = Vector3(z = 1.0)
+ var x: Vector3 = Vector3(x = 1.0f),
+ var y: Vector3 = Vector3(y = 1.0f),
+ var z: Vector3 = Vector3(z = 1.0f)
) {
constructor(m: Matrix3) : this(m.x.copy(), m.y.copy(), m.z.copy())
companion object {
- fun of(vararg a: Double): Matrix3 {
+ fun of(vararg a: Float): Matrix3 {
require(a.size >= 9)
return Matrix3(
Vector3(a[0], a[3], a[6]),
@@ -35,7 +35,7 @@
fun identity() = Matrix3()
}
- inline val m3storage: List<Double>
+ inline val m3storage: List<Float>
get() = x.v3storage + y.v3storage + z.v3storage
operator fun get(column: Int) = when (column) {
@@ -57,7 +57,7 @@
operator fun set(column: Int, v: Vector3) {
this[column].xyz = v
}
- operator fun set(column: Int, row: Int, v: Double) {
+ operator fun set(column: Int, row: Int, v: Float) {
this[column][row] = v
}
@@ -73,10 +73,10 @@
--z
}
- operator fun plus(v: Double) = Matrix3(x + v, y + v, z + v)
- operator fun minus(v: Double) = Matrix3(x - v, y - v, z - v)
- operator fun times(v: Double) = Matrix3(x * v, y * v, z * v)
- operator fun div(v: Double) = Matrix3(x / v, y / v, z / v)
+ operator fun plus(v: Float) = Matrix3(x + v, y + v, z + v)
+ operator fun minus(v: Float) = Matrix3(x - v, y - v, z - v)
+ operator fun times(v: Float) = Matrix3(x * v, y * v, z * v)
+ operator fun div(v: Float) = Matrix3(x / v, y / v, z / v)
operator fun times(m: Matrix3): Matrix3 {
val t = transpose(this)
@@ -92,7 +92,7 @@
return Vector3(dot(t.x, v), dot(t.y, v), dot(t.z, v))
}
- fun toDoubleArray() = doubleArrayOf(
+ fun toFloatArray() = floatArrayOf(
x.x, y.x, z.x,
x.y, y.y, z.y,
x.z, y.z, z.z
diff --git a/ui/port/src/main/java/androidx/ui/vectormath64/Matrix4.kt b/ui/port/src/main/java/androidx/ui/vectormath64/Matrix4.kt
index 3587dbe..ac861d4 100644
--- a/ui/port/src/main/java/androidx/ui/vectormath64/Matrix4.kt
+++ b/ui/port/src/main/java/androidx/ui/vectormath64/Matrix4.kt
@@ -21,18 +21,18 @@
import kotlin.math.sin
data class Matrix4(
- var x: Vector4 = Vector4(x = 1.0),
- var y: Vector4 = Vector4(y = 1.0),
- var z: Vector4 = Vector4(z = 1.0),
- var w: Vector4 = Vector4(w = 1.0)
+ var x: Vector4 = Vector4(x = 1.0f),
+ var y: Vector4 = Vector4(y = 1.0f),
+ var z: Vector4 = Vector4(z = 1.0f),
+ var w: Vector4 = Vector4(w = 1.0f)
) {
constructor(right: Vector3, up: Vector3, forward: Vector3, position: Vector3 = Vector3()) :
- this(Vector4(right), Vector4(up), Vector4(forward), Vector4(position, 1.0))
+ this(Vector4(right), Vector4(up), Vector4(forward), Vector4(position, 1.0f))
constructor(m: Matrix4) : this(m.x.copy(), m.y.copy(), m.z.copy(), m.w.copy())
companion object {
- fun of(vararg a: Double): Matrix4 {
+ fun of(vararg a: Float): Matrix4 {
require(a.size >= 16)
return Matrix4(
Vector4(a[0], a[4], a[8], a[12]),
@@ -42,7 +42,7 @@
)
}
- fun zero() = diagonal3Values(0.0, 0.0, 0.0)
+ fun zero() = diagonal3Values(0.0f, 0.0f, 0.0f)
fun identity() = Matrix4()
@@ -50,29 +50,29 @@
return diagonal3Values(x = scale.x, y = scale.y, z = scale.z)
}
- fun diagonal3Values(x: Double, y: Double, z: Double): Matrix4 {
+ fun diagonal3Values(x: Float, y: Float, z: Float): Matrix4 {
return Matrix4(
- Vector4(x, 0.0, 0.0, 0.0),
- Vector4(0.0, y, 0.0, 0.0),
- Vector4(0.0, 0.0, z, 0.0),
- Vector4(0.0, 0.0, 0.0, 1.0)
+ Vector4(x, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, y, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, z, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 1.0f)
)
}
/** Rotation of [radians_] around X. */
- fun rotationX(radians: Double) = Matrix4.zero().apply {
- set(3, 3, 1.0)
+ fun rotationX(radians: Float) = Matrix4.zero().apply {
+ set(3, 3, 1.0f)
rotateX(radians)
}
/** Rotation of [radians_] around Y. */
- fun rotationY(radians: Double) = Matrix4.zero().apply {
- set(3, 3, 1.0)
+ fun rotationY(radians: Float) = Matrix4.zero().apply {
+ set(3, 3, 1.0f)
rotateY(radians)
}
- fun rotationZ(radians: Double) = Matrix4.zero().apply {
- set(3, 3, 1.0)
+ fun rotationZ(radians: Float) = Matrix4.zero().apply {
+ set(3, 3, 1.0f)
rotateZ(radians)
}
@@ -81,11 +81,11 @@
setTranslationRaw(x = translation.x, y = translation.y, z = translation.z)
}
- fun translationValues(x: Double, y: Double, z: Double) =
+ fun translationValues(x: Float, y: Float, z: Float) =
Matrix4.identity().apply { setTranslationRaw(x, y, z) }
}
- inline val m4storage: List<Double>
+ inline val m4storage: List<Float>
get() = x.v4storage + y.v4storage + z.v4storage + w.v4storage
inline var right: Vector3
@@ -120,8 +120,8 @@
val z = normalize(forward)
return when {
- z.y <= -1.0f -> Vector3(degrees(-HALF_PI), 0.0, degrees(atan2(x.z, y.z)))
- z.y >= 1.0f -> Vector3(degrees(HALF_PI), 0.0, degrees(atan2(-x.z, -y.z)))
+ z.y <= -1.0f -> Vector3(degrees(-HALF_PI), 0.0f, degrees(atan2(x.z, y.z)))
+ z.y >= 1.0f -> Vector3(degrees(HALF_PI), 0.0f, degrees(atan2(-x.z, -y.z)))
else -> Vector3(
degrees(-asin(z.y)), degrees(-atan2(z.x, z.z)), degrees(atan2(x.y, y.y))
)
@@ -158,7 +158,7 @@
this[column].xyzw = v
}
- operator fun set(column: Int, row: Int, v: Double) {
+ operator fun set(column: Int, row: Int, v: Float) {
this[column][row] = v
}
@@ -177,10 +177,10 @@
--w
}
- operator fun plus(v: Double) = Matrix4(x + v, y + v, z + v, w + v)
- operator fun minus(v: Double) = Matrix4(x - v, y - v, z - v, w - v)
- operator fun times(v: Double) = Matrix4(x * v, y * v, z * v, w * v)
- operator fun div(v: Double) = Matrix4(x / v, y / v, z / v, w / v)
+ operator fun plus(v: Float) = Matrix4(x + v, y + v, z + v, w + v)
+ operator fun minus(v: Float) = Matrix4(x - v, y - v, z - v, w - v)
+ operator fun times(v: Float) = Matrix4(x * v, y * v, z * v, w * v)
+ operator fun div(v: Float) = Matrix4(x / v, y / v, z / v, w / v)
operator fun times(m: Matrix4): Matrix4 {
val t = transpose(this)
@@ -208,7 +208,7 @@
this.w = other.w
}
- fun assignFromStorage(storage: List<Double>) {
+ fun assignFromStorage(storage: List<Float>) {
assert(storage.size == 16)
x.assignFromStorage(storage.subList(0, 4))
y.assignFromStorage(storage.subList(4, 8))
@@ -216,7 +216,7 @@
w.assignFromStorage(storage.subList(12, 16))
}
- fun toDoubleArray() = doubleArrayOf(
+ fun toFloatArray() = floatArrayOf(
x.x, y.x, z.x, w.x,
x.y, y.y, z.y, w.y,
x.z, y.z, z.z, w.z,
@@ -252,18 +252,18 @@
m4storage[6] * argStorage[1] +
m4storage[10] * argStorage[2] +
m4storage[14]
- val w_ = 1.0 / (m4storage[3] * argStorage[0] +
+ val w_ = 1.0f / (m4storage[3] * argStorage[0] +
m4storage[7] * argStorage[1] +
m4storage[11] * argStorage[2] +
m4storage[15])
- arg.x = x_ * w_.toDouble()
- arg.y = y_ * w_.toDouble()
- arg.z = z_ * w_.toDouble()
+ arg.x = x_ * w_
+ arg.y = y_ * w_
+ arg.z = z_ * w_
return arg
}
/** Returns the determinant of this matrix. */
- val determinant: Double
+ val determinant: Float
get() {
val det2_01_01 = m4storage[0] * m4storage[5] - m4storage[1] * m4storage[4]
val det2_01_02 = m4storage[0] * m4storage[6] - m4storage[2] * m4storage[4]
@@ -280,14 +280,14 @@
val det3_201_123 = m4storage[9] * det2_01_23 - m4storage[10] * det2_01_13 +
m4storage[11] * det2_01_12
return -det3_201_123 * m4storage[12] + det3_201_023 * m4storage[13] -
- det3_201_013 * m4storage[14] + det3_201_012 * m4storage[15].toDouble()
+ det3_201_013 * m4storage[14] + det3_201_012 * m4storage[15]
}
/** Invert [this]. */
fun invert() = copyInverse(this)
/** Set this matrix to be the inverse of [arg] */
- fun copyInverse(arg: Matrix4): Double {
+ fun copyInverse(arg: Matrix4): Float {
val argStorage = arg.m4storage
val a00 = argStorage[0]
val a01 = argStorage[1]
@@ -319,12 +319,12 @@
val b11 = a22 * a33 - a23 * a32
val det =
(b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06)
- if (det == 0.0) {
+ if (det == 0.0f) {
setFrom(arg)
- return 0.0
+ return 0.0f
}
- val invDet = 1.0 / det
- val newStorage = MutableList(16) { 0.0 }
+ val invDet = 1.0f / det
+ val newStorage = MutableList(16) { 0.0f }
newStorage[0] = ((a11 * b11 - a12 * b10 + a13 * b09) * invDet)
newStorage[1] = ((-a01 * b11 + a02 * b10 - a03 * b09) * invDet)
newStorage[2] = ((a31 * b05 - a32 * b04 + a33 * b03) * invDet)
@@ -350,78 +350,78 @@
assignFromStorage(arg.m4storage)
}
- fun rotateX(radians: Double) {
+ fun rotateX(radians: Float) {
val c = cos(radians)
val s = sin(radians)
val newStorage = m4storage.toMutableList()
- newStorage[0] = 1.0
- newStorage[1] = 0.0
- newStorage[2] = 0.0
- newStorage[4] = 0.0
+ newStorage[0] = 1.0f
+ newStorage[1] = 0.0f
+ newStorage[2] = 0.0f
+ newStorage[4] = 0.0f
newStorage[5] = c
newStorage[6] = s
- newStorage[8] = 0.0
+ newStorage[8] = 0.0f
newStorage[9] = -s
newStorage[10] = c
- newStorage[3] = 0.0
- newStorage[7] = 0.0
- newStorage[11] = 0.0
+ newStorage[3] = 0.0f
+ newStorage[7] = 0.0f
+ newStorage[11] = 0.0f
assignFromStorage(newStorage)
}
/** Sets the upper 3x3 to a rotation of [radians] around Y */
- fun rotateY(radians: Double) {
+ fun rotateY(radians: Float) {
val c = cos(radians)
val s = sin(radians)
val newStorage = m4storage.toMutableList()
newStorage[0] = c
- newStorage[1] = 0.0
+ newStorage[1] = 0.0f
newStorage[2] = -s
- newStorage[4] = 0.0
- newStorage[5] = 1.0
- newStorage[6] = 0.0
+ newStorage[4] = 0.0f
+ newStorage[5] = 1.0f
+ newStorage[6] = 0.0f
newStorage[8] = s
- newStorage[9] = 0.0
+ newStorage[9] = 0.0f
newStorage[10] = c
- newStorage[3] = 0.0
- newStorage[7] = 0.0
- newStorage[11] = 0.0
+ newStorage[3] = 0.0f
+ newStorage[7] = 0.0f
+ newStorage[11] = 0.0f
assignFromStorage(newStorage)
}
/** Sets the upper 3x3 to a rotation of [radians] around Z */
- fun rotateZ(radians: Double) {
+ fun rotateZ(radians: Float) {
val c = cos(radians)
val s = sin(radians)
val newStorage = m4storage.toMutableList()
newStorage[0] = c
newStorage[1] = s
- newStorage[2] = 0.0
+ newStorage[2] = 0.0f
newStorage[4] = -s
newStorage[5] = c
- newStorage[6] = 0.0
- newStorage[8] = 0.0
- newStorage[9] = 0.0
- newStorage[10] = 1.0
- newStorage[3] = 0.0
- newStorage[7] = 0.0
- newStorage[11] = 0.0
+ newStorage[6] = 0.0f
+ newStorage[8] = 0.0f
+ newStorage[9] = 0.0f
+ newStorage[10] = 1.0f
+ newStorage[3] = 0.0f
+ newStorage[7] = 0.0f
+ newStorage[11] = 0.0f
assignFromStorage(newStorage)
}
/** Sets the translation vector in this homogeneous transformation matrix. */
- fun setTranslationRaw(x: Double, y: Double, z: Double) {
+ fun setTranslationRaw(x: Float, y: Float, z: Float) {
set(3, 0, x)
set(3, 1, y)
set(3, 2, z)
}
/** Scale this matrix by a [Vector3], [Vector4], or x,y,z */
- fun scale(x: Any, y: Double? = null, z: Double? = null) {
- var sx: Double? = null
- var sy: Double? = null
- var sz: Double? = null
- val sw = if (x is Vector4) x.w else 1.0
+ fun scale(x: Any, y: Float? = null, z: Float? = null) {
+ var sx: Float? = null
+ var sy: Float? = null
+ var sz: Float? = null
+ val sw = if (x is Vector4) x.w else 1.0f
if (x is Vector3) {
sx = x.x
sy = x.y
@@ -430,14 +430,14 @@
sx = x.x
sy = x.y
sz = x.z
- } else if (x is Double) {
+ } else if (x is Float) {
sx = x
sy = if (y != null) y else x
sz = if (z != null) z else x
}
- sx as Double
- sy as Double
- sz as Double
+ sx as Float
+ sy as Float
+ sz as Float
val newStorage = m4storage.toMutableList()
newStorage[0] *= sx
newStorage[1] *= sx
@@ -459,11 +459,11 @@
}
/** Translate this matrix by a [Vector3], [Vector4], or x,y,z */
- fun translate(x: Any, y: Double = 0.0, z: Double = 0.0) {
- var tx: Double? = null
- var ty: Double? = null
- var tz: Double? = null
- var tw = if (x is Vector4) x.w else 1.0
+ fun translate(x: Any, y: Float = 0.0f, z: Float = 0.0f) {
+ var tx: Float? = null
+ var ty: Float? = null
+ var tz: Float? = null
+ var tw = if (x is Vector4) x.w else 1.0f
if (x is Vector3) {
tx = x.x
ty = x.y
@@ -472,14 +472,14 @@
tx = x.x
ty = x.y
tz = x.z
- } else if (x is Double) {
+ } else if (x is Float) {
tx = x
ty = y
tz = z
}
- tx as Double
- ty as Double
- tz as Double
+ tx as Float
+ ty as Float
+ tz as Float
val newStorage = m4storage.toMutableList()
val t1 = newStorage[0] * tx +
newStorage[4] * ty +
diff --git a/ui/port/src/main/java/androidx/ui/vectormath64/MatrixExtensions.kt b/ui/port/src/main/java/androidx/ui/vectormath64/MatrixExtensions.kt
index 119f3b1..d3ccf46 100644
--- a/ui/port/src/main/java/androidx/ui/vectormath64/MatrixExtensions.kt
+++ b/ui/port/src/main/java/androidx/ui/vectormath64/MatrixExtensions.kt
@@ -131,7 +131,7 @@
fun scale(s: Vector3) = Matrix4(Vector4(x = s.x), Vector4(y = s.y), Vector4(z = s.z))
fun scale(m: Matrix4) = scale(m.scale)
-fun translation(t: Vector3) = Matrix4(w = Vector4(t, 1.0))
+fun translation(t: Vector3) = Matrix4(w = Vector4(t, 1.0f))
fun translation(m: Matrix4) = translation(m.translation)
fun rotation(m: Matrix4) = Matrix4(normalize(m.right), normalize(m.up), normalize(m.forward))
@@ -141,13 +141,13 @@
val s = transform(r, { x -> sin(x) })
return Matrix4.of(
- c.y * c.z, -c.x * s.z + s.x * s.y * c.z, s.x * s.z + c.x * s.y * c.z, 0.0,
- c.y * s.z, c.x * c.z + s.x * s.y * s.z, -s.x * c.z + c.x * s.y * s.z, 0.0,
- -s.y, s.x * c.y, c.x * c.y, 0.0,
- 0.0, 0.0, 0.0, 1.0
+ c.y * c.z, -c.x * s.z + s.x * s.y * c.z, s.x * s.z + c.x * s.y * c.z, 0.0f,
+ c.y * s.z, c.x * c.z + s.x * s.y * s.z, -s.x * c.z + c.x * s.y * s.z, 0.0f,
+ -s.y, s.x * c.y, c.x * c.y, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
)
}
-fun rotation(axis: Vector3, angle: Double): Matrix4 {
+fun rotation(axis: Vector3, angle: Float): Matrix4 {
val x = axis.x
val y = axis.y
val z = axis.z
@@ -158,38 +158,38 @@
val d = 1.0f - c
return Matrix4.of(
- x * x * d + c, x * y * d - z * s, x * y * d + y * s, 0.0,
- y * x * d + z * s, y * y * d + c, y * z * d - x * s, 0.0,
- z * x * d - y * s, z * y * d + x * s, z * z * d + c, 0.0,
- 0.0, 0.0, 0.0, 1.0
+ x * x * d + c, x * y * d - z * s, x * y * d + y * s, 0.0f,
+ y * x * d + z * s, y * y * d + c, y * z * d - x * s, 0.0f,
+ z * x * d - y * s, z * y * d + x * s, z * z * d + c, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
)
}
-fun normal(m: Matrix4) = scale(1.0 / Vector3(length2(m.right),
+fun normal(m: Matrix4) = scale(1.0f / Vector3(length2(m.right),
length2(m.up), length2(m.forward))) * m
-fun lookAt(eye: Vector3, target: Vector3, up: Vector3 = Vector3(z = 1.0)): Matrix4 {
+fun lookAt(eye: Vector3, target: Vector3, up: Vector3 = Vector3(z = 1.0f)): Matrix4 {
return lookTowards(eye, target - eye, up)
}
-fun lookTowards(eye: Vector3, forward: Vector3, up: Vector3 = Vector3(z = 1.0)): Matrix4 {
+fun lookTowards(eye: Vector3, forward: Vector3, up: Vector3 = Vector3(z = 1.0f)): Matrix4 {
val f = normalize(forward)
val r = normalize(f x up)
val u = normalize(r x f)
- return Matrix4(Vector4(r), Vector4(u), Vector4(f), Vector4(eye, 1.0))
+ return Matrix4(Vector4(r), Vector4(u), Vector4(f), Vector4(eye, 1.0f))
}
-fun perspective(fov: Double, ratio: Double, near: Double, far: Double): Matrix4 {
+fun perspective(fov: Float, ratio: Float, near: Float, far: Float): Matrix4 {
val t = 1.0f / tan(radians(fov) * 0.5f)
val a = (far + near) / (far - near)
val b = (2.0f * far * near) / (far - near)
val c = t / ratio
- return Matrix4(Vector4(x = c), Vector4(y = t), Vector4(z = a, w = 1.0), Vector4(z = -b))
+ return Matrix4(Vector4(x = c), Vector4(y = t), Vector4(z = a, w = 1.0f), Vector4(z = -b))
}
-fun ortho(l: Double, r: Double, b: Double, t: Double, n: Double, f: Double) = Matrix4(
+fun ortho(l: Float, r: Float, b: Float, t: Float, n: Float, f: Float) = Matrix4(
Vector4(x = 2.0f / (r - 1.0f)),
Vector4(y = 2.0f / (t - b)),
Vector4(z = -2.0f / (f - n)),
- Vector4(-(r + l) / (r - l), -(t + b) / (t - b), -(f + n) / (f - n), 1.0)
+ Vector4(-(r + l) / (r - l), -(t + b) / (t - b), -(f + n) / (f - n), 1.0f)
)
\ No newline at end of file
diff --git a/ui/port/src/main/java/androidx/ui/vectormath64/Scalar.kt b/ui/port/src/main/java/androidx/ui/vectormath64/Scalar.kt
index 4ee873b..1e9c3cb 100644
--- a/ui/port/src/main/java/androidx/ui/vectormath64/Scalar.kt
+++ b/ui/port/src/main/java/androidx/ui/vectormath64/Scalar.kt
@@ -17,22 +17,20 @@
package androidx.ui.vectormath64
-const val PI = 3.1415926536
-const val HALF_PI = PI * 0.5
-const val TWO_PI = PI * 2.0
-const val FOUR_PI = PI * 4.0
-const val INV_PI = 1.0 / PI
-const val INV_TWO_PI = INV_PI * 0.5
-const val INV_FOUR_PI = INV_PI * 0.25
+const val PI = 3.1415926536f
+const val HALF_PI = PI * 0.5f
+const val TWO_PI = PI * 2.0f
+const val FOUR_PI = PI * 4.0f
+const val INV_PI = 1.0f / PI
+const val INV_TWO_PI = INV_PI * 0.5f
+const val INV_FOUR_PI = INV_PI * 0.25f
-inline fun mix(a: Double, b: Double, x: Double) = a * (1.0 - x) + b * x
+inline fun mix(a: Float, b: Float, x: Float) = a * (1.0f - x) + b * x
-inline fun degrees(v: Double) = v * (180.0 * INV_PI)
+inline fun degrees(v: Float) = v * (180.0f * INV_PI)
-inline fun radians(v: Double) = v * (PI / 180.0)
+inline fun radians(v: Float) = v * (PI / 180.0f)
-inline fun fract(v: Double) = v % 1
+inline fun fract(v: Float) = v % 1
-inline fun sqr(v: Double) = v * v
-
-inline fun pow(x: Double, y: Double) = StrictMath.pow(x, y)
+inline fun sqr(v: Float) = v * v
diff --git a/ui/port/src/main/java/androidx/ui/vectormath64/Vector2.kt b/ui/port/src/main/java/androidx/ui/vectormath64/Vector2.kt
index 351cbed..1eeba21 100644
--- a/ui/port/src/main/java/androidx/ui/vectormath64/Vector2.kt
+++ b/ui/port/src/main/java/androidx/ui/vectormath64/Vector2.kt
@@ -15,29 +15,29 @@
*/
package androidx.ui.vectormath64
-data class Vector2(var x: Double = 0.0, var y: Double = 0.0) {
+data class Vector2(var x: Float = 0.0f, var y: Float = 0.0f) {
constructor(v: Vector2) : this(v.x, v.y)
- inline val v2storage: List<Double>
+ inline val v2storage: List<Float>
get() = listOf(x, y)
- inline var r: Double
+ inline var r: Float
get() = x
set(value) {
x = value
}
- inline var g: Double
+ inline var g: Float
get() = y
set(value) {
y = value
}
- inline var s: Double
+ inline var s: Float
get() = x
set(value) {
x = value
}
- inline var t: Double
+ inline var t: Float
get() = y
set(value) {
y = value
@@ -80,24 +80,24 @@
operator fun get(index1: Int, index2: Int) = Vector2(get(index1), get(index2))
- operator fun set(index: Int, v: Double) = when (index) {
+ operator fun set(index: Int, v: Float) = when (index) {
0 -> x = v
1 -> y = v
else -> throw IllegalArgumentException("index must be in 0..1")
}
- operator fun set(index1: Int, index2: Int, v: Double) {
+ operator fun set(index1: Int, index2: Int, v: Float) {
set(index1, v)
set(index2, v)
}
- operator fun set(index: VectorComponent, v: Double) = when (index) {
+ operator fun set(index: VectorComponent, v: Float) = when (index) {
VectorComponent.X, VectorComponent.R, VectorComponent.S -> x = v
VectorComponent.Y, VectorComponent.G, VectorComponent.T -> y = v
else -> throw IllegalArgumentException("index must be X, Y, R, G, S or T")
}
- operator fun set(index1: VectorComponent, index2: VectorComponent, v: Double) {
+ operator fun set(index1: VectorComponent, index2: VectorComponent, v: Float) {
set(index1, v)
set(index2, v)
}
@@ -112,17 +112,17 @@
--y
}
- inline operator fun plus(v: Double) = Vector2(x + v, y + v)
- inline operator fun minus(v: Double) = Vector2(x - v, y - v)
- inline operator fun times(v: Double) = Vector2(x * v, y * v)
- inline operator fun div(v: Double) = Vector2(x / v, y / v)
+ inline operator fun plus(v: Float) = Vector2(x + v, y + v)
+ inline operator fun minus(v: Float) = Vector2(x - v, y - v)
+ inline operator fun times(v: Float) = Vector2(x * v, y * v)
+ inline operator fun div(v: Float) = Vector2(x / v, y / v)
inline operator fun plus(v: Vector2) = Vector2(x + v.x, y + v.y)
inline operator fun minus(v: Vector2) = Vector2(x - v.x, y - v.y)
inline operator fun times(v: Vector2) = Vector2(x * v.x, y * v.y)
inline operator fun div(v: Vector2) = Vector2(x / v.x, y / v.y)
- inline fun transform(block: (Double) -> Double): Vector2 {
+ inline fun transform(block: (Float) -> Float): Vector2 {
x = block(x)
y = block(y)
return this
diff --git a/ui/port/src/main/java/androidx/ui/vectormath64/Vector3.kt b/ui/port/src/main/java/androidx/ui/vectormath64/Vector3.kt
index 968ae4a..e35a77a 100644
--- a/ui/port/src/main/java/androidx/ui/vectormath64/Vector3.kt
+++ b/ui/port/src/main/java/androidx/ui/vectormath64/Vector3.kt
@@ -15,40 +15,40 @@
*/
package androidx.ui.vectormath64
-data class Vector3(var x: Double = 0.0, var y: Double = 0.0, var z: Double = 0.0) {
- constructor(v: Vector2, z: Double = 0.0) : this(v.x, v.y, z)
+data class Vector3(var x: Float = 0.0f, var y: Float = 0.0f, var z: Float = 0.0f) {
+ constructor(v: Vector2, z: Float = 0.0f) : this(v.x, v.y, z)
constructor(v: Vector3) : this(v.x, v.y, v.z)
- inline val v3storage: List<Double>
+ inline val v3storage: List<Float>
get() = listOf(x, y, z)
- inline var r: Double
+ inline var r: Float
get() = x
set(value) {
x = value
}
- inline var g: Double
+ inline var g: Float
get() = y
set(value) {
y = value
}
- inline var b: Double
+ inline var b: Float
get() = z
set(value) {
z = value
}
- inline var s: Double
+ inline var s: Float
get() = x
set(value) {
x = value
}
- inline var t: Double
+ inline var t: Float
get() = y
set(value) {
y = value
}
- inline var p: Double
+ inline var p: Float
get() = z
set(value) {
z = value
@@ -125,32 +125,32 @@
return Vector3(get(index1), get(index2), get(index3))
}
- operator fun set(index: Int, v: Double) = when (index) {
+ operator fun set(index: Int, v: Float) = when (index) {
0 -> x = v
1 -> y = v
2 -> z = v
else -> throw IllegalArgumentException("index must be in 0..2")
}
- operator fun set(index1: Int, index2: Int, v: Double) {
+ operator fun set(index1: Int, index2: Int, v: Float) {
set(index1, v)
set(index2, v)
}
- operator fun set(index1: Int, index2: Int, index3: Int, v: Double) {
+ operator fun set(index1: Int, index2: Int, index3: Int, v: Float) {
set(index1, v)
set(index2, v)
set(index3, v)
}
- operator fun set(index: VectorComponent, v: Double) = when (index) {
+ operator fun set(index: VectorComponent, v: Float) = when (index) {
VectorComponent.X, VectorComponent.R, VectorComponent.S -> x = v
VectorComponent.Y, VectorComponent.G, VectorComponent.T -> y = v
VectorComponent.Z, VectorComponent.B, VectorComponent.P -> z = v
else -> throw IllegalArgumentException("index must be X, Y, Z, R, G, B, S, T or P")
}
- operator fun set(index1: VectorComponent, index2: VectorComponent, v: Double) {
+ operator fun set(index1: VectorComponent, index2: VectorComponent, v: Float) {
set(index1, v)
set(index2, v)
}
@@ -159,7 +159,7 @@
index1: VectorComponent,
index2: VectorComponent,
index3: VectorComponent,
- v: Double
+ v: Float
) {
set(index1, v)
set(index2, v)
@@ -178,10 +178,10 @@
--z
}
- inline operator fun plus(v: Double) = Vector3(x + v, y + v, z + v)
- inline operator fun minus(v: Double) = Vector3(x - v, y - v, z - v)
- inline operator fun times(v: Double) = Vector3(x * v, y * v, z * v)
- inline operator fun div(v: Double) = Vector3(x / v, y / v, z / v)
+ inline operator fun plus(v: Float) = Vector3(x + v, y + v, z + v)
+ inline operator fun minus(v: Float) = Vector3(x - v, y - v, z - v)
+ inline operator fun times(v: Float) = Vector3(x * v, y * v, z * v)
+ inline operator fun div(v: Float) = Vector3(x / v, y / v, z / v)
inline operator fun plus(v: Vector2) = Vector3(x + v.x, y + v.y, z)
inline operator fun minus(v: Vector2) = Vector3(x - v.x, y - v.y, z)
@@ -193,7 +193,7 @@
inline operator fun times(v: Vector3) = Vector3(x * v.x, y * v.y, z * v.z)
inline operator fun div(v: Vector3) = Vector3(x / v.x, y / v.y, z / v.z)
- inline fun transform(block: (Double) -> Double): Vector3 {
+ inline fun transform(block: (Float) -> Float): Vector3 {
x = block(x)
y = block(y)
z = block(z)
diff --git a/ui/port/src/main/java/androidx/ui/vectormath64/Vector4.kt b/ui/port/src/main/java/androidx/ui/vectormath64/Vector4.kt
index c7a1ac8..ccf0e5b 100644
--- a/ui/port/src/main/java/androidx/ui/vectormath64/Vector4.kt
+++ b/ui/port/src/main/java/androidx/ui/vectormath64/Vector4.kt
@@ -17,55 +17,55 @@
package androidx.ui.vectormath64
data class Vector4(
- var x: Double = 0.0,
- var y: Double = 0.0,
- var z: Double = 0.0,
- var w: Double = 0.0
+ var x: Float = 0.0f,
+ var y: Float = 0.0f,
+ var z: Float = 0.0f,
+ var w: Float = 0.0f
) {
- constructor(v: Vector2, z: Double = 0.0, w: Double = 0.0) : this(v.x, v.y, z, w)
- constructor(v: Vector3, w: Double = 0.0) : this(v.x, v.y, v.z, w)
+ constructor(v: Vector2, z: Float = 0.0f, w: Float = 0.0f) : this(v.x, v.y, z, w)
+ constructor(v: Vector3, w: Float = 0.0f) : this(v.x, v.y, v.z, w)
constructor(v: Vector4) : this(v.x, v.y, v.z, v.w)
- inline val v4storage: List<Double>
+ inline val v4storage: List<Float>
get() = listOf(x, y, z, w)
- inline var r: Double
+ inline var r: Float
get() = x
set(value) {
x = value
}
- inline var g: Double
+ inline var g: Float
get() = y
set(value) {
y = value
}
- inline var b: Double
+ inline var b: Float
get() = z
set(value) {
z = value
}
- inline var a: Double
+ inline var a: Float
get() = w
set(value) {
w = value
}
- inline var s: Double
+ inline var s: Float
get() = x
set(value) {
x = value
}
- inline var t: Double
+ inline var t: Float
get() = y
set(value) {
y = value
}
- inline var p: Double
+ inline var p: Float
get() = z
set(value) {
z = value
}
- inline var q: Double
+ inline var q: Float
get() = w
set(value) {
w = value
@@ -179,7 +179,7 @@
return Vector4(get(index1), get(index2), get(index3), get(index4))
}
- operator fun set(index: Int, v: Double) = when (index) {
+ operator fun set(index: Int, v: Float) = when (index) {
0 -> x = v
1 -> y = v
2 -> z = v
@@ -187,32 +187,32 @@
else -> throw IllegalArgumentException("index must be in 0..3")
}
- operator fun set(index1: Int, index2: Int, v: Double) {
+ operator fun set(index1: Int, index2: Int, v: Float) {
set(index1, v)
set(index2, v)
}
- operator fun set(index1: Int, index2: Int, index3: Int, v: Double) {
+ operator fun set(index1: Int, index2: Int, index3: Int, v: Float) {
set(index1, v)
set(index2, v)
set(index3, v)
}
- operator fun set(index1: Int, index2: Int, index3: Int, index4: Int, v: Double) {
+ operator fun set(index1: Int, index2: Int, index3: Int, index4: Int, v: Float) {
set(index1, v)
set(index2, v)
set(index3, v)
set(index4, v)
}
- operator fun set(index: VectorComponent, v: Double) = when (index) {
+ operator fun set(index: VectorComponent, v: Float) = when (index) {
VectorComponent.X, VectorComponent.R, VectorComponent.S -> x = v
VectorComponent.Y, VectorComponent.G, VectorComponent.T -> y = v
VectorComponent.Z, VectorComponent.B, VectorComponent.P -> z = v
VectorComponent.W, VectorComponent.A, VectorComponent.Q -> w = v
}
- operator fun set(index1: VectorComponent, index2: VectorComponent, v: Double) {
+ operator fun set(index1: VectorComponent, index2: VectorComponent, v: Float) {
set(index1, v)
set(index2, v)
}
@@ -221,7 +221,7 @@
index1: VectorComponent,
index2: VectorComponent,
index3: VectorComponent,
- v: Double
+ v: Float
) {
set(index1, v)
set(index2, v)
@@ -233,7 +233,7 @@
index2: VectorComponent,
index3: VectorComponent,
index4: VectorComponent,
- v: Double
+ v: Float
) {
set(index1, v)
set(index2, v)
@@ -255,10 +255,10 @@
--w
}
- inline operator fun plus(v: Double) = Vector4(x + v, y + v, z + v, w + v)
- inline operator fun minus(v: Double) = Vector4(x - v, y - v, z - v, w - v)
- inline operator fun times(v: Double) = Vector4(x * v, y * v, z * v, w * v)
- inline operator fun div(v: Double) = Vector4(x / v, y / v, z / v, w / v)
+ inline operator fun plus(v: Float) = Vector4(x + v, y + v, z + v, w + v)
+ inline operator fun minus(v: Float) = Vector4(x - v, y - v, z - v, w - v)
+ inline operator fun times(v: Float) = Vector4(x * v, y * v, z * v, w * v)
+ inline operator fun div(v: Float) = Vector4(x / v, y / v, z / v, w / v)
inline operator fun plus(v: Vector2) = Vector4(x + v.x, y + v.y, z, w)
inline operator fun minus(v: Vector2) = Vector4(x - v.x, y - v.y, z, w)
@@ -275,7 +275,7 @@
inline operator fun times(v: Vector4) = Vector4(x * v.x, y * v.y, z * v.z, w * v.w)
inline operator fun div(v: Vector4) = Vector4(x / v.x, y / v.y, z / v.z, w / v.w)
- inline fun transform(block: (Double) -> Double): Vector4 {
+ inline fun transform(block: (Float) -> Float): Vector4 {
x = block(x)
y = block(y)
z = block(z)
@@ -283,7 +283,7 @@
return this
}
- fun assignFromStorage(storage: List<Double>) {
+ fun assignFromStorage(storage: List<Float>) {
assert(storage.size >= 4)
x = storage[0]
y = storage[1]
diff --git a/ui/port/src/main/java/androidx/ui/vectormath64/VectorExtensions.kt b/ui/port/src/main/java/androidx/ui/vectormath64/VectorExtensions.kt
index c8e927b..071bf4d 100644
--- a/ui/port/src/main/java/androidx/ui/vectormath64/VectorExtensions.kt
+++ b/ui/port/src/main/java/androidx/ui/vectormath64/VectorExtensions.kt
@@ -22,10 +22,10 @@
import kotlin.math.min
import kotlin.math.sqrt
-inline operator fun Double.plus(v: Vector2) = Vector2(this + v.x, this + v.y)
-inline operator fun Double.minus(v: Vector2) = Vector2(this - v.x, this - v.y)
-inline operator fun Double.times(v: Vector2) = Vector2(this * v.x, this * v.y)
-inline operator fun Double.div(v: Vector2) = Vector2(this / v.x, this / v.y)
+inline operator fun Float.plus(v: Vector2) = Vector2(this + v.x, this + v.y)
+inline operator fun Float.minus(v: Vector2) = Vector2(this - v.x, this - v.y)
+inline operator fun Float.times(v: Vector2) = Vector2(this * v.x, this * v.y)
+inline operator fun Float.div(v: Vector2) = Vector2(this / v.x, this / v.y)
inline fun abs(v: Vector2) = Vector2(abs(v.x), abs(v.y))
inline fun length(v: Vector2) = sqrt(v.x * v.x + v.y * v.y)
@@ -33,18 +33,18 @@
inline fun distance(a: Vector2, b: Vector2) = length(a - b)
inline fun dot(a: Vector2, b: Vector2) = a.x * b.x + a.y * b.y
fun normalize(v: Vector2): Vector2 {
- val l = 1.0 / length(v)
+ val l = 1.0f / length(v)
return Vector2(v.x * l, v.y * l)
}
-inline fun reflect(i: Vector2, n: Vector2) = i - 2.0 * dot(n, i) * n
-fun refract(i: Vector2, n: Vector2, eta: Double): Vector2 {
+inline fun reflect(i: Vector2, n: Vector2) = i - 2.0f * dot(n, i) * n
+fun refract(i: Vector2, n: Vector2, eta: Float): Vector2 {
val d = dot(n, i)
- val k = 1.0 - eta * eta * (1.0 - sqr(d))
- return if (k < 0.0) Vector2(0.0) else eta * i - (eta * d + sqrt(k)) * n
+ val k = 1.0f - eta * eta * (1.0f - sqr(d))
+ return if (k < 0.0f) Vector2(0.0f) else eta * i - (eta * d + sqrt(k)) * n
}
-inline fun clamp(v: Vector2, min: Double, max: Double): Vector2 {
+inline fun clamp(v: Vector2, min: Float, max: Float): Vector2 {
return Vector2(
v.x.clamp(min, max),
v.y.clamp(min, max))
@@ -56,7 +56,7 @@
v.y.clamp(min.y, max.y))
}
-inline fun mix(a: Vector2, b: Vector2, x: Double): Vector2 {
+inline fun mix(a: Vector2, b: Vector2, x: Float): Vector2 {
return Vector2(
mix(a.x, b.x, x),
mix(a.y, b.y, x))
@@ -73,12 +73,12 @@
inline fun max(v: Vector2) = max(v.x, v.y)
inline fun max(a: Vector2, b: Vector2) = Vector2(max(a.x, b.x), max(a.y, b.y))
-inline fun transform(v: Vector2, block: (Double) -> Double) = v.copy().transform(block)
+inline fun transform(v: Vector2, block: (Float) -> Float) = v.copy().transform(block)
-inline operator fun Double.plus(v: Vector3) = Vector3(this + v.x, this + v.y, this + v.z)
-inline operator fun Double.minus(v: Vector3) = Vector3(this - v.x, this - v.y, this - v.z)
-inline operator fun Double.times(v: Vector3) = Vector3(this * v.x, this * v.y, this * v.z)
-inline operator fun Double.div(v: Vector3) = Vector3(this / v.x, this / v.y, this / v.z)
+inline operator fun Float.plus(v: Vector3) = Vector3(this + v.x, this + v.y, this + v.z)
+inline operator fun Float.minus(v: Vector3) = Vector3(this - v.x, this - v.y, this - v.z)
+inline operator fun Float.times(v: Vector3) = Vector3(this * v.x, this * v.y, this * v.z)
+inline operator fun Float.div(v: Vector3) = Vector3(this / v.x, this / v.y, this / v.z)
inline fun abs(v: Vector3) = Vector3(abs(v.x), abs(v.y), abs(v.z))
inline fun length(v: Vector3) = sqrt(v.x * v.x + v.y * v.y + v.z * v.z)
@@ -92,18 +92,18 @@
return Vector3(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x)
}
fun normalize(v: Vector3): Vector3 {
- val l = 1.0 / length(v)
+ val l = 1.0f / length(v)
return Vector3(v.x * l, v.y * l, v.z * l)
}
-inline fun reflect(i: Vector3, n: Vector3) = i - 2.0 * dot(n, i) * n
-fun refract(i: Vector3, n: Vector3, eta: Double): Vector3 {
+inline fun reflect(i: Vector3, n: Vector3) = i - 2.0f * dot(n, i) * n
+fun refract(i: Vector3, n: Vector3, eta: Float): Vector3 {
val d = dot(n, i)
- val k = 1.0 - eta * eta * (1.0 - sqr(d))
- return if (k < 0.0) Vector3(0.0) else eta * i - (eta * d + sqrt(k)) * n
+ val k = 1.0f - eta * eta * (1.0f - sqr(d))
+ return if (k < 0.0f) Vector3(0.0f) else eta * i - (eta * d + sqrt(k)) * n
}
-inline fun clamp(v: Vector3, min: Double, max: Double): Vector3 {
+inline fun clamp(v: Vector3, min: Float, max: Float): Vector3 {
return Vector3(
v.x.clamp(min, max),
v.y.clamp(min, max),
@@ -117,7 +117,7 @@
v.z.clamp(min.z, max.z))
}
-inline fun mix(a: Vector3, b: Vector3, x: Double): Vector3 {
+inline fun mix(a: Vector3, b: Vector3, x: Float): Vector3 {
return Vector3(
mix(a.x, b.x, x),
mix(a.y, b.y, x),
@@ -136,15 +136,15 @@
inline fun max(v: Vector3) = max(v.x, max(v.y, v.z))
inline fun max(a: Vector3, b: Vector3) = Vector3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z))
-inline fun transform(v: Vector3, block: (Double) -> Double) = v.copy().transform(block)
+inline fun transform(v: Vector3, block: (Float) -> Float) = v.copy().transform(block)
-inline operator fun Double.plus(v: Vector4) = Vector4(this + v.x, this + v.y,
+inline operator fun Float.plus(v: Vector4) = Vector4(this + v.x, this + v.y,
this + v.z, this + v.w)
-inline operator fun Double.minus(v: Vector4) = Vector4(this - v.x, this - v.y,
+inline operator fun Float.minus(v: Vector4) = Vector4(this - v.x, this - v.y,
this - v.z, this - v.w)
-inline operator fun Double.times(v: Vector4) = Vector4(this * v.x, this * v.y,
+inline operator fun Float.times(v: Vector4) = Vector4(this * v.x, this * v.y,
this * v.z, this * v.w)
-inline operator fun Double.div(v: Vector4) = Vector4(this / v.x, this / v.y, this / v.z, this / v.w)
+inline operator fun Float.div(v: Vector4) = Vector4(this / v.x, this / v.y, this / v.z, this / v.w)
inline fun abs(v: Vector4) = Vector4(abs(v.x), abs(v.y), abs(v.z), abs(v.w))
inline fun length(v: Vector4) = sqrt(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w)
@@ -152,11 +152,11 @@
inline fun distance(a: Vector4, b: Vector4) = length(a - b)
inline fun dot(a: Vector4, b: Vector4) = a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w
fun normalize(v: Vector4): Vector4 {
- val l = 1.0 / length(v)
+ val l = 1.0f / length(v)
return Vector4(v.x * l, v.y * l, v.z * l, v.w * l)
}
-inline fun clamp(v: Vector4, min: Double, max: Double): Vector4 {
+inline fun clamp(v: Vector4, min: Float, max: Float): Vector4 {
return Vector4(
v.x.clamp(min, max),
v.y.clamp(min, max),
@@ -172,7 +172,7 @@
v.w.clamp(min.w, max.w))
}
-inline fun mix(a: Vector4, b: Vector4, x: Double): Vector4 {
+inline fun mix(a: Vector4, b: Vector4, x: Float): Vector4 {
return Vector4(
mix(a.x, b.x, x),
mix(a.y, b.y, x),
@@ -197,4 +197,4 @@
return Vector4(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w))
}
-inline fun transform(v: Vector4, block: (Double) -> Double) = v.copy().transform(block)
+inline fun transform(v: Vector4, block: (Float) -> Float) = v.copy().transform(block)
diff --git a/ui/port/src/main/java/androidx/ui/widgets/basic/Align.kt b/ui/port/src/main/java/androidx/ui/widgets/basic/Align.kt
index 436549f..243c154 100644
--- a/ui/port/src/main/java/androidx/ui/widgets/basic/Align.kt
+++ b/ui/port/src/main/java/androidx/ui/widgets/basic/Align.kt
@@ -3,7 +3,7 @@
import androidx.ui.foundation.Key
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
import androidx.ui.foundation.diagnostics.DiagnosticsProperty
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.painting.alignment.Alignment
import androidx.ui.rendering.obj.RenderObject
import androidx.ui.rendering.shiftedbox.RenderPositionedBox
@@ -63,19 +63,19 @@
*
* Can be both greater and less than 1.0 but must be non-negative.
*/
- val widthFactor: Double? = null,
+ val widthFactor: Float? = null,
/**
* If non-null, sets its height to the child's height multiplied by this factor.
*
* Can be both greater and less than 1.0 but must be non-negative.
*/
- val heightFactor: Double? = null,
+ val heightFactor: Float? = null,
child: Widget
) : SingleChildRenderObjectWidget(key = key, child = child) {
init {
- assert(widthFactor == null || widthFactor >= 0.0)
- assert(heightFactor == null || heightFactor >= 0.0)
+ assert(widthFactor == null || widthFactor >= 0.0f)
+ assert(heightFactor == null || heightFactor >= 0.0f)
}
override fun createRenderObject(context: BuildContext): RenderPositionedBox {
@@ -100,7 +100,7 @@
override fun debugFillProperties(properties: DiagnosticPropertiesBuilder) {
super.debugFillProperties(properties)
properties.add(DiagnosticsProperty.create("alignment", alignment))
- properties.add(DoubleProperty.create("widthFactor", widthFactor, defaultValue = null))
- properties.add(DoubleProperty.create("heightFactor", heightFactor, defaultValue = null))
+ properties.add(FloatProperty.create("widthFactor", widthFactor, defaultValue = null))
+ properties.add(FloatProperty.create("heightFactor", heightFactor, defaultValue = null))
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/widgets/basic/AspectRatio.kt b/ui/port/src/main/java/androidx/ui/widgets/basic/AspectRatio.kt
index 9447f25..b00d183 100644
--- a/ui/port/src/main/java/androidx/ui/widgets/basic/AspectRatio.kt
+++ b/ui/port/src/main/java/androidx/ui/widgets/basic/AspectRatio.kt
@@ -18,7 +18,7 @@
import androidx.ui.foundation.Key
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.rendering.obj.RenderObject
import androidx.ui.rendering.proxybox.RenderAspectRatio
import androidx.ui.widgets.framework.BuildContext
@@ -67,7 +67,7 @@
// ///
// /// The aspect ratio is expressed as a ratio of width to height. For example,
// /// a 16:9 width:height aspect ratio would have a value of 16.0/9.0.
- val aspectRatio: Double,
+ val aspectRatio: Float,
child: Widget? = null
) : SingleChildRenderObjectWidget(key, child) {
@@ -81,6 +81,6 @@
override fun debugFillProperties(properties: DiagnosticPropertiesBuilder) {
super.debugFillProperties(properties)
- properties.add(DoubleProperty.create("aspectRatio", aspectRatio))
+ properties.add(FloatProperty.create("aspectRatio", aspectRatio))
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/widgets/basic/Center.kt b/ui/port/src/main/java/androidx/ui/widgets/basic/Center.kt
index fbaa8b5..49692ba 100644
--- a/ui/port/src/main/java/androidx/ui/widgets/basic/Center.kt
+++ b/ui/port/src/main/java/androidx/ui/widgets/basic/Center.kt
@@ -26,8 +26,8 @@
*/
class Center(
key: Key,
- widthFactor: Double?,
- heightFactor: Double?,
+ widthFactor: Float?,
+ heightFactor: Float?,
child: Widget
) : Align(
key = key,
diff --git a/ui/port/src/main/java/androidx/ui/widgets/basic/PhysicalShape.kt b/ui/port/src/main/java/androidx/ui/widgets/basic/PhysicalShape.kt
index 387dbfa..8c52b47 100644
--- a/ui/port/src/main/java/androidx/ui/widgets/basic/PhysicalShape.kt
+++ b/ui/port/src/main/java/androidx/ui/widgets/basic/PhysicalShape.kt
@@ -19,7 +19,7 @@
import androidx.ui.foundation.Key
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
import androidx.ui.foundation.diagnostics.DiagnosticsProperty
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.painting.Color
import androidx.ui.painting.Path
import androidx.ui.rendering.obj.RenderObject
@@ -54,7 +54,7 @@
*/
val clipper: CustomClipper<Path>,
/** The z-coordinate at which to place this physical object. */
- val elevation: Double = 0.0,
+ val elevation: Float = 0.0f,
/** The background color. */
val color: Color,
/** When elevation is non zero the color to use for the shadow color. */
@@ -83,7 +83,7 @@
override fun debugFillProperties(properties: DiagnosticPropertiesBuilder) {
super.debugFillProperties(properties)
properties.add(DiagnosticsProperty.create("clipper", clipper))
- properties.add(DoubleProperty.create("elevation", elevation))
+ properties.add(FloatProperty.create("elevation", elevation))
properties.add(DiagnosticsProperty.create("color", color))
properties.add(DiagnosticsProperty.create("shadowColor", shadowColor))
}
diff --git a/ui/port/src/main/java/androidx/ui/widgets/basic/RawImage.kt b/ui/port/src/main/java/androidx/ui/widgets/basic/RawImage.kt
index 1ea5ece..c594d352 100644
--- a/ui/port/src/main/java/androidx/ui/widgets/basic/RawImage.kt
+++ b/ui/port/src/main/java/androidx/ui/widgets/basic/RawImage.kt
@@ -20,7 +20,7 @@
import androidx.ui.foundation.Key
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
import androidx.ui.foundation.diagnostics.DiagnosticsProperty
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.foundation.diagnostics.EnumProperty
import androidx.ui.foundation.diagnostics.FlagProperty
import androidx.ui.painting.BlendMode
@@ -60,20 +60,20 @@
* If null, the image will pick a size that best preserves its intrinsic
* aspect ratio.
*/
- val width: Double? = null,
+ val width: Float? = null,
/**
* If non-null, require the image to have this height.
*
* If null, the image will pick a size that best preserves its intrinsic
* aspect ratio.
*/
- val height: Double? = null,
+ val height: Float? = null,
/**
* Specifies the image's scale.
*
* Used when determining the best display size for the image.
*/
- val scale: Double = 1.0,
+ val scale: Float = 1.0f,
/** If non-null, this color is blended with each image pixel using [colorBlendMode]. */
val color: Color? = null,
/**
@@ -195,9 +195,9 @@
override fun debugFillProperties(properties: DiagnosticPropertiesBuilder) {
super.debugFillProperties(properties)
properties.add(DiagnosticsProperty.create("image", image))
- properties.add(DoubleProperty.create("width", width, defaultValue = null))
- properties.add(DoubleProperty.create("height", height, defaultValue = null))
- properties.add(DoubleProperty.create("scale", scale, defaultValue = 1.0))
+ properties.add(FloatProperty.create("width", width, defaultValue = null))
+ properties.add(FloatProperty.create("height", height, defaultValue = null))
+ properties.add(FloatProperty.create("scale", scale, defaultValue = 1.0f))
properties.add(DiagnosticsProperty.create("color", color, defaultValue = null))
properties.add(EnumProperty("colorBlendMode", colorBlendMode, defaultValue = null))
properties.add(EnumProperty("fit", fit, defaultValue = null))
@@ -210,4 +210,4 @@
ifTrue = "match text direction"
))
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/main/java/androidx/ui/widgets/basic/RichText.kt b/ui/port/src/main/java/androidx/ui/widgets/basic/RichText.kt
index 1c6fb3c..e5af593 100644
--- a/ui/port/src/main/java/androidx/ui/widgets/basic/RichText.kt
+++ b/ui/port/src/main/java/androidx/ui/widgets/basic/RichText.kt
@@ -20,7 +20,7 @@
import androidx.ui.engine.text.TextDirection
import androidx.ui.foundation.Key
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.foundation.diagnostics.EnumProperty
import androidx.ui.foundation.diagnostics.FlagProperty
import androidx.ui.foundation.diagnostics.IntProperty
@@ -82,7 +82,7 @@
val textDirection: TextDirection? = null,
val softWrap: Boolean = true,
val overflow: TextOverflow = TextOverflow.CLIP,
- val textScaleFactor: Double = 1.0,
+ val textScaleFactor: Float = 1.0f,
val maxLines: Int? = null
) : LeafRenderObjectWidget(key = key) {
init {
@@ -148,10 +148,10 @@
)
)
properties.add(
- DoubleProperty.create(
+ FloatProperty.create(
"textScaleFactor",
textScaleFactor,
- defaultValue = 1.0
+ defaultValue = 1.0f
)
)
properties.add(IntProperty("maxLines", maxLines, ifNull = "unlimited"))
diff --git a/ui/port/src/main/java/androidx/ui/widgets/gesturedetector/GestureDetector.kt b/ui/port/src/main/java/androidx/ui/widgets/gesturedetector/GestureDetector.kt
index c5e94b6..cd7504e 100644
--- a/ui/port/src/main/java/androidx/ui/widgets/gesturedetector/GestureDetector.kt
+++ b/ui/port/src/main/java/androidx/ui/widgets/gesturedetector/GestureDetector.kt
@@ -708,7 +708,7 @@
it(updateDetails)
}
recognizer.onEnd?.let {
- it(DragEndDetails(primaryVelocity = 0.0))
+ it(DragEndDetails(primaryVelocity = 0.0f))
}
return
}
@@ -747,7 +747,7 @@
it(updateDetails)
}
recognizer.onEnd?.let {
- it(DragEndDetails(primaryVelocity = 0.0))
+ it(DragEndDetails(primaryVelocity = 0.0f))
}
return
}
diff --git a/ui/port/src/main/java/androidx/ui/widgets/implicitanimation/AnimatedWidgetBaseState.kt b/ui/port/src/main/java/androidx/ui/widgets/implicitanimation/AnimatedWidgetBaseState.kt
index 06acad0..64c3180 100644
--- a/ui/port/src/main/java/androidx/ui/widgets/implicitanimation/AnimatedWidgetBaseState.kt
+++ b/ui/port/src/main/java/androidx/ui/widgets/implicitanimation/AnimatedWidgetBaseState.kt
@@ -53,7 +53,7 @@
private var controller: AnimationController? = null
/** The animation driving this widget's implicit animations. */
- var animation: Animation<Double>? = null
+ var animation: Animation<Float>? = null
private set
override fun initState() {
@@ -88,7 +88,7 @@
}
})
controller.apply {
- value = 0.0
+ value = 0.0f
forward()
}
}
diff --git a/ui/port/src/main/java/androidx/ui/widgets/text/Text.kt b/ui/port/src/main/java/androidx/ui/widgets/text/Text.kt
index 91e93f9..afd3edd 100644
--- a/ui/port/src/main/java/androidx/ui/widgets/text/Text.kt
+++ b/ui/port/src/main/java/androidx/ui/widgets/text/Text.kt
@@ -21,7 +21,7 @@
import androidx.ui.foundation.Key
import androidx.ui.foundation.diagnostics.DiagnosticPropertiesBuilder
import androidx.ui.foundation.diagnostics.DiagnosticsTreeStyle
-import androidx.ui.foundation.diagnostics.DoubleProperty
+import androidx.ui.foundation.diagnostics.FloatProperty
import androidx.ui.foundation.diagnostics.EnumProperty
import androidx.ui.foundation.diagnostics.FlagProperty
import androidx.ui.foundation.diagnostics.IntProperty
@@ -83,7 +83,7 @@
/** How visual overflow should be handled. */
val overflow: TextOverflow? = null,
/** The number of font pixels for each logical pixel. */
- val textScaleFactor: Double? = null,
+ val textScaleFactor: Float? = null,
/**
* An optional maximum number of lines for the text to span, wrapping if necessary.If the text
* exceeds the given number of lines, it will be truncated according to [overflow].
@@ -125,7 +125,7 @@
textDirection: TextDirection? = null,
softWrap: Boolean? = null,
overflow: TextOverflow? = null,
- textScaleFactor: Double? = null,
+ textScaleFactor: Float? = null,
maxLines: Int? = null
) : this(key, style, textAlign, textDirection, softWrap, overflow, textScaleFactor, maxLines) {
this.data = data
@@ -141,7 +141,7 @@
textDirection: TextDirection? = null,
softWrap: Boolean? = null,
overflow: TextOverflow? = null,
- textScaleFactor: Double? = null,
+ textScaleFactor: Float? = null,
maxLines: Int? = null
) : this(key, style, textAlign, textDirection, softWrap, overflow, textScaleFactor, maxLines) {
this.textSpan = textSpan
@@ -167,7 +167,7 @@
overflow = overflow ?: defaultTextStyle.overflow,
// TODO(Migration/qqd): Implement textScaleFactor's fallback value
// MediaQuery.textScaleFactorOf(context) after MediaQuery is implemented.
- textScaleFactor = textScaleFactor ?: 1.0,
+ textScaleFactor = textScaleFactor ?: 1.0f,
maxLines = maxLines ?: defaultTextStyle.maxLines,
text = TextSpan(
style = effectiveTextStyle,
@@ -208,7 +208,7 @@
)
properties.add(EnumProperty<TextOverflow>("overflow", overflow, defaultValue = null))
properties.add(
- DoubleProperty.create(
+ FloatProperty.create(
"textScaleFactor",
textScaleFactor,
defaultValue = null
diff --git a/ui/port/src/main/java/androidx/ui/widgets/view/ViewRenderObject.kt b/ui/port/src/main/java/androidx/ui/widgets/view/ViewRenderObject.kt
index 781b9c3..c6ce8f2 100644
--- a/ui/port/src/main/java/androidx/ui/widgets/view/ViewRenderObject.kt
+++ b/ui/port/src/main/java/androidx/ui/widgets/view/ViewRenderObject.kt
@@ -50,8 +50,8 @@
val layoutParams = view.layoutParams
var widthMode: Int
var heightMode: Int
- var width: Double
- var height: Double
+ var width: Float
+ var height: Float
width = obtainDimension(largest.width, layoutParams?.width)
height = obtainDimension(largest.height, layoutParams?.height)
@@ -62,12 +62,12 @@
height = boxConstraints.constrainHeight(height)
if (width.isInfinite()) {
- width = 0.0
+ width = 0.0f
widthMode = View.MeasureSpec.UNSPECIFIED
}
if (height.isInfinite()) {
- height = 0.0
+ height = 0.0f
heightMode = View.MeasureSpec.UNSPECIFIED
}
@@ -79,19 +79,19 @@
// Constrain the Size in case the measured View dimensions do not fit within
// the given constraints
this.size = Size(
- boxConstraints.constrainWidth(view.measuredWidth.toDouble()),
- boxConstraints.constrainHeight(view.measuredHeight.toDouble())
+ boxConstraints.constrainWidth(view.measuredWidth.toFloat()),
+ boxConstraints.constrainHeight(view.measuredHeight.toFloat())
)
}
- private fun obtainDimension(maxDimen: Double, viewLayoutParam: Int?): Double {
+ private fun obtainDimension(maxDimen: Float, viewLayoutParam: Int?): Float {
val shouldMatchConstrainedWidth = viewLayoutParam == null ||
viewLayoutParam == MATCH_PARENT ||
viewLayoutParam == WRAP_CONTENT
return if (shouldMatchConstrainedWidth) {
maxDimen
} else {
- viewLayoutParam!!.toDouble()
+ viewLayoutParam!!.toFloat()
}
}
@@ -119,8 +119,8 @@
}
val canvas = context.canvas.toFrameworkCanvas()
- val dx = offset.dx.toFloat()
- val dy = offset.dy.toFloat()
+ val dx = offset.dx
+ val dy = offset.dy
canvas.translate(dx, dy)
view.draw(canvas)
canvas.translate(-dx, -dy)
diff --git a/ui/port/src/test/java/androidx/ui/engine/geometry/RRectTest.kt b/ui/port/src/test/java/androidx/ui/engine/geometry/RRectTest.kt
index f4e0dcf..95d9b30 100644
--- a/ui/port/src/test/java/androidx/ui/engine/geometry/RRectTest.kt
+++ b/ui/port/src/test/java/androidx/ui/engine/geometry/RRectTest.kt
@@ -28,40 +28,40 @@
@Test
fun `RRect_contains()`() {
val rrect = RRect(
- Rect.fromLTRB(1.0, 1.0, 2.0, 2.0),
- topLeft = Radius.circular(0.5),
- topRight = Radius.circular(0.25),
- bottomRight = Radius.elliptical(0.25, 0.75),
+ Rect.fromLTRB(1.0f, 1.0f, 2.0f, 2.0f),
+ topLeft = Radius.circular(0.5f),
+ topRight = Radius.circular(0.25f),
+ bottomRight = Radius.elliptical(0.25f, 0.75f),
bottomLeft = Radius.zero
)
- assertFalse(rrect.contains(Offset(1.0, 1.0)))
- assertFalse(rrect.contains(Offset(1.1, 1.1)))
- assertTrue(rrect.contains(Offset(1.15, 1.15)))
- assertFalse(rrect.contains(Offset(2.0, 1.0)))
- assertFalse(rrect.contains(Offset(1.93, 1.07)))
- assertFalse(rrect.contains(Offset(1.97, 1.7)))
- assertTrue(rrect.contains(Offset(1.7, 1.97)))
- assertTrue(rrect.contains(Offset(1.0, 1.99)))
+ assertFalse(rrect.contains(Offset(1.0f, 1.0f)))
+ assertFalse(rrect.contains(Offset(1.1f, 1.1f)))
+ assertTrue(rrect.contains(Offset(1.15f, 1.15f)))
+ assertFalse(rrect.contains(Offset(2.0f, 1.0f)))
+ assertFalse(rrect.contains(Offset(1.93f, 1.07f)))
+ assertFalse(rrect.contains(Offset(1.97f, 1.7f)))
+ assertTrue(rrect.contains(Offset(1.7f, 1.97f)))
+ assertTrue(rrect.contains(Offset(1.0f, 1.99f)))
}
@Test
fun `RRect_contains() large radii`() {
val rrect = RRect(
- Rect.fromLTRB(1.0, 1.0, 2.0, 2.0),
- topLeft = Radius.circular(5000.0),
- topRight = Radius.circular(2500.0),
- bottomRight = Radius.elliptical(2500.0, 7500.0),
+ Rect.fromLTRB(1.0f, 1.0f, 2.0f, 2.0f),
+ topLeft = Radius.circular(5000.0f),
+ topRight = Radius.circular(2500.0f),
+ bottomRight = Radius.elliptical(2500.0f, 7500.0f),
bottomLeft = Radius.zero
)
- assertFalse(rrect.contains(Offset(1.0, 1.0)))
- assertFalse(rrect.contains(Offset(1.1, 1.1)))
- assertTrue(rrect.contains(Offset(1.15, 1.15)))
- assertFalse(rrect.contains(Offset(2.0, 1.0)))
- assertFalse(rrect.contains(Offset(1.93, 1.07)))
- assertFalse(rrect.contains(Offset(1.97, 1.7)))
- assertTrue(rrect.contains(Offset(1.7, 1.97)))
- assertTrue(rrect.contains(Offset(1.0, 1.99)))
+ assertFalse(rrect.contains(Offset(1.0f, 1.0f)))
+ assertFalse(rrect.contains(Offset(1.1f, 1.1f)))
+ assertTrue(rrect.contains(Offset(1.15f, 1.15f)))
+ assertFalse(rrect.contains(Offset(2.0f, 1.0f)))
+ assertFalse(rrect.contains(Offset(1.93f, 1.07f)))
+ assertFalse(rrect.contains(Offset(1.97f, 1.7f)))
+ assertTrue(rrect.contains(Offset(1.7f, 1.97f)))
+ assertTrue(rrect.contains(Offset(1.0f, 1.99f)))
}
}
\ No newline at end of file
diff --git a/ui/port/src/test/java/androidx/ui/engine/geometry/RectTest.kt b/ui/port/src/test/java/androidx/ui/engine/geometry/RectTest.kt
index 41b16e3..3f3e5ca 100644
--- a/ui/port/src/test/java/androidx/ui/engine/geometry/RectTest.kt
+++ b/ui/port/src/test/java/androidx/ui/engine/geometry/RectTest.kt
@@ -25,36 +25,36 @@
class RectTest {
companion object {
- private const val DELTA = 0.01
+ private const val DELTA = 0.01f
}
@Test
fun `rect accessors`() {
- val r = Rect.fromLTRB(1.0, 3.0, 5.0, 7.0)
- assertEquals(1.0, r.left, DELTA)
- assertEquals(3.0, r.top, DELTA)
- assertEquals(5.0, r.right, DELTA)
- assertEquals(7.0, r.bottom, DELTA)
+ val r = Rect.fromLTRB(1.0f, 3.0f, 5.0f, 7.0f)
+ assertEquals(1.0f, r.left, DELTA)
+ assertEquals(3.0f, r.top, DELTA)
+ assertEquals(5.0f, r.right, DELTA)
+ assertEquals(7.0f, r.bottom, DELTA)
}
@Test
fun `rect created by width and height`() {
- val r = Rect.fromLTWH(1.0, 3.0, 5.0, 7.0)
- assertEquals(1.0, r.left, DELTA)
- assertEquals(3.0, r.top, DELTA)
- assertEquals(6.0, r.right, DELTA)
- assertEquals(10.0, r.bottom, DELTA)
+ val r = Rect.fromLTWH(1.0f, 3.0f, 5.0f, 7.0f)
+ assertEquals(1.0f, r.left, DELTA)
+ assertEquals(3.0f, r.top, DELTA)
+ assertEquals(6.0f, r.right, DELTA)
+ assertEquals(10.0f, r.bottom, DELTA)
}
@Test
fun `rect intersection`() {
- val r1 = Rect.fromLTRB(0.0, 0.0, 100.0, 100.0)
- val r2 = Rect.fromLTRB(50.0, 50.0, 200.0, 200.0)
+ val r1 = Rect.fromLTRB(0.0f, 0.0f, 100.0f, 100.0f)
+ val r2 = Rect.fromLTRB(50.0f, 50.0f, 200.0f, 200.0f)
val r3 = r1.intersect(r2)
- assertEquals(50.0, r3.left, DELTA)
- assertEquals(50.0, r3.top, DELTA)
- assertEquals(100.0, r3.right, DELTA)
- assertEquals(100.0, r3.bottom, DELTA)
+ assertEquals(50.0f, r3.left, DELTA)
+ assertEquals(50.0f, r3.top, DELTA)
+ assertEquals(100.0f, r3.right, DELTA)
+ assertEquals(100.0f, r3.bottom, DELTA)
val r4 = r2.intersect(r1)
assertEquals(r3, r4)
}
diff --git a/ui/port/src/test/java/androidx/ui/engine/text/FontWeightTest.kt b/ui/port/src/test/java/androidx/ui/engine/text/FontWeightTest.kt
index 391754a..40b7af0 100644
--- a/ui/port/src/test/java/androidx/ui/engine/text/FontWeightTest.kt
+++ b/ui/port/src/test/java/androidx/ui/engine/text/FontWeightTest.kt
@@ -25,13 +25,13 @@
@Test
fun `lerp with null parameters`() {
- assertThat(FontWeight.lerp(null, null, 0.0)).isEqualTo(FontWeight.normal)
+ assertThat(FontWeight.lerp(null, null, 0.0f)).isEqualTo(FontWeight.normal)
}
@Test
fun `lerp with one null parameter should use normal for null value`() {
- assertThat(FontWeight.lerp(FontWeight.w200, null, 0.5)).isEqualTo(FontWeight.w300)
- assertThat(FontWeight.lerp(null, FontWeight.w200, 0.5)).isEqualTo(FontWeight.w300)
+ assertThat(FontWeight.lerp(FontWeight.w200, null, 0.5f)).isEqualTo(FontWeight.w300)
+ assertThat(FontWeight.lerp(null, FontWeight.w200, 0.5f)).isEqualTo(FontWeight.w300)
}
@Test
@@ -40,7 +40,7 @@
FontWeight.lerp(
FontWeight.w200,
FontWeight.w400,
- 0.0
+ 0.0f
)
).isEqualTo(FontWeight.w200)
}
@@ -51,7 +51,7 @@
FontWeight.lerp(
FontWeight.w200,
FontWeight.w400,
- 1.0
+ 1.0f
)
).isEqualTo(FontWeight.w400)
}
@@ -62,7 +62,7 @@
FontWeight.lerp(
FontWeight.w200,
FontWeight.w800,
- 0.5
+ 0.5f
)
).isEqualTo(FontWeight.w500)
}
@@ -73,7 +73,7 @@
FontWeight.lerp(
FontWeight.w200,
FontWeight.w900,
- 0.5
+ 0.5f
)
).isEqualTo(FontWeight.w600)
}
diff --git a/ui/port/src/test/java/androidx/ui/engine/text/ParagraphBuilderTest.kt b/ui/port/src/test/java/androidx/ui/engine/text/ParagraphBuilderTest.kt
index 7f5bb910..39d164d 100644
--- a/ui/port/src/test/java/androidx/ui/engine/text/ParagraphBuilderTest.kt
+++ b/ui/port/src/test/java/androidx/ui/engine/text/ParagraphBuilderTest.kt
@@ -168,7 +168,7 @@
TextStyle(color = Color.fromARGB(1, 2, 3, 4)),
TextStyle(fontStyle = FontStyle.italic),
TextStyle(fontWeight = FontWeight.bold),
- TextStyle(letterSpacing = 1.0)
+ TextStyle(letterSpacing = 1.0f)
)
val paragraphBuilder = ParagraphBuilder(paragraphStyle)
@@ -241,8 +241,8 @@
val fontWeight = FontWeight.bold
val fontStyle = FontStyle.italic
val maxLines = 2
- val fontSize = 1.0
- val lineHeight = 2.0
+ val fontSize = 1.0f
+ val lineHeight = 2.0f
val ellipsis = "dot dot"
val locale = Locale("en")
diff --git a/ui/port/src/test/java/androidx/ui/engine/text/ParagraphConstraintsTest.kt b/ui/port/src/test/java/androidx/ui/engine/text/ParagraphConstraintsTest.kt
index ed9dbb4..da3bcb1 100644
--- a/ui/port/src/test/java/androidx/ui/engine/text/ParagraphConstraintsTest.kt
+++ b/ui/port/src/test/java/androidx/ui/engine/text/ParagraphConstraintsTest.kt
@@ -27,7 +27,7 @@
@Test
fun `toString with values`() {
- val paragraphConstraints = ParagraphConstraints(width = 101.0)
+ val paragraphConstraints = ParagraphConstraints(width = 101.0f)
assertThat(
paragraphConstraints.toString(),
`is`(equalTo("ParagraphConstraints(width: 101.0)"))
diff --git a/ui/port/src/test/java/androidx/ui/engine/text/ParagraphStyleTest.kt b/ui/port/src/test/java/androidx/ui/engine/text/ParagraphStyleTest.kt
index 5243553..b1a7c7c 100644
--- a/ui/port/src/test/java/androidx/ui/engine/text/ParagraphStyleTest.kt
+++ b/ui/port/src/test/java/androidx/ui/engine/text/ParagraphStyleTest.kt
@@ -61,8 +61,8 @@
val fontStyle = FontStyle.italic
val maxLines = 2
val fontFamily = FontFamily("sans-serif")
- val fontSize = 1.0
- val lineHeight = 2.0
+ val fontSize = 1.0f
+ val lineHeight = 2.0f
val ellipsis = "dot dot"
val locale = Locale("en")
val fontSynthesis = FontSynthesis.style
@@ -129,8 +129,8 @@
val fontStyle = FontStyle.italic
val maxLines = 2
val fontFamily = FontFamily("sans-serif")
- val fontSize = 1.0
- val lineHeight = 2.0
+ val fontSize = 1.0f
+ val lineHeight = 2.0f
val ellipsis = "dot dot"
val locale = Locale("en")
val fontSynthesis = FontSynthesis.style
diff --git a/ui/port/src/test/java/androidx/ui/engine/text/ParagraphTest.kt b/ui/port/src/test/java/androidx/ui/engine/text/ParagraphTest.kt
index 3cc66df..dc7cb00 100644
--- a/ui/port/src/test/java/androidx/ui/engine/text/ParagraphTest.kt
+++ b/ui/port/src/test/java/androidx/ui/engine/text/ParagraphTest.kt
@@ -31,42 +31,42 @@
fun `width default value`() {
val paragraphStyle = createParagraphStyle()
val paragraph = Paragraph(StringBuilder(), paragraphStyle, listOf())
- assertThat(paragraph.width, equalTo(-1.0))
+ assertThat(paragraph.width, equalTo(-1.0f))
}
@Test
fun `height default value`() {
val paragraphStyle = createParagraphStyle()
val paragraph = Paragraph(StringBuilder(), paragraphStyle, listOf())
- assertThat(paragraph.height, equalTo(0.0))
+ assertThat(paragraph.height, equalTo(0.0f))
}
@Test
fun `minIntrinsicWidth default value`() {
val paragraphStyle = createParagraphStyle()
val paragraph = Paragraph(StringBuilder(), paragraphStyle, listOf())
- assertThat(paragraph.minIntrinsicWidth, equalTo(0.0))
+ assertThat(paragraph.minIntrinsicWidth, equalTo(0.0f))
}
@Test
fun `maxIntrinsicWidth default value`() {
val paragraphStyle = createParagraphStyle()
val paragraph = Paragraph(StringBuilder(), paragraphStyle, listOf())
- assertThat(paragraph.maxIntrinsicWidth, equalTo(0.0))
+ assertThat(paragraph.maxIntrinsicWidth, equalTo(0.0f))
}
@Test
fun `alphabeticBaseline default value`() {
val paragraphStyle = createParagraphStyle()
val paragraph = Paragraph(StringBuilder(), paragraphStyle, listOf())
- assertThat(paragraph.alphabeticBaseline, equalTo(Double.MAX_VALUE))
+ assertThat(paragraph.alphabeticBaseline, equalTo(Float.MAX_VALUE))
}
@Test
fun `ideographicBaseline default value`() {
val paragraphStyle = createParagraphStyle()
val paragraph = Paragraph(StringBuilder(), paragraphStyle, listOf())
- assertThat(paragraph.ideographicBaseline, equalTo(Double.MAX_VALUE))
+ assertThat(paragraph.ideographicBaseline, equalTo(Float.MAX_VALUE))
}
@Test
@@ -80,14 +80,14 @@
fun `paint throws exception if layout is not called`() {
val paragraphStyle = createParagraphStyle()
val paragraph = Paragraph(StringBuilder(), paragraphStyle, listOf())
- paragraph.paint(mock(), 0.0, 0.0)
+ paragraph.paint(mock(), 0.0f, 0.0f)
}
@Test(expected = IllegalStateException::class)
fun `getPositionForOffset throws exception if layout is not called`() {
val paragraphStyle = createParagraphStyle()
val paragraph = Paragraph(StringBuilder(), paragraphStyle, listOf())
- paragraph.getPositionForOffset(Offset(0.0, 0.0))
+ paragraph.getPositionForOffset(Offset(0.0f, 0.0f))
}
private fun createParagraphStyle(): ParagraphStyle {
@@ -96,8 +96,8 @@
val fontWeight = FontWeight.bold
val fontStyle = FontStyle.italic
val maxLines = 2
- val fontSize = 1.0
- val lineHeight = 2.0
+ val fontSize = 1.0f
+ val lineHeight = 2.0f
val ellipsis = "dot dot"
val locale = Locale("en")
diff --git a/ui/port/src/test/java/androidx/ui/engine/text/TextBoxTest.kt b/ui/port/src/test/java/androidx/ui/engine/text/TextBoxTest.kt
index fe33b84..cf71357 100644
--- a/ui/port/src/test/java/androidx/ui/engine/text/TextBoxTest.kt
+++ b/ui/port/src/test/java/androidx/ui/engine/text/TextBoxTest.kt
@@ -28,44 +28,44 @@
@Test
fun `toRect`() {
- val textBox = TextBox(1.0, 2.0, 3.0, 4.0, TextDirection.LTR)
- assertThat(textBox.toRect(), `is`(equalTo(Rect.fromLTRB(1.0, 2.0, 3.0, 4.0))))
+ val textBox = TextBox(1.0f, 2.0f, 3.0f, 4.0f, TextDirection.LTR)
+ assertThat(textBox.toRect(), `is`(equalTo(Rect.fromLTRB(1.0f, 2.0f, 3.0f, 4.0f))))
}
@Test
fun `start for LTR`() {
- val textBox = TextBox(1.0, 2.0, 3.0, 4.0, TextDirection.LTR)
- assertThat(textBox.start(), `is`(equalTo(1.0)))
+ val textBox = TextBox(1.0f, 2.0f, 3.0f, 4.0f, TextDirection.LTR)
+ assertThat(textBox.start(), `is`(equalTo(1.0f)))
}
@Test
fun `start for RTL`() {
- val textBox = TextBox(1.0, 2.0, 3.0, 4.0, TextDirection.RTL)
- assertThat(textBox.start(), `is`(equalTo(3.0)))
+ val textBox = TextBox(1.0f, 2.0f, 3.0f, 4.0f, TextDirection.RTL)
+ assertThat(textBox.start(), `is`(equalTo(3.0f)))
}
@Test
fun `end for LTR`() {
- val textBox = TextBox(1.0, 2.0, 3.0, 4.0, TextDirection.LTR)
- assertThat(textBox.end(), `is`(equalTo(3.0)))
+ val textBox = TextBox(1.0f, 2.0f, 3.0f, 4.0f, TextDirection.LTR)
+ assertThat(textBox.end(), `is`(equalTo(3.0f)))
}
@Test
fun `end for RTL`() {
- val textBox = TextBox(1.0, 2.0, 3.0, 4.0, TextDirection.RTL)
- assertThat(textBox.end(), `is`(equalTo(1.0)))
+ val textBox = TextBox(1.0f, 2.0f, 3.0f, 4.0f, TextDirection.RTL)
+ assertThat(textBox.end(), `is`(equalTo(1.0f)))
}
@Test
fun `fromLTRBD`() {
- val textBox = TextBox.fromLTRBD(1.0, 2.0, 3.0, 4.0, TextDirection.LTR)
- assertThat(textBox.toRect(), `is`(equalTo(Rect.fromLTRB(1.0, 2.0, 3.0, 4.0))))
+ val textBox = TextBox.fromLTRBD(1.0f, 2.0f, 3.0f, 4.0f, TextDirection.LTR)
+ assertThat(textBox.toRect(), `is`(equalTo(Rect.fromLTRB(1.0f, 2.0f, 3.0f, 4.0f))))
assertThat(textBox.direction, `is`(equalTo(TextDirection.LTR)))
}
@Test
fun `toString `() {
- val textBox = TextBox(1.0, 2.0, 3.0, 4.0, TextDirection.LTR)
+ val textBox = TextBox(1.0f, 2.0f, 3.0f, 4.0f, TextDirection.LTR)
assertThat(
textBox.toString(),
`is`(equalTo("TextBox.fromLTRBD(1.0, 2.0, 3.0, 4.0, ${TextDirection.LTR})"))
diff --git a/ui/port/src/test/java/androidx/ui/engine/text/TextStyleTest.kt b/ui/port/src/test/java/androidx/ui/engine/text/TextStyleTest.kt
index 5e95ac0..c50babb 100644
--- a/ui/port/src/test/java/androidx/ui/engine/text/TextStyleTest.kt
+++ b/ui/port/src/test/java/androidx/ui/engine/text/TextStyleTest.kt
@@ -77,10 +77,10 @@
val fontStyle = FontStyle.italic
val textBaseline = TextBaseline.alphabetic
val fontFamily = FontFamily("sans-serif")
- val fontSize = 1.0
- val letterSpacing = 2.0
- val wordSpacing = 3.0
- val height = 4.0
+ val fontSize = 1.0f
+ val letterSpacing = 2.0f
+ val wordSpacing = 3.0f
+ val height = 4.0f
val locale = Locale("en")
val background = Color(0xFF000000.toInt())
val fontSynthesis = FontSynthesis.style
diff --git a/ui/port/src/test/java/androidx/ui/foundation/ComponentNodeTest.kt b/ui/port/src/test/java/androidx/ui/foundation/ComponentNodeTest.kt
index 5a3cb8d..2cfce69 100644
--- a/ui/port/src/test/java/androidx/ui/foundation/ComponentNodeTest.kt
+++ b/ui/port/src/test/java/androidx/ui/foundation/ComponentNodeTest.kt
@@ -40,7 +40,7 @@
// Ensure that attach and detach work properly
@Test
fun componentNodeAttachDetach() {
- val node = LayoutNode { _, _ -> Size(0.0, 0.0) }
+ val node = LayoutNode { _, _ -> Size(0.0f, 0.0f) }
assertNull(node.owner)
val owner = mock(Owner::class.java)
@@ -268,7 +268,7 @@
// Ensure that depth is as expected
@Test
fun depth() {
- val root = LayoutNode { _, _ -> Size(0.0, 0.0) }
+ val root = LayoutNode { _, _ -> Size(0.0f, 0.0f) }
val (child, grand1, grand2) = createSimpleLayout()
root.add(0, child)
@@ -284,8 +284,8 @@
// layoutNode hierarchy should be set properly when a LayoutNode is a child of a LayoutNode
@Test
fun directLayoutNodeHierarchy() {
- val layoutNode = LayoutNode { _, _ -> Size(0.0, 0.0) }
- val childLayoutNode = LayoutNode { _, _ -> Size(0.0, 0.0) }
+ val layoutNode = LayoutNode { _, _ -> Size(0.0f, 0.0f) }
+ val childLayoutNode = LayoutNode { _, _ -> Size(0.0f, 0.0f) }
layoutNode.add(0, childLayoutNode)
val owner = mock(Owner::class.java)
@@ -305,9 +305,9 @@
// layoutNode hierarchy should be set properly when a LayoutNode is a grandchild of a LayoutNode
@Test
fun indirectLayoutNodeHierarchy() {
- val layoutNode = LayoutNode { _, _ -> Size(0.0, 0.0) }
+ val layoutNode = LayoutNode { _, _ -> Size(0.0f, 0.0f) }
val intermediate = GestureNode()
- val childLayoutNode = LayoutNode { _, _ -> Size(0.0, 0.0) }
+ val childLayoutNode = LayoutNode { _, _ -> Size(0.0f, 0.0f) }
layoutNode.add(0, intermediate)
intermediate.add(0, childLayoutNode)
@@ -349,7 +349,7 @@
val owner = mock(Owner::class.java)
node.attach(owner)
verify(owner, times(1)).onRequestLayout(node)
- LayoutNode.measure(node, BoxConstraints.tightFor(0.0, 0.0), false)
+ LayoutNode.measure(node, BoxConstraints.tightFor(0.0f, 0.0f), false)
reset(owner)
node.dirtyLayout()
@@ -367,10 +367,10 @@
val (parent, child) = createNestedLayout()
val owner = mock(Owner::class.java)
parent.attach(owner)
- val constraints = BoxConstraints.tightFor(width = 20.0, height = 25.0)
+ val constraints = BoxConstraints.tightFor(width = 20.0f, height = 25.0f)
LayoutNode.measure(parent, constraints, true)
assertEquals(constraints, parent.constraints)
- val childConstraints = BoxConstraints.tightFor(width = 10.0, height = 15.0)
+ val childConstraints = BoxConstraints.tightFor(width = 10.0f, height = 15.0f)
assertEquals(childConstraints, child.constraints)
assertTrue(parent.parentUsesSize)
assertFalse(child.parentUsesSize)
@@ -468,9 +468,9 @@
}
private fun createSimpleLayout(): Triple<LayoutNode, ComponentNode, ComponentNode> {
- val layoutNode = LayoutNode { _, _ -> Size(0.0, 0.0) }
- val child1 = LayoutNode { _, _ -> Size(0.0, 0.0) }
- val child2 = LayoutNode { _, _ -> Size(0.0, 0.0) }
+ val layoutNode = LayoutNode { _, _ -> Size(0.0f, 0.0f) }
+ val child1 = LayoutNode { _, _ -> Size(0.0f, 0.0f) }
+ val child2 = LayoutNode { _, _ -> Size(0.0f, 0.0f) }
layoutNode.add(0, child1)
layoutNode.add(1, child2)
return Triple(layoutNode, child1, child2)
@@ -480,7 +480,8 @@
val parent = LayoutNode { c, _ ->
val child = layoutChildren.values.first()!!
c as BoxConstraints
- val constraints = BoxConstraints.tightFor(c.minWidth - 10.0, c.minHeight - 10.0)
+ val constraints = BoxConstraints.tightFor(c.minWidth - 10.0f,
+ c.minHeight - 10.0f)
measure(child, constraints, false)
position(child, 5, 4)
Size(c.minWidth, c.minHeight)
diff --git a/ui/port/src/test/java/androidx/ui/foundation/diagnostics/DiagnosticsTest.kt b/ui/port/src/test/java/androidx/ui/foundation/diagnostics/DiagnosticsTest.kt
index b60c86f..0f591dc 100644
--- a/ui/port/src/test/java/androidx/ui/foundation/diagnostics/DiagnosticsTest.kt
+++ b/ui/port/src/test/java/androidx/ui/foundation/diagnostics/DiagnosticsTest.kt
@@ -125,7 +125,7 @@
validatePropertyJsonSerializationHelper(json, property)
}
- fun validateDoublePropertyJsonSerialization(property: DoubleProperty) {
+ fun validateDoublePropertyJsonSerialization(property: FloatProperty) {
val json: Map<String, Any> = simulateJsonSerialization(property)
if (property.unit != null) {
assertEquals(property.unit, json["unit"])
@@ -353,8 +353,8 @@
val tree = TestTree(
properties = listOf(
StringProperty("stringProperty1", "value1", quoted = false),
- DoubleProperty.create("doubleProperty1", 42.5),
- DoubleProperty.create("roundedProperty", 1.0 / 3.0),
+ FloatProperty.create("doubleProperty1", 42.5f),
+ FloatProperty.create("roundedProperty", 1.0f / 3.0f),
StringProperty("DO_NOT_SHOW", "DO_NOT_SHOW", level = DiagnosticLevel.hidden,
quoted = false),
DiagnosticsProperty.create("DO_NOT_SHOW_NULL", null, defaultValue = null),
@@ -864,56 +864,56 @@
}
@Test
- fun `double property test`() {
- val doubleProperty = DoubleProperty.create(
+ fun `Float property test`() {
+ val doubleProperty = FloatProperty.create(
"name",
- 42.0
+ 42.0f
)
assertEquals("name: 42.0", doubleProperty.toString())
assertFalse(doubleProperty.isFiltered(DiagnosticLevel.info))
- assertEquals(42.0, doubleProperty.getValue())
+ assertEquals(42.0f, doubleProperty.getValue())
validateDoublePropertyJsonSerialization(doubleProperty)
- assertEquals("name: 1.3", DoubleProperty.create("name", 1.3333).toString())
+ assertEquals("name: 1.3", FloatProperty.create("name", 1.3333f).toString())
- assertEquals("name: null", DoubleProperty.create("name", null).toString())
- assertEquals(false, DoubleProperty.create("name", null).isFiltered(DiagnosticLevel.info))
+ assertEquals("name: null", FloatProperty.create("name", null).toString())
+ assertEquals(false, FloatProperty.create("name", null).isFiltered(DiagnosticLevel.info))
assertEquals(
- DoubleProperty.create("name", null, ifNull = "missing").toString(),
+ FloatProperty.create("name", null, ifNull = "missing").toString(),
"name: missing"
)
- val doubleWithUnit = DoubleProperty.create("name", 42.0, unit = "px")
+ val doubleWithUnit = FloatProperty.create("name", 42.0f, unit = "px")
assertEquals("name: 42.0px", doubleWithUnit.toString())
validateDoublePropertyJsonSerialization(doubleWithUnit)
}
@Test
- fun `unsafe double property test`() {
- val safe = DoubleProperty.createLazy(
+ fun `unsafe Float property test`() {
+ val safe = FloatProperty.createLazy(
"name",
- { 42.0 }
+ { 42.0f }
)
assertEquals("name: 42.0", safe.toString())
assertFalse(safe.isFiltered(DiagnosticLevel.info))
- assertEquals(42.0, safe.getValue())
+ assertEquals(42.0f, safe.getValue())
validateDoublePropertyJsonSerialization(safe)
assertEquals(
- DoubleProperty.createLazy("name", { 1.3333 }).toString(),
+ FloatProperty.createLazy("name", { 1.3333f }).toString(),
"name: 1.3"
)
assertEquals(
- DoubleProperty.createLazy("name", { null }).toString(),
+ FloatProperty.createLazy("name", { null }).toString(),
"name: null"
)
assertEquals(
- DoubleProperty.createLazy("name", { null }).isFiltered(DiagnosticLevel.info),
+ FloatProperty.createLazy("name", { null }).isFiltered(DiagnosticLevel.info),
false
)
- val throwingProperty = DoubleProperty.createLazy(
+ val throwingProperty = FloatProperty.createLazy(
"name",
{ throw FlutterError("Invalid constraints") }
)
@@ -932,11 +932,11 @@
@Test
fun `percent property`() {
assertEquals(
- PercentProperty("name", 0.4).toString(),
+ PercentProperty("name", 0.4f).toString(),
"name: 40.0%"
)
- val complexPercentProperty = PercentProperty("name", 0.99, unit = "invisible",
+ val complexPercentProperty = PercentProperty("name", 0.99f, unit = "invisible",
tooltip = "almost transparent")
assertEquals(
complexPercentProperty.toString(),
@@ -950,23 +950,23 @@
)
assertEquals(
- PercentProperty("name", 0.4).getValue(),
- 0.4
+ PercentProperty("name", 0.4f).getValue(),
+ 0.4f
)
assertEquals(
- PercentProperty("name", 0.0).toString(),
+ PercentProperty("name", 0.0f).toString(),
"name: 0.0%"
)
assertEquals(
- PercentProperty("name", -10.0).toString(),
+ PercentProperty("name", -10.0f).toString(),
"name: 0.0%"
)
assertEquals(
- PercentProperty("name", 1.0).toString(),
+ PercentProperty("name", 1.0f).toString(),
"name: 100.0%"
)
assertEquals(
- PercentProperty("name", 3.0).toString(),
+ PercentProperty("name", 3.0f).toString(),
"name: 100.0%"
)
assertEquals(
@@ -993,7 +993,7 @@
assertEquals(
PercentProperty(
"name",
- 0.5,
+ 0.5f,
showName = false
).toString(),
"50.0%"
@@ -1247,7 +1247,7 @@
@Test
fun `Any property test`() {
- val rect = Rect.fromLTRB(0.0, 0.0, 20.0, 20.0)
+ val rect = Rect.fromLTRB(0.0f, 0.0f, 20.0f, 20.0f)
val simple = DiagnosticsProperty.create(
"name",
rect
@@ -1323,7 +1323,7 @@
@Test
fun `lazy Any property test`() {
- val rect = Rect.fromLTRB(0.0, 0.0, 20.0, 20.0)
+ val rect = Rect.fromLTRB(0.0f, 0.0f, 20.0f, 20.0f)
val simple = DiagnosticsProperty.createLazy(
"name",
{ rect },
@@ -1502,7 +1502,7 @@
// TODO(Migration/Andrey): Replaced Color class usages with ColorInt
val objects = listOf(
- Rect.fromLTRB(0.0, 0.0, 20.0, 20.0),
+ Rect.fromLTRB(0.0f, 0.0f, 20.0f, 20.0f),
Color.fromARGB(255, 255, 255, 255)
)
val objectsProperty = IterableProperty(
@@ -1600,4 +1600,4 @@
assertTrue(messageProperty.getShowName())
validatePropertyJsonSerialization(messageProperty)
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/test/java/androidx/ui/gestures/double_tap_test/DoubleTapTest.kt b/ui/port/src/test/java/androidx/ui/gestures/double_tap_test/DoubleTapTest.kt
index d39723d..e6c8628 100644
--- a/ui/port/src/test/java/androidx/ui/gestures/double_tap_test/DoubleTapTest.kt
+++ b/ui/port/src/test/java/androidx/ui/gestures/double_tap_test/DoubleTapTest.kt
@@ -524,61 +524,61 @@
// Down/up pair 1: normal tap sequence
val down1 = PointerDownEvent(
pointer = 1,
- position = Offset(10.0, 10.0)
+ position = Offset(10.0f, 10.0f)
)
val up1 = PointerUpEvent(
pointer = 1,
- position = Offset(11.0, 9.0)
+ position = Offset(11.0f, 9.0f)
)
// Down/up pair 2: normal tap sequence close to pair 1
val down2 = PointerDownEvent(
pointer = 2,
- position = Offset(12.0, 12.0)
+ position = Offset(12.0f, 12.0f)
)
val up2 = PointerUpEvent(
pointer = 2,
- position = Offset(13.0, 11.0)
+ position = Offset(13.0f, 11.0f)
)
// Down/up pair 3: normal tap sequence far away from pair 1
val down3 = PointerDownEvent(
pointer = 3,
- position = Offset(130.0, 130.0)
+ position = Offset(130.0f, 130.0f)
)
val up3 = PointerUpEvent(
pointer = 3,
- position = Offset(131.0, 129.0)
+ position = Offset(131.0f, 129.0f)
)
// Down/move/up sequence 4: intervening motion
val down4 = PointerDownEvent(
pointer = 4,
- position = Offset(10.0, 10.0)
+ position = Offset(10.0f, 10.0f)
)
val move4 = PointerMoveEvent(
pointer = 4,
- position = Offset(25.0, 25.0)
+ position = Offset(25.0f, 25.0f)
)
val up4 = PointerUpEvent(
pointer = 4,
- position = Offset(25.0, 25.0)
+ position = Offset(25.0f, 25.0f)
)
// Down/up pair 5: normal tap sequence identical to pair 1 with different pointer
val down5 = PointerDownEvent(
pointer = 5,
- position = Offset(10.0, 10.0)
+ position = Offset(10.0f, 10.0f)
)
val up5 = PointerUpEvent(
pointer = 5,
- position = Offset(11.0, 9.0)
+ position = Offset(11.0f, 9.0f)
)
}
}
diff --git a/ui/port/src/test/java/androidx/ui/gestures/long_press/LongPressTest.kt b/ui/port/src/test/java/androidx/ui/gestures/long_press/LongPressTest.kt
index f543d0a..1463f98 100644
--- a/ui/port/src/test/java/androidx/ui/gestures/long_press/LongPressTest.kt
+++ b/ui/port/src/test/java/androidx/ui/gestures/long_press/LongPressTest.kt
@@ -38,11 +38,11 @@
private val down = PointerDownEvent(
pointer = 5,
- position = Offset(10.0, 10.0)
+ position = Offset(10.0f, 10.0f)
)
private val up = PointerUpEvent(
pointer = 5,
- position = Offset(11.0, 9.0)
+ position = Offset(11.0f, 9.0f)
)
private val testCoroutineContext = TestCoroutineContext()
diff --git a/ui/port/src/test/java/androidx/ui/gestures/lsq_solver/LeastSquaresSolverTest.kt b/ui/port/src/test/java/androidx/ui/gestures/lsq_solver/LeastSquaresSolverTest.kt
index 6441c43..70c8504 100644
--- a/ui/port/src/test/java/androidx/ui/gestures/lsq_solver/LeastSquaresSolverTest.kt
+++ b/ui/port/src/test/java/androidx/ui/gestures/lsq_solver/LeastSquaresSolverTest.kt
@@ -29,67 +29,67 @@
@Test
fun `Least-squares fit, linear polynomial to line`() {
- val x = doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
- val y = doubleArrayOf(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)
- val w = doubleArrayOf(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)
+ val x = floatArrayOf(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f)
+ val y = floatArrayOf(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f)
+ val w = floatArrayOf(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f)
val solver = LeastSquaresSolver(x, y, w)
val fit = solver.solve(1)
assertThat(fit, `is`(notNullValue()))
assertThat(fit!!.coefficients.size, `is`(2))
- assertThat(fit.coefficients[0], MoreOrLessEquals(1.0))
- assertThat(fit.coefficients[1], MoreOrLessEquals(0.0))
- assertThat(fit.confidence, MoreOrLessEquals(1.0))
+ assertThat(fit.coefficients[0], MoreOrLessEquals(1.0f))
+ assertThat(fit.coefficients[1], MoreOrLessEquals(0.0f))
+ assertThat(fit.confidence, MoreOrLessEquals(1.0f))
}
@Test
fun `Least-squares fit, linear polynomial to sloped line`() {
- val x = doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
- val y = doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)
- val w = doubleArrayOf(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)
+ val x = floatArrayOf(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f)
+ val y = floatArrayOf(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f)
+ val w = floatArrayOf(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f)
val solver = LeastSquaresSolver(x, y, w)
val fit = solver.solve(1)
assertThat(fit, `is`(notNullValue()))
assertThat(fit!!.coefficients.size, `is`(2))
- assertThat(fit.coefficients[0], MoreOrLessEquals(1.0))
- assertThat(fit.coefficients[1], MoreOrLessEquals(1.0))
- assertThat(fit.confidence, MoreOrLessEquals(1.0))
+ assertThat(fit.coefficients[0], MoreOrLessEquals(1.0f))
+ assertThat(fit.coefficients[1], MoreOrLessEquals(1.0f))
+ assertThat(fit.confidence, MoreOrLessEquals(1.0f))
}
@Test
fun `Least-squares fit, quadratic polynomial to line`() {
- val x = doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
- val y = doubleArrayOf(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)
- val w = doubleArrayOf(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)
+ val x = floatArrayOf(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f)
+ val y = floatArrayOf(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f)
+ val w = floatArrayOf(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f)
val solver = LeastSquaresSolver(x, y, w)
val fit = solver.solve(2)
assertThat(fit, `is`(notNullValue()))
assertThat(fit!!.coefficients.size, `is`(3))
- assertThat(fit.coefficients[0], MoreOrLessEquals(1.0))
- assertThat(fit.coefficients[1], MoreOrLessEquals(0.0))
- assertThat(fit.coefficients[2], MoreOrLessEquals(0.0))
- assertThat(fit.confidence, MoreOrLessEquals(1.0))
+ assertThat(fit.coefficients[0], MoreOrLessEquals(1.0f))
+ assertThat(fit.coefficients[1], MoreOrLessEquals(0.0f))
+ assertThat(fit.coefficients[2], MoreOrLessEquals(0.0f))
+ assertThat(fit.confidence, MoreOrLessEquals(1.0f))
}
@Test
fun `Least-squares fit, quadratic polynomial to sloped line`() {
- val x = doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
- val y = doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)
- val w = doubleArrayOf(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)
+ val x = floatArrayOf(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f)
+ val y = floatArrayOf(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f)
+ val w = floatArrayOf(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f)
val solver = LeastSquaresSolver(x, y, w)
val fit = solver.solve(2)
assertThat(fit, `is`(notNullValue()))
assertThat(fit!!.coefficients.size, `is`(3))
- assertThat(fit.coefficients[0], MoreOrLessEquals(1.0))
- assertThat(fit.coefficients[1], MoreOrLessEquals(1.0))
- assertThat(fit.coefficients[2], MoreOrLessEquals(0.0))
- assertThat(fit.confidence, MoreOrLessEquals(1.0))
+ assertThat(fit.coefficients[0], MoreOrLessEquals(1.0f))
+ assertThat(fit.coefficients[1], MoreOrLessEquals(1.0f))
+ assertThat(fit.coefficients[2], MoreOrLessEquals(0.0f))
+ assertThat(fit.confidence, MoreOrLessEquals(1.0f))
}
}
\ No newline at end of file
diff --git a/ui/port/src/test/java/androidx/ui/gestures/multitap_test/MultiTapTest.kt b/ui/port/src/test/java/androidx/ui/gestures/multitap_test/MultiTapTest.kt
index 4876c85..4b12c54 100644
--- a/ui/port/src/test/java/androidx/ui/gestures/multitap_test/MultiTapTest.kt
+++ b/ui/port/src/test/java/androidx/ui/gestures/multitap_test/MultiTapTest.kt
@@ -66,7 +66,7 @@
tap. pointer -> log.add("tap-cancel $pointer") }
val pointer5 = TestPointer(5)
- val down5 = pointer5.down(Offset(10.0, 10.0))
+ val down5 = pointer5.down(Offset(10.0f, 10.0f))
tap.addPointer(down5)
gestureArena.close(5)
assertThat(log, `is`(equalTo(mutableListOf("tap-down 5"))))
@@ -75,7 +75,7 @@
assertThat(log, `is`(equalTo(mutableListOf())))
val pointer6 = TestPointer(6)
- val down6 = pointer6.down(Offset(15.0, 15.0))
+ val down6 = pointer6.down(Offset(15.0f, 15.0f))
tap.addPointer(down6)
gestureArena.close(6)
assertThat(log, `is`(equalTo(mutableListOf("tap-down 6"))))
@@ -83,10 +83,10 @@
pointerRouter.route(down6)
assertThat(log, `is`(equalTo(mutableListOf())))
- pointerRouter.route(pointer5.move(Offset(11.0, 12.0)))
+ pointerRouter.route(pointer5.move(Offset(11.0f, 12.0f)))
assertThat(log, `is`(equalTo(mutableListOf())))
- pointerRouter.route(pointer6.move(Offset(14.0, 13.0)))
+ pointerRouter.route(pointer6.move(Offset(14.0f, 13.0f)))
assertThat(log, `is`(equalTo(mutableListOf())))
pointerRouter.route(pointer5.up())
@@ -99,7 +99,7 @@
log.clear()*/
// move more than kTouchSlop from 15.0,15.0
- pointerRouter.route(pointer6.move(Offset(40.0, 30.0)))
+ pointerRouter.route(pointer6.move(Offset(40.0f, 30.0f)))
assertThat(log, `is`(equalTo(mutableListOf("tap-cancel 6"))))
log.clear()
@@ -108,4 +108,4 @@
tap.dispose()
}
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/test/java/androidx/ui/gestures/scale_test/ScaleTest.kt b/ui/port/src/test/java/androidx/ui/gestures/scale_test/ScaleTest.kt
index ff5e03a..af88a8f 100644
--- a/ui/port/src/test/java/androidx/ui/gestures/scale_test/ScaleTest.kt
+++ b/ui/port/src/test/java/androidx/ui/gestures/scale_test/ScaleTest.kt
@@ -31,6 +31,7 @@
import org.hamcrest.CoreMatchers.equalTo
import org.hamcrest.CoreMatchers.nullValue
import org.junit.After
+import org.junit.Assert.assertEquals
import org.junit.Assert.assertThat
import org.junit.Before
import org.junit.Test
@@ -66,7 +67,7 @@
updatedFocalPoint = details.focalPoint
}
- var updatedScale: Double? = null
+ var updatedScale: Float? = null
scale. details ->
updatedScale = details.scale
updatedFocalPoint = details.focalPoint
@@ -84,7 +85,7 @@
val pointer1 = TestPointer(1)
- val down = pointer1.down(Offset(0.0, 0.0))
+ val down = pointer1.down(Offset(0.0f, 0.0f))
scale.addPointer(down)
tap.addPointer(down)
@@ -103,19 +104,19 @@
assertThat(didEndScale, `is`(false))
assertThat(didTap, `is`(false))
- pointerRouter.route(pointer1.move(Offset(20.0, 30.0)))
+ pointerRouter.route(pointer1.move(Offset(20.0f, 30.0f)))
assertThat(didStartScale, `is`(true))
didStartScale = false
- assertThat(updatedFocalPoint, `is`(equalTo(Offset(20.0, 30.0))))
+ assertThat(updatedFocalPoint, `is`(equalTo(Offset(20.0f, 30.0f))))
updatedFocalPoint = null
- assertThat(updatedScale, `is`(1.0))
+ assertThat(updatedScale, `is`(1.0f))
updatedScale = null
assertThat(didEndScale, `is`(false))
assertThat(didTap, `is`(false))
// Two-finger scaling
val pointer2 = TestPointer(2)
- val down2 = pointer2.down(Offset(10.0, 20.0))
+ val down2 = pointer2.down(Offset(10.0f, 20.0f))
scale.addPointer(down2)
tap.addPointer(down2)
gestureArena.close(2)
@@ -128,27 +129,27 @@
assertThat(didStartScale, `is`(false))
// Zoom in
- pointerRouter.route(pointer2.move(Offset(0.0, 10.0)))
+ pointerRouter.route(pointer2.move(Offset(0.0f, 10.0f)))
assertThat(didStartScale, `is`(true))
didStartScale = false
- assertThat(updatedFocalPoint, `is`(equalTo(Offset(10.0, 20.0))))
+ assertThat(updatedFocalPoint, `is`(equalTo(Offset(10.0f, 20.0f))))
updatedFocalPoint = null
- assertThat(updatedScale, `is`(equalTo(2.0)))
+ assertThat(updatedScale, `is`(equalTo(2.0f)))
updatedScale = null
assertThat(didEndScale, `is`(false))
assertThat(didTap, `is`(false))
// Zoom out
- pointerRouter.route(pointer2.move(Offset(15.0, 25.0)))
- assertThat(updatedFocalPoint, `is`(equalTo(Offset(17.5, 27.5))))
+ pointerRouter.route(pointer2.move(Offset(15.0f, 25.0f)))
+ assertThat(updatedFocalPoint, `is`(equalTo(Offset(17.5f, 27.5f))))
updatedFocalPoint = null
- assertThat(updatedScale, `is`(equalTo(0.5)))
+ assertThat(updatedScale, `is`(equalTo(0.5f)))
updatedScale = null
assertThat(didTap, `is`(false))
// Three-finger scaling
val pointer3 = TestPointer(3)
- val down3 = pointer3.down(Offset(25.0, 35.0))
+ val down3 = pointer3.down(Offset(25.0f, 35.0f))
scale.addPointer(down3)
tap.addPointer(down3)
gestureArena.close(3)
@@ -161,24 +162,24 @@
assertThat(didStartScale, `is`(false))
// Zoom in
- pointerRouter.route(pointer3.move(Offset(55.0, 65.0)))
+ pointerRouter.route(pointer3.move(Offset(55.0f, 65.0f)))
assertThat(didStartScale, `is`(true))
didStartScale = false
- assertThat(updatedFocalPoint, `is`(equalTo(Offset(30.0, 40.0))))
+ assertThat(updatedFocalPoint, `is`(equalTo(Offset(30.0f, 40.0f))))
updatedFocalPoint = null
- assertThat(updatedScale, `is`(equalTo(5.0)))
+ assertEquals(5.0f, updatedScale!!, 0.001f)
updatedScale = null
assertThat(didEndScale, `is`(false))
assertThat(didTap, `is`(false))
// Return to original positions but with different fingers
- pointerRouter.route(pointer1.move(Offset(25.0, 35.0)))
- pointerRouter.route(pointer2.move(Offset(20.0, 30.0)))
- pointerRouter.route(pointer3.move(Offset(15.0, 25.0)))
+ pointerRouter.route(pointer1.move(Offset(25.0f, 35.0f)))
+ pointerRouter.route(pointer2.move(Offset(20.0f, 30.0f)))
+ pointerRouter.route(pointer3.move(Offset(15.0f, 25.0f)))
assertThat(didStartScale, `is`(false))
- assertThat(updatedFocalPoint, `is`(equalTo(Offset(20.0, 30.0))))
+ assertThat(updatedFocalPoint, `is`(equalTo(Offset(20.0f, 30.0f))))
updatedFocalPoint = null
- assertThat(updatedScale, `is`(equalTo(1.0)))
+ assertThat(updatedScale, `is`(equalTo(1.0f)))
updatedScale = null
assertThat(didEndScale, `is`(false))
assertThat(didTap, `is`(false))
@@ -192,12 +193,12 @@
assertThat(didTap, `is`(false))
// Continue scaling with two fingers
- pointerRouter.route(pointer3.move(Offset(10.0, 20.0)))
+ pointerRouter.route(pointer3.move(Offset(10.0f, 20.0f)))
assertThat(didStartScale, `is`(true))
didStartScale = false
- assertThat(updatedFocalPoint, `is`(equalTo(Offset(15.0, 25.0))))
+ assertThat(updatedFocalPoint, `is`(equalTo(Offset(15.0f, 25.0f))))
updatedFocalPoint = null
- assertThat(updatedScale, `is`(equalTo(2.0)))
+ assertThat(updatedScale, `is`(equalTo(2.0f)))
updatedScale = null
pointerRouter.route(pointer2.up())
@@ -209,12 +210,12 @@
assertThat(didTap, `is`(false))
// Continue panning with one finger
- pointerRouter.route(pointer3.move(Offset(0.0, 0.0)))
+ pointerRouter.route(pointer3.move(Offset(0.0f, 0.0f)))
assertThat(didStartScale, `is`(true))
didStartScale = false
- assertThat(updatedFocalPoint, `is`(equalTo(Offset(0.0, 0.0))))
+ assertThat(updatedFocalPoint, `is`(equalTo(Offset(0.0f, 0.0f))))
updatedFocalPoint = null
- assertThat(updatedScale, `is`(equalTo(1.0)))
+ assertThat(updatedScale, `is`(equalTo(1.0f)))
updatedScale = null
// We are done
@@ -313,4 +314,4 @@
// scale.dispose()
// drag.dispose()
// }
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/test/java/androidx/ui/gestures/tap_test/TapTest.kt b/ui/port/src/test/java/androidx/ui/gestures/tap_test/TapTest.kt
index 03eb716..e8fe65d 100644
--- a/ui/port/src/test/java/androidx/ui/gestures/tap_test/TapTest.kt
+++ b/ui/port/src/test/java/androidx/ui/gestures/tap_test/TapTest.kt
@@ -389,55 +389,55 @@
// Down/up pair 1: normal tap sequence
val down1 = PointerDownEvent(
pointer = 1,
- position = Offset(10.0, 10.0)
+ position = Offset(10.0f, 10.0f)
)
val up1 = PointerUpEvent(
pointer = 1,
- position = Offset(11.0, 9.0)
+ position = Offset(11.0f, 9.0f)
)
// Down/up pair 2: normal tap sequence far away from pair 1
val down2 = PointerDownEvent(
pointer = 2,
- position = Offset(30.0, 30.0)
+ position = Offset(30.0f, 30.0f)
)
val up2 = PointerUpEvent(
pointer = 2,
- position = Offset(31.0, 29.0)
+ position = Offset(31.0f, 29.0f)
)
// Down/move/up sequence 3: intervening motion, more than kTouchSlop. (~21px)
val down3 = PointerDownEvent(
pointer = 3,
- position = Offset(10.0, 10.0)
+ position = Offset(10.0f, 10.0f)
)
val move3 = PointerMoveEvent(
pointer = 3,
- position = Offset(25.0, 25.0)
+ position = Offset(25.0f, 25.0f)
)
val up3 = PointerUpEvent(
pointer = 3,
- position = Offset(25.0, 25.0)
+ position = Offset(25.0f, 25.0f)
)
// Down/move/up sequence 4: intervening motion, less than kTouchSlop. (~17px)
val down4 = PointerDownEvent(
pointer = 4,
- position = Offset(10.0, 10.0)
+ position = Offset(10.0f, 10.0f)
)
val move4 = PointerMoveEvent(
pointer = 4,
- position = Offset(22.0, 22.0)
+ position = Offset(22.0f, 22.0f)
)
val up4 = PointerUpEvent(
pointer = 4,
- position = Offset(22.0, 22.0)
+ position = Offset(22.0f, 22.0f)
)
}
}
\ No newline at end of file
diff --git a/ui/port/src/test/java/androidx/ui/gestures/velocity_tracker/VelocityTrackerData.kt b/ui/port/src/test/java/androidx/ui/gestures/velocity_tracker/VelocityTrackerData.kt
index 355e8bb..2221a5f 100644
--- a/ui/port/src/test/java/androidx/ui/gestures/velocity_tracker/VelocityTrackerData.kt
+++ b/ui/port/src/test/java/androidx/ui/gestures/velocity_tracker/VelocityTrackerData.kt
@@ -27,1532 +27,1532 @@
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216690896),
pointer = 1,
- position = Offset(270.0, 538.2857055664062)
+ position = Offset(270.0f, 538.2857055664062f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216690906),
pointer = 1,
- position = Offset(270.0, 538.2857055664062)
+ position = Offset(270.0f, 538.2857055664062f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216690951),
pointer = 1,
- position = Offset(270.0, 530.8571166992188)
+ position = Offset(270.0f, 530.8571166992188f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216690959),
pointer = 1,
- position = Offset(270.0, 526.8571166992188)
+ position = Offset(270.0f, 526.8571166992188f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216690967),
pointer = 1,
- position = Offset(270.0, 521.4285888671875)
+ position = Offset(270.0f, 521.4285888671875f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216690975),
pointer = 1,
- position = Offset(270.0, 515.4285888671875)
+ position = Offset(270.0f, 515.4285888671875f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216690983),
pointer = 1,
- position = Offset(270.0, 506.8571472167969)
+ position = Offset(270.0f, 506.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216690991),
pointer = 1,
- position = Offset(268.8571472167969, 496.0)
+ position = Offset(268.8571472167969f, 496.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216690998),
pointer = 1,
- position = Offset(267.4285583496094, 483.1428527832031)
+ position = Offset(267.4285583496094f, 483.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691006),
pointer = 1,
- position = Offset(266.28570556640625, 469.71429443359375)
+ position = Offset(266.28570556640625f, 469.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691014),
pointer = 1,
- position = Offset(265.4285583496094, 456.8571472167969)
+ position = Offset(265.4285583496094f, 456.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691021),
pointer = 1,
- position = Offset(264.28570556640625, 443.71429443359375)
+ position = Offset(264.28570556640625f, 443.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691029),
pointer = 1,
- position = Offset(264.0, 431.71429443359375)
+ position = Offset(264.0f, 431.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691036),
pointer = 1,
- position = Offset(263.4285583496094, 421.1428527832031)
+ position = Offset(263.4285583496094f, 421.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691044),
pointer = 1,
- position = Offset(263.4285583496094, 412.5714416503906)
+ position = Offset(263.4285583496094f, 412.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691052),
pointer = 1,
- position = Offset(263.4285583496094, 404.5714416503906)
+ position = Offset(263.4285583496094f, 404.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691060),
pointer = 1,
- position = Offset(263.4285583496094, 396.5714416503906)
+ position = Offset(263.4285583496094f, 396.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691068),
pointer = 1,
- position = Offset(264.5714416503906, 390.0)
+ position = Offset(264.5714416503906f, 390.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691075),
pointer = 1,
- position = Offset(265.1428527832031, 384.8571472167969)
+ position = Offset(265.1428527832031f, 384.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691083),
pointer = 1,
- position = Offset(266.0, 380.28570556640625)
+ position = Offset(266.0f, 380.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691091),
pointer = 1,
- position = Offset(266.5714416503906, 376.28570556640625)
+ position = Offset(266.5714416503906f, 376.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691098),
pointer = 1,
- position = Offset(267.1428527832031, 373.1428527832031)
+ position = Offset(267.1428527832031f, 373.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691106),
pointer = 1,
- position = Offset(267.71429443359375, 370.28570556640625)
+ position = Offset(267.71429443359375f, 370.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691114),
pointer = 1,
- position = Offset(268.28570556640625, 367.71429443359375)
+ position = Offset(268.28570556640625f, 367.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691121),
pointer = 1,
- position = Offset(268.5714416503906, 366.0)
+ position = Offset(268.5714416503906f, 366.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691130),
pointer = 1,
- position = Offset(268.8571472167969, 364.5714416503906)
+ position = Offset(268.8571472167969f, 364.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691137),
pointer = 1,
- position = Offset(269.1428527832031, 363.71429443359375)
+ position = Offset(269.1428527832031f, 363.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691145),
pointer = 1,
- position = Offset(269.1428527832031, 362.8571472167969)
+ position = Offset(269.1428527832031f, 362.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691153),
pointer = 1,
- position = Offset(269.4285583496094, 362.8571472167969)
+ position = Offset(269.4285583496094f, 362.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691168),
pointer = 1,
- position = Offset(268.5714416503906, 365.4285583496094)
+ position = Offset(268.5714416503906f, 365.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691176),
pointer = 1,
- position = Offset(267.1428527832031, 370.28570556640625)
+ position = Offset(267.1428527832031f, 370.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691183),
pointer = 1,
- position = Offset(265.4285583496094, 376.8571472167969)
+ position = Offset(265.4285583496094f, 376.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691191),
pointer = 1,
- position = Offset(263.1428527832031, 385.71429443359375)
+ position = Offset(263.1428527832031f, 385.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691199),
pointer = 1,
- position = Offset(261.4285583496094, 396.5714416503906)
+ position = Offset(261.4285583496094f, 396.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691207),
pointer = 1,
- position = Offset(259.71429443359375, 408.5714416503906)
+ position = Offset(259.71429443359375f, 408.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691215),
pointer = 1,
- position = Offset(258.28570556640625, 419.4285583496094)
+ position = Offset(258.28570556640625f, 419.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691222),
pointer = 1,
- position = Offset(257.4285583496094, 428.5714416503906)
+ position = Offset(257.4285583496094f, 428.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691230),
pointer = 1,
- position = Offset(256.28570556640625, 436.0)
+ position = Offset(256.28570556640625f, 436.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691238),
pointer = 1,
- position = Offset(255.7142791748047, 442.0)
+ position = Offset(255.7142791748047f, 442.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691245),
pointer = 1,
- position = Offset(255.14285278320312, 447.71429443359375)
+ position = Offset(255.14285278320312f, 447.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691253),
pointer = 1,
- position = Offset(254.85714721679688, 453.1428527832031)
+ position = Offset(254.85714721679688f, 453.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691261),
pointer = 1,
- position = Offset(254.57142639160156, 458.5714416503906)
+ position = Offset(254.57142639160156f, 458.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691268),
pointer = 1,
- position = Offset(254.2857208251953, 463.71429443359375)
+ position = Offset(254.2857208251953f, 463.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691276),
pointer = 1,
- position = Offset(254.2857208251953, 470.28570556640625)
+ position = Offset(254.2857208251953f, 470.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691284),
pointer = 1,
- position = Offset(254.2857208251953, 477.71429443359375)
+ position = Offset(254.2857208251953f, 477.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691292),
pointer = 1,
- position = Offset(255.7142791748047, 487.1428527832031)
+ position = Offset(255.7142791748047f, 487.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691300),
pointer = 1,
- position = Offset(256.8571472167969, 498.5714416503906)
+ position = Offset(256.8571472167969f, 498.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691307),
pointer = 1,
- position = Offset(258.28570556640625, 507.71429443359375)
+ position = Offset(258.28570556640625f, 507.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691315),
pointer = 1,
- position = Offset(259.4285583496094, 516.0)
+ position = Offset(259.4285583496094f, 516.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691323),
pointer = 1,
- position = Offset(260.28570556640625, 521.7142944335938)
+ position = Offset(260.28570556640625f, 521.7142944335938f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216691338),
pointer = 1,
- position = Offset(260.28570556640625, 521.7142944335938)
+ position = Offset(260.28570556640625f, 521.7142944335938f)
),
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216691573),
pointer = 2,
- position = Offset(266.0, 327.4285583496094)
+ position = Offset(266.0f, 327.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691588),
pointer = 2,
- position = Offset(266.0, 327.4285583496094)
+ position = Offset(266.0f, 327.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691626),
pointer = 2,
- position = Offset(261.1428527832031, 337.1428527832031)
+ position = Offset(261.1428527832031f, 337.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691634),
pointer = 2,
- position = Offset(258.28570556640625, 343.1428527832031)
+ position = Offset(258.28570556640625f, 343.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691642),
pointer = 2,
- position = Offset(254.57142639160156, 354.0)
+ position = Offset(254.57142639160156f, 354.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691650),
pointer = 2,
- position = Offset(250.2857208251953, 368.28570556640625)
+ position = Offset(250.2857208251953f, 368.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691657),
pointer = 2,
- position = Offset(247.42857360839844, 382.8571472167969)
+ position = Offset(247.42857360839844f, 382.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691665),
pointer = 2,
- position = Offset(245.14285278320312, 397.4285583496094)
+ position = Offset(245.14285278320312f, 397.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691673),
pointer = 2,
- position = Offset(243.14285278320312, 411.71429443359375)
+ position = Offset(243.14285278320312f, 411.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691680),
pointer = 2,
- position = Offset(242.2857208251953, 426.28570556640625)
+ position = Offset(242.2857208251953f, 426.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691688),
pointer = 2,
- position = Offset(241.7142791748047, 440.5714416503906)
+ position = Offset(241.7142791748047f, 440.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691696),
pointer = 2,
- position = Offset(241.7142791748047, 454.5714416503906)
+ position = Offset(241.7142791748047f, 454.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691703),
pointer = 2,
- position = Offset(242.57142639160156, 467.71429443359375)
+ position = Offset(242.57142639160156f, 467.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691712),
pointer = 2,
- position = Offset(243.42857360839844, 477.4285583496094)
+ position = Offset(243.42857360839844f, 477.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691720),
pointer = 2,
- position = Offset(244.85714721679688, 485.71429443359375)
+ position = Offset(244.85714721679688f, 485.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691727),
pointer = 2,
- position = Offset(246.2857208251953, 493.1428527832031)
+ position = Offset(246.2857208251953f, 493.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216691735),
pointer = 2,
- position = Offset(248.0, 499.71429443359375)
+ position = Offset(248.0f, 499.71429443359375f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216691750),
pointer = 2,
- position = Offset(248.0, 499.71429443359375)
+ position = Offset(248.0f, 499.71429443359375f)
),
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216692255),
pointer = 3,
- position = Offset(249.42857360839844, 351.4285583496094)
+ position = Offset(249.42857360839844f, 351.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692270),
pointer = 3,
- position = Offset(249.42857360839844, 351.4285583496094)
+ position = Offset(249.42857360839844f, 351.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692309),
pointer = 3,
- position = Offset(246.2857208251953, 361.71429443359375)
+ position = Offset(246.2857208251953f, 361.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692317),
pointer = 3,
- position = Offset(244.0, 368.5714416503906)
+ position = Offset(244.0f, 368.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692325),
pointer = 3,
- position = Offset(241.42857360839844, 377.71429443359375)
+ position = Offset(241.42857360839844f, 377.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692333),
pointer = 3,
- position = Offset(237.7142791748047, 391.71429443359375)
+ position = Offset(237.7142791748047f, 391.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692340),
pointer = 3,
- position = Offset(235.14285278320312, 406.5714416503906)
+ position = Offset(235.14285278320312f, 406.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692348),
pointer = 3,
- position = Offset(232.57142639160156, 421.4285583496094)
+ position = Offset(232.57142639160156f, 421.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692356),
pointer = 3,
- position = Offset(230.2857208251953, 436.5714416503906)
+ position = Offset(230.2857208251953f, 436.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692363),
pointer = 3,
- position = Offset(228.2857208251953, 451.71429443359375)
+ position = Offset(228.2857208251953f, 451.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692371),
pointer = 3,
- position = Offset(227.42857360839844, 466.0)
+ position = Offset(227.42857360839844f, 466.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692378),
pointer = 3,
- position = Offset(226.2857208251953, 479.71429443359375)
+ position = Offset(226.2857208251953f, 479.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692387),
pointer = 3,
- position = Offset(225.7142791748047, 491.71429443359375)
+ position = Offset(225.7142791748047f, 491.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692395),
pointer = 3,
- position = Offset(225.14285278320312, 501.71429443359375)
+ position = Offset(225.14285278320312f, 501.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692402),
pointer = 3,
- position = Offset(224.85714721679688, 509.1428527832031)
+ position = Offset(224.85714721679688f, 509.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692410),
pointer = 3,
- position = Offset(224.57142639160156, 514.8571166992188)
+ position = Offset(224.57142639160156f, 514.8571166992188f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692418),
pointer = 3,
- position = Offset(224.2857208251953, 519.4285888671875)
+ position = Offset(224.2857208251953f, 519.4285888671875f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692425),
pointer = 3,
- position = Offset(224.0, 523.4285888671875)
+ position = Offset(224.0f, 523.4285888671875f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692433),
pointer = 3,
- position = Offset(224.0, 527.1428833007812)
+ position = Offset(224.0f, 527.1428833007812f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692441),
pointer = 3,
- position = Offset(224.0, 530.5714111328125)
+ position = Offset(224.0f, 530.5714111328125f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692448),
pointer = 3,
- position = Offset(224.0, 533.1428833007812)
+ position = Offset(224.0f, 533.1428833007812f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692456),
pointer = 3,
- position = Offset(224.0, 535.4285888671875)
+ position = Offset(224.0f, 535.4285888671875f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692464),
pointer = 3,
- position = Offset(223.7142791748047, 536.8571166992188)
+ position = Offset(223.7142791748047f, 536.8571166992188f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692472),
pointer = 3,
- position = Offset(223.7142791748047, 538.2857055664062)
+ position = Offset(223.7142791748047f, 538.2857055664062f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216692487),
pointer = 3,
- position = Offset(223.7142791748047, 538.2857055664062)
+ position = Offset(223.7142791748047f, 538.2857055664062f)
),
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216692678),
pointer = 4,
- position = Offset(221.42857360839844, 526.2857055664062)
+ position = Offset(221.42857360839844f, 526.2857055664062f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692701),
pointer = 4,
- position = Offset(220.57142639160156, 514.8571166992188)
+ position = Offset(220.57142639160156f, 514.8571166992188f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692708),
pointer = 4,
- position = Offset(220.2857208251953, 508.0)
+ position = Offset(220.2857208251953f, 508.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692716),
pointer = 4,
- position = Offset(220.2857208251953, 498.0)
+ position = Offset(220.2857208251953f, 498.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692724),
pointer = 4,
- position = Offset(221.14285278320312, 484.28570556640625)
+ position = Offset(221.14285278320312f, 484.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692732),
pointer = 4,
- position = Offset(221.7142791748047, 469.4285583496094)
+ position = Offset(221.7142791748047f, 469.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692740),
pointer = 4,
- position = Offset(223.42857360839844, 453.1428527832031)
+ position = Offset(223.42857360839844f, 453.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692748),
pointer = 4,
- position = Offset(225.7142791748047, 436.28570556640625)
+ position = Offset(225.7142791748047f, 436.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692755),
pointer = 4,
- position = Offset(229.14285278320312, 418.28570556640625)
+ position = Offset(229.14285278320312f, 418.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692763),
pointer = 4,
- position = Offset(232.85714721679688, 400.28570556640625)
+ position = Offset(232.85714721679688f, 400.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692770),
pointer = 4,
- position = Offset(236.85714721679688, 382.5714416503906)
+ position = Offset(236.85714721679688f, 382.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692778),
pointer = 4,
- position = Offset(241.14285278320312, 366.0)
+ position = Offset(241.14285278320312f, 366.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692786),
pointer = 4,
- position = Offset(244.85714721679688, 350.28570556640625)
+ position = Offset(244.85714721679688f, 350.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216692793),
pointer = 4,
- position = Offset(249.14285278320312, 335.4285583496094)
+ position = Offset(249.14285278320312f, 335.4285583496094f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216692809),
pointer = 4,
- position = Offset(249.14285278320312, 335.4285583496094)
+ position = Offset(249.14285278320312f, 335.4285583496094f)
),
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216693222),
pointer = 5,
- position = Offset(224.0, 545.4285888671875)
+ position = Offset(224.0f, 545.4285888671875f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216693245),
pointer = 5,
- position = Offset(224.0, 545.4285888671875)
+ position = Offset(224.0f, 545.4285888671875f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216693275),
pointer = 5,
- position = Offset(222.85714721679688, 535.1428833007812)
+ position = Offset(222.85714721679688f, 535.1428833007812f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216693284),
pointer = 5,
- position = Offset(222.85714721679688, 528.8571166992188)
+ position = Offset(222.85714721679688f, 528.8571166992188f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216693291),
pointer = 5,
- position = Offset(222.2857208251953, 518.5714111328125)
+ position = Offset(222.2857208251953f, 518.5714111328125f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216693299),
pointer = 5,
- position = Offset(222.0, 503.4285583496094)
+ position = Offset(222.0f, 503.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216693307),
pointer = 5,
- position = Offset(222.0, 485.4285583496094)
+ position = Offset(222.0f, 485.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216693314),
pointer = 5,
- position = Offset(221.7142791748047, 464.0)
+ position = Offset(221.7142791748047f, 464.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216693322),
pointer = 5,
- position = Offset(222.2857208251953, 440.28570556640625)
+ position = Offset(222.2857208251953f, 440.28570556640625f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216693337),
pointer = 5,
- position = Offset(222.2857208251953, 440.28570556640625)
+ position = Offset(222.2857208251953f, 440.28570556640625f)
),
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216693985),
pointer = 6,
- position = Offset(208.0, 544.0)
+ position = Offset(208.0f, 544.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694047),
pointer = 6,
- position = Offset(208.57142639160156, 532.2857055664062)
+ position = Offset(208.57142639160156f, 532.2857055664062f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694054),
pointer = 6,
- position = Offset(208.85714721679688, 525.7142944335938)
+ position = Offset(208.85714721679688f, 525.7142944335938f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694062),
pointer = 6,
- position = Offset(208.85714721679688, 515.1428833007812)
+ position = Offset(208.85714721679688f, 515.1428833007812f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694070),
pointer = 6,
- position = Offset(208.0, 501.4285583496094)
+ position = Offset(208.0f, 501.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694077),
pointer = 6,
- position = Offset(207.42857360839844, 487.1428527832031)
+ position = Offset(207.42857360839844f, 487.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694085),
pointer = 6,
- position = Offset(206.57142639160156, 472.8571472167969)
+ position = Offset(206.57142639160156f, 472.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694092),
pointer = 6,
- position = Offset(206.57142639160156, 458.8571472167969)
+ position = Offset(206.57142639160156f, 458.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694100),
pointer = 6,
- position = Offset(206.57142639160156, 446.0)
+ position = Offset(206.57142639160156f, 446.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694108),
pointer = 6,
- position = Offset(206.57142639160156, 434.28570556640625)
+ position = Offset(206.57142639160156f, 434.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694116),
pointer = 6,
- position = Offset(207.14285278320312, 423.71429443359375)
+ position = Offset(207.14285278320312f, 423.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694124),
pointer = 6,
- position = Offset(208.57142639160156, 412.8571472167969)
+ position = Offset(208.57142639160156f, 412.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694131),
pointer = 6,
- position = Offset(209.7142791748047, 402.28570556640625)
+ position = Offset(209.7142791748047f, 402.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694139),
pointer = 6,
- position = Offset(211.7142791748047, 393.1428527832031)
+ position = Offset(211.7142791748047f, 393.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694147),
pointer = 6,
- position = Offset(213.42857360839844, 385.1428527832031)
+ position = Offset(213.42857360839844f, 385.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694154),
pointer = 6,
- position = Offset(215.42857360839844, 378.28570556640625)
+ position = Offset(215.42857360839844f, 378.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694162),
pointer = 6,
- position = Offset(217.42857360839844, 371.71429443359375)
+ position = Offset(217.42857360839844f, 371.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694169),
pointer = 6,
- position = Offset(219.42857360839844, 366.0)
+ position = Offset(219.42857360839844f, 366.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694177),
pointer = 6,
- position = Offset(221.42857360839844, 360.8571472167969)
+ position = Offset(221.42857360839844f, 360.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694185),
pointer = 6,
- position = Offset(223.42857360839844, 356.5714416503906)
+ position = Offset(223.42857360839844f, 356.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694193),
pointer = 6,
- position = Offset(225.14285278320312, 352.28570556640625)
+ position = Offset(225.14285278320312f, 352.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694201),
pointer = 6,
- position = Offset(226.85714721679688, 348.5714416503906)
+ position = Offset(226.85714721679688f, 348.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694209),
pointer = 6,
- position = Offset(228.2857208251953, 346.0)
+ position = Offset(228.2857208251953f, 346.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694216),
pointer = 6,
- position = Offset(229.14285278320312, 343.71429443359375)
+ position = Offset(229.14285278320312f, 343.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694224),
pointer = 6,
- position = Offset(230.0, 342.0)
+ position = Offset(230.0f, 342.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694232),
pointer = 6,
- position = Offset(230.57142639160156, 340.5714416503906)
+ position = Offset(230.57142639160156f, 340.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694239),
pointer = 6,
- position = Offset(230.85714721679688, 339.71429443359375)
+ position = Offset(230.85714721679688f, 339.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694247),
pointer = 6,
- position = Offset(230.85714721679688, 339.4285583496094)
+ position = Offset(230.85714721679688f, 339.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694262),
pointer = 6,
- position = Offset(230.2857208251953, 342.0)
+ position = Offset(230.2857208251953f, 342.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694270),
pointer = 6,
- position = Offset(228.85714721679688, 346.28570556640625)
+ position = Offset(228.85714721679688f, 346.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694278),
pointer = 6,
- position = Offset(227.14285278320312, 352.5714416503906)
+ position = Offset(227.14285278320312f, 352.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694286),
pointer = 6,
- position = Offset(225.42857360839844, 359.4285583496094)
+ position = Offset(225.42857360839844f, 359.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694294),
pointer = 6,
- position = Offset(223.7142791748047, 367.71429443359375)
+ position = Offset(223.7142791748047f, 367.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694301),
pointer = 6,
- position = Offset(222.57142639160156, 376.0)
+ position = Offset(222.57142639160156f, 376.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694309),
pointer = 6,
- position = Offset(221.42857360839844, 384.28570556640625)
+ position = Offset(221.42857360839844f, 384.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694317),
pointer = 6,
- position = Offset(220.85714721679688, 392.28570556640625)
+ position = Offset(220.85714721679688f, 392.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694324),
pointer = 6,
- position = Offset(220.0, 400.5714416503906)
+ position = Offset(220.0f, 400.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694332),
pointer = 6,
- position = Offset(219.14285278320312, 409.71429443359375)
+ position = Offset(219.14285278320312f, 409.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694339),
pointer = 6,
- position = Offset(218.85714721679688, 419.1428527832031)
+ position = Offset(218.85714721679688f, 419.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694348),
pointer = 6,
- position = Offset(218.2857208251953, 428.8571472167969)
+ position = Offset(218.2857208251953f, 428.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694356),
pointer = 6,
- position = Offset(218.2857208251953, 438.8571472167969)
+ position = Offset(218.2857208251953f, 438.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694363),
pointer = 6,
- position = Offset(218.2857208251953, 447.71429443359375)
+ position = Offset(218.2857208251953f, 447.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694371),
pointer = 6,
- position = Offset(218.2857208251953, 455.71429443359375)
+ position = Offset(218.2857208251953f, 455.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694379),
pointer = 6,
- position = Offset(219.14285278320312, 462.8571472167969)
+ position = Offset(219.14285278320312f, 462.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694386),
pointer = 6,
- position = Offset(220.0, 469.4285583496094)
+ position = Offset(220.0f, 469.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694394),
pointer = 6,
- position = Offset(221.14285278320312, 475.4285583496094)
+ position = Offset(221.14285278320312f, 475.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694401),
pointer = 6,
- position = Offset(222.0, 480.5714416503906)
+ position = Offset(222.0f, 480.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694409),
pointer = 6,
- position = Offset(222.85714721679688, 485.4285583496094)
+ position = Offset(222.85714721679688f, 485.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694417),
pointer = 6,
- position = Offset(224.0, 489.71429443359375)
+ position = Offset(224.0f, 489.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694425),
pointer = 6,
- position = Offset(224.85714721679688, 492.8571472167969)
+ position = Offset(224.85714721679688f, 492.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694433),
pointer = 6,
- position = Offset(225.42857360839844, 495.4285583496094)
+ position = Offset(225.42857360839844f, 495.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694440),
pointer = 6,
- position = Offset(226.0, 497.1428527832031)
+ position = Offset(226.0f, 497.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694448),
pointer = 6,
- position = Offset(226.2857208251953, 498.28570556640625)
+ position = Offset(226.2857208251953f, 498.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694456),
pointer = 6,
- position = Offset(226.2857208251953, 498.8571472167969)
+ position = Offset(226.2857208251953f, 498.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694471),
pointer = 6,
- position = Offset(226.2857208251953, 498.28570556640625)
+ position = Offset(226.2857208251953f, 498.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694479),
pointer = 6,
- position = Offset(226.2857208251953, 496.5714416503906)
+ position = Offset(226.2857208251953f, 496.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694486),
pointer = 6,
- position = Offset(226.2857208251953, 493.71429443359375)
+ position = Offset(226.2857208251953f, 493.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694494),
pointer = 6,
- position = Offset(226.2857208251953, 490.0)
+ position = Offset(226.2857208251953f, 490.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694502),
pointer = 6,
- position = Offset(226.2857208251953, 486.0)
+ position = Offset(226.2857208251953f, 486.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694510),
pointer = 6,
- position = Offset(226.2857208251953, 480.5714416503906)
+ position = Offset(226.2857208251953f, 480.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694518),
pointer = 6,
- position = Offset(226.2857208251953, 475.71429443359375)
+ position = Offset(226.2857208251953f, 475.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694525),
pointer = 6,
- position = Offset(226.2857208251953, 468.8571472167969)
+ position = Offset(226.2857208251953f, 468.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694533),
pointer = 6,
- position = Offset(226.2857208251953, 461.4285583496094)
+ position = Offset(226.2857208251953f, 461.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694541),
pointer = 6,
- position = Offset(226.2857208251953, 452.5714416503906)
+ position = Offset(226.2857208251953f, 452.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694548),
pointer = 6,
- position = Offset(226.57142639160156, 442.28570556640625)
+ position = Offset(226.57142639160156f, 442.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694556),
pointer = 6,
- position = Offset(226.57142639160156, 432.28570556640625)
+ position = Offset(226.57142639160156f, 432.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694564),
pointer = 6,
- position = Offset(226.85714721679688, 423.4285583496094)
+ position = Offset(226.85714721679688f, 423.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694571),
pointer = 6,
- position = Offset(227.42857360839844, 416.0)
+ position = Offset(227.42857360839844f, 416.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694580),
pointer = 6,
- position = Offset(227.7142791748047, 410.0)
+ position = Offset(227.7142791748047f, 410.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694587),
pointer = 6,
- position = Offset(228.2857208251953, 404.28570556640625)
+ position = Offset(228.2857208251953f, 404.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694595),
pointer = 6,
- position = Offset(228.85714721679688, 399.71429443359375)
+ position = Offset(228.85714721679688f, 399.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694603),
pointer = 6,
- position = Offset(229.14285278320312, 395.4285583496094)
+ position = Offset(229.14285278320312f, 395.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694610),
pointer = 6,
- position = Offset(229.42857360839844, 392.28570556640625)
+ position = Offset(229.42857360839844f, 392.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694618),
pointer = 6,
- position = Offset(229.7142791748047, 390.0)
+ position = Offset(229.7142791748047f, 390.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694625),
pointer = 6,
- position = Offset(229.7142791748047, 388.0)
+ position = Offset(229.7142791748047f, 388.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694633),
pointer = 6,
- position = Offset(229.7142791748047, 386.8571472167969)
+ position = Offset(229.7142791748047f, 386.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694641),
pointer = 6,
- position = Offset(229.7142791748047, 386.28570556640625)
+ position = Offset(229.7142791748047f, 386.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694648),
pointer = 6,
- position = Offset(229.7142791748047, 386.0)
+ position = Offset(229.7142791748047f, 386.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694657),
pointer = 6,
- position = Offset(228.85714721679688, 386.0)
+ position = Offset(228.85714721679688f, 386.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694665),
pointer = 6,
- position = Offset(228.0, 388.0)
+ position = Offset(228.0f, 388.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694672),
pointer = 6,
- position = Offset(226.0, 392.5714416503906)
+ position = Offset(226.0f, 392.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694680),
pointer = 6,
- position = Offset(224.0, 397.71429443359375)
+ position = Offset(224.0f, 397.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694688),
pointer = 6,
- position = Offset(222.0, 404.28570556640625)
+ position = Offset(222.0f, 404.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694695),
pointer = 6,
- position = Offset(219.7142791748047, 411.1428527832031)
+ position = Offset(219.7142791748047f, 411.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694703),
pointer = 6,
- position = Offset(218.2857208251953, 418.0)
+ position = Offset(218.2857208251953f, 418.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694710),
pointer = 6,
- position = Offset(217.14285278320312, 425.4285583496094)
+ position = Offset(217.14285278320312f, 425.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694718),
pointer = 6,
- position = Offset(215.7142791748047, 433.4285583496094)
+ position = Offset(215.7142791748047f, 433.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694726),
pointer = 6,
- position = Offset(214.85714721679688, 442.28570556640625)
+ position = Offset(214.85714721679688f, 442.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694734),
pointer = 6,
- position = Offset(214.0, 454.0)
+ position = Offset(214.0f, 454.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694742),
pointer = 6,
- position = Offset(214.0, 469.4285583496094)
+ position = Offset(214.0f, 469.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694749),
pointer = 6,
- position = Offset(215.42857360839844, 485.4285583496094)
+ position = Offset(215.42857360839844f, 485.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694757),
pointer = 6,
- position = Offset(217.7142791748047, 502.8571472167969)
+ position = Offset(217.7142791748047f, 502.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694765),
pointer = 6,
- position = Offset(221.14285278320312, 521.4285888671875)
+ position = Offset(221.14285278320312f, 521.4285888671875f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694772),
pointer = 6,
- position = Offset(224.57142639160156, 541.1428833007812)
+ position = Offset(224.57142639160156f, 541.1428833007812f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694780),
pointer = 6,
- position = Offset(229.14285278320312, 561.1428833007812)
+ position = Offset(229.14285278320312f, 561.1428833007812f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216694788),
pointer = 6,
- position = Offset(233.42857360839844, 578.8571166992188)
+ position = Offset(233.42857360839844f, 578.8571166992188f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216694802),
pointer = 6,
- position = Offset(233.42857360839844, 578.8571166992188)
+ position = Offset(233.42857360839844f, 578.8571166992188f)
),
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216695344),
pointer = 7,
- position = Offset(253.42857360839844, 310.5714416503906)
+ position = Offset(253.42857360839844f, 310.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695352),
pointer = 7,
- position = Offset(253.42857360839844, 310.5714416503906)
+ position = Offset(253.42857360839844f, 310.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695359),
pointer = 7,
- position = Offset(252.85714721679688, 318.0)
+ position = Offset(252.85714721679688f, 318.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695367),
pointer = 7,
- position = Offset(251.14285278320312, 322.0)
+ position = Offset(251.14285278320312f, 322.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695375),
pointer = 7,
- position = Offset(248.85714721679688, 327.1428527832031)
+ position = Offset(248.85714721679688f, 327.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695382),
pointer = 7,
- position = Offset(246.0, 334.8571472167969)
+ position = Offset(246.0f, 334.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695390),
pointer = 7,
- position = Offset(242.57142639160156, 344.5714416503906)
+ position = Offset(242.57142639160156f, 344.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695397),
pointer = 7,
- position = Offset(238.85714721679688, 357.4285583496094)
+ position = Offset(238.85714721679688f, 357.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695406),
pointer = 7,
- position = Offset(235.7142791748047, 371.71429443359375)
+ position = Offset(235.7142791748047f, 371.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695414),
pointer = 7,
- position = Offset(232.2857208251953, 386.8571472167969)
+ position = Offset(232.2857208251953f, 386.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695421),
pointer = 7,
- position = Offset(229.42857360839844, 402.0)
+ position = Offset(229.42857360839844f, 402.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695429),
pointer = 7,
- position = Offset(227.42857360839844, 416.8571472167969)
+ position = Offset(227.42857360839844f, 416.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695437),
pointer = 7,
- position = Offset(226.2857208251953, 431.4285583496094)
+ position = Offset(226.2857208251953f, 431.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695444),
pointer = 7,
- position = Offset(226.2857208251953, 446.0)
+ position = Offset(226.2857208251953f, 446.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695452),
pointer = 7,
- position = Offset(227.7142791748047, 460.28570556640625)
+ position = Offset(227.7142791748047f, 460.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695459),
pointer = 7,
- position = Offset(230.0, 475.1428527832031)
+ position = Offset(230.0f, 475.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695467),
pointer = 7,
- position = Offset(232.2857208251953, 489.71429443359375)
+ position = Offset(232.2857208251953f, 489.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695475),
pointer = 7,
- position = Offset(235.7142791748047, 504.0)
+ position = Offset(235.7142791748047f, 504.0f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216695490),
pointer = 7,
- position = Offset(235.7142791748047, 504.0)
+ position = Offset(235.7142791748047f, 504.0f)
),
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216695885),
pointer = 8,
- position = Offset(238.85714721679688, 524.0)
+ position = Offset(238.85714721679688f, 524.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695908),
pointer = 8,
- position = Offset(236.2857208251953, 515.7142944335938)
+ position = Offset(236.2857208251953f, 515.7142944335938f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695916),
pointer = 8,
- position = Offset(234.85714721679688, 509.1428527832031)
+ position = Offset(234.85714721679688f, 509.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695924),
pointer = 8,
- position = Offset(232.57142639160156, 498.5714416503906)
+ position = Offset(232.57142639160156f, 498.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695931),
pointer = 8,
- position = Offset(230.57142639160156, 483.71429443359375)
+ position = Offset(230.57142639160156f, 483.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695939),
pointer = 8,
- position = Offset(229.14285278320312, 466.5714416503906)
+ position = Offset(229.14285278320312f, 466.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695947),
pointer = 8,
- position = Offset(229.14285278320312, 446.5714416503906)
+ position = Offset(229.14285278320312f, 446.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695955),
pointer = 8,
- position = Offset(230.57142639160156, 424.8571472167969)
+ position = Offset(230.57142639160156f, 424.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695963),
pointer = 8,
- position = Offset(232.57142639160156, 402.28570556640625)
+ position = Offset(232.57142639160156f, 402.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695970),
pointer = 8,
- position = Offset(235.14285278320312, 380.0)
+ position = Offset(235.14285278320312f, 380.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216695978),
pointer = 8,
- position = Offset(238.57142639160156, 359.4285583496094)
+ position = Offset(238.57142639160156f, 359.4285583496094f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216695993),
pointer = 8,
- position = Offset(238.57142639160156, 359.4285583496094)
+ position = Offset(238.57142639160156f, 359.4285583496094f)
),
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216696429),
pointer = 9,
- position = Offset(238.2857208251953, 568.5714111328125)
+ position = Offset(238.2857208251953f, 568.5714111328125f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216696459),
pointer = 9,
- position = Offset(234.0, 560.0)
+ position = Offset(234.0f, 560.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216696467),
pointer = 9,
- position = Offset(231.42857360839844, 553.1428833007812)
+ position = Offset(231.42857360839844f, 553.1428833007812f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216696475),
pointer = 9,
- position = Offset(228.2857208251953, 543.1428833007812)
+ position = Offset(228.2857208251953f, 543.1428833007812f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216696483),
pointer = 9,
- position = Offset(225.42857360839844, 528.8571166992188)
+ position = Offset(225.42857360839844f, 528.8571166992188f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216696491),
pointer = 9,
- position = Offset(223.14285278320312, 512.2857055664062)
+ position = Offset(223.14285278320312f, 512.2857055664062f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216696498),
pointer = 9,
- position = Offset(222.0, 495.4285583496094)
+ position = Offset(222.0f, 495.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216696506),
pointer = 9,
- position = Offset(221.7142791748047, 477.4285583496094)
+ position = Offset(221.7142791748047f, 477.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216696514),
pointer = 9,
- position = Offset(221.7142791748047, 458.28570556640625)
+ position = Offset(221.7142791748047f, 458.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216696521),
pointer = 9,
- position = Offset(223.14285278320312, 438.0)
+ position = Offset(223.14285278320312f, 438.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216696529),
pointer = 9,
- position = Offset(224.2857208251953, 416.28570556640625)
+ position = Offset(224.2857208251953f, 416.28570556640625f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216696544),
pointer = 9,
- position = Offset(224.2857208251953, 416.28570556640625)
+ position = Offset(224.2857208251953f, 416.28570556640625f)
),
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216696974),
pointer = 10,
- position = Offset(218.57142639160156, 530.5714111328125)
+ position = Offset(218.57142639160156f, 530.5714111328125f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697012),
pointer = 10,
- position = Offset(220.2857208251953, 522.0)
+ position = Offset(220.2857208251953f, 522.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697020),
pointer = 10,
- position = Offset(221.14285278320312, 517.7142944335938)
+ position = Offset(221.14285278320312f, 517.7142944335938f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697028),
pointer = 10,
- position = Offset(222.2857208251953, 511.71429443359375)
+ position = Offset(222.2857208251953f, 511.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697036),
pointer = 10,
- position = Offset(224.0, 504.28570556640625)
+ position = Offset(224.0f, 504.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697044),
pointer = 10,
- position = Offset(227.14285278320312, 490.5714416503906)
+ position = Offset(227.14285278320312f, 490.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697052),
pointer = 10,
- position = Offset(229.42857360839844, 474.0)
+ position = Offset(229.42857360839844f, 474.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697059),
pointer = 10,
- position = Offset(231.42857360839844, 454.5714416503906)
+ position = Offset(231.42857360839844f, 454.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697067),
pointer = 10,
- position = Offset(233.7142791748047, 431.1428527832031)
+ position = Offset(233.7142791748047f, 431.1428527832031f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216697082),
pointer = 10,
- position = Offset(233.7142791748047, 431.1428527832031)
+ position = Offset(233.7142791748047f, 431.1428527832031f)
),
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216697435),
pointer = 11,
- position = Offset(257.1428527832031, 285.1428527832031)
+ position = Offset(257.1428527832031f, 285.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697465),
pointer = 11,
- position = Offset(251.7142791748047, 296.8571472167969)
+ position = Offset(251.7142791748047f, 296.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697473),
pointer = 11,
- position = Offset(248.2857208251953, 304.0)
+ position = Offset(248.2857208251953f, 304.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697481),
pointer = 11,
- position = Offset(244.57142639160156, 314.8571472167969)
+ position = Offset(244.57142639160156f, 314.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697489),
pointer = 11,
- position = Offset(240.2857208251953, 329.1428527832031)
+ position = Offset(240.2857208251953f, 329.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697497),
pointer = 11,
- position = Offset(236.85714721679688, 345.1428527832031)
+ position = Offset(236.85714721679688f, 345.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697505),
pointer = 11,
- position = Offset(233.7142791748047, 361.4285583496094)
+ position = Offset(233.7142791748047f, 361.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697512),
pointer = 11,
- position = Offset(231.14285278320312, 378.28570556640625)
+ position = Offset(231.14285278320312f, 378.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697520),
pointer = 11,
- position = Offset(229.42857360839844, 395.4285583496094)
+ position = Offset(229.42857360839844f, 395.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697528),
pointer = 11,
- position = Offset(229.42857360839844, 412.8571472167969)
+ position = Offset(229.42857360839844f, 412.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697535),
pointer = 11,
- position = Offset(230.85714721679688, 430.8571472167969)
+ position = Offset(230.85714721679688f, 430.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697543),
pointer = 11,
- position = Offset(233.42857360839844, 449.71429443359375)
+ position = Offset(233.42857360839844f, 449.71429443359375f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216697558),
pointer = 11,
- position = Offset(233.42857360839844, 449.71429443359375)
+ position = Offset(233.42857360839844f, 449.71429443359375f)
),
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216697749),
pointer = 12,
- position = Offset(246.0, 311.4285583496094)
+ position = Offset(246.0f, 311.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697780),
pointer = 12,
- position = Offset(244.57142639160156, 318.28570556640625)
+ position = Offset(244.57142639160156f, 318.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697787),
pointer = 12,
- position = Offset(243.14285278320312, 325.4285583496094)
+ position = Offset(243.14285278320312f, 325.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697795),
pointer = 12,
- position = Offset(241.42857360839844, 336.0)
+ position = Offset(241.42857360839844f, 336.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697803),
pointer = 12,
- position = Offset(239.7142791748047, 351.1428527832031)
+ position = Offset(239.7142791748047f, 351.1428527832031f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697811),
pointer = 12,
- position = Offset(238.2857208251953, 368.5714416503906)
+ position = Offset(238.2857208251953f, 368.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697819),
pointer = 12,
- position = Offset(238.0, 389.4285583496094)
+ position = Offset(238.0f, 389.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697826),
pointer = 12,
- position = Offset(239.14285278320312, 412.0)
+ position = Offset(239.14285278320312f, 412.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697834),
pointer = 12,
- position = Offset(242.2857208251953, 438.0)
+ position = Offset(242.2857208251953f, 438.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697842),
pointer = 12,
- position = Offset(247.42857360839844, 466.8571472167969)
+ position = Offset(247.42857360839844f, 466.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216697849),
pointer = 12,
- position = Offset(254.2857208251953, 497.71429443359375)
+ position = Offset(254.2857208251953f, 497.71429443359375f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216697864),
pointer = 12,
- position = Offset(254.2857208251953, 497.71429443359375)
+ position = Offset(254.2857208251953f, 497.71429443359375f)
),
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216698321),
pointer = 13,
- position = Offset(250.0, 306.0)
+ position = Offset(250.0f, 306.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698328),
pointer = 13,
- position = Offset(250.0, 306.0)
+ position = Offset(250.0f, 306.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698344),
pointer = 13,
- position = Offset(249.14285278320312, 314.0)
+ position = Offset(249.14285278320312f, 314.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698351),
pointer = 13,
- position = Offset(247.42857360839844, 319.4285583496094)
+ position = Offset(247.42857360839844f, 319.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698359),
pointer = 13,
- position = Offset(245.14285278320312, 326.8571472167969)
+ position = Offset(245.14285278320312f, 326.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698366),
pointer = 13,
- position = Offset(241.7142791748047, 339.4285583496094)
+ position = Offset(241.7142791748047f, 339.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698374),
pointer = 13,
- position = Offset(238.57142639160156, 355.71429443359375)
+ position = Offset(238.57142639160156f, 355.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698382),
pointer = 13,
- position = Offset(236.2857208251953, 374.28570556640625)
+ position = Offset(236.2857208251953f, 374.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698390),
pointer = 13,
- position = Offset(235.14285278320312, 396.5714416503906)
+ position = Offset(235.14285278320312f, 396.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698398),
pointer = 13,
- position = Offset(236.57142639160156, 421.4285583496094)
+ position = Offset(236.57142639160156f, 421.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698406),
pointer = 13,
- position = Offset(241.14285278320312, 451.4285583496094)
+ position = Offset(241.14285278320312f, 451.4285583496094f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216698421),
pointer = 13,
- position = Offset(241.14285278320312, 451.4285583496094)
+ position = Offset(241.14285278320312f, 451.4285583496094f)
)
)
@@ -1560,33 +1560,33 @@
PointerDownEvent(
timeStamp = Duration.create(milliseconds = 216698321),
pointer = 13,
- position = Offset(250.0, 306.0)
+ position = Offset(250.0f, 306.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698328),
pointer = 13,
- position = Offset(250.0, 306.0)
+ position = Offset(250.0f, 306.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698344),
pointer = 13,
- position = Offset(249.14285278320312, 314.0)
+ position = Offset(249.14285278320312f, 314.0f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698351),
pointer = 13,
- position = Offset(247.42857360839844, 319.4285583496094)
+ position = Offset(247.42857360839844f, 319.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698359),
pointer = 13,
- position = Offset(245.14285278320312, 326.8571472167969)
+ position = Offset(245.14285278320312f, 326.8571472167969f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698366),
pointer = 13,
- position = Offset(241.7142791748047, 339.4285583496094)
+ position = Offset(241.7142791748047f, 339.4285583496094f)
),
// The pointer "stops" here because we've introduced a 40+ms gap
@@ -1596,31 +1596,31 @@
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698374 + 40),
pointer = 13,
- position = Offset(238.57142639160156, 355.71429443359375)
+ position = Offset(238.57142639160156f, 355.71429443359375f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698382 + 40),
pointer = 13,
- position = Offset(236.2857208251953, 374.28570556640625)
+ position = Offset(236.2857208251953f, 374.28570556640625f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698390 + 40),
pointer = 13,
- position = Offset(235.14285278320312, 396.5714416503906)
+ position = Offset(235.14285278320312f, 396.5714416503906f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698398 + 40),
pointer = 13,
- position = Offset(236.57142639160156, 421.4285583496094)
+ position = Offset(236.57142639160156f, 421.4285583496094f)
),
PointerMoveEvent(
timeStamp = Duration.create(milliseconds = 216698406 + 40),
pointer = 13,
- position = Offset(241.14285278320312, 451.4285583496094)
+ position = Offset(241.14285278320312f, 451.4285583496094f)
),
PointerUpEvent(
timeStamp = Duration.create(milliseconds = 216698421 + 40),
pointer = 13,
- position = Offset(241.14285278320312, 451.4285583496094)
+ position = Offset(241.14285278320312f, 451.4285583496094f)
)
)
\ No newline at end of file
diff --git a/ui/port/src/test/java/androidx/ui/gestures/velocity_tracker/VelocityTrackerTest.kt b/ui/port/src/test/java/androidx/ui/gestures/velocity_tracker/VelocityTrackerTest.kt
index 7bf760d..64ebd47 100644
--- a/ui/port/src/test/java/androidx/ui/gestures/velocity_tracker/VelocityTrackerTest.kt
+++ b/ui/port/src/test/java/androidx/ui/gestures/velocity_tracker/VelocityTrackerTest.kt
@@ -40,19 +40,19 @@
fun `Velocity tracker gives expected results`() {
val expected: List<Offset> = listOf(
- Offset(219.59280094228163, 1304.701682306001),
- Offset(355.71046950050845, 967.2112857054104),
- Offset(12.657970884022308, -36.90447839251946),
- Offset(714.1399654786744, -2561.534447931869),
- Offset(-19.668121066218564, -2910.105747052462),
- Offset(646.8690114934209, 2976.977762577527),
- Offset(396.6988447819592, 2106.225572911095),
- Offset(298.31594440044495, -3660.8315955215294),
- Offset(-1.7334232785165882, -3288.13174127454),
- Offset(384.6361280392334, -2645.6612524779835),
- Offset(176.37900397918557, 2711.2542876273264),
- Offset(396.9328560260098, 4280.651578291764),
- Offset(-71.51939428321249, 3716.7385187526947)
+ Offset(219.59280094228163f, 1304.701682306001f),
+ Offset(355.71046950050845f, 967.2112857054104f),
+ Offset(12.657970884022308f, -36.90447839251946f),
+ Offset(714.1399654786744f, -2561.534447931869f),
+ Offset(-19.668121066218564f, -2910.105747052462f),
+ Offset(646.8690114934209f, 2976.977762577527f),
+ Offset(396.6988447819592f, 2106.225572911095f),
+ Offset(298.31594440044495f, -3660.8315955215294f),
+ Offset(-1.7334232785165882f, -3288.13174127454f),
+ Offset(384.6361280392334f, -2645.6612524779835f),
+ Offset(176.37900397918557f, 2711.2542876273264f),
+ Offset(396.9328560260098f, 4280.651578291764f),
+ Offset(-71.51939428321249f, 3716.7385187526947f)
)
val tracker = VelocityTracker()
@@ -70,18 +70,18 @@
@Test
fun `Velocity control test`() {
- val velocity1 = Velocity(pixelsPerSecond = Offset(7.0, 0.0))
- val velocity2 = Velocity(pixelsPerSecond = Offset(12.0, 0.0))
- assertThat(velocity1, `is`(equalTo(Velocity(pixelsPerSecond = Offset(7.0, 0.0)))))
+ val velocity1 = Velocity(pixelsPerSecond = Offset(7.0f, 0.0f))
+ val velocity2 = Velocity(pixelsPerSecond = Offset(12.0f, 0.0f))
+ assertThat(velocity1, `is`(equalTo(Velocity(pixelsPerSecond = Offset(7.0f, 0.0f)))))
assertThat(velocity1, `is`(not(equalTo(velocity2))))
assertThat(
velocity2 - velocity1,
- `is`(equalTo(Velocity(pixelsPerSecond = Offset(5.0, 0.0))))
+ `is`(equalTo(Velocity(pixelsPerSecond = Offset(5.0f, 0.0f))))
)
- assertThat((-velocity1).pixelsPerSecond, `is`(equalTo(Offset(-7.0, 0.0))))
+ assertThat((-velocity1).pixelsPerSecond, `is`(equalTo(Offset(-7.0f, 0.0f))))
assertThat(
velocity1 + velocity2,
- `is`(equalTo(Velocity(pixelsPerSecond = Offset(19.0, 0.0))))
+ `is`(equalTo(Velocity(pixelsPerSecond = Offset(19.0f, 0.0f))))
)
assertThat(velocity1.hashCode(), `is`(not(equalTo(velocity2.hashCode()))))
assertThat(velocity1, HasOneLineDescription)
@@ -95,7 +95,7 @@
if (it is PointerDownEvent || it is PointerMoveEvent)
tracker.addPosition(it.timeStamp, it.position)
if (it is PointerUpEvent) {
- _checkVelocity(tracker.getVelocity(), Offset(649.4893210274806, 3890.3050558907644))
+ _checkVelocity(tracker.getVelocity(), Offset(649.48932102748f, 3890.30505589076f))
}
}
}
@@ -107,7 +107,7 @@
}
private fun _checkVelocity(actual: Velocity, expected: Offset) {
- assertThat(actual.pixelsPerSecond.dx, MoreOrLessEquals(expected.dx, 0.001))
- assertThat(actual.pixelsPerSecond.dy, MoreOrLessEquals(expected.dy, 0.001))
+ assertThat(actual.pixelsPerSecond.dx, MoreOrLessEquals(expected.dx, 0.1f))
+ assertThat(actual.pixelsPerSecond.dy, MoreOrLessEquals(expected.dy, 0.1f))
}
}
\ No newline at end of file
diff --git a/ui/port/src/test/java/androidx/ui/matchers/InInclusiveRange.kt b/ui/port/src/test/java/androidx/ui/matchers/InInclusiveRange.kt
index f9b8169..dad104e 100644
--- a/ui/port/src/test/java/androidx/ui/matchers/InInclusiveRange.kt
+++ b/ui/port/src/test/java/androidx/ui/matchers/InInclusiveRange.kt
@@ -36,12 +36,12 @@
import org.hamcrest.Description
class InInclusiveRange(
- private val min: Double,
- private val max: Double
-) : BaseMatcher<Double>() {
+ private val min: Float,
+ private val max: Float
+) : BaseMatcher<Float>() {
override fun matches(item: Any?): Boolean {
- return item is Double && item >= min && item <= max
+ return item is Float && item >= min && item <= max
}
override fun describeTo(description: Description?) {
diff --git a/ui/port/src/test/java/androidx/ui/matchers/MoreOrLessEquals.kt b/ui/port/src/test/java/androidx/ui/matchers/MoreOrLessEquals.kt
index 19dcf54..c3b3310 100644
--- a/ui/port/src/test/java/androidx/ui/matchers/MoreOrLessEquals.kt
+++ b/ui/port/src/test/java/androidx/ui/matchers/MoreOrLessEquals.kt
@@ -37,7 +37,7 @@
import kotlin.math.absoluteValue
/**
- * Asserts that two [Double]s are equal, within some tolerated error.
+ * Asserts that two [Float]s are equal, within some tolerated error.
*
* Two values are considered equal if the difference between them is within
* 1e-10 of the larger one. This is an arbitrary value which can be adjusted
@@ -53,12 +53,12 @@
* range.
*/
class MoreOrLessEquals(
- private val value: Double,
- private val epsilon: Double = 1e-7
-) : BaseMatcher<Double>() {
+ private val value: Float,
+ private val epsilon: Float = 1e-4f
+) : BaseMatcher<Float>() {
override fun matches(item: Any?): Boolean {
- if (item !is Double) {
+ if (item !is Float) {
return false
}
if (item == value) {
diff --git a/ui/port/src/test/java/androidx/ui/painting/AlignmentTest.kt b/ui/port/src/test/java/androidx/ui/painting/AlignmentTest.kt
index ee101b1..41bca7f 100644
--- a/ui/port/src/test/java/androidx/ui/painting/AlignmentTest.kt
+++ b/ui/port/src/test/java/androidx/ui/painting/AlignmentTest.kt
@@ -57,25 +57,25 @@
@Test
fun `Alignment control test`() {
- val alignment = Alignment(0.5, 0.25)
+ val alignment = Alignment(0.5f, 0.25f)
assertThat(alignment, HasOneLineDescription)
- assertEquals(alignment.hashCode(), Alignment(0.5, 0.25).hashCode())
+ assertEquals(alignment.hashCode(), Alignment(0.5f, 0.25f).hashCode())
- assertEquals(alignment / 2.0, Alignment(0.25, 0.125))
- assertEquals(alignment.truncDiv(2.0), Alignment(0.0, 0.0))
- assertEquals(alignment % 5.0, Alignment(0.5, 0.25))
+ assertEquals(alignment / 2.0f, Alignment(0.25f, 0.125f))
+ assertEquals(alignment.truncDiv(2.0f), Alignment(0.0f, 0.0f))
+ assertEquals(alignment % 5.0f, Alignment(0.5f, 0.25f))
}
@Test
fun `Alignment_lerp()`() {
val a = Alignment.topLeft
val b = Alignment.topCenter
- assertEquals(Alignment.lerp(a, b, 0.25), Alignment(-0.75, -1.0))
+ assertEquals(Alignment.lerp(a, b, 0.25f), Alignment(-0.75f, -1.0f))
- assertNull(Alignment.lerp(null, null, 0.25))
- assertEquals(Alignment.lerp(null, b, 0.25), Alignment(0.0, -0.25))
- assertEquals(Alignment.lerp(a, null, 0.25), Alignment(-0.75, -0.75))
+ assertNull(Alignment.lerp(null, null, 0.25f))
+ assertEquals(Alignment.lerp(null, b, 0.25f), Alignment(0.0f, -0.25f))
+ assertEquals(Alignment.lerp(a, null, 0.25f), Alignment(-0.75f, -0.75f))
}
@Test
@@ -85,10 +85,10 @@
val center = Alignment.center
val topLeft = Alignment.topLeft
val topRight = Alignment.topRight
- val numbers = listOf(0.0, 1.0, -1.0, 2.0, 0.25, 0.5, 100.0, -999.75)
+ val numbers = listOf(0.0f, 1.0f, -1.0f, 2.0f, 0.25f, 0.5f, 100.0f, -999.75f)
- assertEquals(center, (topEnd * 0.0).add(topRight * 0.0))
- assertEquals((topEnd * 0.0).add(topRight * 0.0), topEnd.add(topRight) * 0.0)
+ assertEquals(center, (topEnd * 0.0f).add(topRight * 0.0f))
+ assertEquals((topEnd * 0.0f).add(topRight * 0.0f), topEnd.add(topRight) * 0.0f)
assertEquals(topLeft.add(topStart), topStart.add(topLeft))
assertEquals((topStart.resolve(TextDirection.LTR)) + topLeft,
(topStart.add(topLeft)).resolve(TextDirection.LTR))
@@ -100,28 +100,28 @@
(topStart.add(topLeft)).resolve(TextDirection.RTL))
assertEquals(topLeft, topStart.resolve(TextDirection.LTR))
assertEquals(topRight, topStart.resolve(TextDirection.RTL))
- assertEquals(center, topEnd * 0.0)
- assertEquals(center, topLeft * 0.0)
- assertEquals(topStart, topStart * 1.0)
- assertEquals(topEnd, topEnd * 1.0)
- assertEquals(topLeft, topLeft * 1.0)
- assertEquals(topRight, topRight * 1.0)
+ assertEquals(center, topEnd * 0.0f)
+ assertEquals(center, topLeft * 0.0f)
+ assertEquals(topStart, topStart * 1.0f)
+ assertEquals(topEnd, topEnd * 1.0f)
+ assertEquals(topLeft, topLeft * 1.0f)
+ assertEquals(topRight, topRight * 1.0f)
for (n in numbers) {
- assertEquals(topStart * (n + 1.0), (topStart * n).add(topStart))
- assertEquals(topEnd * (n + 1.0), (topEnd * n).add(topEnd))
+ assertEquals(topStart * (n + 1.0f), (topStart * n).add(topStart))
+ assertEquals(topEnd * (n + 1.0f), (topEnd * n).add(topEnd))
for (m in numbers)
assertEquals(topStart * (n + m), (topStart * n).add(topStart * m))
}
- assertEquals(topStart + topStart + topStart, topStart * 3.0) // without using "add"
+ assertEquals(topStart + topStart + topStart, topStart * 3.0f) // without using "add"
for (x in TextDirection.values()) {
assertEquals(center.add(center).resolve(x),
- (topEnd * 0.0).add(topRight * 0.0).resolve(x))
- assertEquals(center.add(topLeft).resolve(x), (topEnd * 0.0).add(topLeft).resolve(x))
+ (topEnd * 0.0f).add(topRight * 0.0f).resolve(x))
+ assertEquals(center.add(topLeft).resolve(x), (topEnd * 0.0f).add(topLeft).resolve(x))
assertEquals((center.resolve(x)).add(topLeft.resolve(x)),
- ((topEnd * 0.0).resolve(x)).add(topLeft.resolve(x)))
+ ((topEnd * 0.0f).resolve(x)).add(topLeft.resolve(x)))
assertEquals((center.resolve(x)).add(topLeft),
- ((topEnd * 0.0).resolve(x)).add(topLeft))
- assertEquals(center.resolve(x), (topEnd * 0.0).resolve(x))
+ ((topEnd * 0.0f).resolve(x)).add(topLeft))
+ assertEquals(center.resolve(x), (topEnd * 0.0f).resolve(x))
}
assertNotEquals(topLeft, topStart)
assertNotEquals(topLeft, topEnd)
@@ -133,61 +133,61 @@
@Test
fun `AlignmentGeometry_resolve()`() {
- assertEquals(AlignmentDirectional(0.25, 0.3).resolve(TextDirection.LTR),
- Alignment(0.25, 0.3))
- assertEquals(AlignmentDirectional(0.25, 0.3).resolve(TextDirection.RTL),
- Alignment(-0.25, 0.3))
- assertEquals(AlignmentDirectional(-0.25, 0.3).resolve(TextDirection.LTR),
- Alignment(-0.25, 0.3))
- assertEquals(AlignmentDirectional(-0.25, 0.3).resolve(TextDirection.RTL),
- Alignment(0.25, 0.3))
- assertEquals(AlignmentDirectional(1.25, 0.3).resolve(TextDirection.LTR),
- Alignment(1.25, 0.3))
- assertEquals(AlignmentDirectional(1.25, 0.3).resolve(TextDirection.RTL),
- Alignment(-1.25, 0.3))
- assertEquals(AlignmentDirectional(0.5, -0.3).resolve(TextDirection.LTR),
- Alignment(0.5, -0.3))
- assertEquals(AlignmentDirectional(0.5, -0.3).resolve(TextDirection.RTL),
- Alignment(-0.5, -0.3))
- assertEquals(AlignmentDirectional(0.0, 0.0).resolve(TextDirection.LTR),
- Alignment(0.0, 0.0))
- assertEquals(AlignmentDirectional(0.0, 0.0).resolve(TextDirection.RTL),
- Alignment(0.0, 0.0))
- assertEquals(AlignmentDirectional(1.0, 1.0).resolve(TextDirection.LTR),
- Alignment(1.0, 1.0))
- assertEquals(AlignmentDirectional(1.0, 1.0).resolve(TextDirection.RTL),
- Alignment(-1.0, 1.0))
- assertEquals(AlignmentDirectional(1.0, 2.0),
- AlignmentDirectional(1.0, 2.0))
- assertNotEquals(AlignmentDirectional(1.0, 2.0),
- AlignmentDirectional(2.0, 1.0))
- assertEquals(AlignmentDirectional(-1.0, 0.0).resolve(TextDirection.LTR),
- AlignmentDirectional(1.0, 0.0).resolve(TextDirection.RTL))
- assertNotEquals(AlignmentDirectional(-1.0, 0.0).resolve(TextDirection.LTR),
- AlignmentDirectional(1.0, 0.0).resolve(TextDirection.LTR))
- assertNotEquals(AlignmentDirectional(1.0, 0.0).resolve(TextDirection.LTR),
- AlignmentDirectional(1.0, 0.0).resolve(TextDirection.RTL))
+ assertEquals(AlignmentDirectional(0.25f, 0.3f).resolve(TextDirection.LTR),
+ Alignment(0.25f, 0.3f))
+ assertEquals(AlignmentDirectional(0.25f, 0.3f).resolve(TextDirection.RTL),
+ Alignment(-0.25f, 0.3f))
+ assertEquals(AlignmentDirectional(-0.25f, 0.3f).resolve(TextDirection.LTR),
+ Alignment(-0.25f, 0.3f))
+ assertEquals(AlignmentDirectional(-0.25f, 0.3f).resolve(TextDirection.RTL),
+ Alignment(0.25f, 0.3f))
+ assertEquals(AlignmentDirectional(1.25f, 0.3f).resolve(TextDirection.LTR),
+ Alignment(1.25f, 0.3f))
+ assertEquals(AlignmentDirectional(1.25f, 0.3f).resolve(TextDirection.RTL),
+ Alignment(-1.25f, 0.3f))
+ assertEquals(AlignmentDirectional(0.5f, -0.3f).resolve(TextDirection.LTR),
+ Alignment(0.5f, -0.3f))
+ assertEquals(AlignmentDirectional(0.5f, -0.3f).resolve(TextDirection.RTL),
+ Alignment(-0.5f, -0.3f))
+ assertEquals(AlignmentDirectional(0.0f, 0.0f).resolve(TextDirection.LTR),
+ Alignment(0.0f, 0.0f))
+ assertEquals(AlignmentDirectional(0.0f, 0.0f).resolve(TextDirection.RTL),
+ Alignment(0.0f, 0.0f))
+ assertEquals(AlignmentDirectional(1.0f, 1.0f).resolve(TextDirection.LTR),
+ Alignment(1.0f, 1.0f))
+ assertEquals(AlignmentDirectional(1.0f, 1.0f).resolve(TextDirection.RTL),
+ Alignment(-1.0f, 1.0f))
+ assertEquals(AlignmentDirectional(1.0f, 2.0f),
+ AlignmentDirectional(1.0f, 2.0f))
+ assertNotEquals(AlignmentDirectional(1.0f, 2.0f),
+ AlignmentDirectional(2.0f, 1.0f))
+ assertEquals(AlignmentDirectional(-1.0f, 0.0f).resolve(TextDirection.LTR),
+ AlignmentDirectional(1.0f, 0.0f).resolve(TextDirection.RTL))
+ assertNotEquals(AlignmentDirectional(-1.0f, 0.0f).resolve(TextDirection.LTR),
+ AlignmentDirectional(1.0f, 0.0f).resolve(TextDirection.LTR))
+ assertNotEquals(AlignmentDirectional(1.0f, 0.0f).resolve(TextDirection.LTR),
+ AlignmentDirectional(1.0f, 0.0f).resolve(TextDirection.RTL))
}
@Test
fun `AlignmentGeometry_lerp ad hoc tests`() {
- val mixed1 = Alignment(10.0, 20.0).add(AlignmentDirectional(30.0, 50.0))
- val mixed2 = Alignment(70.0, 110.0).add(AlignmentDirectional(130.0, 170.0))
- val mixed3 = Alignment(25.0, 42.5).add(AlignmentDirectional(55.0, 80.0))
+ val mixed1 = Alignment(10.0f, 20.0f).add(AlignmentDirectional(30.0f, 50.0f))
+ val mixed2 = Alignment(70.0f, 110.0f).add(AlignmentDirectional(130.0f, 170.0f))
+ val mixed3 = Alignment(25.0f, 42.5f).add(AlignmentDirectional(55.0f, 80.0f))
for (direction in TextDirection.values()) {
assertEquals(mixed1.resolve(direction),
- AlignmentGeometry.lerp(mixed1, mixed2, 0.0)!!.resolve(direction))
+ AlignmentGeometry.lerp(mixed1, mixed2, 0.0f)!!.resolve(direction))
assertEquals(mixed2.resolve(direction),
- AlignmentGeometry.lerp(mixed1, mixed2, 1.0)!!.resolve(direction))
+ AlignmentGeometry.lerp(mixed1, mixed2, 1.0f)!!.resolve(direction))
assertEquals(mixed3.resolve(direction),
- AlignmentGeometry.lerp(mixed1, mixed2, 0.25)!!.resolve(direction))
+ AlignmentGeometry.lerp(mixed1, mixed2, 0.25f)!!.resolve(direction))
}
}
@Test
fun `lerp commutes with resolve`() {
- val offsets = listOf(
+ val ofsets = listOf(
Alignment.topLeft,
Alignment.topCenter,
Alignment.topRight,
@@ -206,39 +206,39 @@
AlignmentDirectional.bottomStart,
AlignmentDirectional.bottomCenter,
AlignmentDirectional.bottomEnd,
- Alignment(-1.0, 0.65),
- AlignmentDirectional(-1.0, 0.45),
- AlignmentDirectional(0.125, 0.625),
- Alignment(0.25, 0.875),
- Alignment(0.0625, 0.5625).add(AlignmentDirectional(0.1875, 0.6875)),
- AlignmentDirectional(2.0, 3.0),
- Alignment(2.0, 3.0),
- Alignment(2.0, 3.0).add(AlignmentDirectional(5.0, 3.0)),
- Alignment(10.0, 20.0).add(AlignmentDirectional(30.0, 50.0)),
- Alignment(70.0, 110.0).add(AlignmentDirectional(130.0, 170.0)),
- Alignment(25.0, 42.5).add(AlignmentDirectional(55.0, 80.0)),
+ Alignment(-1.0f, 0.65f),
+ AlignmentDirectional(-1.0f, 0.45f),
+ AlignmentDirectional(0.125f, 0.625f),
+ Alignment(0.25f, 0.875f),
+ Alignment(0.0625f, 0.5625f).add(AlignmentDirectional(0.1875f, 0.6875f)),
+ AlignmentDirectional(2.0f, 3.0f),
+ Alignment(2.0f, 3.0f),
+ Alignment(2.0f, 3.0f).add(AlignmentDirectional(5.0f, 3.0f)),
+ Alignment(10.0f, 20.0f).add(AlignmentDirectional(30.0f, 50.0f)),
+ Alignment(70.0f, 110.0f).add(AlignmentDirectional(130.0f, 170.0f)),
+ Alignment(25.0f, 42.5f).add(AlignmentDirectional(55.0f, 80.0f)),
null
)
- val times = listOf(0.25, 0.5, 0.75)
+ val times = listOf(0.25f, 0.5f, 0.75f)
for (direction in TextDirection.values()) {
val defaultValue = AlignmentDirectional.center.resolve(direction)
- for (a in offsets) {
+ for (a in ofsets) {
val resolvedA = a?.resolve(direction) ?: defaultValue
- for (b in offsets) {
+ for (b in ofsets) {
val resolvedB = b?.resolve(direction) ?: defaultValue
- approxExpect(Alignment.lerp(resolvedA, resolvedB, 0.0)!!, resolvedA)
- approxExpect(Alignment.lerp(resolvedA, resolvedB, 1.0)!!, resolvedB)
- approxExpect((AlignmentGeometry.lerp(a, b, 0.0) ?: defaultValue)
+ approxExpect(Alignment.lerp(resolvedA, resolvedB, 0.0f)!!, resolvedA)
+ approxExpect(Alignment.lerp(resolvedA, resolvedB, 1.0f)!!, resolvedB)
+ approxExpect((AlignmentGeometry.lerp(a, b, 0.0f) ?: defaultValue)
.resolve(direction),
resolvedA)
approxExpect(
- (AlignmentGeometry.lerp(a, b, 1.0) ?: defaultValue).resolve(direction),
+ (AlignmentGeometry.lerp(a, b, 1.0f) ?: defaultValue).resolve(direction),
resolvedB)
for (t in times) {
- assert(t > 0.0)
- assert(t < 1.0)
+ assert(t > 0.0f)
+ assert(t < 1.0f)
val value = (AlignmentGeometry.lerp(a, b, t) ?: defaultValue).resolve(
direction)
approxExpect(value, Alignment.lerp(resolvedA, resolvedB, t)!!)
@@ -256,71 +256,71 @@
@Test
fun `AlignmentGeometry add_subtract`() {
- val directional = AlignmentDirectional(1.0, 2.0)
- val normal = Alignment(3.0, 5.0)
- assertEquals(directional.add(normal).resolve(TextDirection.LTR), Alignment(4.0, 7.0))
- assertEquals(directional.add(normal).resolve(TextDirection.RTL), Alignment(2.0, 7.0))
- assertEquals(normal * 2.0, normal.add(normal))
- assertEquals(directional * 2.0, directional.add(directional))
+ val directional = AlignmentDirectional(1.0f, 2.0f)
+ val normal = Alignment(3.0f, 5.0f)
+ assertEquals(directional.add(normal).resolve(TextDirection.LTR), Alignment(4.0f, 7.0f))
+ assertEquals(directional.add(normal).resolve(TextDirection.RTL), Alignment(2.0f, 7.0f))
+ assertEquals(normal * 2.0f, normal.add(normal))
+ assertEquals(directional * 2.0f, directional.add(directional))
}
@Test
fun `AlignmentGeometry operators`() {
- assertEquals(AlignmentDirectional(1.0, 2.0) * 2.0,
- AlignmentDirectional(2.0, 4.0))
- assertEquals(AlignmentDirectional(1.0, 2.0) / 2.0,
- AlignmentDirectional(0.5, 1.0))
- assertEquals(AlignmentDirectional(1.0, 2.0) % 2.0,
- AlignmentDirectional(1.0, 0.0))
- assertEquals(AlignmentDirectional(1.0, 2.0).truncDiv(2.0),
- AlignmentDirectional(0.0, 1.0))
+ assertEquals(AlignmentDirectional(1.0f, 2.0f) * 2.0f,
+ AlignmentDirectional(2.0f, 4.0f))
+ assertEquals(AlignmentDirectional(1.0f, 2.0f) / 2.0f,
+ AlignmentDirectional(0.5f, 1.0f))
+ assertEquals(AlignmentDirectional(1.0f, 2.0f) % 2.0f,
+ AlignmentDirectional(1.0f, 0.0f))
+ assertEquals(AlignmentDirectional(1.0f, 2.0f).truncDiv(2.0f),
+ AlignmentDirectional(0.0f, 1.0f))
for (direction in TextDirection.values()) {
assertEquals(
- Alignment.center.add(AlignmentDirectional(1.0, 2.0) * 2.0).resolve(direction),
- AlignmentDirectional(2.0, 4.0).resolve(direction))
+ Alignment.center.add(AlignmentDirectional(1f, 2f) * 2f).resolve(direction),
+ AlignmentDirectional(2.0f, 4.0f).resolve(direction))
assertEquals(
- Alignment.center.add(AlignmentDirectional(1.0, 2.0) / 2.0).resolve(direction),
- AlignmentDirectional(0.5, 1.0).resolve(direction))
+ Alignment.center.add(AlignmentDirectional(1f, 2f) / 2f).resolve(direction),
+ AlignmentDirectional(0.5f, 1.0f).resolve(direction))
assertEquals(
- Alignment.center.add(AlignmentDirectional(1.0, 2.0) % 2.0).resolve(direction),
- AlignmentDirectional(1.0, 0.0).resolve(direction))
- assertEquals(Alignment.center.add(AlignmentDirectional(1.0, 2.0)
- .truncDiv(2.0)).resolve(
- direction), AlignmentDirectional(0.0, 1.0).resolve(direction))
+ Alignment.center.add(AlignmentDirectional(1f, 2f) % 2f).resolve(direction),
+ AlignmentDirectional(1.0f, 0.0f).resolve(direction))
+ assertEquals(Alignment.center.add(AlignmentDirectional(1.0f, 2.0f)
+ .truncDiv(2.0f)).resolve(
+ direction), AlignmentDirectional(0.0f, 1.0f).resolve(direction))
}
- assertEquals(Alignment(1.0, 2.0) * 2.0, Alignment(2.0, 4.0))
- assertEquals(Alignment(1.0, 2.0) / 2.0, Alignment(0.5, 1.0))
- assertEquals(Alignment(1.0, 2.0) % 2.0, Alignment(1.0, 0.0))
- assertEquals(Alignment(1.0, 2.0).truncDiv(2.0), Alignment(0.0, 1.0))
+ assertEquals(Alignment(1.0f, 2.0f) * 2.0f, Alignment(2.0f, 4.0f))
+ assertEquals(Alignment(1.0f, 2.0f) / 2.0f, Alignment(0.5f, 1.0f))
+ assertEquals(Alignment(1.0f, 2.0f) % 2.0f, Alignment(1.0f, 0.0f))
+ assertEquals(Alignment(1.0f, 2.0f).truncDiv(2.0f), Alignment(0.0f, 1.0f))
}
@Test
fun `AlignmentGeometry operators2`() {
- assertEquals(Alignment(1.0, 2.0) + Alignment(3.0, 5.0),
- Alignment(4.0, 7.0))
- assertEquals(Alignment(1.0, 2.0) - Alignment(3.0, 5.0),
- Alignment(-2.0, -3.0))
- assertEquals(AlignmentDirectional(1.0, 2.0) +
- AlignmentDirectional(3.0, 5.0),
- AlignmentDirectional(4.0, 7.0))
- assertEquals(AlignmentDirectional(1.0, 2.0) -
- AlignmentDirectional(3.0, 5.0),
- AlignmentDirectional(-2.0, -3.0))
+ assertEquals(Alignment(1.0f, 2.0f) + Alignment(3.0f, 5.0f),
+ Alignment(4.0f, 7.0f))
+ assertEquals(Alignment(1.0f, 2.0f) - Alignment(3.0f, 5.0f),
+ Alignment(-2.0f, -3.0f))
+ assertEquals(AlignmentDirectional(1.0f, 2.0f) +
+ AlignmentDirectional(3.0f, 5.0f),
+ AlignmentDirectional(4.0f, 7.0f))
+ assertEquals(AlignmentDirectional(1.0f, 2.0f) -
+ AlignmentDirectional(3.0f, 5.0f),
+ AlignmentDirectional(-2.0f, -3.0f))
}
@Test
fun `AlignmentGeometry toString`() {
- assertEquals(Alignment(1.0001, 2.0001).toString(), "Alignment(1.0, 2.0)")
- assertEquals(Alignment(0.0, 0.0).toString(), "center")
- assertEquals(Alignment(-1.0, 1.0)
- .add(AlignmentDirectional(1.0, 0.0)).toString(),
+ assertEquals(Alignment(1.0001f, 2.0001f).toString(), "Alignment(1.0, 2.0)")
+ assertEquals(Alignment(0.0f, 0.0f).toString(), "center")
+ assertEquals(Alignment(-1.0f, 1.0f)
+ .add(AlignmentDirectional(1.0f, 0.0f)).toString(),
"bottomLeft + AlignmentDirectional.centerEnd")
- assertEquals(Alignment(0.0001, 0.0001).toString(), "Alignment(0.0, 0.0)")
- assertEquals(Alignment(0.0, 0.0).toString(), "center")
- assertEquals(AlignmentDirectional(0.0, 0.0).toString(),
+ assertEquals(Alignment(0.0001f, 0.0001f).toString(), "Alignment(0.0, 0.0)")
+ assertEquals(Alignment(0.0f, 0.0f).toString(), "center")
+ assertEquals(AlignmentDirectional(0.0f, 0.0f).toString(),
"AlignmentDirectional.center")
- assertEquals(Alignment(1.0, 1.0)
- .add(AlignmentDirectional(1.0, 1.0)).toString(),
+ assertEquals(Alignment(1.0f, 1.0f)
+ .add(AlignmentDirectional(1.0f, 1.0f)).toString(),
"Alignment(1.0, 2.0) + AlignmentDirectional.centerEnd")
}
}
\ No newline at end of file
diff --git a/ui/port/src/test/java/androidx/ui/painting/BoxFitTest.kt b/ui/port/src/test/java/androidx/ui/painting/BoxFitTest.kt
index 6245cd0..d334e5b 100644
--- a/ui/port/src/test/java/androidx/ui/painting/BoxFitTest.kt
+++ b/ui/port/src/test/java/androidx/ui/painting/BoxFitTest.kt
@@ -29,21 +29,21 @@
fun `applyBoxFit`() {
var result: FittedSizes
- result = applyBoxFit(BoxFit.scaleDown, Size(100.0, 1000.0), Size(200.0, 2000.0))
- assertEquals(result.source, Size(100.0, 1000.0))
- assertEquals(result.destination, Size(100.0, 1000.0))
+ result = applyBoxFit(BoxFit.scaleDown, Size(100.0f, 1000.0f), Size(200.0f, 2000.0f))
+ assertEquals(result.source, Size(100.0f, 1000.0f))
+ assertEquals(result.destination, Size(100.0f, 1000.0f))
- result = applyBoxFit(BoxFit.scaleDown, Size(300.0, 3000.0), Size(200.0, 2000.0))
- assertEquals(result.source, Size(300.0, 3000.0))
- assertEquals(result.destination, Size(200.0, 2000.0))
+ result = applyBoxFit(BoxFit.scaleDown, Size(300.0f, 3000.0f), Size(200.0f, 2000.0f))
+ assertEquals(result.source, Size(300.0f, 3000.0f))
+ assertEquals(result.destination, Size(200.0f, 2000.0f))
- result = applyBoxFit(BoxFit.fitWidth, Size(2000.0, 400.0), Size(1000.0, 100.0))
- assertEquals(result.source, Size(2000.0, 200.0))
- assertEquals(result.destination, Size(1000.0, 100.0))
+ result = applyBoxFit(BoxFit.fitWidth, Size(2000.0f, 400.0f), Size(1000.0f, 100.0f))
+ assertEquals(result.source, Size(2000.0f, 200.0f))
+ assertEquals(result.destination, Size(1000.0f, 100.0f))
- result = applyBoxFit(BoxFit.fitHeight, Size(400.0, 2000.0), Size(100.0, 1000.0))
- assertEquals(result.source, Size(200.0, 2000.0))
- assertEquals(result.destination, Size(100.0, 1000.0))
+ result = applyBoxFit(BoxFit.fitHeight, Size(400.0f, 2000.0f), Size(100.0f, 1000.0f))
+ assertEquals(result.source, Size(200.0f, 2000.0f))
+ assertEquals(result.destination, Size(100.0f, 1000.0f))
_testZeroAndNegativeSizes(BoxFit.fill)
_testZeroAndNegativeSizes(BoxFit.contain)
@@ -57,35 +57,35 @@
private fun _testZeroAndNegativeSizes(fit: BoxFit) {
var result: FittedSizes
- result = applyBoxFit(fit, Size(-400.0, 2000.0), Size(100.0, 1000.0))
+ result = applyBoxFit(fit, Size(-400.0f, 2000.0f), Size(100.0f, 1000.0f))
assertEquals(Size.zero, result.source)
assertEquals(Size.zero, result.destination)
- result = applyBoxFit(fit, Size(400.0, -2000.0), Size(100.0, 1000.0))
+ result = applyBoxFit(fit, Size(400.0f, -2000.0f), Size(100.0f, 1000.0f))
assertEquals(Size.zero, result.source)
assertEquals(Size.zero, result.destination)
- result = applyBoxFit(fit, Size(400.0, 2000.0), Size(-100.0, 1000.0))
+ result = applyBoxFit(fit, Size(400.0f, 2000.0f), Size(-100.0f, 1000.0f))
assertEquals(Size.zero, result.source)
assertEquals(Size.zero, result.destination)
- result = applyBoxFit(fit, Size(400.0, 2000.0), Size(100.0, -1000.0))
+ result = applyBoxFit(fit, Size(400.0f, 2000.0f), Size(100.0f, -1000.0f))
assertEquals(Size.zero, result.source)
assertEquals(Size.zero, result.destination)
- result = applyBoxFit(fit, Size(0.0, 2000.0), Size(100.0, 1000.0))
+ result = applyBoxFit(fit, Size(0.0f, 2000.0f), Size(100.0f, 1000.0f))
assertEquals(Size.zero, result.source)
assertEquals(Size.zero, result.destination)
- result = applyBoxFit(fit, Size(400.0, 0.0), Size(100.0, 1000.0))
+ result = applyBoxFit(fit, Size(400.0f, 0.0f), Size(100.0f, 1000.0f))
assertEquals(Size.zero, result.source)
assertEquals(Size.zero, result.destination)
- result = applyBoxFit(fit, Size(400.0, 2000.0), Size(0.0, 1000.0))
+ result = applyBoxFit(fit, Size(400.0f, 2000.0f), Size(0.0f, 1000.0f))
assertEquals(Size.zero, result.source)
assertEquals(Size.zero, result.destination)
- result = applyBoxFit(fit, Size(400.0, 2000.0), Size(100.0, 0.0))
+ result = applyBoxFit(fit, Size(400.0f, 2000.0f), Size(100.0f, 0.0f))
assertEquals(Size.zero, result.source)
assertEquals(Size.zero, result.destination)
}
diff --git a/ui/port/src/test/java/androidx/ui/painting/PaintImageTest.kt b/ui/port/src/test/java/androidx/ui/painting/PaintImageTest.kt
index e8abc3d5..f87d04b 100644
--- a/ui/port/src/test/java/androidx/ui/painting/PaintImageTest.kt
+++ b/ui/port/src/test/java/androidx/ui/painting/PaintImageTest.kt
@@ -38,19 +38,19 @@
val canvas = mock<Canvas>()
paintImage(
canvas = canvas,
- rect = Rect.fromLTWH(50.0, 75.0, 200.0, 100.0),
+ rect = Rect.fromLTWH(50.0f, 75.0f, 200.0f, 100.0f),
image = image,
fit = BoxFit.cover,
- alignment = Alignment(-1.0, 0.0)
+ alignment = Alignment(-1.0f, 0.0f)
)
val srcCaptor = argumentCaptor<Rect>()
val dstCaptor = argumentCaptor<Rect>()
verify(canvas).drawImageRect(eq(image), srcCaptor.capture(), dstCaptor.capture(), any())
- assertEquals(Rect.fromLTWH(0.0, 75.0, 300.0, 150.0),
+ assertEquals(Rect.fromLTWH(0.0f, 75.0f, 300.0f, 150.0f),
srcCaptor.firstValue)
- assertEquals(Rect.fromLTWH(50.0, 75.0, 200.0, 100.0),
+ assertEquals(Rect.fromLTWH(50.0f, 75.0f, 200.0f, 100.0f),
dstCaptor.firstValue)
}
}
diff --git a/ui/port/src/test/java/androidx/ui/painting/TextPainterTest.kt b/ui/port/src/test/java/androidx/ui/painting/TextPainterTest.kt
index 1f72877..5773431 100644
--- a/ui/port/src/test/java/androidx/ui/painting/TextPainterTest.kt
+++ b/ui/port/src/test/java/androidx/ui/painting/TextPainterTest.kt
@@ -35,7 +35,7 @@
assertThat(textPainter.text).isNull()
assertThat(textPainter.textAlign).isEqualTo(TextAlign.START)
assertThat(textPainter.textDirection).isNull()
- assertThat(textPainter.textScaleFactor).isEqualTo(1.0)
+ assertThat(textPainter.textScaleFactor).isEqualTo(1.0f)
assertThat(textPainter.maxLines).isNull()
assertThat(textPainter.ellipsis).isNull()
assertThat(textPainter.locale).isNull()
@@ -66,7 +66,7 @@
@Test
fun `constructor with customized textScaleFactor`() {
- val scaleFactor = 2.0
+ val scaleFactor = 2.0f
val textPainter = TextPainter(textScaleFactor = scaleFactor)
@@ -138,7 +138,7 @@
@Test
fun `textScaleFactor setter`() {
val textPainter = TextPainter()
- val scaleFactor = 3.0
+ val scaleFactor = 3.0f
textPainter.textScaleFactor = scaleFactor
@@ -186,8 +186,8 @@
@Test
fun `createParagraphStyle with TextStyle in TextSpan`() {
- val fontSize = 15.0
- val scaleFactor = 3.0
+ val fontSize = 15.0f
+ val scaleFactor = 3.0f
val maxLines = 5
val ellipsis = "..."
val locale = Locale("en", "US")
@@ -215,7 +215,7 @@
@Test
fun `createParagraphStyle without TextStyle in TextSpan`() {
- val scaleFactor = 3.0
+ val scaleFactor = 3.0f
val maxLines = 5
val ellipsis = "..."
val locale = Locale("en", "US")
@@ -242,8 +242,8 @@
@Test
fun `createParagraphStyle with defaultTextDirection`() {
- val fontSize = 15.0
- val scaleFactor = 3.0
+ val fontSize = 15.0f
+ val scaleFactor = 3.0f
val maxLines = 5
val ellipsis = "..."
val locale = Locale("en", "US")
@@ -270,17 +270,17 @@
@Test
fun `applyFloatingPointHack with value is integer toDouble`() {
- assertThat(applyFloatingPointHack(2.toDouble())).isEqualTo(2.0)
+ assertThat(applyFloatingPointHack(2f)).isEqualTo(2.0f)
}
@Test
fun `applyFloatingPointHack with value smaller than half`() {
- assertThat(applyFloatingPointHack(2.2)).isEqualTo(3.0)
+ assertThat(applyFloatingPointHack(2.2f)).isEqualTo(3.0f)
}
@Test
fun `applyFloatingPointHack with value larger than half`() {
- assertThat(applyFloatingPointHack(2.8)).isEqualTo(3.0)
+ assertThat(applyFloatingPointHack(2.8f)).isEqualTo(3.0f)
}
@Test(expected = AssertionError::class)
@@ -338,7 +338,7 @@
TextPainter(text = TextSpan(text = "Hello"), textDirection = TextDirection.LTR)
textPainter.needsLayout = false
- textPainter.layout(0.0, 0.0)
+ textPainter.layout(0.0f, 0.0f)
assertThat(textPainter.paragraph).isNull()
}
@@ -348,6 +348,6 @@
val textPainter = TextPainter()
val canvas = mock<Canvas>()
- textPainter.paint(canvas, Offset(0.0, 0.0))
+ textPainter.paint(canvas, Offset(0.0f, 0.0f))
}
}
diff --git a/ui/port/src/test/java/androidx/ui/painting/TextSpanTest.kt b/ui/port/src/test/java/androidx/ui/painting/TextSpanTest.kt
index ea705fd..c7773ad 100644
--- a/ui/port/src/test/java/androidx/ui/painting/TextSpanTest.kt
+++ b/ui/port/src/test/java/androidx/ui/painting/TextSpanTest.kt
@@ -46,7 +46,7 @@
@Test
fun `constructor with customized style`() {
- val textStyle = TextStyle(fontSize = 10.0, height = 123.0)
+ val textStyle = TextStyle(fontSize = 10.0f, height = 123.0f)
val textSpan = TextSpan(style = textStyle)
assertThat(textSpan.style).isEqualTo(textStyle)
@@ -94,7 +94,7 @@
@Test
fun `build with style`() {
- val textStyle = TextStyle(fontSize = 10.0, height = 123.0)
+ val textStyle = TextStyle(fontSize = 10.0f, height = 123.0f)
val textSpan = TextSpan(style = textStyle)
val mockBuilder = spy(ParagraphBuilder(ParagraphStyle()))
@@ -332,7 +332,7 @@
@Test
fun `compareTo with one null style should return LAYOUT`() {
val textSpan1 = TextSpan()
- val textSpan2 = TextSpan(style = TextStyle(height = 123.0))
+ val textSpan2 = TextSpan(style = TextStyle(height = 123.0f))
assertThat(textSpan1.compareTo(textSpan2)).isEqualTo(RenderComparison.LAYOUT)
}
@@ -359,7 +359,7 @@
@Test
fun `compareTo with different TextStyle with different fontSize should return LAYOUT`() {
val textStyle1 = TextStyle()
- val textStyle2 = TextStyle(fontSize = 10.0)
+ val textStyle2 = TextStyle(fontSize = 10.0f)
val textSpan1 = TextSpan(style = textStyle1)
val textSpan2 = TextSpan(style = textStyle2)
@@ -389,7 +389,7 @@
@Test
fun `compareTo with different children with different fontSize should return LAYOUT`() {
val textStyle1 = TextStyle()
- val textStyle2 = TextStyle(fontSize = 10.0)
+ val textStyle2 = TextStyle(fontSize = 10.0f)
val childTextSpan1 = TextSpan(style = textStyle1)
val childTextSpan2 = TextSpan(style = textStyle2)
val textSpan1 = TextSpan(children = listOf(childTextSpan1))
diff --git a/ui/port/src/test/java/androidx/ui/painting/TextStyleTest.kt b/ui/port/src/test/java/androidx/ui/painting/TextStyleTest.kt
index 6002ee0..6f5042e 100644
--- a/ui/port/src/test/java/androidx/ui/painting/TextStyleTest.kt
+++ b/ui/port/src/test/java/androidx/ui/painting/TextStyleTest.kt
@@ -75,7 +75,7 @@
@Test
fun `constructor with customized fontSize`() {
- val fontSize = 18.0
+ val fontSize = 18.0f
val textStyle = TextStyle(fontSize = fontSize)
@@ -102,7 +102,7 @@
@Test
fun `constructor with customized letterSpacing`() {
- val letterSpacing = 1.0
+ val letterSpacing = 1.0f
val textStyle = TextStyle(letterSpacing = letterSpacing)
@@ -111,7 +111,7 @@
@Test
fun `constructor with customized wordSpacing`() {
- val wordSpacing = 2.0
+ val wordSpacing = 2.0f
val textStyle = TextStyle(wordSpacing = wordSpacing)
@@ -129,7 +129,7 @@
@Test
fun `constructor with customized height`() {
- val height = 123.0
+ val height = 123.0f
val textStyle = TextStyle(height = height)
@@ -276,12 +276,12 @@
@Test
fun `apply with fontSizeFactor and fontSizeDelta`() {
- val textStyle = TextStyle(fontSize = 15.0)
+ val textStyle = TextStyle(fontSize = 15.0f)
- val newTextStyle = textStyle.apply(fontSizeFactor = 2.3, fontSizeDelta = -2.0)
+ val newTextStyle = textStyle.apply(fontSizeFactor = 2.3f, fontSizeDelta = -2.0f)
- // fontSize * fontSizeFactor + fontSizeDelta = 15.0 * 2.3 + (-2.0) = 32.5
- assertThat(newTextStyle.fontSize).isEqualTo(32.5)
+ // fontSize * fontSizeFactor + fontSizeDelta = 15.0f * 2.3f + (-2.0f) = 32.5f
+ assertThat(newTextStyle.fontSize).isWithin(0.00001f).of(32.5f)
}
@Test
@@ -307,32 +307,32 @@
@Test
fun `apply with letterSpacingFactor and letterSpacingDelta`() {
- val textStyle = TextStyle(letterSpacing = 2.2)
+ val textStyle = TextStyle(letterSpacing = 2.2f)
- val newTextStyle = textStyle.apply(letterSpacingFactor = 2.8, letterSpacingDelta = 1.3)
+ val newTextStyle = textStyle.apply(letterSpacingFactor = 2.8f, letterSpacingDelta = 1.3f)
- // letterSpacing * letterSpacingFactor + letterSpacingDelta = 2.2 * 2.8 + 1.3 = 7.46
- assertThat(newTextStyle.letterSpacing).isEqualTo(7.46)
+ // letterSpacing * letterSpacingFactor + letterSpacingDelta = 2.2f * 2.8f + 1.3f = 7.46f
+ assertThat(newTextStyle.letterSpacing).isEqualTo(7.46f)
}
@Test
fun `apply with wordSpacingFactor and wordSpacingDelta`() {
- val textStyle = TextStyle(wordSpacing = 3.1)
+ val textStyle = TextStyle(wordSpacing = 3.1f)
- val newTextStyle = textStyle.apply(wordSpacingFactor = 1.3, wordSpacingDelta = -0.22)
+ val newTextStyle = textStyle.apply(wordSpacingFactor = 1.3f, wordSpacingDelta = -0.22f)
// wordSpacing * wordSpacingFactor + wordSpacingDelta = 3.1 * 1.3 + (-0.22) = 3.81
- assertThat(newTextStyle.wordSpacing).isEqualTo(3.81)
+ assertThat(newTextStyle.wordSpacing).isWithin(0.00001f).of(3.81f)
}
@Test
fun `apply with heightFactor and heightDelta`() {
- val textStyle = TextStyle(height = 124.0)
+ val textStyle = TextStyle(height = 124.0f)
- val newTextStyle = textStyle.apply(heightFactor = 1.3, heightDelta = 3.7)
+ val newTextStyle = textStyle.apply(heightFactor = 1.3f, heightDelta = 3.7f)
// height * heightFactor + heightDelta = 124.0 * 1.3 + 3.7 = 164.9
- assertThat(newTextStyle.height).isEqualTo(164.9)
+ assertThat(newTextStyle.height).isWithin(0.00001f).of(164.9f)
}
@Test
@@ -377,7 +377,7 @@
@Test
fun `merge with other's color is set should use other's color`() {
val color = Color(0xFF00FF00.toInt())
- val otherColor = Color(0x00FFFF00.toInt())
+ val otherColor = Color(0x00FFFF00)
val textStyle = TextStyle(color = color)
val otherTextStyle = TextStyle(color = otherColor)
@@ -411,7 +411,7 @@
@Test
fun `merge with other's fontSize is null should use this' fontSize`() {
- val fontSize = 3.5
+ val fontSize = 3.5f
val textStyle = TextStyle(fontSize = fontSize)
val otherTextStyle = TextStyle()
@@ -422,8 +422,8 @@
@Test
fun `merge with other's fontSize is set should use other's fontSize`() {
- val fontSize = 3.5
- val otherFontSize = 8.7
+ val fontSize = 3.5f
+ val otherFontSize = 8.7f
val textStyle = TextStyle(fontSize = fontSize)
val otherTextStyle = TextStyle(fontSize = otherFontSize)
@@ -504,7 +504,7 @@
@Test
fun `merge with other's letterSpacing is null should use this' letterSpacing`() {
- val letterSpacing = 1.2
+ val letterSpacing = 1.2f
val textStyle = TextStyle(letterSpacing = letterSpacing)
val otherTextStyle = TextStyle()
@@ -515,8 +515,8 @@
@Test
fun `merge with other's letterSpacing is set should use other's letterSpacing`() {
- val letterSpacing = 1.2
- val otherLetterSpacing = 1.5
+ val letterSpacing = 1.2f
+ val otherLetterSpacing = 1.5f
val textStyle = TextStyle(letterSpacing = letterSpacing)
val otherTextStyle = TextStyle(letterSpacing = otherLetterSpacing)
@@ -527,7 +527,7 @@
@Test
fun `merge with other's wordSpacing is null should use this' wordSpacing`() {
- val wordSpacing = 1.2
+ val wordSpacing = 1.2f
val textStyle = TextStyle(wordSpacing = wordSpacing)
val otherTextStyle = TextStyle()
@@ -538,8 +538,8 @@
@Test
fun `merge with other's wordSpacing is set should use other's wordSpacing`() {
- val wordSpacing = 1.2
- val otherWordSpacing = 1.5
+ val wordSpacing = 1.2f
+ val otherWordSpacing = 1.5f
val textStyle = TextStyle(wordSpacing = wordSpacing)
val otherTextStyle = TextStyle(wordSpacing = otherWordSpacing)
@@ -573,7 +573,7 @@
@Test
fun `merge with other's height is null should use this' height`() {
- val height = 123.0
+ val height = 123.0f
val textStyle = TextStyle(height = height)
val otherTextStyle = TextStyle()
@@ -584,8 +584,8 @@
@Test
fun `merge with other's height is set should use other's height`() {
- val height = 123.0
- val otherHeight = 200.0
+ val height = 123.0f
+ val otherHeight = 200.0f
val textStyle = TextStyle(height = height)
val otherTextStyle = TextStyle(height = otherHeight)
@@ -654,7 +654,7 @@
@Test
fun `merge with other's decorationColor is set should use other's decorationColor`() {
val color = Color(0xFF00FF00.toInt())
- val otherColor = Color(0x00FFFF00.toInt())
+ val otherColor = Color(0x00FFFF00)
val textStyle = TextStyle(decorationColor = color)
val otherTextStyle = TextStyle(decorationColor = otherColor)
@@ -751,16 +751,16 @@
@Test
fun `merge with chained debugLabel`() {
- val bar = TextStyle(debugLabel = "bar", fontSize = 2.0)
- val baz = TextStyle(debugLabel = "baz", fontSize = 3.0)
- val foo = TextStyle(debugLabel = "foo", fontSize = 1.0)
+ val bar = TextStyle(debugLabel = "bar", fontSize = 2.0f)
+ val baz = TextStyle(debugLabel = "baz", fontSize = 3.0f)
+ val foo = TextStyle(debugLabel = "foo", fontSize = 1.0f)
assertThat(foo.merge(bar).merge(baz).debugLabel).isEqualTo("((foo).merge(bar)).merge(baz)")
}
@Test
fun `lerp with both Null Textstyles`() {
- val newTextStyle = TextStyle.lerp(t = 1.0)
+ val newTextStyle = TextStyle.lerp(t = 1.0f)
assertThat(newTextStyle).isEqualTo(null)
}
@@ -768,7 +768,7 @@
@Test
fun `lerp color with a is Null and t is smaller than half`() {
val color = Color(0xFF00FF00.toInt())
- val t = 0.3
+ val t = 0.3f
val textStyle = TextStyle(color = color)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -779,7 +779,7 @@
@Test
fun `lerp color with a is Null and t is larger than half`() {
val color = Color(0xFF00FF00.toInt())
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(color = color)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -790,7 +790,7 @@
@Test
fun `lerp color with b is Null and t is smaller than half`() {
val color = Color(0xFF00FF00.toInt())
- val t = 0.3
+ val t = 0.3f
val textStyle = TextStyle(color = color)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -801,7 +801,7 @@
@Test
fun `lerp color with b is Null and t is larger than half`() {
val color = Color(0xFF00FF00.toInt())
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(color = color)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -812,21 +812,21 @@
@Test
fun `lerp color with a and b are not Null`() {
val color1 = Color(0xFF00FF00.toInt())
- val color2 = Color(0x00FFFF00.toInt())
- val t = 0.3
+ val color2 = Color(0x00FFFF00)
+ val t = 0.3f
val textStyle1 = TextStyle(
color = color1,
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f
)
val textStyle2 = TextStyle(
color = color2,
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
@@ -837,7 +837,7 @@
@Test
fun `lerp fontFamily with a is Null and t is smaller than half`() {
val fontFamily = FontFamily(genericFamily = "sans-serif")
- val t = 0.3
+ val t = 0.3f
val textStyle = TextStyle(fontFamily = fontFamily)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -848,7 +848,7 @@
@Test
fun `lerp fontFamily with a is Null and t is larger than half`() {
val fontFamily = FontFamily(genericFamily = "sans-serif")
- val t = 0.7
+ val t = 0.7f
val textStyle = TextStyle(fontFamily = fontFamily)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -859,7 +859,7 @@
@Test
fun `lerp fontFamily with b is Null and t is smaller than half`() {
val fontFamily = FontFamily(genericFamily = "sans-serif")
- val t = 0.3
+ val t = 0.3f
val textStyle = TextStyle(fontFamily = fontFamily)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -870,7 +870,7 @@
@Test
fun `lerp fontFamily with b is Null and t is larger than half`() {
val fontFamily = FontFamily(genericFamily = "sans-serif")
- val t = 0.7
+ val t = 0.7f
val textStyle = TextStyle(fontFamily = fontFamily)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -882,20 +882,20 @@
fun `lerp fontFamily with a and b are not Null and t is smaller than half`() {
val fontFamily1 = FontFamily(genericFamily = "sans-serif")
val fontFamily2 = FontFamily(genericFamily = "serif")
- val t = 0.3
+ val t = 0.3f
val textStyle1 = TextStyle(
fontFamily = fontFamily1,
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f
)
val textStyle2 = TextStyle(
fontFamily = fontFamily2,
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
@@ -907,20 +907,20 @@
fun `lerp fontFamily with a and b are not Null and t is larger than half`() {
val fontFamily1 = FontFamily(genericFamily = "sans-serif")
val fontFamily2 = FontFamily(genericFamily = "serif")
- val t = 0.8
+ val t = 0.8f
val textStyle1 = TextStyle(
fontFamily = fontFamily1,
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f
)
val textStyle2 = TextStyle(
fontFamily = fontFamily2,
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
@@ -930,8 +930,8 @@
@Test
fun `lerp fontSize with a is Null and t is smaller than half`() {
- val fontSize = 8.0
- val t = 0.3
+ val fontSize = 8.0f
+ val t = 0.3f
val textStyle = TextStyle(fontSize = fontSize)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -941,8 +941,8 @@
@Test
fun `lerp fontSize with a is Null and t is larger than half`() {
- val fontSize = 8.0
- val t = 0.8
+ val fontSize = 8.0f
+ val t = 0.8f
val textStyle = TextStyle(fontSize = fontSize)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -952,8 +952,8 @@
@Test
fun `lerp fontSize with b is Null and t is smaller than half`() {
- val fontSize = 8.0
- val t = 0.3
+ val fontSize = 8.0f
+ val t = 0.3f
val textStyle = TextStyle(fontSize = fontSize)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -963,8 +963,8 @@
@Test
fun `lerp fontSize with b is Null and t is larger than half`() {
- val fontSize = 8.0
- val t = 0.8
+ val fontSize = 8.0f
+ val t = 0.8f
val textStyle = TextStyle(fontSize = fontSize)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -974,32 +974,32 @@
@Test
fun `lerp fontSize with a and b are not Null`() {
- val fontSize1 = 8.0
- val fontSize2 = 16.0
- val t = 0.8
+ val fontSize1 = 8.0f
+ val fontSize2 = 16.0f
+ val t = 0.8f
val textStyle1 = TextStyle(
fontSize = fontSize1,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f
)
val textStyle2 = TextStyle(
fontSize = fontSize2,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
- // a + (b - a) * t = 8.0 + (16.0 - 8.0) * 0.8 = 14.4
- assertThat(newTextStyle?.fontSize).isEqualTo(14.4)
+ // a + (b - a) * t = 8.0f + (16.0f - 8.0f) * 0.8f = 14.4f
+ assertThat(newTextStyle?.fontSize).isEqualTo(14.4f)
}
@Test
fun `lerp fontWeight with a is Null and t is smaller than half`() {
val fontWeight = FontWeight.w700
- val t = 0.3
+ val t = 0.3f
val textStyle = TextStyle(fontWeight = fontWeight)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1010,7 +1010,7 @@
@Test
fun `lerp fontWeight with a is Null and t is larger than half`() {
val fontWeight = FontWeight.w700
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(fontWeight = fontWeight)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1021,7 +1021,7 @@
@Test
fun `lerp fontWeight with b is Null and t is smaller than half`() {
val fontWeight = FontWeight.w700
- val t = 0.3
+ val t = 0.3f
val textStyle = TextStyle(fontWeight = fontWeight)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1032,7 +1032,7 @@
@Test
fun `lerp fontWeight with b is Null and t is larger than half`() {
val fontWeight = FontWeight.w700
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(fontWeight = fontWeight)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1044,20 +1044,20 @@
fun `lerp fontWeight with a and b are not Null`() {
val fontWeight1 = FontWeight.w200
val fontWeight2 = FontWeight.w500
- val t = 0.8
+ val t = 0.8f
val textStyle1 = TextStyle(
fontWeight = fontWeight1,
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f
)
val textStyle2 = TextStyle(
fontWeight = fontWeight2,
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
@@ -1068,7 +1068,7 @@
@Test
fun `lerp fontStyle with a is Null and t is smaller than half`() {
val fontStyle = FontStyle.italic
- val t = 0.3
+ val t = 0.3f
val textStyle = TextStyle(fontStyle = fontStyle)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1079,7 +1079,7 @@
@Test
fun `lerp fontStyle with a is Null and t is larger than half`() {
val fontStyle = FontStyle.italic
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(fontStyle = fontStyle)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1090,7 +1090,7 @@
@Test
fun `lerp fontStyle with b is Null and t is smaller than half`() {
val fontStyle = FontStyle.italic
- val t = 0.3
+ val t = 0.3f
val textStyle = TextStyle(fontStyle = fontStyle)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1101,7 +1101,7 @@
@Test
fun `lerp fontStyle with b is Null and t is larger than half`() {
val fontStyle = FontStyle.italic
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(fontStyle = fontStyle)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1113,21 +1113,21 @@
fun `lerp fontStyle with a and b are not Null and t is smaller than half`() {
val fontStyle1 = FontStyle.italic
val fontStyle2 = FontStyle.normal
- val t = 0.3
// attributes other than fontStyle are required for lerp not to throw an exception
+ val t = 0.3f
val textStyle1 = TextStyle(
fontStyle = fontStyle1,
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f
)
val textStyle2 = TextStyle(
fontStyle = fontStyle2,
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
@@ -1139,21 +1139,21 @@
fun `lerp fontStyle with a and b are not Null and t is larger than half`() {
val fontStyle1 = FontStyle.italic
val fontStyle2 = FontStyle.normal
- val t = 0.8
// attributes other than fontStyle are required for lerp not to throw an exception
+ val t = 0.8f
val textStyle1 = TextStyle(
fontStyle = fontStyle1,
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f
)
val textStyle2 = TextStyle(
fontStyle = fontStyle2,
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
@@ -1164,7 +1164,7 @@
@Test
fun `lerp fontSynthesis with a is Null and t is smaller than half`() {
val fontSynthesis = FontSynthesis.style
- val t = 0.3
+ val t = 0.3f
val textStyle = TextStyle(fontSynthesis = fontSynthesis)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1175,7 +1175,7 @@
@Test
fun `lerp fontSynthesis with a is Null and t is larger than half`() {
val fontSynthesis = FontSynthesis.style
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(fontSynthesis = fontSynthesis)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1186,7 +1186,7 @@
@Test
fun `lerp fontSynthesis with b is Null and t is smaller than half`() {
val fontSynthesis = FontSynthesis.style
- val t = 0.3
+ val t = 0.3f
val textStyle = TextStyle(fontSynthesis = fontSynthesis)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1197,7 +1197,7 @@
@Test
fun `lerp fontSynthesis with b is Null and t is larger than half`() {
val fontSynthesis = FontSynthesis.style
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(fontSynthesis = fontSynthesis)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1210,21 +1210,21 @@
val fontSynthesis1 = FontSynthesis.style
val fontSynthesis2 = FontSynthesis.weight
- val t = 0.3
+ val t = 0.3f
// attributes other than fontSynthesis are required for lerp not to throw an exception
val textStyle1 = TextStyle(
fontSynthesis = fontSynthesis1,
- fontSize = 1.0,
- wordSpacing = 1.0,
- letterSpacing = 1.0,
- height = 1.0
+ fontSize = 1.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 1.0f,
+ height = 1.0f
)
val textStyle2 = TextStyle(
fontSynthesis = fontSynthesis2,
- fontSize = 1.0,
- wordSpacing = 1.0,
- letterSpacing = 1.0,
- height = 1.0
+ fontSize = 1.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 1.0f,
+ height = 1.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
@@ -1237,21 +1237,21 @@
val fontSynthesis1 = FontSynthesis.style
val fontSynthesis2 = FontSynthesis.weight
- val t = 0.8
+ val t = 0.8f
// attributes other than fontSynthesis are required for lerp not to throw an exception
val textStyle1 = TextStyle(
fontSynthesis = fontSynthesis1,
- fontSize = 1.0,
- wordSpacing = 1.0,
- letterSpacing = 1.0,
- height = 1.0
+ fontSize = 1.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 1.0f,
+ height = 1.0f
)
val textStyle2 = TextStyle(
fontSynthesis = fontSynthesis2,
- fontSize = 1.0,
- wordSpacing = 1.0,
- letterSpacing = 1.0,
- height = 1.0
+ fontSize = 1.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 1.0f,
+ height = 1.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
@@ -1261,8 +1261,8 @@
@Test
fun `lerp letterSpacing with a is Null and t is smaller than half`() {
- val letterSpacing = 2.0
- val t = 0.3
+ val letterSpacing = 2.0f
+ val t = 0.3f
val textStyle = TextStyle(letterSpacing = letterSpacing)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1272,8 +1272,8 @@
@Test
fun `lerp letterSpacing with a is Null and t is larger than half`() {
- val letterSpacing = 2.0
- val t = 0.8
+ val letterSpacing = 2.0f
+ val t = 0.8f
val textStyle = TextStyle(letterSpacing = letterSpacing)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1283,8 +1283,8 @@
@Test
fun `lerp letterSpacing with b is Null and t is smaller than half`() {
- val letterSpacing = 2.0
- val t = 0.3
+ val letterSpacing = 2.0f
+ val t = 0.3f
val textStyle = TextStyle(letterSpacing = letterSpacing)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1294,8 +1294,8 @@
@Test
fun `lerp letterSpacing with b is Null and t is larger than half`() {
- val letterSpacing = 2.0
- val t = 0.8
+ val letterSpacing = 2.0f
+ val t = 0.8f
val textStyle = TextStyle(letterSpacing = letterSpacing)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1305,32 +1305,32 @@
@Test
fun `lerp letterSpacing with a and b are not Null`() {
- val letterSpacing1 = 1.0
- val letterSpacing2 = 3.0
- val t = 0.8
+ val letterSpacing1 = 1.0f
+ val letterSpacing2 = 3.0f
+ val t = 0.8f
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
letterSpacing = letterSpacing1,
- height = 123.0
+ height = 123.0f
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
letterSpacing = letterSpacing2,
- height = 20.0
+ height = 20.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
- // a + (b - a) * t = 1.0 + (3.0 - 1.0) * 0.8 = 2.6
- assertThat(newTextStyle?.letterSpacing).isEqualTo(2.6)
+ // a + (b - a) * t = 1.0f + (3.0f - 1.0f) * 0.8f = 2.6f
+ assertThat(newTextStyle?.letterSpacing).isEqualTo(2.6f)
}
@Test
fun `lerp wordSpacing with a is Null and t is smaller than half`() {
- val wordSpacing = 2.0
- val t = 0.3
+ val wordSpacing = 2.0f
+ val t = 0.3f
val textStyle = TextStyle(wordSpacing = wordSpacing)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1340,8 +1340,8 @@
@Test
fun `lerp wordSpacing with a is Null and t is larger than half`() {
- val wordSpacing = 2.0
- val t = 0.7
+ val wordSpacing = 2.0f
+ val t = 0.7f
val textStyle = TextStyle(wordSpacing = wordSpacing)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1351,8 +1351,8 @@
@Test
fun `lerp wordSpacing with b is Null and t is smaller than half`() {
- val wordSpacing = 2.0
- val t = 0.3
+ val wordSpacing = 2.0f
+ val t = 0.3f
val textStyle = TextStyle(wordSpacing = wordSpacing)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1362,8 +1362,8 @@
@Test
fun `lerp wordSpacing with b is Null and t is larger than half`() {
- val wordSpacing = 2.0
- val t = 0.7
+ val wordSpacing = 2.0f
+ val t = 0.7f
val textStyle = TextStyle(wordSpacing = wordSpacing)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1373,32 +1373,32 @@
@Test
fun `lerp wordSpacing with a and b are not Null`() {
- val wordSpacing1 = 1.0
- val wordSpacing2 = 3.0
- val t = 0.8
+ val wordSpacing1 = 1.0f
+ val wordSpacing2 = 3.0f
+ val t = 0.8f
val textStyle1 = TextStyle(
- fontSize = 4.0,
+ fontSize = 4.0f,
wordSpacing = wordSpacing1,
- letterSpacing = 2.2,
- height = 123.0
+ letterSpacing = 2.2f,
+ height = 123.0f
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
+ fontSize = 7.0f,
wordSpacing = wordSpacing2,
- letterSpacing = 3.0,
- height = 20.0
+ letterSpacing = 3.0f,
+ height = 20.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
- // a + (b - a) * t = 1.0 + (3.0 - 1.0) * 0.8 = 2.6
- assertThat(newTextStyle?.wordSpacing).isEqualTo(2.6)
+ // a + (b - a) * t = 1.0f + (3.0f - 1.0f) * 0.8f = 2.6f
+ assertThat(newTextStyle?.wordSpacing).isEqualTo(2.6f)
}
@Test
fun `lerp textBaseline with a is Null and t is smaller than half`() {
val textBaseline = TextBaseline.ideographic
- val t = 0.3
+ val t = 0.3f
val textStyle = TextStyle(textBaseline = textBaseline)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1409,7 +1409,7 @@
@Test
fun `lerp textBaseline with a is Null and t is larger than half`() {
val textBaseline = TextBaseline.ideographic
- val t = 0.7
+ val t = 0.7f
val textStyle = TextStyle(textBaseline = textBaseline)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1420,7 +1420,7 @@
@Test
fun `lerp textBaseline with b is Null and t is smaller than half`() {
val textBaseline = TextBaseline.ideographic
- val t = 0.3
+ val t = 0.3f
val textStyle = TextStyle(textBaseline = textBaseline)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1431,7 +1431,7 @@
@Test
fun `lerp textBaseline with b is Null and t is larger than half`() {
val textBaseline = TextBaseline.ideographic
- val t = 0.7
+ val t = 0.7f
val textStyle = TextStyle(textBaseline = textBaseline)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1443,20 +1443,20 @@
fun `lerp textBaseline with a and b are not Null and t is smaller than half`() {
val textBaseline1 = TextBaseline.ideographic
val textBaseline2 = TextBaseline.alphabetic
- val t = 0.3
+ val t = 0.3f
val textStyle1 = TextStyle(
textBaseline = textBaseline1,
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f
)
val textStyle2 = TextStyle(
textBaseline = textBaseline2,
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
@@ -1468,20 +1468,20 @@
fun `lerp textBaseline with a and b are not Null and t is larger than half`() {
val textBaseline1 = TextBaseline.ideographic
val textBaseline2 = TextBaseline.alphabetic
- val t = 0.8
+ val t = 0.8f
val textStyle1 = TextStyle(
textBaseline = textBaseline1,
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f
)
val textStyle2 = TextStyle(
textBaseline = textBaseline2,
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
@@ -1491,8 +1491,8 @@
@Test
fun `lerp height with a is Null and t is smaller than half`() {
- val height = 88.0
- val t = 0.2
+ val height = 88.0f
+ val t = 0.2f
val textStyle = TextStyle(height = height)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1502,8 +1502,8 @@
@Test
fun `lerp height with a is Null and t is larger than half`() {
- val height = 88.0
- val t = 0.8
+ val height = 88.0f
+ val t = 0.8f
val textStyle = TextStyle(height = height)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1513,8 +1513,8 @@
@Test
fun `lerp height with b is Null and t is smaller than half`() {
- val height = 88.0
- val t = 0.2
+ val height = 88.0f
+ val t = 0.2f
val textStyle = TextStyle(height = height)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1524,8 +1524,8 @@
@Test
fun `lerp height with b is Null and t is larger than half`() {
- val height = 88.0
- val t = 0.8
+ val height = 88.0f
+ val t = 0.8f
val textStyle = TextStyle(height = height)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1535,32 +1535,32 @@
@Test
fun `lerp height with a and b are not Null`() {
- val height1 = 88.0
- val height2 = 128.0
- val t = 0.8
+ val height1 = 88.0f
+ val height2 = 128.0f
+ val t = 0.8f
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
height = height1
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
height = height2
)
val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
// a + (b - a) * t = 88.0 + (128.0 - 88.0) * 0.8 = 120.0
- assertThat(newTextStyle?.height).isEqualTo(120.0)
+ assertThat(newTextStyle?.height).isEqualTo(120.0f)
}
@Test
fun `lerp locale with a is Null and t is smaller than half`() {
val locale = Locale("en", "US")
- val t = 0.2
+ val t = 0.2f
val textStyle = TextStyle(locale = locale)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1571,7 +1571,7 @@
@Test
fun `lerp locale with a is Null and t is larger than half`() {
val locale = Locale("en", "US")
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(locale = locale)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1582,7 +1582,7 @@
@Test
fun `lerp locale with b is Null and t is smaller than half`() {
val locale = Locale("en", "US")
- val t = 0.2
+ val t = 0.2f
val textStyle = TextStyle(locale = locale)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1593,7 +1593,7 @@
@Test
fun `lerp locale with b is Null and t is larger than half`() {
val locale = Locale("en", "US")
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(locale = locale)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1605,19 +1605,19 @@
fun `lerp locale with a and b are not Null and t is smaller than half`() {
val locale1 = Locale("en", "US")
val locale2 = Locale("ja", "JP")
- val t = 0.3
+ val t = 0.3f
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f,
locale = locale1
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
locale = locale2
)
@@ -1630,19 +1630,19 @@
fun `lerp locale with a and b are not Null and t is larger than half`() {
val locale1 = Locale("en", "US")
val locale2 = Locale("ja", "JP")
- val t = 0.8
+ val t = 0.8f
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f,
locale = locale1
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
locale = locale2
)
@@ -1654,7 +1654,7 @@
@Test
fun `lerp background with a is Null and t is smaller than half`() {
val color = Color(0xFF00FF00.toInt())
- val t = 0.2
+ val t = 0.2f
val textStyle = TextStyle(background = color)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1665,7 +1665,7 @@
@Test
fun `lerp background with a is Null and t is larger than half`() {
val color = Color(0xFF00FF00.toInt())
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(background = color)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1676,7 +1676,7 @@
@Test
fun `lerp background with b is Null and t is smaller than half`() {
val color = Color(0xFF00FF00.toInt())
- val t = 0.2
+ val t = 0.2f
val textStyle = TextStyle(background = color)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1687,7 +1687,7 @@
@Test
fun `lerp background with b is Null and t is larger than half`() {
val paint = Paint()
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(background = Color(0xFF00FF00.toInt()))
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1699,19 +1699,19 @@
fun `lerp background with a and b are not Null and t is smaller than half`() {
val color1 = Color(0x0)
val color2 = Color(0xf)
- val t = 0.2
+ val t = 0.2f
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f,
background = color1
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
background = color2
)
@@ -1724,19 +1724,19 @@
fun `lerp background with a and b are not Null and t is larger than half`() {
val color1 = Color(0x0)
val color2 = Color(0xf)
- val t = 0.8
+ val t = 0.8f
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f,
background = color1
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
background = color2
)
@@ -1748,7 +1748,7 @@
@Test
fun `lerp decoration with a is Null and t is smaller than half`() {
val decoration = TextDecoration.lineThrough
- val t = 0.2
+ val t = 0.2f
val textStyle = TextStyle(decoration = decoration)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1759,7 +1759,7 @@
@Test
fun `lerp decoration with a is Null and t is larger than half`() {
val decoration = TextDecoration.lineThrough
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(decoration = decoration)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1770,7 +1770,7 @@
@Test
fun `lerp decoration with b is Null and t is smaller than half`() {
val decoration = TextDecoration.lineThrough
- val t = 0.2
+ val t = 0.2f
val textStyle = TextStyle(decoration = decoration)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1781,7 +1781,7 @@
@Test
fun `lerp decoration with b is Null and t is larger than half`() {
val decoration = TextDecoration.lineThrough
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(decoration = decoration)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1793,19 +1793,19 @@
fun `lerp decoration with a and b are not Null and t is smaller than half`() {
val decoration1 = TextDecoration.lineThrough
val decoration2 = TextDecoration.overline
- val t = 0.2
+ val t = 0.2f
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f,
decoration = decoration1
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
decoration = decoration2
)
@@ -1818,19 +1818,19 @@
fun `lerp decoration with a and b are not Null and t is larger than half`() {
val decoration1 = TextDecoration.lineThrough
val decoration2 = TextDecoration.overline
- val t = 0.8
+ val t = 0.8f
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f,
decoration = decoration1
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
decoration = decoration2
)
@@ -1842,7 +1842,7 @@
@Test
fun `lerp decorationColor with a is Null and t is smaller than half`() {
val color = Color(0xFF00FF00.toInt())
- val t = 0.2
+ val t = 0.2f
val textStyle = TextStyle(decorationColor = color)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1853,7 +1853,7 @@
@Test
fun `lerp decorationColor with a is Null and t is larger than half`() {
val color = Color(0xFF00FF00.toInt())
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(decorationColor = color)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1864,7 +1864,7 @@
@Test
fun `lerp decorationColor with b is Null and t is smaller than half`() {
val color = Color(0xFF00FF00.toInt())
- val t = 0.2
+ val t = 0.2f
val textStyle = TextStyle(decorationColor = color)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1875,7 +1875,7 @@
@Test
fun `lerp decorationColor with b is Null and t is larger than half`() {
val color = Color(0xFF00FF00.toInt())
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(decorationColor = color)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1886,20 +1886,20 @@
@Test
fun `lerp decorationColor with a and b are not Null`() {
val color1 = Color(0xFF00FF00.toInt())
- val color2 = Color(0x00FFFF00.toInt())
- val t = 0.8
+ val color2 = Color(0x00FFFF00)
+ val t = 0.8f
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f,
decorationColor = color1
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
decorationColor = color2
)
@@ -1911,7 +1911,7 @@
@Test
fun `lerp decorationStyle with a is Null and t is smaller than half`() {
val decorationStyle = TextDecorationStyle.dotted
- val t = 0.2
+ val t = 0.2f
val textStyle = TextStyle(decorationStyle = decorationStyle)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1922,7 +1922,7 @@
@Test
fun `lerp decorationStyle with a is Null and t is larger than half`() {
val decorationStyle = TextDecorationStyle.dotted
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(decorationStyle = decorationStyle)
val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
@@ -1933,7 +1933,7 @@
@Test
fun `lerp decorationStyle with b is Null and t is smaller than half`() {
val decorationStyle = TextDecorationStyle.dotted
- val t = 0.2
+ val t = 0.2f
val textStyle = TextStyle(decorationStyle = decorationStyle)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1944,7 +1944,7 @@
@Test
fun `lerp decorationStyle with b is Null and t is larger than half`() {
val decorationStyle = TextDecorationStyle.dotted
- val t = 0.8
+ val t = 0.8f
val textStyle = TextStyle(decorationStyle = decorationStyle)
val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
@@ -1956,19 +1956,19 @@
fun `lerp decorationStyle with a and b are not Null and t is smaller than half`() {
val decorationStyle1 = TextDecorationStyle.dashed
val decorationStyle2 = TextDecorationStyle.dotted
- val t = 0.2
+ val t = 0.2f
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f,
decorationStyle = decorationStyle1
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
decorationStyle = decorationStyle2
)
@@ -1981,19 +1981,19 @@
fun `lerp decorationStyle with a and b are not Null and t is larger than half`() {
val decorationStyle1 = TextDecorationStyle.dashed
val decorationStyle2 = TextDecorationStyle.dotted
- val t = 0.8
+ val t = 0.8f
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f,
decorationStyle = decorationStyle1
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
decorationStyle = decorationStyle2
)
@@ -2005,19 +2005,19 @@
@Test
fun `lerp returns debugLabel when both a and b's debugLabel are Null`() {
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f
)
- val newTextStyle = TextStyle.lerp(textStyle1, textStyle2, 0.2)
+ val newTextStyle = TextStyle.lerp(textStyle1, textStyle2, 0.2f)
assertThat(newTextStyle?.debugLabel).isEqualTo("lerp(unknown ⎯0.2→ unknown)")
}
@@ -2025,20 +2025,20 @@
@Test
fun `lerp returns debugLabel when a's debugLabel is Null`() {
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
debugLabel = "foo"
)
- val newTextStyle = TextStyle.lerp(textStyle1, textStyle2, 0.2)
+ val newTextStyle = TextStyle.lerp(textStyle1, textStyle2, 0.2f)
assertThat(newTextStyle?.debugLabel).isEqualTo("lerp(unknown ⎯0.2→ foo)")
}
@@ -2046,20 +2046,20 @@
@Test
fun `lerp returns debugLabel when b's debugLabel is Null`() {
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f,
debugLabel = "foo"
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f
)
- val newTextStyle = TextStyle.lerp(textStyle1, textStyle2, 0.2)
+ val newTextStyle = TextStyle.lerp(textStyle1, textStyle2, 0.2f)
assertThat(newTextStyle?.debugLabel).isEqualTo("lerp(foo ⎯0.2→ unknown)")
}
@@ -2067,21 +2067,21 @@
@Test
fun `lerp returns debugLabel when both debugLabels are not Null`() {
val textStyle1 = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f,
debugLabel = "foo"
)
val textStyle2 = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
debugLabel = "bar"
)
- val newTextStyle = TextStyle.lerp(textStyle1, textStyle2, 0.2)
+ val newTextStyle = TextStyle.lerp(textStyle1, textStyle2, 0.2f)
assertThat(newTextStyle?.debugLabel).isEqualTo("lerp(foo ⎯0.2→ bar)")
}
@@ -2089,36 +2089,36 @@
@Test
fun `lerp returns chained debugLabel`() {
val foo = TextStyle(
- fontSize = 4.0,
- wordSpacing = 1.0,
- letterSpacing = 2.0,
- height = 123.0,
+ fontSize = 4.0f,
+ wordSpacing = 1.0f,
+ letterSpacing = 2.0f,
+ height = 123.0f,
debugLabel = "foo"
)
val bar = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
debugLabel = "bar"
)
val baz = TextStyle(
- fontSize = 7.0,
- wordSpacing = 2.0,
- letterSpacing = 4.0,
- height = 20.0,
+ fontSize = 7.0f,
+ wordSpacing = 2.0f,
+ letterSpacing = 4.0f,
+ height = 20.0f,
debugLabel = "baz"
)
- val newTextStyle = TextStyle.lerp(TextStyle.lerp(foo, bar, 0.2), baz, 0.8)
+ val newTextStyle = TextStyle.lerp(TextStyle.lerp(foo, bar, 0.2f), baz, 0.8f)
assertThat(newTextStyle?.debugLabel).isEqualTo("lerp(lerp(foo ⎯0.2→ bar) ⎯0.8→ baz)")
}
@Test
fun `getTextStyle`() {
- val fontSize = 10.0
- val height = 123.0
+ val fontSize = 10.0f
+ val height = 123.0f
val color = Color(0xFF00FF00.toInt())
val fontSynthesis = FontSynthesis.style
val textStyle = TextStyle(
@@ -2150,8 +2150,8 @@
@Test
fun `getParagraphStyle with text align`() {
- val fontSize = 10.0
- val height = 123.0
+ val fontSize = 10.0f
+ val height = 123.0f
val color = Color(0xFF00FF00.toInt())
val fontSynthesis = FontSynthesis.style
val textStyle = TextStyle(
@@ -2183,7 +2183,7 @@
@Test
fun `getParagraphStyle with LTR text direction`() {
- val defaultFontSize = 14.0
+ val defaultFontSize = 14.0f
val paragraphStyleLTR = TextStyle().getParagraphStyle(textDirection = TextDirection.LTR)
@@ -2197,7 +2197,7 @@
@Test
fun `getParagraphStyle with RTL text direction`() {
- val defaultFontSize = 14.0
+ val defaultFontSize = 14.0f
val paragraphStyleRTL = TextStyle().getParagraphStyle(textDirection = TextDirection.RTL)
@@ -2218,7 +2218,7 @@
@Test
fun `debugLabel with constructor customized values`() {
- val foo = TextStyle(debugLabel = "foo", fontSize = 1.0)
+ val foo = TextStyle(debugLabel = "foo", fontSize = 1.0f)
assertThat(foo.debugLabel).isEqualTo("foo")
}
@@ -2240,8 +2240,8 @@
@Test
fun `compareTo textStyle with different layout returns LAYOUT`() {
- val fontSize = 10.0
- val height = 123.0
+ val fontSize = 10.0f
+ val height = 123.0f
val color = Color(0xFF00FF00.toInt())
val bgColor = Color(0xFFFFFF00.toInt())
@@ -2251,8 +2251,8 @@
fontSize = fontSize,
fontWeight = FontWeight.w800,
fontStyle = FontStyle.italic,
- letterSpacing = 1.0,
- wordSpacing = 2.0,
+ letterSpacing = 1.0f,
+ wordSpacing = 2.0f,
textBaseline = TextBaseline.alphabetic,
height = height,
locale = Locale("en", "US"),
@@ -2274,7 +2274,7 @@
)
).isEqualTo(RenderComparison.LAYOUT)
- assertThat(textStyle.compareTo(textStyle.copy(fontSize = 20.0)))
+ assertThat(textStyle.compareTo(textStyle.copy(fontSize = 20.0f)))
.isEqualTo(RenderComparison.LAYOUT)
assertThat(textStyle.compareTo(textStyle.copy(fontWeight = FontWeight.w100)))
@@ -2286,16 +2286,16 @@
assertThat(textStyle.compareTo(textStyle.copy(fontSynthesis = FontSynthesis.style)))
.isEqualTo(RenderComparison.LAYOUT)
- assertThat(textStyle.compareTo(textStyle.copy(letterSpacing = 2.0)))
+ assertThat(textStyle.compareTo(textStyle.copy(letterSpacing = 2.0f)))
.isEqualTo(RenderComparison.LAYOUT)
- assertThat(textStyle.compareTo(textStyle.copy(wordSpacing = 4.0)))
+ assertThat(textStyle.compareTo(textStyle.copy(wordSpacing = 4.0f)))
.isEqualTo(RenderComparison.LAYOUT)
assertThat(textStyle.compareTo(textStyle.copy(textBaseline = TextBaseline.ideographic)))
.isEqualTo(RenderComparison.LAYOUT)
- assertThat(textStyle.compareTo(textStyle.copy(height = 20.0)))
+ assertThat(textStyle.compareTo(textStyle.copy(height = 20.0f)))
.isEqualTo(RenderComparison.LAYOUT)
assertThat(textStyle.compareTo(textStyle.copy(locale = Locale("ja", "JP"))))
@@ -2304,10 +2304,10 @@
@Test
fun `compareTo textStyle with different paint returns paint`() {
- val fontSize = 10.0
- val height = 123.0
+ val fontSize = 10.0f
+ val height = 123.0f
val color1 = Color(0xFF00FF00.toInt())
- val color2 = Color(0x00FFFF00.toInt())
+ val color2 = Color(0x00FFFF00)
val textStyle = TextStyle(
inherit = false,
@@ -2315,8 +2315,8 @@
fontSize = fontSize,
fontWeight = FontWeight.w800,
fontStyle = FontStyle.italic,
- letterSpacing = 1.0,
- wordSpacing = 2.0,
+ letterSpacing = 1.0f,
+ wordSpacing = 2.0f,
textBaseline = TextBaseline.alphabetic,
height = height,
locale = Locale("en", "US"),
diff --git a/ui/port/src/test/java/androidx/ui/painting/matrixutils/MatrixUtilsTest.kt b/ui/port/src/test/java/androidx/ui/painting/matrixutils/MatrixUtilsTest.kt
index 0afb00a..69958bd 100644
--- a/ui/port/src/test/java/androidx/ui/painting/matrixutils/MatrixUtilsTest.kt
+++ b/ui/port/src/test/java/androidx/ui/painting/matrixutils/MatrixUtilsTest.kt
@@ -33,13 +33,13 @@
@Test
fun `MatrixUtils matrixEquals`() {
- val values = doubleArrayOf(0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5,
- 3.5, 3.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0.0)
+ val values = floatArrayOf(0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f,
+ 3.5f, 3.0f, 2.5f, 2.0f, 1.5f, 1.0f, 0.5f, 0.0f)
val mat1 = Matrix4.of(*values)
val mat2 = Matrix4.of(*values)
assertEquals(mat1, mat2)
- mat2[0][0] = 0.5
+ mat2[0][0] = 0.5f
assertNotEquals(mat1, mat2)
}
@@ -50,59 +50,59 @@
assertEquals(Offset.zero, test.getAsTranslation())
test = Matrix4.zero()
assertNull(test.getAsTranslation())
- test = Matrix4.rotationX(1.0)
+ test = Matrix4.rotationX(1.0f)
assertNull(test.getAsTranslation())
- test = Matrix4.rotationZ(1.0)
+ test = Matrix4.rotationZ(1.0f)
assertNull(test.getAsTranslation())
- test = Matrix4.translationValues(1.0, 2.0, 0.0)
- assertEquals(Offset(1.0, 2.0), test.getAsTranslation())
- test = Matrix4.translationValues(1.0, 2.0, 3.0)
+ test = Matrix4.translationValues(1.0f, 2.0f, 0.0f)
+ assertEquals(Offset(1.0f, 2.0f), test.getAsTranslation())
+ test = Matrix4.translationValues(1.0f, 2.0f, 3.0f)
assertNull(test.getAsTranslation())
test = Matrix4.identity()
assertEquals(Offset.zero, test.getAsTranslation())
- test.rotateZ(2.0)
+ test.rotateZ(2.0f)
assertNull(test.getAsTranslation())
test = Matrix4.identity()
assertEquals(Offset.zero, test.getAsTranslation())
- test.scale(2.0)
+ test.scale(2.0f)
assertNull(test.getAsTranslation())
test = Matrix4.identity()
assertEquals(Offset.zero, test.getAsTranslation())
- test.translate(2.0, -2.0)
- assertEquals(Offset(2.0, -2.0), test.getAsTranslation())
- test.translate(4.0, 8.0)
- assertEquals(Offset(6.0, 6.0), test.getAsTranslation())
+ test.translate(2.0f, -2.0f)
+ assertEquals(Offset(2.0f, -2.0f), test.getAsTranslation())
+ test.translate(4.0f, 8.0f)
+ assertEquals(Offset(6.0f, 6.0f), test.getAsTranslation())
}
@Test
fun `cylindricalProjectionTransform identity`() {
- val initialState = createCylindricalProjectionTransform(0.0, 0.0, 0.0)
+ val initialState = createCylindricalProjectionTransform(0.0f, 0.0f, 0.0f)
assertEquals(Matrix4.identity(), initialState)
}
@Test
fun `cylindricalProjectionTransform rotate with no radius`() {
- val simpleRotate = createCylindricalProjectionTransform(0.0, PI / 2.0, 0.0)
- assertEquals(Matrix4.rotationX(PI / 2.0), simpleRotate)
+ val simpleRotate = createCylindricalProjectionTransform(0.0f, PI / 2.0f, 0.0f)
+ assertEquals(Matrix4.rotationX(PI / 2.0f), simpleRotate)
}
@Test
fun `cylindricalProjectionTransform radius does not change scale`() {
- val noRotation = createCylindricalProjectionTransform(1000000.0, 0.0, 0.0)
+ val noRotation = createCylindricalProjectionTransform(1000000.0f, 0.0f, 0.0f)
assertEquals(Matrix4.identity(), noRotation)
}
@Test
fun `cylindricalProjectionTransform calculation spot check`() {
- val actual = createCylindricalProjectionTransform(100.0, PI / 3.0, 0.001).m4storage
+ val actual = createCylindricalProjectionTransform(100.0f, PI / 3.0f, 0.001f).m4storage
- val expected = listOf(1.0, 0.0, 0.0, 0.0,
- 0.0, 0.5, 0.8660254037844386, -0.0008660254037844386,
- 0.0, -0.8660254037844386, 0.5, -0.0005,
- 0.0, -86.60254037844386, -50.0, 1.05)
+ val expected = listOf(1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.5f, 0.8660254037844386f, -0.0008660254037844386f,
+ 0.0f, -0.8660254037844386f, 0.5f, -0.0005f,
+ 0.0f, -86.60254037844386f, -50.0f, 1.05f)
assertEquals(16, actual.size)
for (i in 0..15) {
diff --git a/ui/port/src/test/java/androidx/ui/rendering/BoxConstraintsTest.kt b/ui/port/src/test/java/androidx/ui/rendering/BoxConstraintsTest.kt
index d39b956..544107b 100644
--- a/ui/port/src/test/java/androidx/ui/rendering/BoxConstraintsTest.kt
+++ b/ui/port/src/test/java/androidx/ui/rendering/BoxConstraintsTest.kt
@@ -45,36 +45,36 @@
class BoxConstraintsTest {
companion object {
- private const val DELTA = 0.01
+ private const val DELTA = 0.01f
}
@Test
fun `BoxConstraints toString`() {
assertTrue(BoxConstraints.expand().toString().contains("biggest"))
assertTrue(BoxConstraints().toString().contains("unconstrained"))
- assertTrue(BoxConstraints.tightFor(width = 50.0).toString().contains("w=50"))
+ assertTrue(BoxConstraints.tightFor(width = 50.0f).toString().contains("w=50"))
}
@Test
fun `BoxConstraints copyWith`() {
val constraints = BoxConstraints(
- minWidth = 3.0,
- maxWidth = 7.0,
- minHeight = 11.0,
- maxHeight = 17.0
+ minWidth = 3.0f,
+ maxWidth = 7.0f,
+ minHeight = 11.0f,
+ maxHeight = 17.0f
)
var copy = constraints.copyWith()
assertEquals(constraints, copy)
copy = constraints.copyWith(
- minWidth = 13.0,
- maxWidth = 17.0,
- minHeight = 111.0,
- maxHeight = 117.0
+ minWidth = 13.0f,
+ maxWidth = 17.0f,
+ minHeight = 111.0f,
+ maxHeight = 117.0f
)
- assertEquals(13.0, copy.minWidth, DELTA)
- assertEquals(17.0, copy.maxWidth, DELTA)
- assertEquals(111.0, copy.minHeight, DELTA)
- assertEquals(117.0, copy.maxHeight, DELTA)
+ assertEquals(13.0f, copy.minWidth, DELTA)
+ assertEquals(17.0f, copy.maxWidth, DELTA)
+ assertEquals(111.0f, copy.minHeight, DELTA)
+ assertEquals(117.0f, copy.maxHeight, DELTA)
assertNotEquals(constraints, copy)
assertNotEquals(constraints.hashCode(), copy.hashCode())
}
@@ -82,169 +82,169 @@
@Test
fun `BoxConstraints operators`() {
val constraints = BoxConstraints(
- minWidth = 3.0,
- maxWidth = 7.0,
- minHeight = 11.0,
- maxHeight = 17.0
+ minWidth = 3.0f,
+ maxWidth = 7.0f,
+ minHeight = 11.0f,
+ maxHeight = 17.0f
)
- var copy = constraints * 2.0
- assertEquals(6.0, copy.minWidth, DELTA)
- assertEquals(14.0, copy.maxWidth, DELTA)
- assertEquals(22.0, copy.minHeight, DELTA)
- assertEquals(34.0, copy.maxHeight, DELTA)
- assertEquals(constraints, copy / 2.0)
- copy = constraints.truncDiv(2.0)
- assertEquals(1.0, copy.minWidth, DELTA)
- assertEquals(3.0, copy.maxWidth, DELTA)
- assertEquals(5.0, copy.minHeight, DELTA)
- assertEquals(8.0, copy.maxHeight, DELTA)
- copy = constraints % 3.0
- assertEquals(0.0, copy.minWidth, DELTA)
- assertEquals(1.0, copy.maxWidth, DELTA)
- assertEquals(2.0, copy.minHeight, DELTA)
- assertEquals(2.0, copy.maxHeight, DELTA)
+ var copy = constraints * 2.0f
+ assertEquals(6.0f, copy.minWidth, DELTA)
+ assertEquals(14.0f, copy.maxWidth, DELTA)
+ assertEquals(22.0f, copy.minHeight, DELTA)
+ assertEquals(34.0f, copy.maxHeight, DELTA)
+ assertEquals(constraints, copy / 2.0f)
+ copy = constraints.truncDiv(2.0f)
+ assertEquals(1.0f, copy.minWidth, DELTA)
+ assertEquals(3.0f, copy.maxWidth, DELTA)
+ assertEquals(5.0f, copy.minHeight, DELTA)
+ assertEquals(8.0f, copy.maxHeight, DELTA)
+ copy = constraints % 3.0f
+ assertEquals(0.0f, copy.minWidth, DELTA)
+ assertEquals(1.0f, copy.maxWidth, DELTA)
+ assertEquals(2.0f, copy.minHeight, DELTA)
+ assertEquals(2.0f, copy.maxHeight, DELTA)
}
@Test
fun `BoxConstraints lerp`() {
- assertNull(BoxConstraints.lerp(null, null, 0.5))
+ assertNull(BoxConstraints.lerp(null, null, 0.5f))
val constraints = BoxConstraints(
- minWidth = 3.0,
- maxWidth = 7.0,
- minHeight = 11.0,
- maxHeight = 17.0
+ minWidth = 3.0f,
+ maxWidth = 7.0f,
+ minHeight = 11.0f,
+ maxHeight = 17.0f
)
- var copy = BoxConstraints.lerp(null, constraints, 0.5)!!
- assertEquals(1.5, copy.minWidth, DELTA)
- assertEquals(3.5, copy.maxWidth, DELTA)
- assertEquals(5.5, copy.minHeight, DELTA)
- assertEquals(8.5, copy.maxHeight, DELTA)
- copy = BoxConstraints.lerp(constraints, null, 0.5)!!
- assertEquals(1.5, copy.minWidth, DELTA)
- assertEquals(3.5, copy.maxWidth, DELTA)
- assertEquals(5.5, copy.minHeight, DELTA)
- assertEquals(8.5, copy.maxHeight, DELTA)
+ var copy = BoxConstraints.lerp(null, constraints, 0.5f)!!
+ assertEquals(1.5f, copy.minWidth, DELTA)
+ assertEquals(3.5f, copy.maxWidth, DELTA)
+ assertEquals(5.5f, copy.minHeight, DELTA)
+ assertEquals(8.5f, copy.maxHeight, DELTA)
+ copy = BoxConstraints.lerp(constraints, null, 0.5f)!!
+ assertEquals(1.5f, copy.minWidth, DELTA)
+ assertEquals(3.5f, copy.maxWidth, DELTA)
+ assertEquals(5.5f, copy.minHeight, DELTA)
+ assertEquals(8.5f, copy.maxHeight, DELTA)
copy = BoxConstraints.lerp(BoxConstraints(
- minWidth = 13.0,
- maxWidth = 17.0,
- minHeight = 111.0,
- maxHeight = 117.0
- ), constraints, 0.2)!!
- assertEquals(11.0, copy.minWidth, DELTA)
- assertEquals(15.0, copy.maxWidth, DELTA)
- assertEquals(91.0, copy.minHeight, DELTA)
- assertEquals(97.0, copy.maxHeight, DELTA)
+ minWidth = 13.0f,
+ maxWidth = 17.0f,
+ minHeight = 111.0f,
+ maxHeight = 117.0f
+ ), constraints, 0.2f)!!
+ assertEquals(11.0f, copy.minWidth, DELTA)
+ assertEquals(15.0f, copy.maxWidth, DELTA)
+ assertEquals(91.0f, copy.minHeight, DELTA)
+ assertEquals(97.0f, copy.maxHeight, DELTA)
}
@Test
fun `BoxConstraints lerp with unbounded width`() {
val constraints1 = BoxConstraints(
- minWidth = Double.POSITIVE_INFINITY,
- maxWidth = Double.POSITIVE_INFINITY,
- minHeight = 10.0,
- maxHeight = 20.0
+ minWidth = Float.POSITIVE_INFINITY,
+ maxWidth = Float.POSITIVE_INFINITY,
+ minHeight = 10.0f,
+ maxHeight = 20.0f
)
val constraints2 = BoxConstraints(
- minWidth = Double.POSITIVE_INFINITY,
- maxWidth = Double.POSITIVE_INFINITY,
- minHeight = 20.0,
- maxHeight = 30.0
+ minWidth = Float.POSITIVE_INFINITY,
+ maxWidth = Float.POSITIVE_INFINITY,
+ minHeight = 20.0f,
+ maxHeight = 30.0f
)
val constraints3 = BoxConstraints(
- minWidth = Double.POSITIVE_INFINITY,
- maxWidth = Double.POSITIVE_INFINITY,
- minHeight = 15.0,
- maxHeight = 25.0
+ minWidth = Float.POSITIVE_INFINITY,
+ maxWidth = Float.POSITIVE_INFINITY,
+ minHeight = 15.0f,
+ maxHeight = 25.0f
)
- assertEquals(BoxConstraints.lerp(constraints1, constraints2, 0.5), constraints3)
+ assertEquals(BoxConstraints.lerp(constraints1, constraints2, 0.5f), constraints3)
}
@Test
fun `BoxConstraints lerp with unbounded height`() {
val constraints1 = BoxConstraints(
- minWidth = 10.0,
- maxWidth = 20.0,
- minHeight = Double.POSITIVE_INFINITY,
- maxHeight = Double.POSITIVE_INFINITY
+ minWidth = 10.0f,
+ maxWidth = 20.0f,
+ minHeight = Float.POSITIVE_INFINITY,
+ maxHeight = Float.POSITIVE_INFINITY
)
val constraints2 = BoxConstraints(
- minWidth = 20.0,
- maxWidth = 30.0,
- minHeight = Double.POSITIVE_INFINITY,
- maxHeight = Double.POSITIVE_INFINITY
+ minWidth = 20.0f,
+ maxWidth = 30.0f,
+ minHeight = Float.POSITIVE_INFINITY,
+ maxHeight = Float.POSITIVE_INFINITY
)
val constraints3 = BoxConstraints(
- minWidth = 15.0,
- maxWidth = 25.0,
- minHeight = Double.POSITIVE_INFINITY,
- maxHeight = Double.POSITIVE_INFINITY
+ minWidth = 15.0f,
+ maxWidth = 25.0f,
+ minHeight = Float.POSITIVE_INFINITY,
+ maxHeight = Float.POSITIVE_INFINITY
)
- assertEquals(BoxConstraints.lerp(constraints1, constraints2, 0.5), constraints3)
+ assertEquals(BoxConstraints.lerp(constraints1, constraints2, 0.5f), constraints3)
}
@Test(expected = AssertionError::class)
fun `BoxConstraints lerp from bounded to unbounded 1`() {
val constraints1 = BoxConstraints(
- minWidth = Double.POSITIVE_INFINITY,
- maxWidth = Double.POSITIVE_INFINITY,
- minHeight = Double.POSITIVE_INFINITY,
- maxHeight = Double.POSITIVE_INFINITY
+ minWidth = Float.POSITIVE_INFINITY,
+ maxWidth = Float.POSITIVE_INFINITY,
+ minHeight = Float.POSITIVE_INFINITY,
+ maxHeight = Float.POSITIVE_INFINITY
)
val constraints2 = BoxConstraints(
- minWidth = 20.0,
- maxWidth = 30.0,
- minHeight = Double.POSITIVE_INFINITY,
- maxHeight = Double.POSITIVE_INFINITY
+ minWidth = 20.0f,
+ maxWidth = 30.0f,
+ minHeight = Float.POSITIVE_INFINITY,
+ maxHeight = Float.POSITIVE_INFINITY
)
- BoxConstraints.lerp(constraints1, constraints2, 0.5)
+ BoxConstraints.lerp(constraints1, constraints2, 0.5f)
}
@Test(expected = AssertionError::class)
fun `BoxConstraints lerp from bounded to unbounded 2`() {
val constraints1 = BoxConstraints(
- minWidth = Double.POSITIVE_INFINITY,
- maxWidth = Double.POSITIVE_INFINITY,
- minHeight = Double.POSITIVE_INFINITY,
- maxHeight = Double.POSITIVE_INFINITY
+ minWidth = Float.POSITIVE_INFINITY,
+ maxWidth = Float.POSITIVE_INFINITY,
+ minHeight = Float.POSITIVE_INFINITY,
+ maxHeight = Float.POSITIVE_INFINITY
)
val constraints3 = BoxConstraints(
- minWidth = Double.POSITIVE_INFINITY,
- maxWidth = Double.POSITIVE_INFINITY,
- minHeight = 20.0,
- maxHeight = 30.0
+ minWidth = Float.POSITIVE_INFINITY,
+ maxWidth = Float.POSITIVE_INFINITY,
+ minHeight = 20.0f,
+ maxHeight = 30.0f
)
- BoxConstraints.lerp(constraints1, constraints3, 0.5)
+ BoxConstraints.lerp(constraints1, constraints3, 0.5f)
}
@Test(expected = AssertionError::class)
fun `BoxConstraints lerp from bounded to unbounded 3`() {
val constraints2 = BoxConstraints(
- minWidth = 20.0,
- maxWidth = 30.0,
- minHeight = Double.POSITIVE_INFINITY,
- maxHeight = Double.POSITIVE_INFINITY
+ minWidth = 20.0f,
+ maxWidth = 30.0f,
+ minHeight = Float.POSITIVE_INFINITY,
+ maxHeight = Float.POSITIVE_INFINITY
)
val constraints3 = BoxConstraints(
- minWidth = Double.POSITIVE_INFINITY,
- maxWidth = Double.POSITIVE_INFINITY,
- minHeight = 20.0,
- maxHeight = 30.0
+ minWidth = Float.POSITIVE_INFINITY,
+ maxWidth = Float.POSITIVE_INFINITY,
+ minHeight = 20.0f,
+ maxHeight = 30.0f
)
- BoxConstraints.lerp(constraints2, constraints3, 0.5)
+ BoxConstraints.lerp(constraints2, constraints3, 0.5f)
}
@Test
fun `BoxConstraints normalize`() {
val constraints = BoxConstraints(
- minWidth = 3.0,
- maxWidth = 2.0,
- minHeight = 11.0,
- maxHeight = 18.0
+ minWidth = 3.0f,
+ maxWidth = 2.0f,
+ minHeight = 11.0f,
+ maxHeight = 18.0f
)
val copy = constraints.normalize()
- assertEquals(3.0, copy.minWidth, DELTA)
- assertEquals(3.0, copy.maxWidth, DELTA)
- assertEquals(11.0, copy.minHeight, DELTA)
- assertEquals(18.0, copy.maxHeight, DELTA)
+ assertEquals(3.0f, copy.minWidth, DELTA)
+ assertEquals(3.0f, copy.maxWidth, DELTA)
+ assertEquals(11.0f, copy.minHeight, DELTA)
+ assertEquals(18.0f, copy.maxHeight, DELTA)
}
}
diff --git a/ui/port/src/test/java/androidx/ui/rendering/DynamicIntrinsicsTest.kt b/ui/port/src/test/java/androidx/ui/rendering/DynamicIntrinsicsTest.kt
index cb377b0..7e65ff4 100644
--- a/ui/port/src/test/java/androidx/ui/rendering/DynamicIntrinsicsTest.kt
+++ b/ui/port/src/test/java/androidx/ui/rendering/DynamicIntrinsicsTest.kt
@@ -35,17 +35,17 @@
class DynamicIntrinsicsTest {
class RenderFixedSize : RenderBox() {
- var dimension = 100.0
+ var dimension = 100.0f
fun grow() {
- dimension *= 2.0
+ dimension *= 2.0f
markNeedsLayout()
}
- override fun computeMinIntrinsicWidth(height: Double) = dimension
- override fun computeMaxIntrinsicWidth(height: Double) = dimension
- override fun computeMinIntrinsicHeight(width: Double) = dimension
- override fun computeMaxIntrinsicHeight(width: Double) = dimension
+ override fun computeMinIntrinsicWidth(height: Float) = dimension
+ override fun computeMaxIntrinsicWidth(height: Float) = dimension
+ override fun computeMinIntrinsicHeight(width: Float) = dimension
+ override fun computeMaxIntrinsicHeight(width: Float) = dimension
override fun performLayout() {
size = Size.square(dimension)
@@ -70,8 +70,8 @@
override fun performLayout() {
child!!.layout(constraints!!)
size = Size(
- child!!.getMinIntrinsicWidth(Double.POSITIVE_INFINITY),
- child!!.getMinIntrinsicHeight(Double.POSITIVE_INFINITY)
+ child!!.getMinIntrinsicWidth(Float.POSITIVE_INFINITY),
+ child!!.getMinIntrinsicHeight(Float.POSITIVE_INFINITY)
)
}
}
@@ -99,10 +99,10 @@
)
layout(root,
constraints = BoxConstraints(
- minWidth = 0.0,
- minHeight = 0.0,
- maxWidth = 1000.0,
- maxHeight = 1000.0
+ minWidth = 0.0f,
+ minHeight = 0.0f,
+ maxWidth = 1000.0f,
+ maxHeight = 1000.0f
)
)
assertEquals(root.size, inner.size)
diff --git a/ui/port/src/test/java/androidx/ui/rendering/ImageTest.kt b/ui/port/src/test/java/androidx/ui/rendering/ImageTest.kt
index 7a458d6..d296cf2 100644
--- a/ui/port/src/test/java/androidx/ui/rendering/ImageTest.kt
+++ b/ui/port/src/test/java/androidx/ui/rendering/ImageTest.kt
@@ -57,12 +57,12 @@
var image = RenderImage(image = squareImage)
layout(image,
constraints = BoxConstraints(
- minWidth = 25.0,
- minHeight = 25.0,
- maxWidth = 100.0,
- maxHeight = 100.0))
- assertThat(image.size.width, MoreOrLessEquals(25.0))
- assertThat(image.size.height, MoreOrLessEquals(25.0))
+ minWidth = 25.0f,
+ minHeight = 25.0f,
+ maxWidth = 100.0f,
+ maxHeight = 100.0f))
+ assertThat(image.size.width, MoreOrLessEquals(25.0f))
+ assertThat(image.size.height, MoreOrLessEquals(25.0f))
assertThat(image, HasGoodToStringDeep)
assertThat(
@@ -80,82 +80,82 @@
image = RenderImage(image = wideImage)
layout(image,
constraints = BoxConstraints(
- minWidth = 5.0,
- minHeight = 30.0,
- maxWidth = 100.0,
- maxHeight = 100.0))
- assertThat(image.size.width, MoreOrLessEquals(60.0))
- assertThat(image.size.height, MoreOrLessEquals(30.0))
+ minWidth = 5.0f,
+ minHeight = 30.0f,
+ maxWidth = 100.0f,
+ maxHeight = 100.0f))
+ assertThat(image.size.width, MoreOrLessEquals(60.0f))
+ assertThat(image.size.height, MoreOrLessEquals(30.0f))
image = RenderImage(image = tallImage)
layout(image,
constraints = BoxConstraints(
- minWidth = 50.0,
- minHeight = 5.0,
- maxWidth = 75.0,
- maxHeight = 75.0))
- assertThat(image.size.width, MoreOrLessEquals(50.0))
- assertThat(image.size.height, MoreOrLessEquals(75.0))
+ minWidth = 50.0f,
+ minHeight = 5.0f,
+ maxWidth = 75.0f,
+ maxHeight = 75.0f))
+ assertThat(image.size.width, MoreOrLessEquals(50.0f))
+ assertThat(image.size.height, MoreOrLessEquals(75.0f))
image = RenderImage(image = wideImage)
layout(image,
constraints = BoxConstraints(
- minWidth = 5.0,
- minHeight = 5.0,
- maxWidth = 100.0,
- maxHeight = 100.0))
- assertThat(image.size.width, MoreOrLessEquals(20.0))
- assertThat(image.size.height, MoreOrLessEquals(10.0))
+ minWidth = 5.0f,
+ minHeight = 5.0f,
+ maxWidth = 100.0f,
+ maxHeight = 100.0f))
+ assertThat(image.size.width, MoreOrLessEquals(20.0f))
+ assertThat(image.size.height, MoreOrLessEquals(10.0f))
image = RenderImage(image = wideImage)
layout(image,
constraints = BoxConstraints(
- minWidth = 5.0,
- minHeight = 5.0,
- maxWidth = 16.0,
- maxHeight = 16.0))
- assertThat(image.size.width, MoreOrLessEquals(16.0))
- assertThat(image.size.height, MoreOrLessEquals(8.0))
+ minWidth = 5.0f,
+ minHeight = 5.0f,
+ maxWidth = 16.0f,
+ maxHeight = 16.0f))
+ assertThat(image.size.width, MoreOrLessEquals(16.0f))
+ assertThat(image.size.height, MoreOrLessEquals(8.0f))
image = RenderImage(image = tallImage)
layout(image,
constraints = BoxConstraints(
- minWidth = 5.0,
- minHeight = 5.0,
- maxWidth = 16.0,
- maxHeight = 16.0))
- assertThat(image.size.width, MoreOrLessEquals(8.0))
- assertThat(image.size.height, MoreOrLessEquals(16.0))
+ minWidth = 5.0f,
+ minHeight = 5.0f,
+ maxWidth = 16.0f,
+ maxHeight = 16.0f))
+ assertThat(image.size.width, MoreOrLessEquals(8.0f))
+ assertThat(image.size.height, MoreOrLessEquals(16.0f))
image = RenderImage(image = squareImage)
layout(image,
constraints = BoxConstraints(
- minWidth = 4.0,
- minHeight = 4.0,
- maxWidth = 8.0,
- maxHeight = 8.0))
- assertThat(image.size.width, MoreOrLessEquals(8.0))
- assertThat(image.size.height, MoreOrLessEquals(8.0))
+ minWidth = 4.0f,
+ minHeight = 4.0f,
+ maxWidth = 8.0f,
+ maxHeight = 8.0f))
+ assertThat(image.size.width, MoreOrLessEquals(8.0f))
+ assertThat(image.size.height, MoreOrLessEquals(8.0f))
image = RenderImage(image = wideImage)
layout(image,
constraints = BoxConstraints(
- minWidth = 20.0,
- minHeight = 20.0,
- maxWidth = 30.0,
- maxHeight = 30.0))
- assertThat(image.size.width, MoreOrLessEquals(30.0))
- assertThat(image.size.height, MoreOrLessEquals(20.0))
+ minWidth = 20.0f,
+ minHeight = 20.0f,
+ maxWidth = 30.0f,
+ maxHeight = 30.0f))
+ assertThat(image.size.width, MoreOrLessEquals(30.0f))
+ assertThat(image.size.height, MoreOrLessEquals(20.0f))
image = RenderImage(image = tallImage)
layout(image,
constraints = BoxConstraints(
- minWidth = 20.0,
- minHeight = 20.0,
- maxWidth = 30.0,
- maxHeight = 30.0))
- assertThat(image.size.width, MoreOrLessEquals(20.0))
- assertThat(image.size.height, MoreOrLessEquals(30.0))
+ minWidth = 20.0f,
+ minHeight = 20.0f,
+ maxWidth = 30.0f,
+ maxHeight = 30.0f))
+ assertThat(image.size.width, MoreOrLessEquals(20.0f))
+ assertThat(image.size.height, MoreOrLessEquals(30.0f))
}
@Test
@@ -163,42 +163,42 @@
var image = RenderImage()
layout(image,
constraints = BoxConstraints(
- minWidth = 25.0,
- minHeight = 25.0,
- maxWidth = 100.0,
- maxHeight = 100.0))
- assertThat(image.size.width, MoreOrLessEquals(25.0))
- assertThat(image.size.height, MoreOrLessEquals(25.0))
+ minWidth = 25.0f,
+ minHeight = 25.0f,
+ maxWidth = 100.0f,
+ maxHeight = 100.0f))
+ assertThat(image.size.width, MoreOrLessEquals(25.0f))
+ assertThat(image.size.height, MoreOrLessEquals(25.0f))
- image = RenderImage(width = 50.0)
+ image = RenderImage(width = 50.0f)
layout(image,
constraints = BoxConstraints(
- minWidth = 25.0,
- minHeight = 25.0,
- maxWidth = 100.0,
- maxHeight = 100.0))
- assertThat(image.size.width, MoreOrLessEquals(50.0))
- assertThat(image.size.height, MoreOrLessEquals(25.0))
+ minWidth = 25.0f,
+ minHeight = 25.0f,
+ maxWidth = 100.0f,
+ maxHeight = 100.0f))
+ assertThat(image.size.width, MoreOrLessEquals(50.0f))
+ assertThat(image.size.height, MoreOrLessEquals(25.0f))
- image = RenderImage(height = 50.0)
+ image = RenderImage(height = 50.0f)
layout(image,
constraints = BoxConstraints(
- minWidth = 25.0,
- minHeight = 25.0,
- maxWidth = 100.0,
- maxHeight = 100.0))
- assertThat(image.size.width, MoreOrLessEquals(25.0))
- assertThat(image.size.height, MoreOrLessEquals(50.0))
+ minWidth = 25.0f,
+ minHeight = 25.0f,
+ maxWidth = 100.0f,
+ maxHeight = 100.0f))
+ assertThat(image.size.width, MoreOrLessEquals(25.0f))
+ assertThat(image.size.height, MoreOrLessEquals(50.0f))
- image = RenderImage(width = 100.0, height = 100.0)
+ image = RenderImage(width = 100.0f, height = 100.0f)
layout(image,
constraints = BoxConstraints(
- minWidth = 25.0,
- minHeight = 25.0,
- maxWidth = 75.0,
- maxHeight = 75.0))
- assertThat(image.size.width, MoreOrLessEquals(75.0))
- assertThat(image.size.height, MoreOrLessEquals(75.0))
+ minWidth = 25.0f,
+ minHeight = 25.0f,
+ maxWidth = 75.0f,
+ maxHeight = 75.0f))
+ assertThat(image.size.width, MoreOrLessEquals(75.0f))
+ assertThat(image.size.height, MoreOrLessEquals(75.0f))
}
@Test
diff --git a/ui/port/src/test/java/androidx/ui/rendering/IntrinsicWidthTest.kt b/ui/port/src/test/java/androidx/ui/rendering/IntrinsicWidthTest.kt
index 5c5a7ce..4893884 100644
--- a/ui/port/src/test/java/androidx/ui/rendering/IntrinsicWidthTest.kt
+++ b/ui/port/src/test/java/androidx/ui/rendering/IntrinsicWidthTest.kt
@@ -39,22 +39,22 @@
// before using this, consider using RenderSizedBox from rendering_tester.dart
class RenderTestBox(private val _intrinsicDimensions: BoxConstraints) : RenderBox() {
- override fun computeMinIntrinsicWidth(height: Double) = _intrinsicDimensions.minWidth
+ override fun computeMinIntrinsicWidth(height: Float) = _intrinsicDimensions.minWidth
- override fun computeMaxIntrinsicWidth(height: Double) = _intrinsicDimensions.maxWidth
+ override fun computeMaxIntrinsicWidth(height: Float) = _intrinsicDimensions.maxWidth
- override fun computeMinIntrinsicHeight(width: Double) = _intrinsicDimensions.minHeight
+ override fun computeMinIntrinsicHeight(width: Float) = _intrinsicDimensions.minHeight
- override fun computeMaxIntrinsicHeight(width: Double) = _intrinsicDimensions.maxHeight
+ override fun computeMaxIntrinsicHeight(width: Float) = _intrinsicDimensions.maxHeight
override val sizedByParent = true
override fun performResize() {
size = constraints!!.constrain(
Size(_intrinsicDimensions.minWidth +
- (_intrinsicDimensions.maxWidth - _intrinsicDimensions.minWidth) / 2.0,
+ (_intrinsicDimensions.maxWidth - _intrinsicDimensions.minWidth) / 2.0f,
_intrinsicDimensions.minHeight + (_intrinsicDimensions.maxHeight -
- _intrinsicDimensions.minHeight) / 2.0))
+ _intrinsicDimensions.minHeight) / 2.0f))
}
}
@@ -74,39 +74,39 @@
@Test
fun `Shrink-wrapping width`() {
val child = RenderTestBox(
- BoxConstraints(minWidth = 10.0, maxWidth = 100.0, minHeight = 20.0,
- maxHeight = 200.0))
+ BoxConstraints(minWidth = 10.0f, maxWidth = 100.0f, minHeight = 20.0f,
+ maxHeight = 200.0f))
val parent = RenderIntrinsicWidth(child = child)
layout(parent,
constraints = BoxConstraints(
- minWidth = 5.0,
- minHeight = 8.0,
- maxWidth = 500.0,
- maxHeight = 800.0
+ minWidth = 5.0f,
+ minHeight = 8.0f,
+ maxWidth = 500.0f,
+ maxHeight = 800.0f
)
)
- assertThat(100.0, MoreOrLessEquals(parent.size.width))
- assertThat(110.0, MoreOrLessEquals(parent.size.height))
+ assertThat(100.0f, MoreOrLessEquals(parent.size.width))
+ assertThat(110.0f, MoreOrLessEquals(parent.size.height))
- assertThat(100.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0)))
- assertThat(100.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0)))
- assertThat(20.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0)))
- assertThat(200.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0f)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0f)))
+ assertThat(20.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0f)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0f)))
- assertThat(100.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0)))
- assertThat(100.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0)))
- assertThat(20.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0)))
- assertThat(200.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0f)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0f)))
+ assertThat(20.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0f)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0f)))
- assertThat(100.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0)))
- assertThat(100.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0)))
- assertThat(20.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0)))
- assertThat(200.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0f)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0f)))
+ assertThat(20.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0f)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0f)))
- assertThat(100.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(100.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(20.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(Double.POSITIVE_INFINITY)))
- assertThat(200.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(Double.POSITIVE_INFINITY)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(20.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(Float.POSITIVE_INFINITY)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(Float.POSITIVE_INFINITY)))
}
@Test
@@ -114,194 +114,194 @@
val parent = RenderIntrinsicWidth()
layout(parent,
constraints = BoxConstraints(
- minWidth = 5.0,
- minHeight = 8.0,
- maxWidth = 500.0,
- maxHeight = 800.0
+ minWidth = 5.0f,
+ minHeight = 8.0f,
+ maxWidth = 500.0f,
+ maxHeight = 800.0f
)
)
- assertThat(5.0, MoreOrLessEquals(parent.size.width))
- assertThat(8.0, MoreOrLessEquals(parent.size.height))
+ assertThat(5.0f, MoreOrLessEquals(parent.size.width))
+ assertThat(8.0f, MoreOrLessEquals(parent.size.height))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0f)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0f)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0f)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(Double.POSITIVE_INFINITY)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(Double.POSITIVE_INFINITY)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(Float.POSITIVE_INFINITY)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(Float.POSITIVE_INFINITY)))
}
@Test
fun `Shrink-wrapping width (stepped width)`() {
val child = RenderTestBox(
- BoxConstraints(minWidth = 10.0, maxWidth = 100.0, minHeight = 20.0,
- maxHeight = 200.0))
- val parent = RenderIntrinsicWidth(child = child, _stepWidth = 47.0)
+ BoxConstraints(minWidth = 10.0f, maxWidth = 100.0f, minHeight = 20.0f,
+ maxHeight = 200.0f))
+ val parent = RenderIntrinsicWidth(child = child, _stepWidth = 47.0f)
layout(parent,
constraints = BoxConstraints(
- minWidth = 5.0,
- minHeight = 8.0,
- maxWidth = 500.0,
- maxHeight = 800.0
+ minWidth = 5.0f,
+ minHeight = 8.0f,
+ maxWidth = 500.0f,
+ maxHeight = 800.0f
)
)
- assertThat(3.0 * 47.0, MoreOrLessEquals(parent.size.width))
- assertThat(110.0, MoreOrLessEquals(parent.size.height))
+ assertThat(3.0f * 47.0f, MoreOrLessEquals(parent.size.width))
+ assertThat(110.0f, MoreOrLessEquals(parent.size.height))
- assertThat(3.0 * 47.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0)))
- assertThat(3.0 * 47.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0)))
- assertThat(20.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0)))
- assertThat(200.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0)))
+ assertThat(3.0f * 47.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0f)))
+ assertThat(3.0f * 47.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0f)))
+ assertThat(20.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0f)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0f)))
- assertThat(3.0 * 47.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0)))
- assertThat(3.0 * 47.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0)))
- assertThat(20.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0)))
- assertThat(200.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0)))
+ assertThat(3.0f * 47.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0f)))
+ assertThat(3.0f * 47.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0f)))
+ assertThat(20.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0f)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0f)))
- assertThat(3.0 * 47.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0)))
- assertThat(3.0 * 47.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0)))
- assertThat(20.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0)))
- assertThat(200.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0)))
+ assertThat(3.0f * 47.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0f)))
+ assertThat(3.0f * 47.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0f)))
+ assertThat(20.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0f)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0f)))
- assertThat(3.0 * 47.0,
- MoreOrLessEquals(parent.getMinIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(3.0 * 47.0,
- MoreOrLessEquals(parent.getMaxIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(20.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(Double.POSITIVE_INFINITY)))
- assertThat(200.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(Double.POSITIVE_INFINITY)))
+ assertThat(3.0f * 47.0f,
+ MoreOrLessEquals(parent.getMinIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(3.0f * 47.0f,
+ MoreOrLessEquals(parent.getMaxIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(20.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(Float.POSITIVE_INFINITY)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(Float.POSITIVE_INFINITY)))
}
@Test
fun `Shrink-wrapping width (stepped height)`() {
val child = RenderTestBox(
- BoxConstraints(minWidth = 10.0, maxWidth = 100.0, minHeight = 20.0,
- maxHeight = 200.0))
- val parent = RenderIntrinsicWidth(child = child, _stepHeight = 47.0)
+ BoxConstraints(minWidth = 10.0f, maxWidth = 100.0f, minHeight = 20.0f,
+ maxHeight = 200.0f))
+ val parent = RenderIntrinsicWidth(child = child, _stepHeight = 47.0f)
layout(parent,
constraints = BoxConstraints(
- minWidth = 5.0,
- minHeight = 8.0,
- maxWidth = 500.0,
- maxHeight = 800.0
+ minWidth = 5.0f,
+ minHeight = 8.0f,
+ maxWidth = 500.0f,
+ maxHeight = 800.0f
)
)
- assertThat(100.0, MoreOrLessEquals(parent.size.width))
- assertThat(235.0, MoreOrLessEquals(parent.size.height))
+ assertThat(100.0f, MoreOrLessEquals(parent.size.width))
+ assertThat(235.0f, MoreOrLessEquals(parent.size.height))
- assertThat(100.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0)))
- assertThat(100.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0)))
- assertThat(1.0 * 47.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0)))
- assertThat(5.0 * 47.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0f)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0f)))
+ assertThat(1.0f * 47.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0f)))
+ assertThat(5.0f * 47.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0f)))
- assertThat(100.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0)))
- assertThat(100.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0)))
- assertThat(1.0 * 47.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0)))
- assertThat(5.0 * 47.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0f)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0f)))
+ assertThat(1.0f * 47.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0f)))
+ assertThat(5.0f * 47.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0f)))
- assertThat(100.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0)))
- assertThat(100.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0)))
- assertThat(1.0 * 47.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0)))
- assertThat(5.0 * 47.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0f)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0f)))
+ assertThat(1.0f * 47.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0f)))
+ assertThat(5.0f * 47.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0f)))
- assertThat(100.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(100.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(1.0 * 47.0,
- MoreOrLessEquals(parent.getMinIntrinsicHeight(Double.POSITIVE_INFINITY)))
- assertThat(5.0 * 47.0,
- MoreOrLessEquals(parent.getMaxIntrinsicHeight(Double.POSITIVE_INFINITY)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(1.0f * 47.0f,
+ MoreOrLessEquals(parent.getMinIntrinsicHeight(Float.POSITIVE_INFINITY)))
+ assertThat(5.0f * 47.0f,
+ MoreOrLessEquals(parent.getMaxIntrinsicHeight(Float.POSITIVE_INFINITY)))
}
@Test
fun `Shrink-wrapping width (stepped everything)`() {
val child = RenderTestBox(
- BoxConstraints(minWidth = 10.0, maxWidth = 100.0, minHeight = 20.0,
- maxHeight = 200.0))
- val parent = RenderIntrinsicWidth(child = child, _stepHeight = 47.0, _stepWidth = 37.0)
+ BoxConstraints(minWidth = 10.0f, maxWidth = 100.0f, minHeight = 20.0f,
+ maxHeight = 200.0f))
+ val parent = RenderIntrinsicWidth(child = child, _stepHeight = 47.0f, _stepWidth = 37.0f)
layout(parent,
constraints = BoxConstraints(
- minWidth = 5.0,
- minHeight = 8.0,
- maxWidth = 500.0,
- maxHeight = 800.0
+ minWidth = 5.0f,
+ minHeight = 8.0f,
+ maxWidth = 500.0f,
+ maxHeight = 800.0f
)
)
- assertThat(3.0 * 37.0, MoreOrLessEquals(parent.size.width))
- assertThat(235.0, MoreOrLessEquals(parent.size.height))
+ assertThat(3.0f * 37.0f, MoreOrLessEquals(parent.size.width))
+ assertThat(235.0f, MoreOrLessEquals(parent.size.height))
- assertThat(3.0 * 37.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0)))
- assertThat(3.0 * 37.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0)))
- assertThat(1.0 * 47.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0)))
- assertThat(5.0 * 47.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0)))
+ assertThat(3.0f * 37.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0f)))
+ assertThat(3.0f * 37.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0f)))
+ assertThat(1.0f * 47.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0f)))
+ assertThat(5.0f * 47.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0f)))
- assertThat(3.0 * 37.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0)))
- assertThat(3.0 * 37.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0)))
- assertThat(1.0 * 47.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0)))
- assertThat(5.0 * 47.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0)))
+ assertThat(3.0f * 37.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0f)))
+ assertThat(3.0f * 37.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0f)))
+ assertThat(1.0f * 47.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0f)))
+ assertThat(5.0f * 47.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0f)))
- assertThat(3.0 * 37.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0)))
- assertThat(3.0 * 37.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0)))
- assertThat(1.0 * 47.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0)))
- assertThat(5.0 * 47.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0)))
+ assertThat(3.0f * 37.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0f)))
+ assertThat(3.0f * 37.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0f)))
+ assertThat(1.0f * 47.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0f)))
+ assertThat(5.0f * 47.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0f)))
- assertThat(3.0 * 37.0,
- MoreOrLessEquals(parent.getMinIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(3.0 * 37.0,
- MoreOrLessEquals(parent.getMaxIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(1.0 * 47.0,
- MoreOrLessEquals(parent.getMinIntrinsicHeight(Double.POSITIVE_INFINITY)))
- assertThat(5.0 * 47.0,
- MoreOrLessEquals(parent.getMaxIntrinsicHeight(Double.POSITIVE_INFINITY)))
+ assertThat(3.0f * 37.0f,
+ MoreOrLessEquals(parent.getMinIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(3.0f * 37.0f,
+ MoreOrLessEquals(parent.getMaxIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(1.0f * 47.0f,
+ MoreOrLessEquals(parent.getMinIntrinsicHeight(Float.POSITIVE_INFINITY)))
+ assertThat(5.0f * 47.0f,
+ MoreOrLessEquals(parent.getMaxIntrinsicHeight(Float.POSITIVE_INFINITY)))
}
@Test
fun `Shrink-wrapping height`() {
val child = RenderTestBox(
- BoxConstraints(minWidth = 10.0, maxWidth = 100.0, minHeight = 20.0,
- maxHeight = 200.0))
+ BoxConstraints(minWidth = 10.0f, maxWidth = 100.0f, minHeight = 20.0f,
+ maxHeight = 200.0f))
val parent = RenderIntrinsicHeight(child = child)
layout(parent,
constraints = BoxConstraints(
- minWidth = 5.0,
- minHeight = 8.0,
- maxWidth = 500.0,
- maxHeight = 800.0
+ minWidth = 5.0f,
+ minHeight = 8.0f,
+ maxWidth = 500.0f,
+ maxHeight = 800.0f
)
)
- assertThat(55.0, MoreOrLessEquals(parent.size.width))
- assertThat(200.0, MoreOrLessEquals(parent.size.height))
+ assertThat(55.0f, MoreOrLessEquals(parent.size.width))
+ assertThat(200.0f, MoreOrLessEquals(parent.size.height))
- assertThat(10.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0)))
- assertThat(100.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0)))
- assertThat(200.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0)))
- assertThat(200.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0)))
+ assertThat(10.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0f)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0f)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0f)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0f)))
- assertThat(10.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0)))
- assertThat(100.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0)))
- assertThat(200.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0)))
- assertThat(200.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0)))
+ assertThat(10.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0f)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0f)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0f)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0f)))
- assertThat(10.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0)))
- assertThat(100.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0)))
- assertThat(200.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0)))
- assertThat(200.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0)))
+ assertThat(10.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0f)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0f)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0f)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0f)))
- assertThat(10.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(100.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(200.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(Double.POSITIVE_INFINITY)))
- assertThat(200.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(Double.POSITIVE_INFINITY)))
+ assertThat(10.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(100.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(Float.POSITIVE_INFINITY)))
+ assertThat(200.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(Float.POSITIVE_INFINITY)))
}
@Test
@@ -309,34 +309,34 @@
val parent = RenderIntrinsicHeight()
layout(parent,
constraints = BoxConstraints(
- minWidth = 5.0,
- minHeight = 8.0,
- maxWidth = 500.0,
- maxHeight = 800.0
+ minWidth = 5.0f,
+ minHeight = 8.0f,
+ maxWidth = 500.0f,
+ maxHeight = 800.0f
)
)
- assertThat(5.0, MoreOrLessEquals(parent.size.width))
- assertThat(8.0, MoreOrLessEquals(parent.size.height))
+ assertThat(5.0f, MoreOrLessEquals(parent.size.width))
+ assertThat(8.0f, MoreOrLessEquals(parent.size.height))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(0.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(0.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(0.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(0.0f)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(10.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(10.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(10.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(10.0f)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(80.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(80.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(80.0f)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(80.0f)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicWidth(Double.POSITIVE_INFINITY)))
- assertThat(0.0, MoreOrLessEquals(parent.getMinIntrinsicHeight(Double.POSITIVE_INFINITY)))
- assertThat(0.0, MoreOrLessEquals(parent.getMaxIntrinsicHeight(Double.POSITIVE_INFINITY)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicWidth(Float.POSITIVE_INFINITY)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMinIntrinsicHeight(Float.POSITIVE_INFINITY)))
+ assertThat(0.0f, MoreOrLessEquals(parent.getMaxIntrinsicHeight(Float.POSITIVE_INFINITY)))
}
// TODO("Migration/Andrey: Next tests needs RenderPadding class")
@@ -495,4 +495,4 @@
// )
// )
// }
-}
\ No newline at end of file
+}
diff --git a/ui/port/src/test/java/androidx/ui/rendering/NonRenderObjectRootTest.kt b/ui/port/src/test/java/androidx/ui/rendering/NonRenderObjectRootTest.kt
index 2541098..51f70ed 100644
--- a/ui/port/src/test/java/androidx/ui/rendering/NonRenderObjectRootTest.kt
+++ b/ui/port/src/test/java/androidx/ui/rendering/NonRenderObjectRootTest.kt
@@ -54,7 +54,7 @@
}
fun layout() {
- child?.layout(BoxConstraints.tight(Size(500.0, 500.0)))
+ child?.layout(BoxConstraints.tight(Size(500.0f, 500.0f)))
}
}
@@ -62,7 +62,7 @@
fun `non-RenderObject roots`() {
val child = RenderPositionedBox(
alignment = Alignment.center,
- child = RenderSizedBox(Size(100.0, 100.0))
+ child = RenderSizedBox(Size(100.0f, 100.0f))
)
val root = RealRoot(child = child)
root.attach(PipelineOwner())
diff --git a/ui/port/src/test/java/androidx/ui/rendering/RenderParagraphTest.kt b/ui/port/src/test/java/androidx/ui/rendering/RenderParagraphTest.kt
index dc45cf7..fb76bd6 100644
--- a/ui/port/src/test/java/androidx/ui/rendering/RenderParagraphTest.kt
+++ b/ui/port/src/test/java/androidx/ui/rendering/RenderParagraphTest.kt
@@ -41,12 +41,12 @@
assertThat(paragraph.textDirection).isEqualTo(TextDirection.LTR)
assertThat(paragraph.softWrap).isTrue()
assertThat(paragraph.overflow).isEqualTo(TextOverflow.CLIP)
- assertThat(paragraph.textScaleFactor).isEqualTo(1.0)
+ assertThat(paragraph.textScaleFactor).isEqualTo(1.0f)
assertThat(paragraph.maxLines).isNull()
assertThat(paragraph.textPainter.text).isEqualTo(text)
assertThat(paragraph.textPainter.textAlign).isEqualTo(TextAlign.START)
assertThat(paragraph.textPainter.textDirection).isEqualTo(TextDirection.LTR)
- assertThat(paragraph.textPainter.textScaleFactor).isEqualTo(1.0)
+ assertThat(paragraph.textPainter.textScaleFactor).isEqualTo(1.0f)
assertThat(paragraph.textPainter.maxLines).isNull()
assertThat(paragraph.textPainter.ellipsis).isNull()
}
@@ -54,7 +54,7 @@
@Test
fun `RenderParagraph constructor with customized values`() {
val text = TextSpan()
- val textScaleFactor = 5.0
+ val textScaleFactor = 5.0f
val maxLines = 7
val defaultEllipsis = "\u2026"
@@ -99,7 +99,7 @@
fun `RenderParagraph text set different color causes RenderComparison PAINT`() {
val initText = TextSpan()
val paragraph = RenderParagraph(text = initText, textDirection = TextDirection.LTR)
- val newText = TextSpan(TextStyle(color = Color(0x0111.toInt())))
+ val newText = TextSpan(TextStyle(color = Color(0x0111)))
paragraph.text = newText
@@ -110,7 +110,7 @@
fun `RenderParagraph text set different letterSpacing causes RenderComparison LAYOUT`() {
val initText = TextSpan()
val paragraph = RenderParagraph(text = initText, textDirection = TextDirection.LTR)
- val newText = TextSpan(TextStyle(letterSpacing = 5.0))
+ val newText = TextSpan(TextStyle(letterSpacing = 5.0f))
paragraph.text = newText
@@ -174,7 +174,7 @@
fun `RenderParagraph textScaleFactor setter`() {
val text = TextSpan()
val paragraph = RenderParagraph(text = text, textDirection = TextDirection.LTR)
- val textScaleFactor = 5.0
+ val textScaleFactor = 5.0f
paragraph.textScaleFactor = textScaleFactor
diff --git a/ui/port/src/test/java/androidx/ui/rendering/RenderSizedBox.kt b/ui/port/src/test/java/androidx/ui/rendering/RenderSizedBox.kt
index 5714e66..c11a785 100644
--- a/ui/port/src/test/java/androidx/ui/rendering/RenderSizedBox.kt
+++ b/ui/port/src/test/java/androidx/ui/rendering/RenderSizedBox.kt
@@ -22,19 +22,19 @@
class RenderSizedBox(private val forcedSize: Size) : RenderBox() {
- override fun computeMinIntrinsicWidth(height: Double): Double {
+ override fun computeMinIntrinsicWidth(height: Float): Float {
return forcedSize.width
}
- override fun computeMaxIntrinsicWidth(height: Double): Double {
+ override fun computeMaxIntrinsicWidth(height: Float): Float {
return forcedSize.width
}
- override fun computeMinIntrinsicHeight(width: Double): Double {
+ override fun computeMinIntrinsicHeight(width: Float): Float {
return forcedSize.height
}
- override fun computeMaxIntrinsicHeight(width: Double): Double {
+ override fun computeMaxIntrinsicHeight(width: Float): Float {
return forcedSize.height
}
diff --git a/ui/port/src/test/java/androidx/ui/rendering/RenderingTester.kt b/ui/port/src/test/java/androidx/ui/rendering/RenderingTester.kt
index 867ecdb..0473a79 100644
--- a/ui/port/src/test/java/androidx/ui/rendering/RenderingTester.kt
+++ b/ui/port/src/test/java/androidx/ui/rendering/RenderingTester.kt
@@ -62,7 +62,7 @@
internal val renderer: TestRenderingFlutterBinding get() {
if (_renderer == null) {
val window = Window().apply {
- physicalSize = Size(800.0, 600.0)
+ physicalSize = Size(800.0f, 600.0f)
}
_renderer = TestRenderingFlutterBinding(
WidgetsFlutterBinding.create(
diff --git a/ui/port/src/test/java/androidx/ui/rendering/SizeTest.kt b/ui/port/src/test/java/androidx/ui/rendering/SizeTest.kt
index b1560f5..268574e 100644
--- a/ui/port/src/test/java/androidx/ui/rendering/SizeTest.kt
+++ b/ui/port/src/test/java/androidx/ui/rendering/SizeTest.kt
@@ -32,13 +32,13 @@
@Test
fun `Stack can layout with top, right, bottom, left 0,0`() {
val box = RenderConstrainedBox(_additionalConstraints = BoxConstraints.tight(
- Size(100.0, 100.0)))
+ Size(100.0f, 100.0f)))
box.layout(constraints = BoxConstraints())
- assertEquals(box.size.width, 100.0, 0.1)
- assertEquals(box.size.height, 100.0, 0.1)
- assertEquals(box.size, Size(100.0, 100.0))
+ assertEquals(box.size.width, 100.0f, 0.1f)
+ assertEquals(box.size.height, 100.0f, 0.1f)
+ assertEquals(box.size, Size(100.0f, 100.0f))
assertTrue(box.size is _DebugSize)
}
}
\ No newline at end of file
diff --git a/ui/port/src/test/java/androidx/ui/rendering/box/CachedIntrinsicsTest.kt b/ui/port/src/test/java/androidx/ui/rendering/box/CachedIntrinsicsTest.kt
index 142565b..5997c93 100644
--- a/ui/port/src/test/java/androidx/ui/rendering/box/CachedIntrinsicsTest.kt
+++ b/ui/port/src/test/java/androidx/ui/rendering/box/CachedIntrinsicsTest.kt
@@ -25,65 +25,65 @@
class CachedIntrinsicsTest {
companion object {
- private const val DELTA = 0.01
+ private const val DELTA = 0.01f
}
private class RenderTestBox : RenderBox() {
- var value: Double = 0.0
+ var value: Float = 0.0f
- fun next(): Double {
- value += 1.0; return value; }
+ fun next(): Float {
+ value += 1.0f; return value; }
- override fun computeMinIntrinsicWidth(height: Double) = next()
- override fun computeMaxIntrinsicWidth(height: Double) = next()
- override fun computeMinIntrinsicHeight(width: Double) = next()
- override fun computeMaxIntrinsicHeight(width: Double) = next()
+ override fun computeMinIntrinsicWidth(height: Float) = next()
+ override fun computeMaxIntrinsicWidth(height: Float) = next()
+ override fun computeMinIntrinsicHeight(width: Float) = next()
+ override fun computeMaxIntrinsicHeight(width: Float) = next()
}
@Test
fun `Intrinsics cache`() {
val test = RenderTestBox()
- assertEquals(1.0, test.getMinIntrinsicWidth(0.0), DELTA)
- assertEquals(2.0, test.getMinIntrinsicWidth(100.0), DELTA)
- assertEquals(3.0, test.getMinIntrinsicWidth(200.0), DELTA)
- assertEquals(1.0, test.getMinIntrinsicWidth(0.0), DELTA)
- assertEquals(2.0, test.getMinIntrinsicWidth(100.0), DELTA)
- assertEquals(3.0, test.getMinIntrinsicWidth(200.0), DELTA)
+ assertEquals(1.0f, test.getMinIntrinsicWidth(0.0f), DELTA)
+ assertEquals(2.0f, test.getMinIntrinsicWidth(100.0f), DELTA)
+ assertEquals(3.0f, test.getMinIntrinsicWidth(200.0f), DELTA)
+ assertEquals(1.0f, test.getMinIntrinsicWidth(0.0f), DELTA)
+ assertEquals(2.0f, test.getMinIntrinsicWidth(100.0f), DELTA)
+ assertEquals(3.0f, test.getMinIntrinsicWidth(200.0f), DELTA)
- assertEquals(4.0, test.getMaxIntrinsicWidth(0.0), DELTA)
- assertEquals(5.0, test.getMaxIntrinsicWidth(100.0), DELTA)
- assertEquals(6.0, test.getMaxIntrinsicWidth(200.0), DELTA)
- assertEquals(4.0, test.getMaxIntrinsicWidth(0.0), DELTA)
- assertEquals(5.0, test.getMaxIntrinsicWidth(100.0), DELTA)
- assertEquals(6.0, test.getMaxIntrinsicWidth(200.0), DELTA)
+ assertEquals(4.0f, test.getMaxIntrinsicWidth(0.0f), DELTA)
+ assertEquals(5.0f, test.getMaxIntrinsicWidth(100.0f), DELTA)
+ assertEquals(6.0f, test.getMaxIntrinsicWidth(200.0f), DELTA)
+ assertEquals(4.0f, test.getMaxIntrinsicWidth(0.0f), DELTA)
+ assertEquals(5.0f, test.getMaxIntrinsicWidth(100.0f), DELTA)
+ assertEquals(6.0f, test.getMaxIntrinsicWidth(200.0f), DELTA)
- assertEquals(7.0, test.getMinIntrinsicHeight(0.0), DELTA)
- assertEquals(8.0, test.getMinIntrinsicHeight(100.0), DELTA)
- assertEquals(9.0, test.getMinIntrinsicHeight(200.0), DELTA)
- assertEquals(7.0, test.getMinIntrinsicHeight(0.0), DELTA)
- assertEquals(8.0, test.getMinIntrinsicHeight(100.0), DELTA)
- assertEquals(9.0, test.getMinIntrinsicHeight(200.0), DELTA)
+ assertEquals(7.0f, test.getMinIntrinsicHeight(0.0f), DELTA)
+ assertEquals(8.0f, test.getMinIntrinsicHeight(100.0f), DELTA)
+ assertEquals(9.0f, test.getMinIntrinsicHeight(200.0f), DELTA)
+ assertEquals(7.0f, test.getMinIntrinsicHeight(0.0f), DELTA)
+ assertEquals(8.0f, test.getMinIntrinsicHeight(100.0f), DELTA)
+ assertEquals(9.0f, test.getMinIntrinsicHeight(200.0f), DELTA)
- assertEquals(10.0, test.getMaxIntrinsicHeight(0.0), DELTA)
- assertEquals(11.0, test.getMaxIntrinsicHeight(100.0), DELTA)
- assertEquals(12.0, test.getMaxIntrinsicHeight(200.0), DELTA)
- assertEquals(10.0, test.getMaxIntrinsicHeight(0.0), DELTA)
- assertEquals(11.0, test.getMaxIntrinsicHeight(100.0), DELTA)
- assertEquals(12.0, test.getMaxIntrinsicHeight(200.0), DELTA)
+ assertEquals(10.0f, test.getMaxIntrinsicHeight(0.0f), DELTA)
+ assertEquals(11.0f, test.getMaxIntrinsicHeight(100.0f), DELTA)
+ assertEquals(12.0f, test.getMaxIntrinsicHeight(200.0f), DELTA)
+ assertEquals(10.0f, test.getMaxIntrinsicHeight(0.0f), DELTA)
+ assertEquals(11.0f, test.getMaxIntrinsicHeight(100.0f), DELTA)
+ assertEquals(12.0f, test.getMaxIntrinsicHeight(200.0f), DELTA)
// now read them all again backwards
- assertEquals(12.0, test.getMaxIntrinsicHeight(200.0), DELTA)
- assertEquals(11.0, test.getMaxIntrinsicHeight(100.0), DELTA)
- assertEquals(10.0, test.getMaxIntrinsicHeight(0.0), DELTA)
- assertEquals(9.0, test.getMinIntrinsicHeight(200.0), DELTA)
- assertEquals(8.0, test.getMinIntrinsicHeight(100.0), DELTA)
- assertEquals(7.0, test.getMinIntrinsicHeight(0.0), DELTA)
- assertEquals(6.0, test.getMaxIntrinsicWidth(200.0), DELTA)
- assertEquals(5.0, test.getMaxIntrinsicWidth(100.0), DELTA)
- assertEquals(4.0, test.getMaxIntrinsicWidth(0.0), DELTA)
- assertEquals(3.0, test.getMinIntrinsicWidth(200.0), DELTA)
- assertEquals(2.0, test.getMinIntrinsicWidth(100.0), DELTA)
- assertEquals(1.0, test.getMinIntrinsicWidth(0.0), DELTA)
+ assertEquals(12.0f, test.getMaxIntrinsicHeight(200.0f), DELTA)
+ assertEquals(11.0f, test.getMaxIntrinsicHeight(100.0f), DELTA)
+ assertEquals(10.0f, test.getMaxIntrinsicHeight(0.0f), DELTA)
+ assertEquals(9.0f, test.getMinIntrinsicHeight(200.0f), DELTA)
+ assertEquals(8.0f, test.getMinIntrinsicHeight(100.0f), DELTA)
+ assertEquals(7.0f, test.getMinIntrinsicHeight(0.0f), DELTA)
+ assertEquals(6.0f, test.getMaxIntrinsicWidth(200.0f), DELTA)
+ assertEquals(5.0f, test.getMaxIntrinsicWidth(100.0f), DELTA)
+ assertEquals(4.0f, test.getMaxIntrinsicWidth(0.0f), DELTA)
+ assertEquals(3.0f, test.getMinIntrinsicWidth(200.0f), DELTA)
+ assertEquals(2.0f, test.getMinIntrinsicWidth(100.0f), DELTA)
+ assertEquals(1.0f, test.getMinIntrinsicWidth(0.0f), DELTA)
}
}
\ No newline at end of file
diff --git a/ui/port/src/test/java/androidx/ui/rendering/viewport_offset/FixedViewportOffsetTest.kt b/ui/port/src/test/java/androidx/ui/rendering/viewport_offset/FixedViewportOffsetTest.kt
index 96ae599..a463586 100644
--- a/ui/port/src/test/java/androidx/ui/rendering/viewport_offset/FixedViewportOffsetTest.kt
+++ b/ui/port/src/test/java/androidx/ui/rendering/viewport_offset/FixedViewportOffsetTest.kt
@@ -26,15 +26,15 @@
@Test
fun `correctBy() test`() {
- val fixedViewportOffset = FixedViewportOffset(100.0)
- fixedViewportOffset.correctBy(50.0)
- assertThat(fixedViewportOffset.pixels).isEqualTo(150.0)
+ val fixedViewportOffset = FixedViewportOffset(100.0f)
+ fixedViewportOffset.correctBy(50.0f)
+ assertThat(fixedViewportOffset.pixels).isEqualTo(150.0f)
}
@Test
fun `animateTo should be finished`() {
- val fixedViewportOffset = FixedViewportOffset(100.0)
- val job = fixedViewportOffset.animateTo(200.0, null, null)
+ val fixedViewportOffset = FixedViewportOffset(100.0f)
+ val job = fixedViewportOffset.animateTo(200.0f, null, null)
assertThat(job.isCompleted).isTrue()
}
}
\ No newline at end of file
diff --git a/ui/port/src/test/java/androidx/ui/rendering/viewport_offset/ViewportOffsetTest.kt b/ui/port/src/test/java/androidx/ui/rendering/viewport_offset/ViewportOffsetTest.kt
index 129f558..12b12dd 100644
--- a/ui/port/src/test/java/androidx/ui/rendering/viewport_offset/ViewportOffsetTest.kt
+++ b/ui/port/src/test/java/androidx/ui/rendering/viewport_offset/ViewportOffsetTest.kt
@@ -31,7 +31,7 @@
@Test
fun `moveTo call jumpTo if duration is null test`() {
- val testValue = 123.4
+ val testValue = 123.4f
val viewportOffset: ViewportOffset = mock()
whenever(viewportOffset.moveTo(testValue)).thenCallRealMethod()
@@ -43,7 +43,7 @@
@Test
fun `moveTo call jumpTo if duration is zero test`() {
- val testValue = 123.4
+ val testValue = 123.4f
val viewportOffset: ViewportOffset = mock()
whenever(viewportOffset.moveTo(testValue, Duration.zero)).thenCallRealMethod()
@@ -55,7 +55,7 @@
@Test
fun `moveTo call animateTo if Duration has time`() {
- val testValue = 123.4
+ val testValue = 123.4f
val duration = Duration(100)
val viewportOffset: ViewportOffset = mock()
diff --git a/ui/port/src/test/java/androidx/ui/semantics/SemanticsNodeTests.kt b/ui/port/src/test/java/androidx/ui/semantics/SemanticsNodeTests.kt
index 6da6daa..1078543 100644
--- a/ui/port/src/test/java/androidx/ui/semantics/SemanticsNodeTests.kt
+++ b/ui/port/src/test/java/androidx/ui/semantics/SemanticsNodeTests.kt
@@ -61,7 +61,7 @@
val tags = mutableSetOf(tag1, tag2)
val node: SemanticsNode = SemanticsNode().also {
- it.rect = Rect.fromLTRB(0.0, 0.0, 10.0, 10.0)
+ it.rect = Rect.fromLTRB(0.0f, 0.0f, 10.0f, 10.0f)
it.tags = tags
}
@@ -79,7 +79,7 @@
childrenInInversePaintOrder = listOf(
SemanticsNode().also {
it.isMergedIntoParent = true
- it.rect = Rect.fromLTRB(5.0, 5.0, 10.0, 10.0)
+ it.rect = Rect.fromLTRB(5.0f, 5.0f, 10.0f, 10.0f)
it.tags = tags
}
)
@@ -149,13 +149,13 @@
@Test
fun `toStringDeep() does not throw with transform == null`() {
val child1: SemanticsNode = SemanticsNode().also {
- it.rect = Rect.fromLTRB(0.0, 0.0, 5.0, 5.0)
+ it.rect = Rect.fromLTRB(0.0f, 0.0f, 5.0f, 5.0f)
}
val child2: SemanticsNode = SemanticsNode().also {
- it.rect = Rect.fromLTRB(5.0, 0.0, 10.0, 5.0)
+ it.rect = Rect.fromLTRB(5.0f, 0.0f, 10.0f, 5.0f)
}
val root: SemanticsNode = SemanticsNode().also {
- it.rect = Rect.fromLTRB(0.0, 0.0, 10.0, 5.0)
+ it.rect = Rect.fromLTRB(0.0f, 0.0f, 10.0f, 5.0f)
}
root.updateWith(
config = null,
@@ -189,22 +189,22 @@
fun `Incompatible OrdinalSortKey throw AssertionError when compared`() {
// Different types.
assertThrows(AssertionError::class) {
- OrdinalSortKey(0.0).compareTo(CustomSortKey(0.0))
+ OrdinalSortKey(0.0f).compareTo(CustomSortKey(0.0f))
}
// Different names.
assertThrows(AssertionError::class) {
- OrdinalSortKey(0.0, name = "a").compareTo(OrdinalSortKey(0.0, name = "b"))
+ OrdinalSortKey(0.0f, name = "a").compareTo(OrdinalSortKey(0.0f, name = "b"))
}
}
@Test
fun `OrdinalSortKey compares correctly`() {
val tests: List<List<SemanticsSortKey>> = listOf(
- listOf(OrdinalSortKey(0.0), OrdinalSortKey(0.0)),
- listOf(OrdinalSortKey(0.0), OrdinalSortKey(1.0)),
- listOf(OrdinalSortKey(1.0), OrdinalSortKey(0.0)),
- listOf(OrdinalSortKey(1.0), OrdinalSortKey(1.0))
+ listOf(OrdinalSortKey(0.0f), OrdinalSortKey(0.0f)),
+ listOf(OrdinalSortKey(0.0f), OrdinalSortKey(1.0f)),
+ listOf(OrdinalSortKey(1.0f), OrdinalSortKey(0.0f)),
+ listOf(OrdinalSortKey(1.0f), OrdinalSortKey(1.0f))
)
val expectedResults: List<Int> = listOf(0, -1, 1, 0)
@@ -218,13 +218,13 @@
@Test
fun `toStringDeep respects childOrder parameter`() {
val child1: SemanticsNode = SemanticsNode().also {
- it.rect = Rect.fromLTRB(15.0, 0.0, 20.0, 5.0)
+ it.rect = Rect.fromLTRB(15.0f, 0.0f, 20.0f, 5.0f)
}
val child2: SemanticsNode = SemanticsNode().also {
- it.rect = Rect.fromLTRB(10.0, 0.0, 15.0, 5.0)
+ it.rect = Rect.fromLTRB(10.0f, 0.0f, 15.0f, 5.0f)
}
val root: SemanticsNode = SemanticsNode().also {
- it.rect = Rect.fromLTRB(0.0, 0.0, 20.0, 5.0)
+ it.rect = Rect.fromLTRB(0.0f, 0.0f, 20.0f, 5.0f)
}
root.updateWith(
config = null,
@@ -268,22 +268,22 @@
)
val child3: SemanticsNode = SemanticsNode().also {
- it.rect = Rect.fromLTRB(0.0, 0.0, 10.0, 5.0)
+ it.rect = Rect.fromLTRB(0.0f, 0.0f, 10.0f, 5.0f)
}
child3.updateWith(
config = null,
childrenInInversePaintOrder = listOf(
SemanticsNode().also {
- it.rect = Rect.fromLTRB(5.0, 0.0, 10.0, 5.0)
+ it.rect = Rect.fromLTRB(5.0f, 0.0f, 10.0f, 5.0f)
},
SemanticsNode().also {
- it.rect = Rect.fromLTRB(0.0, 0.0, 5.0, 5.0)
+ it.rect = Rect.fromLTRB(0.0f, 0.0f, 5.0f, 5.0f)
}
)
)
val rootComplex: SemanticsNode = SemanticsNode().also {
- it.rect = Rect.fromLTRB(0.0, 0.0, 25.0, 5.0)
+ it.rect = Rect.fromLTRB(0.0f, 0.0f, 25.0f, 5.0f)
}
rootComplex.updateWith(
config = null,
@@ -405,11 +405,11 @@
it.isButton = true
it.label = "Use all the properties"
it.textDirection = TextDirection.RTL
- it.sortKey = OrdinalSortKey(1.0)
+ it.sortKey = OrdinalSortKey(1.0f)
}
val allProperties: SemanticsNode = SemanticsNode().also {
- it.rect = Rect.fromLTWH(50.0, 10.0, 20.0, 30.0)
- it.transform = Matrix4.translation(Vector3(10.0, 10.0, 0.0))
+ it.rect = Rect.fromLTWH(50.0f, 10.0f, 20.0f, 30.0f)
+ it.transform = Matrix4.translation(Vector3(10.0f, 10.0f, 0.0f))
it.updateWith(config = config, childrenInInversePaintOrder = null)
}
@@ -439,8 +439,8 @@
)
val scaled: SemanticsNode = SemanticsNode().also {
- it.rect = Rect.fromLTWH(50.0, 10.0, 20.0, 30.0)
- it.transform = Matrix4.diagonal3(Vector3(10.0, 10.0, 1.0))
+ it.rect = Rect.fromLTWH(50.0f, 10.0f, 20.0f, 30.0f)
+ it.transform = Matrix4.diagonal3(Vector3(10.0f, 10.0f, 1.0f))
}
assertThat(
scaled.toStringDeep()
@@ -580,6 +580,6 @@
}
private class CustomSortKey(
- order: Double,
+ order: Float,
name: String? = null
) : OrdinalSortKey(order, name)
diff --git a/ui/port/src/test/java/androidx/ui/vectormath64/MatrixTest.kt b/ui/port/src/test/java/androidx/ui/vectormath64/MatrixTest.kt
index 6183bb7..202de81 100644
--- a/ui/port/src/test/java/androidx/ui/vectormath64/MatrixTest.kt
+++ b/ui/port/src/test/java/androidx/ui/vectormath64/MatrixTest.kt
@@ -29,9 +29,9 @@
fun `Matrix3 identity`() {
assertEquals(
Matrix3(
- Vector3(1.0, 0.0, 0.0),
- Vector3(0.0, 1.0, 0.0),
- Vector3(0.0, 0.0, 1.0)
+ Vector3(1.0f, 0.0f, 0.0f),
+ Vector3(0.0f, 1.0f, 0.0f),
+ Vector3(0.0f, 0.0f, 1.0f)
),
Matrix3.identity()
)
@@ -39,22 +39,22 @@
@Test(expected = IllegalArgumentException::class)
fun `Matrix3 of fails if less than 9 arguments`() {
- Matrix3.of(*8.doubleArray())
+ Matrix3.of(*8.floatArray())
}
@Test
fun `Matrix3 of`() {
- assertEquals(MAT_3, Matrix3.of(*9.doubleArray()))
+ assertEquals(MAT_3, Matrix3.of(*9.floatArray()))
}
@Test
fun `Matrix4 identity`() {
assertEquals(
Matrix4(
- Vector4(1.0, 0.0, 0.0, 0.0),
- Vector4(0.0, 1.0, 0.0, 0.0),
- Vector4(0.0, 0.0, 1.0, 0.0),
- Vector4(0.0, 0.0, 0.0, 1.0)
+ Vector4(1.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 1.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 1.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 1.0f)
),
Matrix4.identity()
)
@@ -62,21 +62,21 @@
@Test(expected = IllegalArgumentException::class)
fun `Matrix4 of fails if less than 16 arguments`() {
- Matrix4.of(*15.doubleArray())
+ Matrix4.of(*15.floatArray())
}
@Test
fun `Matrix4 of`() {
- assertEquals(MAT_4, Matrix4.of(*16.doubleArray()))
+ assertEquals(MAT_4, Matrix4.of(*16.floatArray()))
}
@Test
fun `transpose Matrix3`() {
assertEquals(
Matrix3(
- Vector3(1.0, 2.0, 3.0),
- Vector3(4.0, 5.0, 6.0),
- Vector3(7.0, 8.0, 9.0)
+ Vector3(1.0f, 2.0f, 3.0f),
+ Vector3(4.0f, 5.0f, 6.0f),
+ Vector3(7.0f, 8.0f, 9.0f)
),
transpose(MAT_3)
)
@@ -91,14 +91,14 @@
fun `inverse Matrix3`() {
assertEquals(
Matrix3(
- Vector3(0.0, 1.0, 0.0),
- Vector3(-2.0, 1.0, 1.0),
- Vector3(2.0, -2.0, 0.0)
+ Vector3(0.0f, 1.0f, 0.0f),
+ Vector3(-2.0f, 1.0f, 1.0f),
+ Vector3(2.0f, -2.0f, 0.0f)
),
inverse(Matrix3(
- Vector3(1.0, 0.0, 0.5),
- Vector3(1.0, 0.0, 0.0),
- Vector3(1.0, 1.0, 1.0)
+ Vector3(1.0f, 0.0f, 0.5f),
+ Vector3(1.0f, 0.0f, 0.0f),
+ Vector3(1.0f, 1.0f, 1.0f)
))
)
}
@@ -110,23 +110,23 @@
@Test
fun `scale Vector3`() {
- assertEquals(Matrix4.identity(), scale(Vector3(1.0, 1.0, 1.0)))
+ assertEquals(Matrix4.identity(), scale(Vector3(1.0f, 1.0f, 1.0f)))
}
@Test
fun `scale Matrix4`() {
assertEquals(
Matrix4(
- Vector4(2.0, 0.0, 0.0, 0.0),
- Vector4(0.0, 4.0, 0.0, 0.0),
- Vector4(0.0, 0.0, 6.0, 0.0),
- Vector4(0.0, 0.0, 0.0, 1.0)
+ Vector4(2.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 4.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 6.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 1.0f)
),
scale(Matrix4(
- Vector4(2.0, 0.0, 0.0, 0.0),
- Vector4(4.0, 0.0, 0.0, 0.0),
- Vector4(6.0, 0.0, 0.0, 0.0),
- Vector4(0.0, 0.0, 0.0, 0.0)
+ Vector4(2.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(4.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(6.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 0.0f)
))
)
}
@@ -135,12 +135,12 @@
fun `translation Vector3`() {
assertEquals(
Matrix4(
- Vector4(1.0, 0.0, 0.0, 0.0),
- Vector4(0.0, 1.0, 0.0, 0.0),
- Vector4(0.0, 0.0, 1.0, 0.0),
- Vector4(1.0, 2.0, 3.0, 1.0)
+ Vector4(1.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 1.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 1.0f, 0.0f),
+ Vector4(1.0f, 2.0f, 3.0f, 1.0f)
),
- translation(Vector3(1.0, 2.0, 3.0))
+ translation(Vector3(1.0f, 2.0f, 3.0f))
)
}
@@ -148,10 +148,10 @@
fun `translation Matrix4`() {
assertEquals(
Matrix4(
- Vector4(1.0, 0.0, 0.0, 0.0),
- Vector4(0.0, 1.0, 0.0, 0.0),
- Vector4(0.0, 0.0, 1.0, 0.0),
- Vector4(4.0, 8.0, 12.0, 1.0)
+ Vector4(1.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 1.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 1.0f, 0.0f),
+ Vector4(4.0f, 8.0f, 12.0f, 1.0f)
),
translation(MAT_4)
)
@@ -166,18 +166,18 @@
fun `inverse Matrix4`() {
assertEquals(
Matrix4(
- Vector4(1.0, 0.0, 0.0, 0.0),
- Vector4(-1.0, 1.0, 0.0, 0.0),
- Vector4(4.0, -4.0, 1.0, -2.0),
- Vector4(-2.0, 2.0, 0.0, 1.0)
+ Vector4(1.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(-1.0f, 1.0f, 0.0f, 0.0f),
+ Vector4(4.0f, -4.0f, 1.0f, -2.0f),
+ Vector4(-2.0f, 2.0f, 0.0f, 1.0f)
),
inverse(
Matrix4(
- Vector4(1.0, 0.0, 0.0, 0.0),
- Vector4(1.0, 1.0, 0.0, 0.0),
- Vector4(0.0, 0.0, 1.0, 2.0),
- Vector4(0.0, -2.0, 0.0, 1.0)
+ Vector4(1.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(1.0f, 1.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 1.0f, 2.0f),
+ Vector4(0.0f, -2.0f, 0.0f, 1.0f)
))
)
}
@@ -186,20 +186,20 @@
fun `inverse non-invertible Matrix4`() {
assertEquals(
Matrix4(
- Vector4(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY,
- Double.NaN, Double.NaN),
- Vector4(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
- Double.NaN, Double.NaN),
- Vector4(Double.NaN, Double.NaN, Double.NaN, Double.NaN),
- Vector4(Double.NaN, Double.NaN, Double.NaN, Double.NaN)
+ Vector4(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY,
+ Float.NaN, Float.NaN),
+ Vector4(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY,
+ Float.NaN, Float.NaN),
+ Vector4(Float.NaN, Float.NaN, Float.NaN, Float.NaN),
+ Vector4(Float.NaN, Float.NaN, Float.NaN, Float.NaN)
),
inverse(
Matrix4(
- Vector4(1.0, 1.0, 0.0, 0.0),
- Vector4(1.0, 1.0, 0.0, 0.0),
- Vector4(0.0, 0.0, 1.0, 2.0),
- Vector4(0.0, 0.0, 0.0, 1.0)
+ Vector4(1.0f, 1.0f, 0.0f, 0.0f),
+ Vector4(1.0f, 1.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 1.0f, 2.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 1.0f)
))
)
}
@@ -208,12 +208,12 @@
fun `rotation Vector3`() {
assertArrayEquals(
Matrix4(
- Vector4(0.998, 0.0523, -0.0348, 0.0),
- Vector4(-0.0517, 0.9985, 0.0174, 0.0),
- Vector4(0.0357, -0.0156, 0.9992, 0.0),
- Vector4(0.0, 0.0, 0.0, 1.0)
- ).toDoubleArray(),
- rotation(Vector3(1.0, 2.0, 3.0)).toDoubleArray()
+ Vector4(0.998f, 0.0523f, -0.0348f, 0.0f),
+ Vector4(-0.0517f, 0.9985f, 0.0174f, 0.0f),
+ Vector4(0.0357f, -0.0156f, 0.9992f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 1.0f)
+ ).toFloatArray(),
+ rotation(Vector3(1.0f, 2.0f, 3.0f)).toFloatArray()
)
}
@@ -221,12 +221,12 @@
fun `rotation Matrix4`() {
assertArrayEquals(
Matrix4(
- Vector4(0.0966, 0.4833, 0.87, 0.0),
- Vector4(0.169, 0.507, 0.8451, 0.0),
- Vector4(0.2242, 0.5232, 0.8221, 0.0),
- Vector4(0.0, 0.0, 0.0, 1.0)
- ).toDoubleArray(),
- rotation(MAT_4).toDoubleArray()
+ Vector4(0.0966f, 0.4833f, 0.87f, 0.0f),
+ Vector4(0.169f, 0.507f, 0.8451f, 0.0f),
+ Vector4(0.2242f, 0.5232f, 0.8221f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 1.0f)
+ ).toFloatArray(),
+ rotation(MAT_4).toFloatArray()
)
}
@@ -234,12 +234,12 @@
fun `rotation axis angle`() {
assertArrayEquals(
Matrix4(
- Vector4(0.9999, 5.0, 1.0, 0.0),
- Vector4(-1.0, 4.0, 7.0, 0.0),
- Vector4(4.0, 5.0, 9.0, 0.0),
- Vector4(0.0, 0.0, 0.0, 1.0)
- ).toDoubleArray(),
- rotation(Vector3(1.0, 2.0, 3.0), 90.0).toDoubleArray()
+ Vector4(0.9999f, 5.0f, 1.0f, 0.0f),
+ Vector4(-1.0f, 4.0f, 7.0f, 0.0f),
+ Vector4(4.0f, 5.0f, 9.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 1.0f)
+ ).toFloatArray(),
+ rotation(Vector3(1.0f, 2.0f, 3.0f), 90.0f).toFloatArray()
)
}
@@ -247,12 +247,12 @@
fun normal() {
assertArrayEquals(
Matrix4(
- Vector4(0.0093, 0.0357, 0.0502, 13.0),
- Vector4(0.0186, 0.0428, 0.0558, 14.0),
- Vector4(0.0280, 0.05, 0.0614, 15.0),
- Vector4(0.0373, 0.0571, 0.0670, 16.0)
- ).toDoubleArray(),
- normal(MAT_4).toDoubleArray()
+ Vector4(0.0093f, 0.0357f, 0.0502f, 13.0f),
+ Vector4(0.0186f, 0.0428f, 0.0558f, 14.0f),
+ Vector4(0.0280f, 0.05f, 0.0614f, 15.0f),
+ Vector4(0.0373f, 0.0571f, 0.0670f, 16.0f)
+ ).toFloatArray(),
+ normal(MAT_4).toFloatArray()
)
}
@@ -260,16 +260,16 @@
fun lookAt() {
assertArrayEquals(
Matrix4(
- Vector4(0.53606, -0.7862, 0.30734, 0.0),
- Vector4(0.28377, 0.51073, 0.81155, 0.0),
- Vector4(0.79504, 0.34783, -0.4969, 0.0),
- Vector4(1.0, 2.0, 3.0, 1.0)
- ).toDoubleArray(),
+ Vector4(0.53606f, -0.7862f, 0.30734f, 0.0f),
+ Vector4(0.28377f, 0.51073f, 0.81155f, 0.0f),
+ Vector4(0.79504f, 0.34783f, -0.4969f, 0.0f),
+ Vector4(1.0f, 2.0f, 3.0f, 1.0f)
+ ).toFloatArray(),
lookAt(
- eye = Vector3(1.0, 2.0, 3.0),
- target = Vector3(9.0, 5.5, -2.0),
- up = Vector3(3.0, 4.0, 5.0)
- ).toDoubleArray()
+ eye = Vector3(1.0f, 2.0f, 3.0f),
+ target = Vector3(9.0f, 5.5f, -2.0f),
+ up = Vector3(3.0f, 4.0f, 5.0f)
+ ).toFloatArray()
)
}
@@ -277,16 +277,16 @@
fun lookTowards() {
assertArrayEquals(
Matrix4(
- Vector4(-0.6549, -0.3475, 0.67100, 0.0),
- Vector4(0.10792, 0.83584, 0.53825, 0.0),
- Vector4(0.74791, -0.4249, 0.50994, 0.0),
- Vector4(1.0, 2.0, 3.0, 1.0)
- ).toDoubleArray(),
+ Vector4(-0.6549f, -0.3475f, 0.67100f, 0.0f),
+ Vector4(0.10792f, 0.83584f, 0.53825f, 0.0f),
+ Vector4(0.74791f, -0.4249f, 0.50994f, 0.0f),
+ Vector4(1.0f, 2.0f, 3.0f, 1.0f)
+ ).toFloatArray(),
lookTowards(
- eye = Vector3(1.0, 2.0, 3.0),
- forward = Vector3(4.4, -2.5, 3.0),
- up = Vector3(3.0, 4.0, 5.0)
- ).toDoubleArray()
+ eye = Vector3(1.0f, 2.0f, 3.0f),
+ forward = Vector3(4.4f, -2.5f, 3.0f),
+ up = Vector3(3.0f, 4.0f, 5.0f)
+ ).toFloatArray()
)
}
@@ -294,17 +294,17 @@
fun perspective() {
assertArrayEquals(
Matrix4(
- Vector4(57.2943, 0.0, 0.0, 0.0),
- Vector4(0.0, 114.5886, 0.0, 0.0),
- Vector4(0.0, 0.0, -7.0, 1.0),
- Vector4(0.0, 0.0, 24.0, 0.0)
- ).toDoubleArray(),
+ Vector4(57.2943f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 114.5886f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, -7.0f, 1.0f),
+ Vector4(0.0f, 0.0f, 24.0f, 0.0f)
+ ).toFloatArray(),
perspective(
- fov = 1.0,
- ratio = 2.0,
- far = 3.0,
- near = 4.0
- ).toDoubleArray()
+ fov = 1.0f,
+ ratio = 2.0f,
+ far = 3.0f,
+ near = 4.0f
+ ).toFloatArray()
)
}
@@ -312,45 +312,45 @@
fun ortho() {
assertArrayEquals(
Matrix4(
- Vector4(2.0, 0.0, 0.0, 0.0),
- Vector4(0.0, 2.0, 0.0, 0.0),
- Vector4(0.0, 0.0, -2.0, 0.0),
- Vector4(-3.0, -7.0, -11.0, 1.0)
- ).toDoubleArray(),
+ Vector4(2.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 2.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, -2.0f, 0.0f),
+ Vector4(-3.0f, -7.0f, -11.0f, 1.0f)
+ ).toFloatArray(),
ortho(
- l = 1.0,
- r = 2.0,
- b = 3.0,
- t = 4.0,
- n = 5.0,
- f = 6.0
- ).toDoubleArray()
+ l = 1.0f,
+ r = 2.0f,
+ b = 3.0f,
+ t = 4.0f,
+ n = 5.0f,
+ f = 6.0f
+ ).toFloatArray()
)
}
companion object {
private val MAT_3 = Matrix3(
- Vector3(1.0, 4.0, 7.0),
- Vector3(2.0, 5.0, 8.0),
- Vector3(3.0, 6.0, 9.0)
+ Vector3(1.0f, 4.0f, 7.0f),
+ Vector3(2.0f, 5.0f, 8.0f),
+ Vector3(3.0f, 6.0f, 9.0f)
)
private val MAT_4 = Matrix4(
- Vector4(1.0, 5.0, 9.0, 13.0),
- Vector4(2.0, 6.0, 10.0, 14.0),
- Vector4(3.0, 7.0, 11.0, 15.0),
- Vector4(4.0, 8.0, 12.0, 16.0)
+ Vector4(1.0f, 5.0f, 9.0f, 13.0f),
+ Vector4(2.0f, 6.0f, 10.0f, 14.0f),
+ Vector4(3.0f, 7.0f, 11.0f, 15.0f),
+ Vector4(4.0f, 8.0f, 12.0f, 16.0f)
)
private fun assertArrayEquals(
- expected: DoubleArray,
- actual: DoubleArray,
- delta: Double = 0.0001
+ expected: FloatArray,
+ actual: FloatArray,
+ delta: Float = 0.0001f
) = Assert.assertArrayEquals(expected, actual, delta)
/**
* @return a VectorArray containing n floats 1f,2f,...,n (float) where n
* is the @receiver integer.
*/
- private fun Int.doubleArray() = DoubleArray(this) { (it + 1).toDouble() }
+ private fun Int.floatArray() = FloatArray(this) { (it + 1).toFloat() }
}
}
\ No newline at end of file
diff --git a/ui/port/src/test/java/androidx/ui/widgets/basic/RichTextTest.kt b/ui/port/src/test/java/androidx/ui/widgets/basic/RichTextTest.kt
index a56ea01..33826ed 100644
--- a/ui/port/src/test/java/androidx/ui/widgets/basic/RichTextTest.kt
+++ b/ui/port/src/test/java/androidx/ui/widgets/basic/RichTextTest.kt
@@ -43,7 +43,7 @@
assertThat(richText.textDirection).isNull()
assertThat(richText.softWrap).isTrue()
assertThat(richText.overflow).isEqualTo(TextOverflow.CLIP)
- assertThat(richText.textScaleFactor).isEqualTo(1.0)
+ assertThat(richText.textScaleFactor).isEqualTo(1.0f)
assertThat(richText.maxLines).isNull()
}
@@ -51,7 +51,7 @@
fun `RichText constructor with all customized values`() {
val key = Key.createKey("Hello")
val textSpan = TextSpan(text = "Hello", style = TextStyle())
- val textScaleFactor = 3.0
+ val textScaleFactor = 3.0f
val maxLines = 5
val richText = RichText(
@@ -79,7 +79,7 @@
fun `RichText createRenderObject`() {
val key = Key.createKey("Hello")
val textSpan = TextSpan(text = "Hello", style = TextStyle())
- val textScaleFactor = 3.0
+ val textScaleFactor = 3.0f
val maxLines = 5
val richText = RichText(
key = key,
@@ -107,7 +107,7 @@
fun `RichText updateRenderObject`() {
val key = Key.createKey("Hello")
val textSpan = TextSpan(text = "Hello", style = TextStyle())
- val textScaleFactor = 3.0
+ val textScaleFactor = 3.0f
val maxLines = 5
val richText = RichText(
key = key,
diff --git a/ui/port/src/test/java/androidx/ui/widgets/text/DefaultTextStyleTest.kt b/ui/port/src/test/java/androidx/ui/widgets/text/DefaultTextStyleTest.kt
index e0520e4..e441c11 100644
--- a/ui/port/src/test/java/androidx/ui/widgets/text/DefaultTextStyleTest.kt
+++ b/ui/port/src/test/java/androidx/ui/widgets/text/DefaultTextStyleTest.kt
@@ -102,7 +102,7 @@
val oldDefaultTextStyle = DefaultTextStyle()
val newDefaultTextStyle = DefaultTextStyle(
key = oldDefaultTextStyle.key,
- style = TextStyle(fontSize = 15.0), // style is different.
+ style = TextStyle(fontSize = 15.0f), // style is different.
textAlign = oldDefaultTextStyle.textAlign,
softWrap = oldDefaultTextStyle.softWrap,
overflow = oldDefaultTextStyle.overflow,
diff --git a/ui/port/src/test/java/androidx/ui/widgets/text/TextTest.kt b/ui/port/src/test/java/androidx/ui/widgets/text/TextTest.kt
index ff8f5db..6d49b5f 100644
--- a/ui/port/src/test/java/androidx/ui/widgets/text/TextTest.kt
+++ b/ui/port/src/test/java/androidx/ui/widgets/text/TextTest.kt
@@ -52,7 +52,7 @@
val string = "Hello"
val key = Key.createKey("Hello")
val style = TextStyle()
- val textScaleFactor = 5.0
+ val textScaleFactor = 5.0f
val maxLines = 5
val text = Text(
@@ -102,7 +102,7 @@
val textSpan = TextSpan(text = "Hello")
val key = Key.createKey("Hello")
val style = TextStyle()
- val textScaleFactor = 5.0
+ val textScaleFactor = 5.0f
val maxLines = 5
val text = Text(
diff --git a/ui/text/src/androidTest/java/androidx/text/TextLayoutTest.kt b/ui/text/src/androidTest/java/androidx/text/TextLayoutTest.kt
index 46ae908..a39bf0e 100644
--- a/ui/text/src/androidTest/java/androidx/text/TextLayoutTest.kt
+++ b/ui/text/src/androidTest/java/androidx/text/TextLayoutTest.kt
@@ -61,7 +61,7 @@
@Test
fun specifiedWidth_equalsTo_widthInFramework() {
- val layoutWidth = 100.0
+ val layoutWidth = 100.0f
val textLayout = TextLayout(
charSequence = "",
width = layoutWidth,
@@ -75,12 +75,12 @@
@Test
fun maxIntrinsicWidth_lessThan_specifiedWidth() {
val text = "aaaa"
- val textSize = 20.0
+ val textSize = 20.0f
val layoutWidth = textSize * (text.length - 1)
val textPaint = TextPaint()
textPaint.typeface = sampleTypeface
- textPaint.textSize = textSize.toFloat()
+ textPaint.textSize = textSize
val textLayout = TextLayout(
charSequence = text,
@@ -95,13 +95,13 @@
@Test
fun lineSpacingExtra_whenMultipleLines_returnsSameAsGiven() {
val text = "abcdefgh"
- val textSize = 20.0
+ val textSize = 20.0f
val layoutWidth = textSize * text.length / 4
- val lineSpacingExtra = 1.0
+ val lineSpacingExtra = 1.0f
val textPaint = TextPaint()
textPaint.typeface = sampleTypeface
- textPaint.textSize = textSize.toFloat()
+ textPaint.textSize = textSize
val layout = TextLayout(
charSequence = text,
@@ -116,20 +116,20 @@
for (i in 0 until layout.lineCount - 1) {
// In the sample_font.ttf, the height of the line should be
// fontSize + 0.2 * fontSize(line gap)
- assertThat(layout.getLineHeight(i), equalTo(textSize * 1.2 + lineSpacingExtra))
+ assertThat(layout.getLineHeight(i), equalTo(textSize * 1.2f + lineSpacingExtra))
}
}
@Test
fun lineSpacingExtra_whenMultipleLines_hasNoEffectOnLastLine() {
val text = "abcdefgh"
- val textSize = 20.0
+ val textSize = 20.0f
val layoutWidth = textSize * text.length / 4
- val lineSpacingExtra = 1.0
+ val lineSpacingExtra = 1.0f
val textPaint = TextPaint()
textPaint.typeface = sampleTypeface
- textPaint.textSize = textSize.toFloat()
+ textPaint.textSize = textSize
val layout = TextLayout(
charSequence = text,
@@ -147,19 +147,19 @@
val actualHeight = layout.getLineHeight(lastLine)
// In the sample_font.ttf, the height of the line should be
// fontSize + 0.2 * fontSize(line gap)
- assertThat(actualHeight, equalTo(textSize * 1.2))
+ assertThat(actualHeight, equalTo(textSize * 1.2f))
}
@Test
fun lineSpacingExtra_whenOneLine_hasNoEffects() {
val text = "abc"
- val textSize = 20.0
+ val textSize = 20.0f
val layoutWidth = textSize * text.length
- val lineSpacingExtra = 1.0
+ val lineSpacingExtra = 1.0f
val textPaint = TextPaint()
textPaint.typeface = sampleTypeface
- textPaint.textSize = textSize.toFloat()
+ textPaint.textSize = textSize
val layout = TextLayout(
charSequence = text,
@@ -175,19 +175,19 @@
assertThat(layout.lineCount, equalTo(1))
// In the sample_font.ttf, the height of the line should be
// fontSize + 0.2 * fontSize(line gap)
- assertThat(layout.getLineHeight(0), equalTo(textSize * 1.2))
+ assertThat(layout.getLineHeight(0), equalTo(textSize * 1.2f))
}
@Test
fun lineSpacingExtra_whenOneLine_withTextRTL_hasNoEffects() {
val text = "\u05D0\u05D0\u05D0"
- val textSize = 20.0
+ val textSize = 20.0f
val layoutWidth = textSize * text.length
- val lineSpacingExtra = 1.0
+ val lineSpacingExtra = 1.0f
val textPaint = TextPaint()
textPaint.typeface = sampleTypeface
- textPaint.textSize = textSize.toFloat()
+ textPaint.textSize = textSize
val layout = TextLayout(
charSequence = text,
@@ -203,19 +203,19 @@
assertThat(layout.lineCount, equalTo(1))
// In the sample_font.ttf, the height of the line should be
// fontSize + 0.2 * fontSize(line gap)
- assertThat(layout.getLineHeight(0), equalTo(textSize * 1.2))
+ assertThat(layout.getLineHeight(0), equalTo(textSize * 1.2f))
}
@Test
fun lineSpacingMultiplier_whenMultipleLines_returnsSameAsGiven() {
val text = "abcdefgh"
- val textSize = 20.0
+ val textSize = 20.0f
val layoutWidth = textSize * text.length / 4
- val lineSpacingMultiplier = 1.5
+ val lineSpacingMultiplier = 1.5f
val textPaint = TextPaint()
textPaint.typeface = sampleTypeface
- textPaint.textSize = textSize.toFloat()
+ textPaint.textSize = textSize
val layout = TextLayout(
charSequence = text,
@@ -230,20 +230,20 @@
for (i in 0 until layout.lineCount - 1) {
// In the sample_font.ttf, the height of the line should be
// fontSize + 0.2 * fontSize(line gap)
- assertThat(layout.getLineHeight(i), equalTo(textSize * 1.2 * lineSpacingMultiplier))
+ assertThat(layout.getLineHeight(i), equalTo(textSize * 1.2f * lineSpacingMultiplier))
}
}
@Test
fun lineSpacingMultiplier_whenMultipleLines_hasNoEffectOnLastLine() {
val text = "abcdefgh"
- val textSize = 20.0
+ val textSize = 20.0f
val layoutWidth = textSize * text.length / 4
- val lineSpacingMultiplier = 1.5
+ val lineSpacingMultiplier = 1.5f
val textPaint = TextPaint()
textPaint.typeface = sampleTypeface
- textPaint.textSize = textSize.toFloat()
+ textPaint.textSize = textSize
val layout = TextLayout(
charSequence = text,
@@ -258,19 +258,19 @@
val lastLine = layout.lineCount - 1
// In the sample_font.ttf, the height of the line should be
// fontSize + 0.2 * fontSize(line gap)
- assertThat(layout.getLineHeight(lastLine), equalTo(textSize * 1.2))
+ assertThat(layout.getLineHeight(lastLine), equalTo(textSize * 1.2f))
}
@Test
fun lineSpacingMultiplier_whenOneLine_hasNoEffect() {
val text = "abc"
- val textSize = 20.0
+ val textSize = 20.0f
val layoutWidth = textSize * text.length
- val lineSpacingMultiplier = 1.5
+ val lineSpacingMultiplier = 1.5f
val textPaint = TextPaint()
textPaint.typeface = sampleTypeface
- textPaint.textSize = textSize.toFloat()
+ textPaint.textSize = textSize
val layout = TextLayout(
charSequence = text,
@@ -285,19 +285,19 @@
assertThat(layout.lineCount, equalTo(1))
// In the sample_font.ttf, the height of the line should be
// fontSize + 0.2 * fontSize(line gap)
- assertThat(layout.getLineHeight(0), equalTo(textSize * 1.2))
+ assertThat(layout.getLineHeight(0), equalTo(textSize * 1.2f))
}
@Test
fun lineSpacingMultiplier_whenOneLine_withTextRTL_hasNoEffect() {
val text = "\u05D0\u05D0\u05D0"
- val textSize = 20.0
+ val textSize = 20.0f
val layoutWidth = textSize * text.length
- val lineSpacingMultiplier = 1.5
+ val lineSpacingMultiplier = 1.5f
val textPaint = TextPaint()
textPaint.typeface = sampleTypeface
- textPaint.textSize = textSize.toFloat()
+ textPaint.textSize = textSize
val layout = TextLayout(
charSequence = text,
@@ -312,6 +312,6 @@
assertThat(layout.lineCount, equalTo(1))
// In the sample_font.ttf, the height of the line should be
// fontSize + 0.2 * fontSize(line gap)
- assertThat(layout.getLineHeight(0), equalTo(textSize * 1.2))
+ assertThat(layout.getLineHeight(0), equalTo(textSize * 1.2f))
}
}
\ No newline at end of file
diff --git a/ui/text/src/main/java/androidx/text/StaticLayoutCompat.java b/ui/text/src/main/java/androidx/text/StaticLayoutCompat.java
index 38c0f18..fcfecaa 100644
--- a/ui/text/src/main/java/androidx/text/StaticLayoutCompat.java
+++ b/ui/text/src/main/java/androidx/text/StaticLayoutCompat.java
@@ -113,7 +113,7 @@
private float mLineSpacingExtra;
- @FloatRange(from = 0.0)
+ @FloatRange(from = 0.0f)
float mLineSpacingMultiplier;
boolean mIncludePadding;
@@ -314,7 +314,7 @@
*/
@NonNull
public Builder setLineSpacingMultiplier(
- @FloatRange(from = 0.0) float lineSpacingMultiplier) {
+ @FloatRange(from = 0.0f) float lineSpacingMultiplier) {
mLineSpacingMultiplier = Preconditions.checkArgumentInRange(lineSpacingMultiplier,
0.0f, Float.MAX_VALUE, "LineSpacingMultiplier");
return this;
diff --git a/ui/text/src/main/java/androidx/text/TextLayout.kt b/ui/text/src/main/java/androidx/text/TextLayout.kt
index 52301f2..b3bf5d6 100644
--- a/ui/text/src/main/java/androidx/text/TextLayout.kt
+++ b/ui/text/src/main/java/androidx/text/TextLayout.kt
@@ -56,13 +56,13 @@
@RestrictTo(RestrictTo.Scope.LIBRARY)
class TextLayout constructor(
charSequence: CharSequence,
- width: Double = 0.0,
+ width: Float = 0.0f,
textPaint: TextPaint,
@TextLayoutAlignment alignment: Int = DEFAULT_ALIGNMENT,
ellipsize: TextUtils.TruncateAt? = null,
@TextDirection textDirectionHeuristic: Int = DEFAULT_TEXT_DIRECTION,
- lineSpacingMultiplier: Double = DEFAULT_LINESPACING_MULTIPLIER.toDouble(),
- lineSpacingExtra: Double = DEFAULT_LINESPACING_EXTRA.toDouble(),
+ lineSpacingMultiplier: Float = DEFAULT_LINESPACING_MULTIPLIER,
+ lineSpacingExtra: Float = DEFAULT_LINESPACING_EXTRA,
includePadding: Boolean = true,
maxLines: Int = Int.MAX_VALUE,
@BreakStrategy breakStrategy: Int = DEFAULT_BREAK_STRATEGY,
@@ -71,7 +71,7 @@
leftIndents: IntArray? = null,
rightIndents: IntArray? = null
) {
- val maxIntrinsicWidth: Double
+ val maxIntrinsicWidth: Float
val layout: Layout
val didExceedMaxLines: Boolean
@@ -81,9 +81,9 @@
val frameworkTextDir = getTextDirectionHeuristic(textDirectionHeuristic)
val boringMetrics = BoringLayoutCompat.isBoring(charSequence, textPaint, frameworkTextDir)
- maxIntrinsicWidth = boringMetrics?.width?.toDouble()
+ maxIntrinsicWidth = boringMetrics?.width?.toFloat()
// we may need to getWidthWithLimits(maxWidth: Int, maxLines: Int)
- ?: Layout.getDesiredWidth(charSequence, start, end, textPaint).toDouble()
+ ?: Layout.getDesiredWidth(charSequence, start, end, textPaint)
val finalWidth = width.toInt()
val ellipsizeWidth = finalWidth
@@ -110,8 +110,8 @@
)
.setAlignment(frameworkAlignment)
.setTextDirection(frameworkTextDirectionHeuristic)
- .setLineSpacingExtra(lineSpacingExtra.toFloat())
- .setLineSpacingMultiplier(lineSpacingMultiplier.toFloat())
+ .setLineSpacingExtra(lineSpacingExtra)
+ .setLineSpacingMultiplier(lineSpacingMultiplier)
.setIncludePad(includePadding)
.setEllipsize(ellipsize)
.setEllipsizedWidth(ellipsizeWidth)
@@ -145,20 +145,20 @@
val text: CharSequence
get() = layout.text
- fun getLineLeft(index: Int): Double {
- return layout.getLineLeft(index).toDouble()
+ fun getLineLeft(index: Int): Float {
+ return layout.getLineLeft(index)
}
- fun getLineRight(index: Int): Double {
- return layout.getLineRight(index).toDouble()
+ fun getLineRight(index: Int): Float {
+ return layout.getLineRight(index)
}
- fun getLineHeight(index: Int): Double {
- return (layout.getLineBottom(index) - layout.getLineTop(index)).toDouble()
+ fun getLineHeight(index: Int): Float {
+ return (layout.getLineBottom(index) - layout.getLineTop(index)).toFloat()
}
- fun getLineWidth(index: Int): Double {
- return layout.getLineWidth(index).toDouble()
+ fun getLineWidth(index: Int): Float {
+ return layout.getLineWidth(index)
}
fun paint(canvas: Canvas) {