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

Prepare DragAndDrop for commonization #1510

Merged
merged 4 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions compose/ui/ui/api/desktop/ui.api
Original file line number Diff line number Diff line change
Expand Up @@ -3286,6 +3286,7 @@ public abstract interface class androidx/compose/ui/platform/PlatformContext {
public fun convertLocalToWindowPosition-MK-Hz9U (J)J
public fun convertScreenToLocalPosition-MK-Hz9U (J)J
public fun convertWindowToLocalPosition-MK-Hz9U (J)J
public fun getDragAndDropManager ()Landroidx/compose/ui/platform/PlatformDragAndDropManager;
public abstract fun getInputModeManager ()Landroidx/compose/ui/input/InputModeManager;
public fun getMeasureDrawLayerBounds ()Z
public fun getParentFocusManager ()Landroidx/compose/ui/focus/FocusManager;
Expand All @@ -3298,7 +3299,6 @@ public abstract interface class androidx/compose/ui/platform/PlatformContext {
public fun isWindowTransparent ()Z
public fun requestFocus ()Z
public fun setPointerIcon (Landroidx/compose/ui/input/pointer/PointerIcon;)V
public fun startDrag-12SF9DM (Landroidx/compose/ui/draganddrop/DragAndDropTransferData;JLkotlin/jvm/functions/Function1;)Z
}

public final class androidx/compose/ui/platform/PlatformContext$Companion {
Expand All @@ -3317,6 +3317,24 @@ public abstract interface class androidx/compose/ui/platform/PlatformContext$Sem
public abstract fun onSemanticsOwnerRemoved (Landroidx/compose/ui/semantics/SemanticsOwner;)V
}

public abstract interface class androidx/compose/ui/platform/PlatformDragAndDropManager {
public fun isRequestDragAndDropTransferSupported ()Z
public fun requestDragAndDropTransfer-Uv8p0NA (Landroidx/compose/ui/platform/PlatformDragAndDropSource;J)V
}

public abstract interface class androidx/compose/ui/platform/PlatformDragAndDropSource {
public abstract fun startDragAndDropTransfer-d-4ec7I (Landroidx/compose/ui/platform/PlatformDragAndDropSource$StartTransferScope;JLkotlin/jvm/functions/Function0;)V
}

public abstract interface class androidx/compose/ui/platform/PlatformDragAndDropSource$StartTransferScope {
public abstract fun startDragAndDropTransfer-12SF9DM (Landroidx/compose/ui/draganddrop/DragAndDropTransferData;JLkotlin/jvm/functions/Function1;)Z
}

public abstract interface class androidx/compose/ui/platform/PlatformDragAndDropTarget : androidx/compose/ui/draganddrop/DragAndDropTarget {
public abstract fun acceptDragAndDropTransfer (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)Z
public abstract fun getHasEligibleDropTarget ()Z
}

public final class androidx/compose/ui/platform/PlatformInsets {
public static final field $stable I
public static final field Companion Landroidx/compose/ui/platform/PlatformInsets$Companion;
Expand Down Expand Up @@ -3515,7 +3533,7 @@ public abstract interface class androidx/compose/ui/scene/ComposeScene {
public abstract fun createLayer (Landroidx/compose/ui/unit/Density;Landroidx/compose/ui/unit/LayoutDirection;ZLandroidx/compose/runtime/CompositionContext;)Landroidx/compose/ui/scene/ComposeSceneLayer;
public abstract fun getCompositionLocalContext ()Landroidx/compose/runtime/CompositionLocalContext;
public abstract fun getDensity ()Landroidx/compose/ui/unit/Density;
public abstract fun getDropTarget ()Landroidx/compose/ui/scene/ComposeSceneDropTarget;
public abstract fun getDragAndDropTarget ()Landroidx/compose/ui/scene/ComposeSceneDragAndDropTarget;
public abstract fun getFocusManager ()Landroidx/compose/ui/scene/ComposeSceneFocusManager;
public abstract fun getLayoutDirection ()Landroidx/compose/ui/unit/LayoutDirection;
public abstract fun getSize-bOM6tXw ()Landroidx/compose/ui/unit/IntSize;
Expand Down Expand Up @@ -3545,13 +3563,17 @@ public final class androidx/compose/ui/scene/ComposeSceneContext$Companion {
public final fun getEmpty ()Landroidx/compose/ui/scene/ComposeSceneContext;
}

public final class androidx/compose/ui/scene/ComposeSceneDropTarget {
public final class androidx/compose/ui/scene/ComposeSceneDragAndDropTarget : androidx/compose/ui/draganddrop/DragAndDropTarget {
public static final field $stable I
public final fun onChanged (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)V
public final fun onDrop (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)Z
public final fun onEntered (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)Z
public final fun onExited (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)V
public final fun onMoved (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)V
public final fun acceptDragAndDropTransfer (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)Z
public final fun getHasEligibleDropTarget ()Z
public fun onChanged (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)V
public fun onDrop (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)Z
public fun onEnded (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)V
public fun onEntered (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)V
public fun onExited (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)V
public fun onMoved (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)V
public fun onStarted (Landroidx/compose/ui/draganddrop/DragAndDropEvent;)V
}

public final class androidx/compose/ui/scene/ComposeSceneFocusManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,27 @@

package androidx.compose.ui.draganddrop

import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.geometry.Offset

internal interface DragAndDropManager {

/**
* A [Modifier] that can be added to the [Owners][androidx.compose.ui.node.Owner] modifier
* list that contains the modifiers required by drag and drop.
* (Eg, a root drag and drop modifier).
* Returns a boolean value indicating whether requesting drag and drop transfer is supported. If
* it's not, the transfer might be initiated only be system and calling
* [requestDragAndDropTransfer] will throw an error.
*/
val modifier: Modifier
val isRequestDragAndDropTransferSupported: Boolean
get() = false

/**
* Initiates a drag-and-drop operation for transferring data.
*
* @param transferData the data to be transferred after successful completion of the
* drag and drop gesture.
*
* @param decorationSize the size of the drag decoration to be drawn.
*
* @param drawDragDecoration provides the visual representation of the item dragged during the
* drag and drop gesture.
*
* @return true if the method completes successfully, or false if it fails anywhere.
* Returning false means the system was unable to do a drag because of another
* ongoing operation or some other reasons.
* Requests a drag and drop transfer. It might throw [UnsupportedOperationException] in case if
* the operation is not supported. [isRequestDragAndDropTransferSupported] can be used to check
* if it might be performed.
*/
fun drag(
transferData: DragAndDropTransferData,
decorationSize: Size,
drawDragDecoration: DrawScope.() -> Unit,
): Boolean

/**
* Called to notify this [DragAndDropManager] that a [DragAndDropModifierNode] is interested
* in receiving events for a particular drag and drop session.
*/
fun registerNodeInterest(node: DragAndDropModifierNode)

/**
* Called to check if a [DragAndDropModifierNode] has previously registered interest for a
* drag and drop session.
*/
fun isInterestedNode(node: DragAndDropModifierNode): Boolean
fun requestDragAndDropTransfer(node: DragAndDropNode, offset: Offset) {
throw UnsupportedOperationException(
"requestDragAndDropTransfer is not supported in the current environment. " +
"A Drag & Drop transfer will be initiated by the platform itself"
)
}
}
Loading