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.
Proper clipping of
SwingPanel
interop (#915)
## Proposed Changes - Adopt an approach that we're using for iOS - using custom blending to respect clip/shape modifiers and overlapped drawings. - Fix bounds in window calculation - it should work properly inside scaled content now. ## Testing The new behavior is under a feature flag, so you can test it by setting system property: ```kt System.setProperty("compose.interop.blending", "true") ``` Currently it supports Metal (macOS), Direct3D (Windows) (requires JetBrains/skiko#837), and off-screen rendering (might be enable by another feature flag: `compose.swing.render.on.graphics`) ### Clipping ```kt SwingPanel( modifier = Modifier.clip(RoundedCornerShape(6.dp)) ... ) ``` <img width="262" alt="image" src="https://github.com/JetBrains/compose-multiplatform-core/assets/1836384/a03926f5-8977-4530-8894-d84aedfd5939"> ### Overlapping ```kt Box(modifier = Modifier.fillMaxSize()) { SwingPanel(factory = { JPanel().also { panel -> panel.background = java.awt.Color.red panel.add(JButton().also { button -> button.text = "JButton" }) } }) Snackbar( action = { Button(onClick = {}) { Text("OK") } }, modifier = Modifier.padding(8.dp).align(Alignment.BottomCenter), ) { Text("Snackbar") } Popup(alignment = Alignment.Center) { Box( modifier = Modifier.size(200.dp, 100.dp).background(Gray), contentAlignment = Alignment.Center, ) { Text("Popup") } } } ``` <img width="592" alt="Screenshot 2023-11-27 at 13 57 43" src="https://github.com/JetBrains/compose-multiplatform-core/assets/1836384/dda1f2d6-6a1e-456c-8763-46a82d9562a8"> ## Issues Fixed Fixes JetBrains/compose-multiplatform#3823 Fixes JetBrains/compose-multiplatform#3739 Fixes JetBrains/compose-multiplatform#3353 Fixes JetBrains/compose-multiplatform#3474
- Loading branch information
1 parent
b2dd9cb
commit 9751714
Showing
11 changed files
with
284 additions
and
101 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
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
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.