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

Fix LayoutCoordinates.localToWindow coordinates conversion for non-full Compose components #956

Merged
merged 7 commits into from
Dec 19, 2023

Conversation

MatkovIvan
Copy link
Member

Proposed Changes

  • Replace size to boundsInWindow in ComposeScene
  • Provide implementation for calculatePositionInWindow in Owner
  • Fix layer position if the main scene is placed with offset

@MatkovIvan MatkovIvan merged commit b42dfe4 into jb-main Dec 19, 2023
4 checks passed
@MatkovIvan MatkovIvan deleted the ivan.matkov/fix-position-in-window branch December 19, 2023 13:54
MatkovIvan added a commit that referenced this pull request Dec 19, 2023
## Proposed Changes

- Address TODO from #956
- Use `WindowInfo.contentSize` instead of local constraints in
`Popup`/`Dialog`
- Pass real scene offset relative to the window.
MatkovIvan added a commit that referenced this pull request Jan 11, 2024
## Proposed Changes

- Use root coordinates for interop instead of window ones - it's
different after #956

## Testing

Test: run app from the issue or open "UIKitViewMatryoshka" in mpp

Before | After
---|---
![Simulator Screenshot - iPhone 15 Pro - 2024-01-11 at 13 00
20](https://github.com/JetBrains/compose-multiplatform-core/assets/1836384/0035c206-1f1c-40d6-a59a-f6f3c9d01617)
| ![Simulator Screenshot - iPhone 15 Pro - 2024-01-11 at 13 06
04](https://github.com/JetBrains/compose-multiplatform-core/assets/1836384/cf679f2a-0c35-41c2-ac1a-66c18feced8c)



## Issues Fixed

Fixes JetBrains/compose-multiplatform#4095
MatkovIvan added a commit that referenced this pull request Jan 13, 2024
## Proposed Changes

- Use window coordinates to check if it's in bounds - it's different
after #956

## Testing

Test: run added unit test or the next sample:
```kt
fun main() = SwingUtilities.invokeLater {
    SwingComposeWindow()
}

fun SwingComposeWindow() {
    val window = JFrame()
    window.defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE

    val panel = JPanel()
    panel.layout = GridLayout(2, 1)
    panel.add(JPanel())
    panel.add(ComposePanel().apply {
        setContent {
            ComposeContent(background = Color.Green)
        }
    })
    window.contentPane.add(panel, BorderLayout.CENTER)

    window.setSize(800, 600)
    window.isVisible = true
}

@OptIn(ExperimentalFoundationApi::class)
@composable
fun ComposeContent(background: Color) {
    Box(
        modifier = Modifier.fillMaxSize().background(color = background),
        contentAlignment = Alignment.Center
    ) {

        TooltipArea({ BasicText("Tooltip", Modifier.background(Color.Magenta).padding(8.dp)) }) {
            BasicText("Hover here", Modifier.background(Color.Gray).padding(8.dp))
        }
    }
}
```

## Issues Fixed

Fixes JetBrains/compose-multiplatform#4123
@igordmn igordmn changed the title Fix localToWindow coordinates conversion Fix LayoutCoordinates.localToWindow coordinates conversion for non-full Compose componets Jan 24, 2024
@igordmn igordmn changed the title Fix LayoutCoordinates.localToWindow coordinates conversion for non-full Compose componets Fix LayoutCoordinates.localToWindow coordinates conversion for non-full Compose components Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants