-
Notifications
You must be signed in to change notification settings - Fork 79
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
External drag and drop support for compose application #391
Conversation
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
048229e
to
b57d9bd
Compare
b57d9bd
to
6614da1
Compare
Made few force-pushes with rebasing on up-to-date main branch and removed links to the issues in commit messages, since it spams there :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nitpicks. A great PR overall.
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
* @param onDragStart will be called when the pointer with external content entered the component. | ||
* @param onDrag will be called for all drag events inside the component. | ||
* @param onDrop is called when the pointer is released with [DropData] the pointer held. | ||
* @param onDragCancel is called if the pointer exited the component bounds or unknown data was dropped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style guide says we're supposed to fit into 100 columns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, weird that IDEA doesn't move it to the new line. Where do you see this into styleguide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure; @igordmn told me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was worked perfectly in Android Studio in AOSP, but we have bugs in our fork, and this limit doesn't always apply.
There is an idea to increase it for our fork. It will complicate upstreaming into AOSP, but that is another discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I manually controll this length and change it here or it is ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use the project one, weird
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I reviewed only API and behavior. Let's m-sasha do a full review.
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
…ponent bounds change
…e new component bounds to Swing
@m-sasha thank you for your review! I've fixed most of your comments, most importantly, I've rewritten the code that handles component bounds changes, please take a look at it. |
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/dnd/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
@m-sasha thank you for your comments, fixed most of them (except code style, since don't get what to do better) |
* don't use sealed interface and data classes * provide mimeTypes for all drop data * provide methods to read drop data content instead of having properties
@igordmn I've updated the pull request with changes in API, please take a look at it. I'd keep it experimental, since there are a few things that can be improved, but we can decide how to do that only according to the feedback. |
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! API looks good now.
Left one small comment, and we good to merge
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/ExternalDrag.desktop.kt
Outdated
Show resolved
Hide resolved
…nalDrag.desktop.kt Co-authored-by: Igor Demin <igordmn@users.noreply.github.com>
Proposed Changes
Introduce drag and drop support from external resources to compose application.
For now, for desktop only.
Testing
It can be tested by introduced
androidx.compose.ui.dnd.ExternalDragTest
or manually byandroidx.compose.desktop.examples.dnd.Main_jvmKt#main
Issues Fixed
Fixes: JetBrains/compose-multiplatform#222