Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwingPanel doesn't respect clipping #3207

Closed
rock3r opened this issue May 25, 2023 · 3 comments · Fixed by JetBrains/compose-multiplatform-core#1147
Closed

SwingPanel doesn't respect clipping #3207

rock3r opened this issue May 25, 2023 · 3 comments · Fixed by JetBrains/compose-multiplatform-core#1147
Assignees
Labels
bug Something isn't working rendering Low level rendering swing interop Swing interop issue

Comments

@rock3r
Copy link
Contributor

rock3r commented May 25, 2023

Describe the bug
SwingPanel contents don't respect clipping set on themselves nor their parents. This is especially problematic when used in a scrollable container that has other composable around it along the scroll axis.

Affected platforms

  • Desktop

Versions

  • Kotlin version*: 1.7.20
  • Compose Multiplatform version*: 1.2.1
  • OS version(s)* (required for Desktop and iOS issues): macOS Ventura, Swing
  • OS architecture (x86 or arm64): arm64 but irrelevant
  • JDK (for desktop issues): 17

To Reproduce

  1. Create a Box, set a fixed size on it, and clipToBounds
  2. Add a SwingPanel inside with a Swing component that's larger than the Box
  3. Observe that the SwingPanel content doesn't respect the clipping

Expected behavior
Clipping should always be respected

@rock3r rock3r added bug Something isn't working submitted labels May 25, 2023
@igordmn igordmn added swing interop Swing interop issue rendering Low level rendering p:high High priority labels May 25, 2023
@MatkovIvan MatkovIvan self-assigned this Feb 21, 2024
@MatkovIvan
Copy link
Member

Should be mitigated by JetBrains/compose-multiplatform-core#915

@MatkovIvan MatkovIvan removed the p:high High priority label Feb 21, 2024
@MatkovIvan
Copy link
Member

Actually, it works even without JetBrains/compose-multiplatform-core#915

The most likely fix is JetBrains/compose-multiplatform-core#922 (not sure, there are a few changes there). Anyway, it should work in 1.6.0. Please let me know if it doesn't

@MatkovIvan
Copy link
Member

Ah. It sets bounds instead of actual clipping now. Reopening

Screen.Recording.2024-02-27.at.18.50.08.mov

@MatkovIvan MatkovIvan reopened this Feb 27, 2024
MatkovIvan added a commit to JetBrains/compose-multiplatform-core that referenced this issue Feb 29, 2024
## Proposed Changes

- Fix setting bounds - currently it relys on clipped size
- Use clipped bounds for actual clipping, but not clipped for interop
layout
- Based on #1145

## Testing

Test: try to use `SwingPanel` inside scroll

```kt
Column(Modifier.size(250.dp).verticalScroll(rememberScrollState())) {
    repeat(10) {
        SwingPanel(
            factory = { JButton() },
            modifier = Modifier.size(100.dp)
        )
    }
}
````

Before:


https://github.com/JetBrains/compose-multiplatform-core/assets/1836384/362198c2-f8fa-4004-881b-5a7a6867f0c0

After:


https://github.com/JetBrains/compose-multiplatform-core/assets/1836384/546968e6-dcff-4f70-9935-0465dcb2a6e4




## Issues Fixed

Fixes JetBrains/compose-multiplatform#3207
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rendering Low level rendering swing interop Swing interop issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants