forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove TestComposeWindow in favor to ImageComposeScene
This CL introduces ImageComposeScene - simplified version of ComposeScene, with drawing only into Image. It is almost the same as the old TestComposeWindow, but with a different class and method names. TestComposeWindow was deprecated before Compose 1.0, so it is safe to remove. See examples of usage in ImageComposeSceneTest. Also, we introduce: - renderComposeScene - one-liner function to draw Composable content into an image - ImageComposeScene.use - similar to AutoClosable.use to disposing created resources. We don't inherit AutoCloseable, because we want to move ImageComposeScene into skikoMain. For now, common code doesn't have Closeable, but in the future it can (https://github.com/Kotlin/kotlinx-io/blob/c5bba0114e33c2afd8e4b1ab214aad94ee416d00/core/commonMain/src/kotlinx/io/Closeable.common.kt#L7), so I renamed `dispose` method to `close. ImageComposeScene still has some flaws, which will be fixed in the future (https://github.com/JetBrains/compose-jb/search?q=ImageComposeScene&type=issues) Test: ./gradlew jvmTest desktopTest -Pandroidx.compose.multiplatformEnabled=true Change-Id: I48d2769fd2eaff53e391371aea9ed37964b6afc3
- Loading branch information
Showing
16 changed files
with
690 additions
and
595 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ose/foundation/foundation/src/desktopTest/kotlin/androidx/compose/foundation/TestUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2022 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.compose.foundation | ||
|
||
import java.awt.Component | ||
import java.awt.event.MouseWheelEvent | ||
|
||
private val EventComponent = object : Component() {} | ||
|
||
internal fun awtWheelEvent(isScrollByPages: Boolean = false) = MouseWheelEvent( | ||
EventComponent, | ||
MouseWheelEvent.MOUSE_WHEEL, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
false, | ||
if (isScrollByPages) { | ||
MouseWheelEvent.WHEEL_BLOCK_SCROLL | ||
} else { | ||
MouseWheelEvent.WHEEL_UNIT_SCROLL | ||
}, | ||
1, | ||
0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.