Added VectorPainter API
Relnote: "Added VectorPainter API to
replace existing subcomposition API for
vector graphics. Result of subcomposition
is a VectorPainter object instead of a
DrawModifier. Deprecated previous DrawVector
composables in favor of VectorPainter.
Renamed Image(Painter) API to PaintBox(Painter)
Created Vector composable that behaves like the
Image composable except with a VectorAsset instead
of an ImageAsset"
Test: Created VectorTest
Bug: b/149030271
Change-Id: I9af9a365eb744e0cdb343cf424f4df5160d6c2b4
diff --git a/ui/integration-tests/test/src/main/java/androidx/ui/integration/test/framework/VectorAssetTestCase.kt b/ui/integration-tests/test/src/main/java/androidx/ui/integration/test/framework/VectorAssetTestCase.kt
index cd82d10..17b2167 100644
--- a/ui/integration-tests/test/src/main/java/androidx/ui/integration/test/framework/VectorAssetTestCase.kt
+++ b/ui/integration-tests/test/src/main/java/androidx/ui/integration/test/framework/VectorAssetTestCase.kt
@@ -19,6 +19,7 @@
import androidx.compose.Composable
import androidx.ui.core.TestTag
import androidx.ui.foundation.Box
+import androidx.ui.core.asModifier
import androidx.ui.unit.dp
import androidx.ui.graphics.Color
import androidx.ui.graphics.SolidColor
@@ -27,7 +28,7 @@
import androidx.ui.graphics.vector.PathData
import androidx.ui.graphics.vector.VectorAsset
import androidx.ui.graphics.vector.VectorAssetBuilder
-import androidx.ui.graphics.vector.drawVector
+import androidx.ui.graphics.vector.VectorPainter
import androidx.ui.layout.LayoutSize
import androidx.ui.res.vectorResource
import androidx.ui.semantics.Semantics
@@ -46,7 +47,7 @@
Box {
TestTag(testTag) {
Semantics(container = true) {
- val background = drawVector(vectorImage = getVectorAsset())
+ val background = VectorPainter(getVectorAsset()).asModifier()
Box(LayoutSize(24.dp) + background)
}
}
diff --git a/ui/ui-foundation/api/0.1.0-dev07.txt b/ui/ui-foundation/api/0.1.0-dev07.txt
index 69e28a1..b48068e 100644
--- a/ui/ui-foundation/api/0.1.0-dev07.txt
+++ b/ui/ui-foundation/api/0.1.0-dev07.txt
@@ -99,7 +99,8 @@
}
public final class ImageKt {
- method public static void Image(androidx.ui.graphics.ImageAsset image, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
+ method public static inline void Image(androidx.ui.graphics.ImageAsset asset, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
+ method public static inline void Image(androidx.ui.graphics.vector.VectorAsset asset, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
method public static void Image(androidx.ui.graphics.painter.Painter painter, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
method @Deprecated public static void SimpleImage(androidx.ui.graphics.ImageAsset image, androidx.ui.graphics.Color? tint = null);
}
diff --git a/ui/ui-foundation/api/current.txt b/ui/ui-foundation/api/current.txt
index 69e28a1..b48068e 100644
--- a/ui/ui-foundation/api/current.txt
+++ b/ui/ui-foundation/api/current.txt
@@ -99,7 +99,8 @@
}
public final class ImageKt {
- method public static void Image(androidx.ui.graphics.ImageAsset image, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
+ method public static inline void Image(androidx.ui.graphics.ImageAsset asset, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
+ method public static inline void Image(androidx.ui.graphics.vector.VectorAsset asset, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
method public static void Image(androidx.ui.graphics.painter.Painter painter, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
method @Deprecated public static void SimpleImage(androidx.ui.graphics.ImageAsset image, androidx.ui.graphics.Color? tint = null);
}
diff --git a/ui/ui-foundation/api/public_plus_experimental_0.1.0-dev07.txt b/ui/ui-foundation/api/public_plus_experimental_0.1.0-dev07.txt
index 69e28a1..b48068e 100644
--- a/ui/ui-foundation/api/public_plus_experimental_0.1.0-dev07.txt
+++ b/ui/ui-foundation/api/public_plus_experimental_0.1.0-dev07.txt
@@ -99,7 +99,8 @@
}
public final class ImageKt {
- method public static void Image(androidx.ui.graphics.ImageAsset image, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
+ method public static inline void Image(androidx.ui.graphics.ImageAsset asset, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
+ method public static inline void Image(androidx.ui.graphics.vector.VectorAsset asset, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
method public static void Image(androidx.ui.graphics.painter.Painter painter, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
method @Deprecated public static void SimpleImage(androidx.ui.graphics.ImageAsset image, androidx.ui.graphics.Color? tint = null);
}
diff --git a/ui/ui-foundation/api/public_plus_experimental_current.txt b/ui/ui-foundation/api/public_plus_experimental_current.txt
index 69e28a1..b48068e 100644
--- a/ui/ui-foundation/api/public_plus_experimental_current.txt
+++ b/ui/ui-foundation/api/public_plus_experimental_current.txt
@@ -99,7 +99,8 @@
}
public final class ImageKt {
- method public static void Image(androidx.ui.graphics.ImageAsset image, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
+ method public static inline void Image(androidx.ui.graphics.ImageAsset asset, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
+ method public static inline void Image(androidx.ui.graphics.vector.VectorAsset asset, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
method public static void Image(androidx.ui.graphics.painter.Painter painter, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
method @Deprecated public static void SimpleImage(androidx.ui.graphics.ImageAsset image, androidx.ui.graphics.Color? tint = null);
}
diff --git a/ui/ui-foundation/api/restricted_0.1.0-dev07.txt b/ui/ui-foundation/api/restricted_0.1.0-dev07.txt
index 69e28a1..b48068e 100644
--- a/ui/ui-foundation/api/restricted_0.1.0-dev07.txt
+++ b/ui/ui-foundation/api/restricted_0.1.0-dev07.txt
@@ -99,7 +99,8 @@
}
public final class ImageKt {
- method public static void Image(androidx.ui.graphics.ImageAsset image, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
+ method public static inline void Image(androidx.ui.graphics.ImageAsset asset, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
+ method public static inline void Image(androidx.ui.graphics.vector.VectorAsset asset, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
method public static void Image(androidx.ui.graphics.painter.Painter painter, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
method @Deprecated public static void SimpleImage(androidx.ui.graphics.ImageAsset image, androidx.ui.graphics.Color? tint = null);
}
diff --git a/ui/ui-foundation/api/restricted_current.txt b/ui/ui-foundation/api/restricted_current.txt
index 69e28a1..b48068e 100644
--- a/ui/ui-foundation/api/restricted_current.txt
+++ b/ui/ui-foundation/api/restricted_current.txt
@@ -99,7 +99,8 @@
}
public final class ImageKt {
- method public static void Image(androidx.ui.graphics.ImageAsset image, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
+ method public static inline void Image(androidx.ui.graphics.ImageAsset asset, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
+ method public static inline void Image(androidx.ui.graphics.vector.VectorAsset asset, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
method public static void Image(androidx.ui.graphics.painter.Painter painter, androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, float alpha = 1.0f, androidx.ui.graphics.ColorFilter? colorFilter = null);
method @Deprecated public static void SimpleImage(androidx.ui.graphics.ImageAsset image, androidx.ui.graphics.Color? tint = null);
}
diff --git a/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/ImageSamples.kt b/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/ImageSamples.kt
index 5dbd5c9..929b7f2 100644
--- a/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/ImageSamples.kt
+++ b/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/ImageSamples.kt
@@ -18,19 +18,66 @@
import androidx.annotation.Sampled
import androidx.compose.Composable
+import androidx.compose.remember
import androidx.ui.foundation.Image
import androidx.ui.geometry.Offset
+import androidx.ui.geometry.Rect
import androidx.ui.graphics.Canvas
import androidx.ui.graphics.Color
+import androidx.ui.graphics.ColorFilter
import androidx.ui.graphics.ImageAsset
import androidx.ui.graphics.Paint
+import androidx.ui.graphics.ScaleFit
+import androidx.ui.graphics.painter.Painter
+import androidx.ui.layout.LayoutSize
+import androidx.ui.res.loadVectorResource
+import androidx.ui.unit.PxSize
+import androidx.ui.unit.dp
+import androidx.ui.unit.px
@Sampled
@Composable
fun ImageSample() {
val imageAsset = createTestImage()
// Lays out and draws an image sized to the dimensions of the ImageAsset
- Image(image = imageAsset)
+ Image(asset = imageAsset)
+}
+
+@Sampled
+@Composable
+fun ImageVectorAssetSample() {
+ val vectorAsset = loadVectorResource(R.drawable.ic_sample_vector)
+ vectorAsset.resource.resource?.let {
+ Image(
+ asset = it,
+ modifier = LayoutSize(200.dp, 200.dp),
+ scaleFit = ScaleFit.FillMinDimension,
+ colorFilter = ColorFilter.tint(Color.Cyan)
+ )
+ }
+}
+
+@Sampled
+@Composable
+fun ImagePainterSample() {
+ val customPainter = remember {
+ object : Painter() {
+
+ val paint = Paint().apply { this.color = Color.Cyan }
+
+ override val intrinsicSize: PxSize
+ get() = PxSize(100.px, 100.px)
+
+ override fun onDraw(canvas: Canvas, bounds: PxSize) {
+ canvas.drawRect(
+ Rect.fromLTWH(0.0f, 0.0f, bounds.width.value, bounds.height.value),
+ paint
+ )
+ }
+ }
+ }
+
+ Image(painter = customPainter, modifier = LayoutSize(100.dp, 100.dp))
}
/**
diff --git a/ui/ui-foundation/samples/src/main/res/drawable/ic_sample_vector.xml b/ui/ui-foundation/samples/src/main/res/drawable/ic_sample_vector.xml
new file mode 100644
index 0000000..d49a476
--- /dev/null
+++ b/ui/ui-foundation/samples/src/main/res/drawable/ic_sample_vector.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#000000"
+ android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
+</vector>
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ImageTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ImageTest.kt
index 5cbfb60..62ac258 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ImageTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ImageTest.kt
@@ -22,6 +22,7 @@
import androidx.ui.core.Alignment
import androidx.ui.core.DensityAmbient
import androidx.ui.core.TestTag
+import androidx.ui.foundation.test.R
import androidx.ui.test.createComposeRule
import androidx.ui.geometry.Rect
import androidx.ui.graphics.Canvas
@@ -30,10 +31,10 @@
import androidx.ui.graphics.Paint
import androidx.ui.graphics.Path
import androidx.ui.graphics.ScaleFit
-import androidx.ui.graphics.painter.ColorPainter
import androidx.ui.graphics.toArgb
import androidx.ui.layout.LayoutAlign
import androidx.ui.layout.LayoutSize
+import androidx.ui.res.loadVectorResource
import androidx.ui.test.captureToBitmap
import androidx.ui.test.findByTag
import androidx.ui.unit.dp
@@ -92,7 +93,7 @@
val size = (containerSize / DensityAmbient.current.density).dp
Box(modifier = LayoutSize(size) + DrawBackground(Color.White) + LayoutAlign.Center) {
TestTag(contentTag) {
- Image(image = createImageAsset())
+ Image(asset = createImageAsset())
}
}
}
@@ -125,7 +126,7 @@
// The resultant Image composable should be twice the size of the underlying
// ImageAsset that is to be drawn and will stretch the content to fit
// the bounds
- Image(image = createImageAsset(),
+ Image(asset = createImageAsset(),
modifier = LayoutSize(
(imageComposableWidth / density).dp,
(imageComposableHeight / density).dp
@@ -163,7 +164,7 @@
TestTag(contentTag) {
// The resultant Image composable should be twice the size of the underlying
// ImageAsset that is to be drawn in the bottom end section of the composable
- Image(image = createImageAsset(),
+ Image(asset = createImageAsset(),
modifier = LayoutSize(
(imageComposableWidth / density).dp,
(imageComposableHeight / density).dp
@@ -192,20 +193,23 @@
}
@Test
- fun testImageMinSizeCentered() {
+ fun testVectorScaledCentered() {
+ val boxWidth = 240
+ val boxHeight = 240
rule.setContent {
val density = DensityAmbient.current.density
- val size = (containerSize * 2 / density).dp
- val minWidth = (imageWidth / density).dp
- val minHeight = (imageHeight / density).dp
+ val size = (boxWidth * 2 / density).dp
+ val minWidth = (boxWidth / density).dp
+ val minHeight = (boxHeight / density).dp
Box(modifier = LayoutSize(size) + DrawBackground(Color.White) + LayoutAlign.Center) {
TestTag(contentTag) {
- // The resultant Image composable should be sized to the minimum values here
- // as [ColorPainter] has no intrinsic width or height
- Image(painter = ColorPainter(Color.Red),
- modifier = LayoutSize.Min(minWidth, minHeight),
- alignment = Alignment.Center
- )
+ loadVectorResource(R.drawable.ic_vector_asset_test).resource.resource?.let {
+ Image(
+ it,
+ modifier = LayoutSize.Min(minWidth, minHeight),
+ scaleFit = ScaleFit.FillMinDimension
+ )
+ }
}
}
}
@@ -213,23 +217,23 @@
val imageColor = Color.Red.toArgb()
val containerBgColor = Color.White.toArgb()
findByTag(contentTag).captureToBitmap().apply {
- val imageStartX = width / 2 - imageWidth / 2
- val imageStartY = height / 2 - imageHeight / 2
+ val imageStartX = width / 2 - boxWidth / 2
+ val imageStartY = height / 2 - boxHeight / 2
Assert.assertEquals(containerBgColor, getPixel(imageStartX - 1, imageStartY - 1))
- Assert.assertEquals(containerBgColor, getPixel(imageStartX + imageWidth + 1,
+ Assert.assertEquals(containerBgColor, getPixel(imageStartX + boxWidth + 1,
imageStartY - 1))
- Assert.assertEquals(containerBgColor, getPixel(imageStartX + imageWidth + 1,
- imageStartY + imageHeight + 1))
+ Assert.assertEquals(containerBgColor, getPixel(imageStartX + boxWidth + 1,
+ imageStartY + boxHeight + 1))
Assert.assertEquals(containerBgColor, getPixel(imageStartX - 1, imageStartY +
- imageHeight + 1))
+ boxHeight + 1))
- Assert.assertEquals(imageColor, getPixel(imageStartX, imageStartY))
- Assert.assertEquals(imageColor, getPixel(imageStartX + imageWidth - 1,
- imageStartY))
- Assert.assertEquals(imageColor, getPixel(imageStartX + imageWidth - 1,
- imageStartY + imageHeight - 1))
+ Assert.assertEquals(imageColor, getPixel(imageStartX, imageStartY + 15))
+ Assert.assertEquals(containerBgColor, getPixel(imageStartX + boxWidth - 2,
+ imageStartY - 1))
+ Assert.assertEquals(imageColor, getPixel(imageStartX + boxWidth - 10,
+ imageStartY + boxHeight - 2))
Assert.assertEquals(imageColor, getPixel(imageStartX, imageStartY +
- imageHeight - 1))
+ boxHeight - 2))
}
}
}
\ No newline at end of file
diff --git a/ui/ui-foundation/src/androidTest/res/drawable/ic_vector_asset_test.xml b/ui/ui-foundation/src/androidTest/res/drawable/ic_vector_asset_test.xml
new file mode 100644
index 0000000..bbe937e
--- /dev/null
+++ b/ui/ui-foundation/src/androidTest/res/drawable/ic_vector_asset_test.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FF0000"
+ android:pathData="L24,24,0,24z"/>
+</vector>
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Icon.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Icon.kt
index aa50260..af39c13 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Icon.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Icon.kt
@@ -25,7 +25,7 @@
import androidx.ui.graphics.ColorFilter
import androidx.ui.graphics.painter.Painter
import androidx.ui.graphics.vector.VectorAsset
-import androidx.ui.graphics.vector.drawVector
+import androidx.ui.graphics.vector.VectorPainter
import androidx.ui.layout.LayoutHeight
import androidx.ui.layout.LayoutSize
import androidx.ui.layout.LayoutWidth
@@ -52,7 +52,7 @@
// TODO: b/149735981 semantics for content description
Box(
modifier = modifier + LayoutWidth(icon.defaultWidth) + LayoutHeight(icon.defaultHeight) +
- drawVector(vectorImage = icon, tintColor = tint)
+ VectorPainter(icon).asModifier(colorFilter = ColorFilter.tint(tint))
) {
}
}
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Image.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Image.kt
index 3801812..d50d21e 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Image.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Image.kt
@@ -20,11 +20,10 @@
import androidx.compose.remember
import androidx.ui.core.Alignment
import androidx.ui.core.DensityAmbient
-import androidx.ui.core.DrawModifier
+import androidx.ui.core.DrawClipToBounds
import androidx.ui.core.Modifier
import androidx.ui.core.asModifier
import androidx.ui.graphics.BlendMode
-import androidx.ui.graphics.Canvas
import androidx.ui.graphics.Color
import androidx.ui.graphics.ColorFilter
import androidx.ui.graphics.DefaultAlpha
@@ -33,10 +32,9 @@
import androidx.ui.graphics.painter.ColorPainter
import androidx.ui.graphics.painter.ImagePainter
import androidx.ui.graphics.painter.Painter
+import androidx.ui.graphics.vector.VectorAsset
+import androidx.ui.graphics.vector.VectorPainter
import androidx.ui.layout.LayoutSize
-import androidx.ui.unit.Density
-import androidx.ui.unit.PxSize
-import androidx.ui.unit.toRect
/**
* A composable that lays out and draws a given [ImageAsset]. This will attempt to
@@ -47,7 +45,7 @@
*
* @sample androidx.ui.foundation.samples.ImageSample
*
- * @param image The [ImageAsset] to draw.
+ * @param asset The [ImageAsset] to draw.
* @param modifier Modifier used to adjust the layout algorithm or draw decoration content (ex.
* background)
* @param alignment Optional alignment parameter used to place the [ImageAsset] in the given
@@ -58,18 +56,17 @@
* @param colorFilter Optional ColorFilter to apply for the [ImageAsset] when it is rendered
* onscreen
*/
+@Suppress("NOTHING_TO_INLINE")
@Composable
-fun Image(
- image: ImageAsset,
+inline fun Image(
+ asset: ImageAsset,
modifier: Modifier = Modifier.None,
alignment: Alignment = Alignment.Center,
scaleFit: ScaleFit = ScaleFit.Fit,
alpha: Float = DefaultAlpha,
colorFilter: ColorFilter? = null
) {
- val imagePainter = remember(image) { ImagePainter(image) }
- // Min width/height are intentionally not provided in this call as they are consumed
- // from the ImagePainter directly
+ val imagePainter = remember(asset) { ImagePainter(asset) }
Image(
painter = imagePainter,
modifier = modifier,
@@ -81,6 +78,44 @@
}
/**
+ * A composable that lays out and draws a given [VectorAsset]. This will attempt to
+ * size the composable according to the [VectorAsset]'s given width and height. However, an
+ * optional [Modifier] parameter can be provided to adjust sizing or draw additional content (ex.
+ * background). Any unspecified dimension will leverage the [VectorAsset]'s size as a minimum
+ * constraint.
+ *
+ * @sample androidx.ui.foundation.samples.ImageVectorAssetSample
+ *
+ * @param asset The [VectorAsset] to draw.
+ * @param modifier Modifier used to adjust the layout algorithm or draw decoration content (ex.
+ * background)
+ * @param alignment Optional alignment parameter used to place the [VectorAsset] in the given
+ * bounds defined by the width and height.
+ * @param scaleFit Optional scale parameter used to determine the aspect ratio scaling to be used
+ * if the bounds are a different size from the intrinsic size of the [VectorAsset].
+ * @param alpha Optional opacity to be applied to the [VectorAsset] when it is rendered onscreen
+ * @param colorFilter Optional ColorFilter to apply for the [VectorAsset] when it is rendered
+ * onscreen
+ */
+@Suppress("NOTHING_TO_INLINE")
+@Composable
+inline fun Image(
+ asset: VectorAsset,
+ modifier: Modifier = Modifier.None,
+ alignment: Alignment = Alignment.Center,
+ scaleFit: ScaleFit = ScaleFit.Fit,
+ alpha: Float = DefaultAlpha,
+ colorFilter: ColorFilter? = null
+) = Image(
+ painter = VectorPainter(asset),
+ modifier = modifier,
+ alignment = alignment,
+ scaleFit = scaleFit,
+ alpha = alpha,
+ colorFilter = colorFilter
+)
+
+/**
* Creates a composable that lays out and draws a given [Painter]. This will attempt to size
* the composable according to the [Painter]'s intrinsic size. However, an optional [Modifier]
* parameter can be provided to adjust sizing or draw additional content (ex. background)
@@ -90,6 +125,8 @@
* of zero and will not draw any content. This can happen for Painter implementations that
* always attempt to fill the bounds like [ColorPainter]
*
+ * @sample androidx.ui.foundation.samples.ImagePainterSample
+ *
* @param painter to draw
* @param modifier Modifier used to adjust the layout algorithm or draw decoration content (ex.
* background)
@@ -117,7 +154,7 @@
colorFilter = colorFilter
)
- Box(modifier + ClipModifier + painterModifier)
+ Box(modifier + DrawClipToBounds + painterModifier)
}
/**
@@ -148,17 +185,10 @@
scaleFit = ScaleFit.FillMaxDimension,
colorFilter = tint?.let { ColorFilter(it, BlendMode.srcIn) }
)
- Box(LayoutSize(image.width.toDp(), image.height.toDp()) + ClipModifier + imageModifier)
- }
-}
-
-// TODO(mount, malkov) : remove when RepaintBoundary is a modifier: b/149982905
-// This is class and not val because if b/149985596
-private object ClipModifier : DrawModifier {
- override fun draw(density: Density, drawContent: () -> Unit, canvas: Canvas, size: PxSize) {
- canvas.save()
- canvas.clipRect(size.toRect())
- drawContent()
- canvas.restore()
+ Box(
+ LayoutSize(image.width.toDp(), image.height.toDp()) +
+ DrawClipToBounds +
+ imageModifier
+ )
}
}
\ No newline at end of file
diff --git a/ui/ui-framework/api/0.1.0-dev07.txt b/ui/ui-framework/api/0.1.0-dev07.txt
index a3de8af..a040aab 100644
--- a/ui/ui-framework/api/0.1.0-dev07.txt
+++ b/ui/ui-framework/api/0.1.0-dev07.txt
@@ -401,13 +401,13 @@
}
public final class VectorAssetKt {
- method public static androidx.ui.core.Modifier drawVector(androidx.ui.graphics.vector.VectorAsset vectorImage, androidx.ui.graphics.Color tintColor = Color.Transparent, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit fit = ScaleFit.Fit);
+ method @Deprecated public static androidx.ui.core.Modifier drawVector(androidx.ui.graphics.vector.VectorAsset vectorImage, androidx.ui.graphics.Color tintColor = Color.Transparent, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit fit = ScaleFit.Fit);
}
public final class VectorComposeKt {
method public static void Group(androidx.ui.graphics.vector.VectorScope, String name = "", float rotation = 0.0f, float pivotX = 0.0f, float pivotY = 0.0f, float scaleX = 1.0f, float scaleY = 1.0f, float translationX = 0.0f, float translationY = 0.0f, java.util.List<? extends androidx.ui.graphics.vector.PathNode> clipPathData = EmptyPath, kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.VectorScope,kotlin.Unit> children);
method public static void Path(androidx.ui.graphics.vector.VectorScope, java.util.List<? extends androidx.ui.graphics.vector.PathNode> pathData, String name = "", androidx.ui.graphics.Brush? fill = null, float fillAlpha = 1.0f, androidx.ui.graphics.Brush? stroke = null, float strokeAlpha = 1.0f, float strokeLineWidth = 0.0f, androidx.ui.graphics.StrokeCap strokeLineCap = DefaultStrokeLineCap, androidx.ui.graphics.StrokeJoin strokeLineJoin = DefaultStrokeLineJoin, float strokeLineMiter = 4.0f);
- method public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = -1.0f, float viewportHeight = -1.0f, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
+ method @Deprecated public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = -1.0f, float viewportHeight = -1.0f, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
method public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight, float viewportWidth = defaultWidth.value, float viewportHeight = defaultHeight.value, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
}
@@ -432,6 +432,18 @@
public abstract sealed class VectorNode {
}
+ public final class VectorPainter extends androidx.ui.graphics.painter.Painter {
+ method public androidx.ui.unit.PxSize getIntrinsicSize();
+ method protected void onDraw(androidx.ui.graphics.Canvas canvas, androidx.ui.unit.PxSize bounds);
+ property public androidx.ui.unit.PxSize intrinsicSize;
+ }
+
+ public final class VectorPainterKt {
+ method public static androidx.ui.graphics.vector.VectorPainter VectorPainter(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = Float.NaN, float viewportHeight = Float.NaN, String name = "VectorRootGroup", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
+ method public static androidx.ui.graphics.vector.VectorPainter VectorPainter(androidx.ui.graphics.vector.VectorAsset asset);
+ field public static final String RootGroupName = "VectorRootGroup";
+ }
+
public final class VectorPath extends androidx.ui.graphics.vector.VectorNode {
ctor public VectorPath(String name, java.util.List<? extends androidx.ui.graphics.vector.PathNode> pathData, androidx.ui.graphics.Brush? fill, float fillAlpha, androidx.ui.graphics.Brush? stroke, float strokeAlpha, float strokeLineWidth, androidx.ui.graphics.StrokeCap strokeLineCap, androidx.ui.graphics.StrokeJoin strokeLineJoin, float strokeLineMiter);
method public String component1();
diff --git a/ui/ui-framework/api/current.txt b/ui/ui-framework/api/current.txt
index a3de8af..a040aab 100644
--- a/ui/ui-framework/api/current.txt
+++ b/ui/ui-framework/api/current.txt
@@ -401,13 +401,13 @@
}
public final class VectorAssetKt {
- method public static androidx.ui.core.Modifier drawVector(androidx.ui.graphics.vector.VectorAsset vectorImage, androidx.ui.graphics.Color tintColor = Color.Transparent, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit fit = ScaleFit.Fit);
+ method @Deprecated public static androidx.ui.core.Modifier drawVector(androidx.ui.graphics.vector.VectorAsset vectorImage, androidx.ui.graphics.Color tintColor = Color.Transparent, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit fit = ScaleFit.Fit);
}
public final class VectorComposeKt {
method public static void Group(androidx.ui.graphics.vector.VectorScope, String name = "", float rotation = 0.0f, float pivotX = 0.0f, float pivotY = 0.0f, float scaleX = 1.0f, float scaleY = 1.0f, float translationX = 0.0f, float translationY = 0.0f, java.util.List<? extends androidx.ui.graphics.vector.PathNode> clipPathData = EmptyPath, kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.VectorScope,kotlin.Unit> children);
method public static void Path(androidx.ui.graphics.vector.VectorScope, java.util.List<? extends androidx.ui.graphics.vector.PathNode> pathData, String name = "", androidx.ui.graphics.Brush? fill = null, float fillAlpha = 1.0f, androidx.ui.graphics.Brush? stroke = null, float strokeAlpha = 1.0f, float strokeLineWidth = 0.0f, androidx.ui.graphics.StrokeCap strokeLineCap = DefaultStrokeLineCap, androidx.ui.graphics.StrokeJoin strokeLineJoin = DefaultStrokeLineJoin, float strokeLineMiter = 4.0f);
- method public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = -1.0f, float viewportHeight = -1.0f, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
+ method @Deprecated public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = -1.0f, float viewportHeight = -1.0f, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
method public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight, float viewportWidth = defaultWidth.value, float viewportHeight = defaultHeight.value, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
}
@@ -432,6 +432,18 @@
public abstract sealed class VectorNode {
}
+ public final class VectorPainter extends androidx.ui.graphics.painter.Painter {
+ method public androidx.ui.unit.PxSize getIntrinsicSize();
+ method protected void onDraw(androidx.ui.graphics.Canvas canvas, androidx.ui.unit.PxSize bounds);
+ property public androidx.ui.unit.PxSize intrinsicSize;
+ }
+
+ public final class VectorPainterKt {
+ method public static androidx.ui.graphics.vector.VectorPainter VectorPainter(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = Float.NaN, float viewportHeight = Float.NaN, String name = "VectorRootGroup", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
+ method public static androidx.ui.graphics.vector.VectorPainter VectorPainter(androidx.ui.graphics.vector.VectorAsset asset);
+ field public static final String RootGroupName = "VectorRootGroup";
+ }
+
public final class VectorPath extends androidx.ui.graphics.vector.VectorNode {
ctor public VectorPath(String name, java.util.List<? extends androidx.ui.graphics.vector.PathNode> pathData, androidx.ui.graphics.Brush? fill, float fillAlpha, androidx.ui.graphics.Brush? stroke, float strokeAlpha, float strokeLineWidth, androidx.ui.graphics.StrokeCap strokeLineCap, androidx.ui.graphics.StrokeJoin strokeLineJoin, float strokeLineMiter);
method public String component1();
diff --git a/ui/ui-framework/api/public_plus_experimental_0.1.0-dev07.txt b/ui/ui-framework/api/public_plus_experimental_0.1.0-dev07.txt
index a3de8af..a040aab 100644
--- a/ui/ui-framework/api/public_plus_experimental_0.1.0-dev07.txt
+++ b/ui/ui-framework/api/public_plus_experimental_0.1.0-dev07.txt
@@ -401,13 +401,13 @@
}
public final class VectorAssetKt {
- method public static androidx.ui.core.Modifier drawVector(androidx.ui.graphics.vector.VectorAsset vectorImage, androidx.ui.graphics.Color tintColor = Color.Transparent, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit fit = ScaleFit.Fit);
+ method @Deprecated public static androidx.ui.core.Modifier drawVector(androidx.ui.graphics.vector.VectorAsset vectorImage, androidx.ui.graphics.Color tintColor = Color.Transparent, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit fit = ScaleFit.Fit);
}
public final class VectorComposeKt {
method public static void Group(androidx.ui.graphics.vector.VectorScope, String name = "", float rotation = 0.0f, float pivotX = 0.0f, float pivotY = 0.0f, float scaleX = 1.0f, float scaleY = 1.0f, float translationX = 0.0f, float translationY = 0.0f, java.util.List<? extends androidx.ui.graphics.vector.PathNode> clipPathData = EmptyPath, kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.VectorScope,kotlin.Unit> children);
method public static void Path(androidx.ui.graphics.vector.VectorScope, java.util.List<? extends androidx.ui.graphics.vector.PathNode> pathData, String name = "", androidx.ui.graphics.Brush? fill = null, float fillAlpha = 1.0f, androidx.ui.graphics.Brush? stroke = null, float strokeAlpha = 1.0f, float strokeLineWidth = 0.0f, androidx.ui.graphics.StrokeCap strokeLineCap = DefaultStrokeLineCap, androidx.ui.graphics.StrokeJoin strokeLineJoin = DefaultStrokeLineJoin, float strokeLineMiter = 4.0f);
- method public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = -1.0f, float viewportHeight = -1.0f, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
+ method @Deprecated public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = -1.0f, float viewportHeight = -1.0f, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
method public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight, float viewportWidth = defaultWidth.value, float viewportHeight = defaultHeight.value, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
}
@@ -432,6 +432,18 @@
public abstract sealed class VectorNode {
}
+ public final class VectorPainter extends androidx.ui.graphics.painter.Painter {
+ method public androidx.ui.unit.PxSize getIntrinsicSize();
+ method protected void onDraw(androidx.ui.graphics.Canvas canvas, androidx.ui.unit.PxSize bounds);
+ property public androidx.ui.unit.PxSize intrinsicSize;
+ }
+
+ public final class VectorPainterKt {
+ method public static androidx.ui.graphics.vector.VectorPainter VectorPainter(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = Float.NaN, float viewportHeight = Float.NaN, String name = "VectorRootGroup", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
+ method public static androidx.ui.graphics.vector.VectorPainter VectorPainter(androidx.ui.graphics.vector.VectorAsset asset);
+ field public static final String RootGroupName = "VectorRootGroup";
+ }
+
public final class VectorPath extends androidx.ui.graphics.vector.VectorNode {
ctor public VectorPath(String name, java.util.List<? extends androidx.ui.graphics.vector.PathNode> pathData, androidx.ui.graphics.Brush? fill, float fillAlpha, androidx.ui.graphics.Brush? stroke, float strokeAlpha, float strokeLineWidth, androidx.ui.graphics.StrokeCap strokeLineCap, androidx.ui.graphics.StrokeJoin strokeLineJoin, float strokeLineMiter);
method public String component1();
diff --git a/ui/ui-framework/api/public_plus_experimental_current.txt b/ui/ui-framework/api/public_plus_experimental_current.txt
index a3de8af..a040aab 100644
--- a/ui/ui-framework/api/public_plus_experimental_current.txt
+++ b/ui/ui-framework/api/public_plus_experimental_current.txt
@@ -401,13 +401,13 @@
}
public final class VectorAssetKt {
- method public static androidx.ui.core.Modifier drawVector(androidx.ui.graphics.vector.VectorAsset vectorImage, androidx.ui.graphics.Color tintColor = Color.Transparent, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit fit = ScaleFit.Fit);
+ method @Deprecated public static androidx.ui.core.Modifier drawVector(androidx.ui.graphics.vector.VectorAsset vectorImage, androidx.ui.graphics.Color tintColor = Color.Transparent, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit fit = ScaleFit.Fit);
}
public final class VectorComposeKt {
method public static void Group(androidx.ui.graphics.vector.VectorScope, String name = "", float rotation = 0.0f, float pivotX = 0.0f, float pivotY = 0.0f, float scaleX = 1.0f, float scaleY = 1.0f, float translationX = 0.0f, float translationY = 0.0f, java.util.List<? extends androidx.ui.graphics.vector.PathNode> clipPathData = EmptyPath, kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.VectorScope,kotlin.Unit> children);
method public static void Path(androidx.ui.graphics.vector.VectorScope, java.util.List<? extends androidx.ui.graphics.vector.PathNode> pathData, String name = "", androidx.ui.graphics.Brush? fill = null, float fillAlpha = 1.0f, androidx.ui.graphics.Brush? stroke = null, float strokeAlpha = 1.0f, float strokeLineWidth = 0.0f, androidx.ui.graphics.StrokeCap strokeLineCap = DefaultStrokeLineCap, androidx.ui.graphics.StrokeJoin strokeLineJoin = DefaultStrokeLineJoin, float strokeLineMiter = 4.0f);
- method public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = -1.0f, float viewportHeight = -1.0f, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
+ method @Deprecated public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = -1.0f, float viewportHeight = -1.0f, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
method public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight, float viewportWidth = defaultWidth.value, float viewportHeight = defaultHeight.value, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
}
@@ -432,6 +432,18 @@
public abstract sealed class VectorNode {
}
+ public final class VectorPainter extends androidx.ui.graphics.painter.Painter {
+ method public androidx.ui.unit.PxSize getIntrinsicSize();
+ method protected void onDraw(androidx.ui.graphics.Canvas canvas, androidx.ui.unit.PxSize bounds);
+ property public androidx.ui.unit.PxSize intrinsicSize;
+ }
+
+ public final class VectorPainterKt {
+ method public static androidx.ui.graphics.vector.VectorPainter VectorPainter(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = Float.NaN, float viewportHeight = Float.NaN, String name = "VectorRootGroup", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
+ method public static androidx.ui.graphics.vector.VectorPainter VectorPainter(androidx.ui.graphics.vector.VectorAsset asset);
+ field public static final String RootGroupName = "VectorRootGroup";
+ }
+
public final class VectorPath extends androidx.ui.graphics.vector.VectorNode {
ctor public VectorPath(String name, java.util.List<? extends androidx.ui.graphics.vector.PathNode> pathData, androidx.ui.graphics.Brush? fill, float fillAlpha, androidx.ui.graphics.Brush? stroke, float strokeAlpha, float strokeLineWidth, androidx.ui.graphics.StrokeCap strokeLineCap, androidx.ui.graphics.StrokeJoin strokeLineJoin, float strokeLineMiter);
method public String component1();
diff --git a/ui/ui-framework/api/restricted_0.1.0-dev07.txt b/ui/ui-framework/api/restricted_0.1.0-dev07.txt
index ba28d26..012ac5c 100644
--- a/ui/ui-framework/api/restricted_0.1.0-dev07.txt
+++ b/ui/ui-framework/api/restricted_0.1.0-dev07.txt
@@ -401,13 +401,13 @@
}
public final class VectorAssetKt {
- method public static androidx.ui.core.Modifier drawVector(androidx.ui.graphics.vector.VectorAsset vectorImage, androidx.ui.graphics.Color tintColor = Color.Transparent, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit fit = ScaleFit.Fit);
+ method @Deprecated public static androidx.ui.core.Modifier drawVector(androidx.ui.graphics.vector.VectorAsset vectorImage, androidx.ui.graphics.Color tintColor = Color.Transparent, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit fit = ScaleFit.Fit);
}
public final class VectorComposeKt {
method public static void Group(androidx.ui.graphics.vector.VectorScope, String name = "", float rotation = 0.0f, float pivotX = 0.0f, float pivotY = 0.0f, float scaleX = 1.0f, float scaleY = 1.0f, float translationX = 0.0f, float translationY = 0.0f, java.util.List<? extends androidx.ui.graphics.vector.PathNode> clipPathData = EmptyPath, kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.VectorScope,kotlin.Unit> children);
method public static void Path(androidx.ui.graphics.vector.VectorScope, java.util.List<? extends androidx.ui.graphics.vector.PathNode> pathData, String name = "", androidx.ui.graphics.Brush? fill = null, float fillAlpha = 1.0f, androidx.ui.graphics.Brush? stroke = null, float strokeAlpha = 1.0f, float strokeLineWidth = 0.0f, androidx.ui.graphics.StrokeCap strokeLineCap = DefaultStrokeLineCap, androidx.ui.graphics.StrokeJoin strokeLineJoin = DefaultStrokeLineJoin, float strokeLineMiter = 4.0f);
- method public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = -1.0f, float viewportHeight = -1.0f, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
+ method @Deprecated public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = -1.0f, float viewportHeight = -1.0f, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
method public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight, float viewportWidth = defaultWidth.value, float viewportHeight = defaultHeight.value, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
}
@@ -432,6 +432,18 @@
public abstract sealed class VectorNode {
}
+ public final class VectorPainter extends androidx.ui.graphics.painter.Painter {
+ method public androidx.ui.unit.PxSize getIntrinsicSize();
+ method protected void onDraw(androidx.ui.graphics.Canvas canvas, androidx.ui.unit.PxSize bounds);
+ property public androidx.ui.unit.PxSize intrinsicSize;
+ }
+
+ public final class VectorPainterKt {
+ method public static androidx.ui.graphics.vector.VectorPainter VectorPainter(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = Float.NaN, float viewportHeight = Float.NaN, String name = "VectorRootGroup", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
+ method public static androidx.ui.graphics.vector.VectorPainter VectorPainter(androidx.ui.graphics.vector.VectorAsset asset);
+ field public static final String RootGroupName = "VectorRootGroup";
+ }
+
public final class VectorPath extends androidx.ui.graphics.vector.VectorNode {
ctor public VectorPath(String name, java.util.List<? extends androidx.ui.graphics.vector.PathNode> pathData, androidx.ui.graphics.Brush? fill, float fillAlpha, androidx.ui.graphics.Brush? stroke, float strokeAlpha, float strokeLineWidth, androidx.ui.graphics.StrokeCap strokeLineCap, androidx.ui.graphics.StrokeJoin strokeLineJoin, float strokeLineMiter);
method public String component1();
diff --git a/ui/ui-framework/api/restricted_current.txt b/ui/ui-framework/api/restricted_current.txt
index ba28d26..012ac5c 100644
--- a/ui/ui-framework/api/restricted_current.txt
+++ b/ui/ui-framework/api/restricted_current.txt
@@ -401,13 +401,13 @@
}
public final class VectorAssetKt {
- method public static androidx.ui.core.Modifier drawVector(androidx.ui.graphics.vector.VectorAsset vectorImage, androidx.ui.graphics.Color tintColor = Color.Transparent, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit fit = ScaleFit.Fit);
+ method @Deprecated public static androidx.ui.core.Modifier drawVector(androidx.ui.graphics.vector.VectorAsset vectorImage, androidx.ui.graphics.Color tintColor = Color.Transparent, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = Alignment.Center, androidx.ui.graphics.ScaleFit fit = ScaleFit.Fit);
}
public final class VectorComposeKt {
method public static void Group(androidx.ui.graphics.vector.VectorScope, String name = "", float rotation = 0.0f, float pivotX = 0.0f, float pivotY = 0.0f, float scaleX = 1.0f, float scaleY = 1.0f, float translationX = 0.0f, float translationY = 0.0f, java.util.List<? extends androidx.ui.graphics.vector.PathNode> clipPathData = EmptyPath, kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.VectorScope,kotlin.Unit> children);
method public static void Path(androidx.ui.graphics.vector.VectorScope, java.util.List<? extends androidx.ui.graphics.vector.PathNode> pathData, String name = "", androidx.ui.graphics.Brush? fill = null, float fillAlpha = 1.0f, androidx.ui.graphics.Brush? stroke = null, float strokeAlpha = 1.0f, float strokeLineWidth = 0.0f, androidx.ui.graphics.StrokeCap strokeLineCap = DefaultStrokeLineCap, androidx.ui.graphics.StrokeJoin strokeLineJoin = DefaultStrokeLineJoin, float strokeLineMiter = 4.0f);
- method public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = -1.0f, float viewportHeight = -1.0f, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
+ method @Deprecated public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = -1.0f, float viewportHeight = -1.0f, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
method public static androidx.ui.core.Modifier drawVector(androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight, float viewportWidth = defaultWidth.value, float viewportHeight = defaultHeight.value, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode tintBlendMode = DefaultTintBlendMode, androidx.ui.core.Alignment alignment = androidx.ui.graphics.vector.VectorComposeKt.DefaultAlignment, androidx.ui.graphics.ScaleFit scaleFit = ScaleFit.Fit, String name = "", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
}
@@ -432,6 +432,18 @@
public abstract sealed class VectorNode {
}
+ public final class VectorPainter extends androidx.ui.graphics.painter.Painter {
+ method public androidx.ui.unit.PxSize getIntrinsicSize();
+ method protected void onDraw(androidx.ui.graphics.Canvas canvas, androidx.ui.unit.PxSize bounds);
+ property public androidx.ui.unit.PxSize intrinsicSize;
+ }
+
+ public final class VectorPainterKt {
+ method public static androidx.ui.graphics.vector.VectorPainter VectorPainter(androidx.ui.unit.Dp defaultWidth, androidx.ui.unit.Dp defaultHeight, float viewportWidth = Float.NaN, float viewportHeight = Float.NaN, String name = "VectorRootGroup", kotlin.jvm.functions.Function3<? super androidx.ui.graphics.vector.VectorScope,? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
+ method public static androidx.ui.graphics.vector.VectorPainter VectorPainter(androidx.ui.graphics.vector.VectorAsset asset);
+ field public static final String RootGroupName = "VectorRootGroup";
+ }
+
public final class VectorPath extends androidx.ui.graphics.vector.VectorNode {
ctor public VectorPath(String name, java.util.List<? extends androidx.ui.graphics.vector.PathNode> pathData, androidx.ui.graphics.Brush? fill, float fillAlpha, androidx.ui.graphics.Brush? stroke, float strokeAlpha, float strokeLineWidth, androidx.ui.graphics.StrokeCap strokeLineCap, androidx.ui.graphics.StrokeJoin strokeLineJoin, float strokeLineMiter);
method public String component1();
diff --git a/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/VectorGraphicsDemo.kt b/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/VectorGraphicsDemo.kt
index 0b80389..d1307a0 100644
--- a/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/VectorGraphicsDemo.kt
+++ b/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/VectorGraphicsDemo.kt
@@ -17,8 +17,7 @@
package androidx.ui.framework.demos
import androidx.compose.Composable
-import androidx.ui.core.Modifier
-import androidx.ui.foundation.Box
+import androidx.ui.foundation.Image
import androidx.ui.graphics.Color
import androidx.ui.graphics.HorizontalGradient
import androidx.ui.graphics.RadialGradient
@@ -26,14 +25,15 @@
import androidx.ui.graphics.SolidColor
import androidx.ui.graphics.TileMode
import androidx.ui.graphics.VerticalGradient
+import androidx.ui.graphics.painter.Painter
import androidx.ui.graphics.vector.Group
import androidx.ui.graphics.vector.Path
import androidx.ui.graphics.vector.PathBuilder
import androidx.ui.graphics.vector.PathData
+import androidx.ui.graphics.vector.VectorPainter
import androidx.ui.graphics.vector.VectorScope
-import androidx.ui.graphics.vector.drawVector
-import androidx.ui.layout.Center
import androidx.ui.layout.Column
+import androidx.ui.layout.LayoutAlign
import androidx.ui.layout.LayoutSize
import androidx.ui.res.loadVectorResource
import androidx.ui.unit.Dp
@@ -42,29 +42,30 @@
@Composable
fun VectorGraphicsDemo() {
- Column {
+ Column(modifier = LayoutAlign.Center) {
val vectorAsset = loadVectorResource(R.drawable.ic_crane)
vectorAsset.resource.resource?.let {
- Center {
- Box(LayoutSize(200.dp, 100.dp) + drawVector(it))
- }
+ Image(
+ asset = it,
+ modifier = LayoutSize(200.dp, 200.dp),
+ scaleFit = ScaleFit.FillMinDimension
+ )
}
- Center {
- val width = 120.dp
- val height = 120.dp
- Box(LayoutSize(width, height) + vectorShape(width, height))
- }
+ Image(
+ painter = vectorShape(120.dp, 120.dp),
+ modifier = LayoutSize(200.dp, 150.dp)
+ )
}
}
@Composable
-private fun vectorShape(width: Dp, height: Dp): Modifier = drawVector(
- name = "vectorShape",
- defaultWidth = width,
- defaultHeight = height,
- scaleFit = ScaleFit.FillMaxDimension
-) { viewportWidth, viewportHeight ->
+private fun vectorShape(width: Dp, height: Dp): Painter =
+ VectorPainter(
+ name = "vectorShape",
+ defaultWidth = width,
+ defaultHeight = height
+ ) { viewportWidth, viewportHeight ->
Group(
scaleX = 0.75f,
scaleY = 0.75f,
diff --git a/ui/ui-framework/src/androidTest/java/androidx/ui/core/PopupTest.kt b/ui/ui-framework/src/androidTest/java/androidx/ui/core/PopupTest.kt
index e3f167c..bcf8c15 100644
--- a/ui/ui-framework/src/androidTest/java/androidx/ui/core/PopupTest.kt
+++ b/ui/ui-framework/src/androidTest/java/androidx/ui/core/PopupTest.kt
@@ -23,6 +23,7 @@
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.BoundedMatcher
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
+import androidx.test.filters.FlakyTest
import androidx.test.filters.MediumTest
import androidx.ui.core.selection.SimpleContainer
import androidx.ui.test.createComposeRule
@@ -47,6 +48,7 @@
@MediumTest
@RunWith(JUnit4::class)
+@FlakyTest(bugId = 150214184)
class PopupTest {
@get:Rule
val composeTestRule = createComposeRule(disableTransitions = true)
diff --git a/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt b/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt
index c048bf9..2c1bb77 100644
--- a/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt
+++ b/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt
@@ -33,19 +33,20 @@
import androidx.ui.core.Modifier
import androidx.ui.core.Ref
import androidx.ui.core.WithConstraints
+import androidx.ui.core.asModifier
import androidx.ui.core.draw
import androidx.ui.core.onPositioned
import androidx.ui.core.setContent
import androidx.ui.framework.test.TestActivity
import androidx.ui.graphics.Color
import androidx.ui.graphics.Paint
-import androidx.ui.graphics.vector.drawVector
+import androidx.ui.graphics.vector.VectorPainter
import androidx.ui.unit.Density
import androidx.ui.unit.IntPx
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
+import androidx.ui.unit.dp
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import androidx.ui.unit.toRect
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
@@ -220,11 +221,15 @@
activity.setContent {
WithConstraints { _, _ ->
// this block is called as a subcomposition from LayoutNode.measure()
- // DrawVector introduces additional subcomposition which is closing the
+ // VectorPainter introduces additional subcomposition which is closing the
// current frame and opens a new one. our model reads during measure()
// wasn't possible to survide Frames swicth previously so the model read
// within the child Layout wasn't recorded
- val background = drawVector(100.px, 100.px) { _, _ -> }
+ val background = VectorPainter(
+ name = "testPainter",
+ defaultWidth = 10.dp,
+ defaultHeight = 10.dp) { _, _ -> /* intentionally empty */
+ }.asModifier()
Layout(modifier = background, children = {}) { _, _, _ ->
// read the model
model.value
diff --git a/ui/ui-framework/src/androidTest/java/androidx/ui/graphics/vector/VectorInvalidationTestCase.kt b/ui/ui-framework/src/androidTest/java/androidx/ui/graphics/vector/VectorInvalidationTestCase.kt
index e2aaef8..0df4e8c 100644
--- a/ui/ui-framework/src/androidTest/java/androidx/ui/graphics/vector/VectorInvalidationTestCase.kt
+++ b/ui/ui-framework/src/androidTest/java/androidx/ui/graphics/vector/VectorInvalidationTestCase.kt
@@ -20,6 +20,7 @@
import androidx.compose.MutableState
import androidx.compose.state
import androidx.ui.core.DensityAmbient
+import androidx.ui.core.asModifier
import androidx.ui.core.draw
import androidx.ui.core.test.AtLeastSize
import androidx.ui.framework.test.R
@@ -50,7 +51,9 @@
vectorAsset.resource.resource?.let {
val width = it.defaultWidth
vectorSize = width.toIntPx().value
- AtLeastSize(size = width.toIntPx(), modifier = WhiteBackground + drawVector(it)) {
+ AtLeastSize(
+ size = width.toIntPx(),
+ modifier = WhiteBackground + VectorPainter(it).asModifier()) {
latch.countDown()
}
}
diff --git a/ui/ui-framework/src/androidTest/java/androidx/ui/graphics/vector/VectorTest.kt b/ui/ui-framework/src/androidTest/java/androidx/ui/graphics/vector/VectorTest.kt
index fe9508b..be49f82 100644
--- a/ui/ui-framework/src/androidTest/java/androidx/ui/graphics/vector/VectorTest.kt
+++ b/ui/ui-framework/src/androidTest/java/androidx/ui/graphics/vector/VectorTest.kt
@@ -23,15 +23,19 @@
import androidx.test.filters.SmallTest
import androidx.test.rule.ActivityTestRule
import androidx.ui.core.Alignment
+import androidx.ui.core.DensityAmbient
+import androidx.ui.core.asModifier
import androidx.ui.core.setContent
import androidx.ui.core.test.AtLeastSize
import androidx.ui.core.test.runOnUiThreadIR
import androidx.ui.core.test.waitAndScreenShot
import androidx.ui.framework.test.TestActivity
import androidx.ui.graphics.Color
+import androidx.ui.graphics.ColorFilter
import androidx.ui.graphics.SolidColor
import androidx.ui.graphics.toArgb
import androidx.ui.unit.IntPx
+import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.toPx
import org.junit.Assert
@@ -129,11 +133,10 @@
alignment: Alignment = Alignment.Center
) {
val sizePx = size.toPx()
- val background = drawVector(
- defaultWidth = sizePx,
- defaultHeight = sizePx,
- tintColor = Color.Cyan,
- alignment = alignment) { _, _ ->
+ val sizeDp = (size.value / DensityAmbient.current.density).dp
+ val background = VectorPainter(
+ defaultWidth = sizeDp,
+ defaultHeight = sizeDp) { _, _ ->
Path(
pathData = PathData {
lineTo(sizePx.value, 0.0f)
@@ -145,7 +148,7 @@
)
drawLatch.countDown()
- }
+ }.asModifier(colorFilter = ColorFilter.tint(Color.Cyan), alignment = alignment)
AtLeastSize(size = minimumSize, modifier = background) {
}
}
diff --git a/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorAsset.kt b/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorAsset.kt
index 5319415..1e1f29d 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorAsset.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorAsset.kt
@@ -19,9 +19,11 @@
import androidx.compose.Composable
import androidx.ui.core.Alignment
import androidx.ui.core.Modifier
+import androidx.ui.core.asModifier
import androidx.ui.graphics.BlendMode
import androidx.ui.graphics.Brush
import androidx.ui.graphics.Color
+import androidx.ui.graphics.ColorFilter
import androidx.ui.graphics.ScaleFit
import androidx.ui.graphics.StrokeCap
import androidx.ui.graphics.StrokeJoin
@@ -29,7 +31,7 @@
/**
* Vector graphics object that is generated as a result of [VectorAssetBuilder]]
- * It can be composed and rendered by passing it as an argument to [drawVector]
+ * It can be composed and rendered by passing it as an argument to [VectorPainter]
*/
data class VectorAsset internal constructor(
@@ -242,6 +244,9 @@
* @param[tintColor] Optional color used to tint this vector graphic
* @param[tintBlendMode] Optional blend mode used with [tintColor], default is [BlendMode.srcIn]
*/
+@Deprecated("Use VectorPainter instead",
+ ReplaceWith("VectorPainter(vectorAsset)")
+)
@Composable
fun drawVector(
vectorImage: VectorAsset,
@@ -249,54 +254,11 @@
tintBlendMode: BlendMode = DefaultTintBlendMode,
alignment: Alignment = Alignment.Center,
fit: ScaleFit = ScaleFit.Fit
-): Modifier = drawVector(
- name = vectorImage.name,
- viewportWidth = vectorImage.viewportWidth,
- viewportHeight = vectorImage.viewportHeight,
- defaultWidth = vectorImage.defaultWidth,
- defaultHeight = vectorImage.defaultHeight,
- tintColor = tintColor,
- tintBlendMode = tintBlendMode,
+): Modifier = VectorPainter(vectorImage).asModifier(
alignment = alignment,
- scaleFit = fit
-) { _, _ ->
- RenderVectorGroup(group = vectorImage.root)
-}
-
-/**
- * Recursive method for creating the vector graphic composition by traversing
- * the tree structure
- */
-@Composable
-private fun VectorScope.RenderVectorGroup(group: VectorGroup) {
- for (vectorNode in group) {
- if (vectorNode is VectorPath) {
- Path(
- pathData = vectorNode.pathData,
- name = vectorNode.name,
- fill = vectorNode.fill,
- fillAlpha = vectorNode.fillAlpha,
- stroke = vectorNode.stroke,
- strokeAlpha = vectorNode.strokeAlpha,
- strokeLineWidth = vectorNode.strokeLineWidth,
- strokeLineCap = vectorNode.strokeLineCap,
- strokeLineJoin = vectorNode.strokeLineJoin,
- strokeLineMiter = vectorNode.strokeLineMiter
- )
- } else if (vectorNode is VectorGroup) {
- Group(
- name = vectorNode.name,
- rotation = vectorNode.rotation,
- scaleX = vectorNode.scaleX,
- scaleY = vectorNode.scaleY,
- translationX = vectorNode.translationX,
- translationY = vectorNode.translationY,
- pivotX = vectorNode.pivotX,
- pivotY = vectorNode.pivotY,
- clipPathData = vectorNode.clipPathData
- ) {
- RenderVectorGroup(group = vectorNode)
- }
- }
- }
-}
\ No newline at end of file
+ scaleFit = fit,
+ colorFilter = if (tintColor != Color.Transparent) {
+ ColorFilter(tintColor, tintBlendMode)
+ } else {
+ null
+ })
\ No newline at end of file
diff --git a/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorAssetBuilder.kt b/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorAssetBuilder.kt
index 2869bac..0326062 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorAssetBuilder.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorAssetBuilder.kt
@@ -27,7 +27,7 @@
* This is useful for caching the result of expensive operations used to construct
* a vector graphic for compose.
* For example, the vector graphic could be serialized and downloaded from a server and represented
- * internally in a VectorAsset before it is composed through [DrawVector]
+ * internally in a VectorAsset before it is composed through [VectorPainter]
* The generated VectorAsset is recommended to be memoized across composition calls to avoid
* doing redundant work
*/
diff --git a/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorCompose.kt b/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorCompose.kt
index 147a01e..ef90540 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorCompose.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorCompose.kt
@@ -27,6 +27,7 @@
import androidx.ui.graphics.BlendMode
import androidx.ui.graphics.Brush
import androidx.ui.graphics.Color
+import androidx.ui.graphics.ColorFilter
import androidx.ui.graphics.ScaleFit
import androidx.ui.graphics.StrokeCap
import androidx.ui.graphics.StrokeJoin
@@ -48,7 +49,7 @@
/**
* Modifier to draw a vector graphic with the provided width, height and viewport dimensions
* @param[defaultWidth] Intrinsic width of the Vector in [Dp]
- * @param[defaultHeight] Intrinsic height of hte Vector in [Dp]
+ * @param[defaultHeight] Intrinsic height of the Vector in [Dp]
* @param[viewportWidth] Width of the viewport space. The viewport is the virtual canvas where
* paths are drawn on.
* This parameter is optional. Not providing it will use the [defaultWidth] converted to [Px]
@@ -60,6 +61,16 @@
* @param[alignment] Specifies the placement of the vector within the drawing bounds
* @param[scaleFit] Specifies how the vector is to be scaled within the parent bounds
*/
+@Deprecated("Favor usage of VectorPainter instead",
+ ReplaceWith("VectorPainter(" +
+ "defaultWidth, " +
+ "defaultHeight, " +
+ "viewportWidth, " +
+ "viewportHeight, " +
+ "colorFilter, " +
+ "name"
+ )
+)
@Composable
fun drawVector(
defaultWidth: Dp,
@@ -124,11 +135,11 @@
val vector =
remember(name, viewportWidth, viewportHeight) {
VectorComponent(
- name,
- viewportWidth,
- viewportHeight,
- defaultWidth,
- defaultHeight
+ name = name,
+ viewportWidth = viewportWidth,
+ viewportHeight = viewportHeight,
+ defaultWidth = defaultWidth,
+ defaultHeight = defaultHeight
)
}
@@ -165,7 +176,7 @@
canvas.withSave {
canvas.translate(translateX, translateY)
- vector.draw(canvas, tintColor, tintBlendMode)
+ vector.draw(canvas, DefaultAlpha, ColorFilter(tintColor, tintBlendMode))
}
}
}
diff --git a/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorPainter.kt b/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorPainter.kt
new file mode 100644
index 0000000..eaa5e93
--- /dev/null
+++ b/ui/ui-framework/src/main/java/androidx/ui/graphics/vector/VectorPainter.kt
@@ -0,0 +1,196 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.graphics.vector
+
+import androidx.compose.Composable
+import androidx.compose.compositionReference
+import androidx.compose.onPreCommit
+import androidx.compose.remember
+import androidx.ui.core.DensityAmbient
+import androidx.ui.graphics.Canvas
+import androidx.ui.graphics.ColorFilter
+import androidx.ui.graphics.painter.Painter
+import androidx.ui.unit.Dp
+import androidx.ui.unit.IntPx
+import androidx.ui.unit.Px
+import androidx.ui.unit.PxSize
+import kotlin.math.ceil
+import kotlin.math.roundToInt
+
+/**
+ * Default identifier for the root group if a Vector graphic
+ */
+const val RootGroupName = "VectorRootGroup"
+
+/**
+ * Create a [VectorPainter] with the Vector defined by the provided
+ * sub-composition
+ *
+ * @param [defaultWidth] Intrinsic width of the Vector in [Dp]
+ * @param [defaultHeight] Intrinsic height of the Vector in [Dp]
+ * @param [viewportWidth] Width of the viewport space. The viewport is the virtual canvas where
+ * paths are drawn on.
+ * This parameter is optional. Not providing it will use the [defaultWidth] converted to [Px]
+ * @param [viewportHeight] Height of the viewport space. The viewport is the virtual canvas where
+ * paths are drawn on.
+ * This parameter is optional. Not providing it will use the [defaultHeight] converted to [Px]
+ * @param [name] optional identifier used to identify the root of this vector graphic
+ * @param [children] Composable used to define the structure and contents of the vector graphic
+ */
+@Composable
+fun VectorPainter(
+ defaultWidth: Dp,
+ defaultHeight: Dp,
+ viewportWidth: Float = Float.NaN,
+ viewportHeight: Float = Float.NaN,
+ name: String = RootGroupName,
+ children: @Composable() VectorScope.(viewportWidth: Float, viewportHeight: Float) -> Unit
+): VectorPainter {
+ val density = DensityAmbient.current
+ val widthPx = with(density) { defaultWidth.toPx() }
+ val heightPx = with(density) { defaultHeight.toPx() }
+
+ val vpWidth = if (viewportWidth.isNaN()) widthPx.value else viewportWidth
+ val vpHeight = if (viewportHeight.isNaN()) heightPx.value else viewportHeight
+
+ return VectorPainter(
+ createVector(
+ name = name,
+ defaultWidth = widthPx,
+ defaultHeight = heightPx,
+ viewportWidth = vpWidth,
+ viewportHeight = vpHeight,
+ children = children
+ )
+ )
+}
+
+/**
+ * Create a [VectorPainter] with the given [VectorAsset]. This will create a
+ * sub-composition of the vector hierarchy given the tree structure in [VectorAsset]
+ *
+ * @param [asset] VectorAsset used to create a vector graphic sub-composition
+ */
+@Composable
+fun VectorPainter(asset: VectorAsset): VectorPainter {
+ return VectorPainter(
+ name = asset.name,
+ defaultWidth = asset.defaultWidth,
+ defaultHeight = asset.defaultHeight,
+ viewportWidth = asset.viewportWidth,
+ viewportHeight = asset.viewportHeight,
+ children = { _, _ -> RenderVectorGroup(group = asset.root) }
+ )
+}
+
+/**
+ * [Painter] implementation that abstracts the drawing of a Vector graphic.
+ * This can be represented by either a [VectorAsset] or a programmatic
+ * composition of a vector
+ */
+class VectorPainter internal constructor(private val vector: VectorComponent) : Painter() {
+
+ private var currentAlpha: Float = DefaultAlpha
+ private var currentColorFilter: ColorFilter? = null
+
+ override val intrinsicSize: PxSize = PxSize(
+ IntPx(ceil(vector.defaultWidth.value).roundToInt()),
+ IntPx(ceil(vector.defaultHeight.value).roundToInt())
+ )
+
+ override fun onDraw(canvas: Canvas, bounds: PxSize) {
+ vector.draw(canvas, currentAlpha, currentColorFilter)
+ }
+
+ override fun applyAlpha(alpha: Float): Boolean {
+ currentAlpha = alpha
+ return true
+ }
+
+ override fun applyColorFilter(colorFilter: ColorFilter?): Boolean {
+ currentColorFilter = colorFilter
+ return true
+ }
+}
+
+@Composable
+private fun createVector(
+ name: String,
+ defaultWidth: Px,
+ defaultHeight: Px,
+ viewportWidth: Float = defaultWidth.value,
+ viewportHeight: Float = defaultHeight.value,
+ children: @Composable() VectorScope.(viewportWidth: Float, viewportHeight: Float) -> Unit
+): VectorComponent {
+ val vector =
+ remember(name, viewportWidth, viewportHeight) {
+ VectorComponent(
+ name = name,
+ viewportWidth = viewportWidth,
+ viewportHeight = viewportHeight,
+ defaultWidth = defaultWidth,
+ defaultHeight = defaultHeight
+ )
+ }
+
+ val ref = compositionReference()
+ composeVector(vector, ref, children)
+ onPreCommit(vector) {
+ onDispose {
+ disposeVector(vector, ref)
+ }
+ }
+ return vector
+}
+
+/**
+ * Recursive method for creating the vector graphic composition by traversing
+ * the tree structure
+ */
+@Composable
+private fun VectorScope.RenderVectorGroup(group: VectorGroup) {
+ for (vectorNode in group) {
+ if (vectorNode is VectorPath) {
+ Path(
+ pathData = vectorNode.pathData,
+ name = vectorNode.name,
+ fill = vectorNode.fill,
+ fillAlpha = vectorNode.fillAlpha,
+ stroke = vectorNode.stroke,
+ strokeAlpha = vectorNode.strokeAlpha,
+ strokeLineWidth = vectorNode.strokeLineWidth,
+ strokeLineCap = vectorNode.strokeLineCap,
+ strokeLineJoin = vectorNode.strokeLineJoin,
+ strokeLineMiter = vectorNode.strokeLineMiter
+ )
+ } else if (vectorNode is VectorGroup) {
+ Group(
+ name = vectorNode.name,
+ rotation = vectorNode.rotation,
+ scaleX = vectorNode.scaleX,
+ scaleY = vectorNode.scaleY,
+ translationX = vectorNode.translationX,
+ translationY = vectorNode.translationY,
+ pivotX = vectorNode.pivotX,
+ pivotY = vectorNode.pivotY,
+ clipPathData = vectorNode.clipPathData
+ ) {
+ RenderVectorGroup(group = vectorNode)
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ui/ui-graphics/api/0.1.0-dev07.txt b/ui/ui-graphics/api/0.1.0-dev07.txt
index d010e48..e5f96ac 100644
--- a/ui/ui-graphics/api/0.1.0-dev07.txt
+++ b/ui/ui-graphics/api/0.1.0-dev07.txt
@@ -172,6 +172,11 @@
method public androidx.ui.graphics.ColorFilter copy(androidx.ui.graphics.Color color, androidx.ui.graphics.BlendMode blendMode);
method public androidx.ui.graphics.BlendMode getBlendMode();
method public androidx.ui.graphics.Color getColor();
+ field public static final androidx.ui.graphics.ColorFilter.Companion! Companion;
+ }
+
+ public static final class ColorFilter.Companion {
+ method public androidx.ui.graphics.ColorFilter tint(androidx.ui.graphics.Color color);
}
public final class ColorKt {
diff --git a/ui/ui-graphics/api/current.txt b/ui/ui-graphics/api/current.txt
index d010e48..e5f96ac 100644
--- a/ui/ui-graphics/api/current.txt
+++ b/ui/ui-graphics/api/current.txt
@@ -172,6 +172,11 @@
method public androidx.ui.graphics.ColorFilter copy(androidx.ui.graphics.Color color, androidx.ui.graphics.BlendMode blendMode);
method public androidx.ui.graphics.BlendMode getBlendMode();
method public androidx.ui.graphics.Color getColor();
+ field public static final androidx.ui.graphics.ColorFilter.Companion! Companion;
+ }
+
+ public static final class ColorFilter.Companion {
+ method public androidx.ui.graphics.ColorFilter tint(androidx.ui.graphics.Color color);
}
public final class ColorKt {
diff --git a/ui/ui-graphics/api/public_plus_experimental_0.1.0-dev07.txt b/ui/ui-graphics/api/public_plus_experimental_0.1.0-dev07.txt
index d010e48..e5f96ac 100644
--- a/ui/ui-graphics/api/public_plus_experimental_0.1.0-dev07.txt
+++ b/ui/ui-graphics/api/public_plus_experimental_0.1.0-dev07.txt
@@ -172,6 +172,11 @@
method public androidx.ui.graphics.ColorFilter copy(androidx.ui.graphics.Color color, androidx.ui.graphics.BlendMode blendMode);
method public androidx.ui.graphics.BlendMode getBlendMode();
method public androidx.ui.graphics.Color getColor();
+ field public static final androidx.ui.graphics.ColorFilter.Companion! Companion;
+ }
+
+ public static final class ColorFilter.Companion {
+ method public androidx.ui.graphics.ColorFilter tint(androidx.ui.graphics.Color color);
}
public final class ColorKt {
diff --git a/ui/ui-graphics/api/public_plus_experimental_current.txt b/ui/ui-graphics/api/public_plus_experimental_current.txt
index d010e48..e5f96ac 100644
--- a/ui/ui-graphics/api/public_plus_experimental_current.txt
+++ b/ui/ui-graphics/api/public_plus_experimental_current.txt
@@ -172,6 +172,11 @@
method public androidx.ui.graphics.ColorFilter copy(androidx.ui.graphics.Color color, androidx.ui.graphics.BlendMode blendMode);
method public androidx.ui.graphics.BlendMode getBlendMode();
method public androidx.ui.graphics.Color getColor();
+ field public static final androidx.ui.graphics.ColorFilter.Companion! Companion;
+ }
+
+ public static final class ColorFilter.Companion {
+ method public androidx.ui.graphics.ColorFilter tint(androidx.ui.graphics.Color color);
}
public final class ColorKt {
diff --git a/ui/ui-graphics/api/restricted_0.1.0-dev07.txt b/ui/ui-graphics/api/restricted_0.1.0-dev07.txt
index d010e48..e5f96ac 100644
--- a/ui/ui-graphics/api/restricted_0.1.0-dev07.txt
+++ b/ui/ui-graphics/api/restricted_0.1.0-dev07.txt
@@ -172,6 +172,11 @@
method public androidx.ui.graphics.ColorFilter copy(androidx.ui.graphics.Color color, androidx.ui.graphics.BlendMode blendMode);
method public androidx.ui.graphics.BlendMode getBlendMode();
method public androidx.ui.graphics.Color getColor();
+ field public static final androidx.ui.graphics.ColorFilter.Companion! Companion;
+ }
+
+ public static final class ColorFilter.Companion {
+ method public androidx.ui.graphics.ColorFilter tint(androidx.ui.graphics.Color color);
}
public final class ColorKt {
diff --git a/ui/ui-graphics/api/restricted_current.txt b/ui/ui-graphics/api/restricted_current.txt
index d010e48..e5f96ac 100644
--- a/ui/ui-graphics/api/restricted_current.txt
+++ b/ui/ui-graphics/api/restricted_current.txt
@@ -172,6 +172,11 @@
method public androidx.ui.graphics.ColorFilter copy(androidx.ui.graphics.Color color, androidx.ui.graphics.BlendMode blendMode);
method public androidx.ui.graphics.BlendMode getBlendMode();
method public androidx.ui.graphics.Color getColor();
+ field public static final androidx.ui.graphics.ColorFilter.Companion! Companion;
+ }
+
+ public static final class ColorFilter.Companion {
+ method public androidx.ui.graphics.ColorFilter tint(androidx.ui.graphics.Color color);
}
public final class ColorKt {
diff --git a/ui/ui-graphics/src/main/java/androidx/ui/graphics/ColorFilter.kt b/ui/ui-graphics/src/main/java/androidx/ui/graphics/ColorFilter.kt
index 4d0729f..83e14f8 100644
--- a/ui/ui-graphics/src/main/java/androidx/ui/graphics/ColorFilter.kt
+++ b/ui/ui-graphics/src/main/java/androidx/ui/graphics/ColorFilter.kt
@@ -17,18 +17,6 @@
package androidx.ui.graphics
/**
- * A description of a color filter to apply when drawing a shape or compositing
- * a layer with a particular [Paint]. A color filter is a function that takes
- * two colors, and outputs one color. When applied during compositing, it is
- * independently applied to each pixel of the layer being drawn before the
- * entire layer is merged with the destination.
- *
- * Instances of this class are used with [Paint.colorFilter] on [Paint]
- * objects.
- *
- */
-// Ctor comment:
-/**
* Creates a color filter that applies the blend mode given as the second
* argument. The source color is the one given as the first argument, and the
* destination color is the one from the layer being composited.
@@ -41,19 +29,10 @@
val color: Color,
val blendMode: BlendMode
) {
-
-// TODO(Filip): Not needed for data class
-// @override
-// bool operator ==(dynamic other) {
-// if (other is! ColorFilter)
-// return false;
-// final ColorFilter typedOther = other;
-// return _color == typedOther._color &&
-// _blendMode == typedOther._blendMode;
-// }
-//
-// @override
-// int get hashCode => hashValues(_color, _blendMode);
-
- override fun toString() = "ColorFilter($color, $blendMode)"
-}
+ companion object {
+ /**
+ * Helper method to create a [ColorFilter] that tints contents to the specified color
+ */
+ fun tint(color: Color): ColorFilter = ColorFilter(color, BlendMode.srcIn)
+ }
+}
\ No newline at end of file
diff --git a/ui/ui-material/icons/core/samples/src/main/java/androidx/ui/material/icons/samples/IconSamples.kt b/ui/ui-material/icons/core/samples/src/main/java/androidx/ui/material/icons/samples/IconSamples.kt
index 26bf8bc..393fa53 100644
--- a/ui/ui-material/icons/core/samples/src/main/java/androidx/ui/material/icons/samples/IconSamples.kt
+++ b/ui/ui-material/icons/core/samples/src/main/java/androidx/ui/material/icons/samples/IconSamples.kt
@@ -18,10 +18,11 @@
import androidx.annotation.Sampled
import androidx.compose.Composable
+import androidx.ui.core.asModifier
import androidx.ui.foundation.Box
import androidx.ui.foundation.Icon
import androidx.ui.graphics.vector.VectorAsset
-import androidx.ui.graphics.vector.drawVector
+import androidx.ui.graphics.vector.VectorPainter
import androidx.ui.material.icons.Icons
import androidx.ui.material.icons.rounded.Menu
@@ -41,5 +42,5 @@
@Composable
private fun SomeComposable(icon: VectorAsset) {
- Box(modifier = drawVector(icon))
+ Box(modifier = VectorPainter(icon).asModifier())
}
diff --git a/ui/ui-material/icons/extended/src/androidTest/java/androidx/ui/material/icons/test/IconComparisonTest.kt b/ui/ui-material/icons/extended/src/androidTest/java/androidx/ui/material/icons/test/IconComparisonTest.kt
index e018724..ae51c13 100644
--- a/ui/ui-material/icons/extended/src/androidTest/java/androidx/ui/material/icons/test/IconComparisonTest.kt
+++ b/ui/ui-material/icons/extended/src/androidTest/java/androidx/ui/material/icons/test/IconComparisonTest.kt
@@ -27,11 +27,13 @@
import androidx.ui.core.ContextAmbient
import androidx.ui.core.DensityAmbient
import androidx.ui.core.TestTag
+import androidx.ui.core.asModifier
import androidx.ui.core.setContent
import androidx.ui.foundation.Box
import androidx.ui.graphics.Color
+import androidx.ui.graphics.ColorFilter
import androidx.ui.graphics.vector.VectorAsset
-import androidx.ui.graphics.vector.drawVector
+import androidx.ui.graphics.vector.VectorPainter
import androidx.ui.layout.Center
import androidx.ui.layout.Column
import androidx.ui.layout.LayoutSize
@@ -173,7 +175,8 @@
Semantics(container = true) {
Box(
modifier = layoutSize +
- drawVector(vectorImage = programmaticVector, tintColor = Color.Red)
+ VectorPainter(programmaticVector)
+ .asModifier(colorFilter = ColorFilter.tint(Color.Red))
)
}
}
@@ -181,7 +184,8 @@
Semantics(container = true) {
Box(
modifier = layoutSize +
- drawVector(vectorImage = xmlVector, tintColor = Color.Red)
+ VectorPainter(xmlVector)
+ .asModifier(colorFilter = ColorFilter.tint(Color.Red))
)
}
}
diff --git a/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/Icons.kt b/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/Icons.kt
index c29bf53..8ab4cdb 100644
--- a/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/Icons.kt
+++ b/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/Icons.kt
@@ -18,11 +18,13 @@
import androidx.compose.Composable
import androidx.ui.core.Modifier
+import androidx.ui.core.asModifier
import androidx.ui.foundation.Box
import androidx.ui.foundation.Clickable
import androidx.ui.graphics.Color
+import androidx.ui.graphics.ColorFilter
import androidx.ui.graphics.vector.VectorAsset
-import androidx.ui.graphics.vector.drawVector
+import androidx.ui.graphics.vector.VectorPainter
import androidx.ui.layout.LayoutHeight
import androidx.ui.layout.LayoutWidth
import androidx.ui.material.ripple.Ripple
@@ -59,9 +61,8 @@
) {
Box(
modifier = LayoutHeight(size) + LayoutWidth(size) + modifier +
- drawVector(
- vectorImage = vectorImage,
- tintColor = tintColor
+ VectorPainter(vectorImage).asModifier(
+ colorFilter = ColorFilter.tint(tintColor)
)
)
}
\ No newline at end of file
diff --git a/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/FloatingActionButtonSamples.kt b/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/FloatingActionButtonSamples.kt
index bb71515..901026b 100644
--- a/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/FloatingActionButtonSamples.kt
+++ b/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/FloatingActionButtonSamples.kt
@@ -32,7 +32,7 @@
@Composable
fun FloatingActionButtonCustomContent(icon: ImageAsset) {
FloatingActionButton( /*do something*/ }) {
- Image(image = icon)
+ Image(asset = icon)
}
}
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/DataTable.kt b/ui/ui-material/src/main/java/androidx/ui/material/DataTable.kt
index d80b6f0..a076170 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/DataTable.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/DataTable.kt
@@ -214,7 +214,7 @@
Text(text = text(j))
} else {
Row {
- Image(image = image)
+ Image(asset = image)
Spacer(LayoutWidth(2.dp))
Text(text = text(j))
}
@@ -259,7 +259,7 @@
Text(text = text(j))
} else {
Row {
- Image(image = image)
+ Image(asset = image)
Spacer(LayoutWidth(2.dp))
Text(text = text(j))
}
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/FloatingActionButton.kt b/ui/ui-material/src/main/java/androidx/ui/material/FloatingActionButton.kt
index 2a6c5114..9767978 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/FloatingActionButton.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/FloatingActionButton.kt
@@ -109,7 +109,7 @@
color = color,
elevation = elevation
) {
- Image(image = icon)
+ Image(asset = icon)
}
}
@@ -157,7 +157,7 @@
)
} else {
Row(LayoutPadding(start = ExtendedFabIconPadding, end = ExtendedFabTextPadding)) {
- Image(image = icon)
+ Image(asset = icon)
Spacer(LayoutWidth(ExtendedFabIconPadding))
Text(text = text, style = textStyle ?: TextStyle.Default)
}
diff --git a/ui/ui-vector/api/0.1.0-dev07.txt b/ui/ui-vector/api/0.1.0-dev07.txt
index 253bea7..1507e9e 100644
--- a/ui/ui-vector/api/0.1.0-dev07.txt
+++ b/ui/ui-vector/api/0.1.0-dev07.txt
@@ -4,6 +4,8 @@
public final class GroupComponent extends androidx.ui.graphics.vector.VNode {
ctor public GroupComponent(String name);
ctor public GroupComponent();
+ method public String component1();
+ method public androidx.ui.graphics.vector.GroupComponent copy(String name);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public java.util.List<androidx.ui.graphics.vector.PathNode> getClipPathData();
method public String getName();
@@ -40,6 +42,8 @@
public final class PathComponent extends androidx.ui.graphics.vector.VNode {
ctor public PathComponent(String name);
+ method public String component1();
+ method public androidx.ui.graphics.vector.PathComponent copy(String name);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public androidx.ui.graphics.Brush? getFill();
method public float getFillAlpha();
@@ -80,8 +84,8 @@
}
public final class VectorComponent extends androidx.ui.graphics.vector.VNode {
- ctor public VectorComponent(String name, float viewportWidth, float viewportHeight, androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight);
- method public void draw(androidx.ui.graphics.Canvas canvas, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode blendMode = DefaultTintBlendMode);
+ ctor public VectorComponent(float viewportWidth, float viewportHeight, androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight, String name);
+ method public void draw(androidx.ui.graphics.Canvas canvas, float alpha, androidx.ui.graphics.ColorFilter? colorFilter);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public androidx.ui.unit.Px getDefaultHeight();
method public androidx.ui.unit.Px getDefaultWidth();
diff --git a/ui/ui-vector/api/current.txt b/ui/ui-vector/api/current.txt
index 253bea7..1507e9e 100644
--- a/ui/ui-vector/api/current.txt
+++ b/ui/ui-vector/api/current.txt
@@ -4,6 +4,8 @@
public final class GroupComponent extends androidx.ui.graphics.vector.VNode {
ctor public GroupComponent(String name);
ctor public GroupComponent();
+ method public String component1();
+ method public androidx.ui.graphics.vector.GroupComponent copy(String name);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public java.util.List<androidx.ui.graphics.vector.PathNode> getClipPathData();
method public String getName();
@@ -40,6 +42,8 @@
public final class PathComponent extends androidx.ui.graphics.vector.VNode {
ctor public PathComponent(String name);
+ method public String component1();
+ method public androidx.ui.graphics.vector.PathComponent copy(String name);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public androidx.ui.graphics.Brush? getFill();
method public float getFillAlpha();
@@ -80,8 +84,8 @@
}
public final class VectorComponent extends androidx.ui.graphics.vector.VNode {
- ctor public VectorComponent(String name, float viewportWidth, float viewportHeight, androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight);
- method public void draw(androidx.ui.graphics.Canvas canvas, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode blendMode = DefaultTintBlendMode);
+ ctor public VectorComponent(float viewportWidth, float viewportHeight, androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight, String name);
+ method public void draw(androidx.ui.graphics.Canvas canvas, float alpha, androidx.ui.graphics.ColorFilter? colorFilter);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public androidx.ui.unit.Px getDefaultHeight();
method public androidx.ui.unit.Px getDefaultWidth();
diff --git a/ui/ui-vector/api/public_plus_experimental_0.1.0-dev07.txt b/ui/ui-vector/api/public_plus_experimental_0.1.0-dev07.txt
index 253bea7..1507e9e 100644
--- a/ui/ui-vector/api/public_plus_experimental_0.1.0-dev07.txt
+++ b/ui/ui-vector/api/public_plus_experimental_0.1.0-dev07.txt
@@ -4,6 +4,8 @@
public final class GroupComponent extends androidx.ui.graphics.vector.VNode {
ctor public GroupComponent(String name);
ctor public GroupComponent();
+ method public String component1();
+ method public androidx.ui.graphics.vector.GroupComponent copy(String name);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public java.util.List<androidx.ui.graphics.vector.PathNode> getClipPathData();
method public String getName();
@@ -40,6 +42,8 @@
public final class PathComponent extends androidx.ui.graphics.vector.VNode {
ctor public PathComponent(String name);
+ method public String component1();
+ method public androidx.ui.graphics.vector.PathComponent copy(String name);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public androidx.ui.graphics.Brush? getFill();
method public float getFillAlpha();
@@ -80,8 +84,8 @@
}
public final class VectorComponent extends androidx.ui.graphics.vector.VNode {
- ctor public VectorComponent(String name, float viewportWidth, float viewportHeight, androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight);
- method public void draw(androidx.ui.graphics.Canvas canvas, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode blendMode = DefaultTintBlendMode);
+ ctor public VectorComponent(float viewportWidth, float viewportHeight, androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight, String name);
+ method public void draw(androidx.ui.graphics.Canvas canvas, float alpha, androidx.ui.graphics.ColorFilter? colorFilter);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public androidx.ui.unit.Px getDefaultHeight();
method public androidx.ui.unit.Px getDefaultWidth();
diff --git a/ui/ui-vector/api/public_plus_experimental_current.txt b/ui/ui-vector/api/public_plus_experimental_current.txt
index 253bea7..1507e9e 100644
--- a/ui/ui-vector/api/public_plus_experimental_current.txt
+++ b/ui/ui-vector/api/public_plus_experimental_current.txt
@@ -4,6 +4,8 @@
public final class GroupComponent extends androidx.ui.graphics.vector.VNode {
ctor public GroupComponent(String name);
ctor public GroupComponent();
+ method public String component1();
+ method public androidx.ui.graphics.vector.GroupComponent copy(String name);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public java.util.List<androidx.ui.graphics.vector.PathNode> getClipPathData();
method public String getName();
@@ -40,6 +42,8 @@
public final class PathComponent extends androidx.ui.graphics.vector.VNode {
ctor public PathComponent(String name);
+ method public String component1();
+ method public androidx.ui.graphics.vector.PathComponent copy(String name);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public androidx.ui.graphics.Brush? getFill();
method public float getFillAlpha();
@@ -80,8 +84,8 @@
}
public final class VectorComponent extends androidx.ui.graphics.vector.VNode {
- ctor public VectorComponent(String name, float viewportWidth, float viewportHeight, androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight);
- method public void draw(androidx.ui.graphics.Canvas canvas, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode blendMode = DefaultTintBlendMode);
+ ctor public VectorComponent(float viewportWidth, float viewportHeight, androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight, String name);
+ method public void draw(androidx.ui.graphics.Canvas canvas, float alpha, androidx.ui.graphics.ColorFilter? colorFilter);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public androidx.ui.unit.Px getDefaultHeight();
method public androidx.ui.unit.Px getDefaultWidth();
diff --git a/ui/ui-vector/api/restricted_0.1.0-dev07.txt b/ui/ui-vector/api/restricted_0.1.0-dev07.txt
index 253bea7..1507e9e 100644
--- a/ui/ui-vector/api/restricted_0.1.0-dev07.txt
+++ b/ui/ui-vector/api/restricted_0.1.0-dev07.txt
@@ -4,6 +4,8 @@
public final class GroupComponent extends androidx.ui.graphics.vector.VNode {
ctor public GroupComponent(String name);
ctor public GroupComponent();
+ method public String component1();
+ method public androidx.ui.graphics.vector.GroupComponent copy(String name);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public java.util.List<androidx.ui.graphics.vector.PathNode> getClipPathData();
method public String getName();
@@ -40,6 +42,8 @@
public final class PathComponent extends androidx.ui.graphics.vector.VNode {
ctor public PathComponent(String name);
+ method public String component1();
+ method public androidx.ui.graphics.vector.PathComponent copy(String name);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public androidx.ui.graphics.Brush? getFill();
method public float getFillAlpha();
@@ -80,8 +84,8 @@
}
public final class VectorComponent extends androidx.ui.graphics.vector.VNode {
- ctor public VectorComponent(String name, float viewportWidth, float viewportHeight, androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight);
- method public void draw(androidx.ui.graphics.Canvas canvas, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode blendMode = DefaultTintBlendMode);
+ ctor public VectorComponent(float viewportWidth, float viewportHeight, androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight, String name);
+ method public void draw(androidx.ui.graphics.Canvas canvas, float alpha, androidx.ui.graphics.ColorFilter? colorFilter);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public androidx.ui.unit.Px getDefaultHeight();
method public androidx.ui.unit.Px getDefaultWidth();
diff --git a/ui/ui-vector/api/restricted_current.txt b/ui/ui-vector/api/restricted_current.txt
index 253bea7..1507e9e 100644
--- a/ui/ui-vector/api/restricted_current.txt
+++ b/ui/ui-vector/api/restricted_current.txt
@@ -4,6 +4,8 @@
public final class GroupComponent extends androidx.ui.graphics.vector.VNode {
ctor public GroupComponent(String name);
ctor public GroupComponent();
+ method public String component1();
+ method public androidx.ui.graphics.vector.GroupComponent copy(String name);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public java.util.List<androidx.ui.graphics.vector.PathNode> getClipPathData();
method public String getName();
@@ -40,6 +42,8 @@
public final class PathComponent extends androidx.ui.graphics.vector.VNode {
ctor public PathComponent(String name);
+ method public String component1();
+ method public androidx.ui.graphics.vector.PathComponent copy(String name);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public androidx.ui.graphics.Brush? getFill();
method public float getFillAlpha();
@@ -80,8 +84,8 @@
}
public final class VectorComponent extends androidx.ui.graphics.vector.VNode {
- ctor public VectorComponent(String name, float viewportWidth, float viewportHeight, androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight);
- method public void draw(androidx.ui.graphics.Canvas canvas, androidx.ui.graphics.Color tintColor = DefaultTintColor, androidx.ui.graphics.BlendMode blendMode = DefaultTintBlendMode);
+ ctor public VectorComponent(float viewportWidth, float viewportHeight, androidx.ui.unit.Px defaultWidth, androidx.ui.unit.Px defaultHeight, String name);
+ method public void draw(androidx.ui.graphics.Canvas canvas, float alpha, androidx.ui.graphics.ColorFilter? colorFilter);
method public void draw(androidx.ui.graphics.Canvas canvas);
method public androidx.ui.unit.Px getDefaultHeight();
method public androidx.ui.unit.Px getDefaultWidth();
diff --git a/ui/ui-vector/src/main/java/androidx/ui/graphics/vector/Vector.kt b/ui/ui-vector/src/main/java/androidx/ui/graphics/vector/Vector.kt
index 32fc912..f61c4ae 100644
--- a/ui/ui-vector/src/main/java/androidx/ui/graphics/vector/Vector.kt
+++ b/ui/ui-vector/src/main/java/androidx/ui/graphics/vector/Vector.kt
@@ -91,11 +91,11 @@
}
class VectorComponent(
- val name: String = "",
var viewportWidth: Float,
var viewportHeight: Float,
var defaultWidth: Px,
- var defaultHeight: Px
+ var defaultHeight: Px,
+ val name: String = ""
) : VNode() {
val root = GroupComponent(this@VectorComponent.name).apply {
@@ -110,7 +110,7 @@
private var isDirty: Boolean = true
- private var tintPaint: Paint? = null
+ private var vectorPaint: Paint? = null
/**
* Cached Image of the Vector Graphic to be re-used across draw calls
@@ -122,11 +122,7 @@
val size: Int
get() = root.size
- fun draw(
- canvas: Canvas,
- tintColor: Color = DefaultTintColor,
- blendMode: BlendMode = DefaultTintBlendMode
- ) {
+ fun draw(canvas: Canvas, alpha: Float, colorFilter: ColorFilter?) {
var targetImage = cachedImage
if (targetImage == null) {
targetImage = ImageAsset(
@@ -139,11 +135,11 @@
root.draw(Canvas(targetImage))
isDirty = false
}
- canvas.drawImage(targetImage, Offset.zero, obtainTintPaint(tintColor, blendMode))
+ canvas.drawImage(targetImage, Offset.zero, obtainVectorPaint(alpha, colorFilter))
}
override fun draw(canvas: Canvas) {
- draw(canvas, DefaultTintColor, DefaultTintBlendMode)
+ draw(canvas, DefaultAlpha, null)
}
override fun toString(): String {
@@ -157,24 +153,24 @@
}
}
- private fun obtainTintPaint(
- tintColor: Color,
- blendMode: BlendMode = DefaultTintBlendMode
- ): Paint {
- return if (tintColor.alpha == 0.0f) {
+ private fun obtainVectorPaint(alpha: Float, colorFilter: ColorFilter?): Paint {
+ return if (colorFilter == null && alpha == DefaultAlpha) {
EmptyPaint
} else {
- val targetPaint = tintPaint ?: Paint().also { tintPaint = it }
- val colorFilter = targetPaint.colorFilter
- if (colorFilter?.color != tintColor || colorFilter.blendMode != blendMode) {
- targetPaint.colorFilter = ColorFilter(tintColor, blendMode)
+ val targetPaint = vectorPaint ?: Paint().also { vectorPaint = it }
+ val currentColorFilter = targetPaint.colorFilter
+ if (currentColorFilter != colorFilter) {
+ targetPaint.colorFilter = colorFilter
+ }
+ if (targetPaint.alpha != alpha) {
+ targetPaint.alpha = alpha
}
targetPaint
}
}
}
-class PathComponent(val name: String) : VNode() {
+data class PathComponent(val name: String) : VNode() {
var fill: Brush? = null
set(value) {
@@ -354,7 +350,7 @@
}
}
-class GroupComponent(val name: String = DefaultGroupName) : VNode() {
+data class GroupComponent(val name: String = DefaultGroupName) : VNode() {
private var groupMatrix: Matrix? = null