blob: 308dbbee302be5028bcd9998b17523611e194151 [file] [log] [blame]
The Android Open Source Project31dd5032009-03-03 19:32:27 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Joe Onoratoa5902522009-07-30 13:37:37 -070017package com.android.launcher2;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080018
Jeff Sharkey70864282009-04-07 21:08:40 -070019import android.graphics.Rect;
20
The Android Open Source Project31dd5032009-03-03 19:32:27 -080021/**
22 * Interface defining an object that can receive a drag.
23 *
24 */
25public interface DropTarget {
Michael Jurka0280c3b2010-09-17 15:00:07 -070026 /**
27 * Used to temporarily disable certain drop targets
28 *
29 * @return boolean specifying whether this drop target is currently enabled
30 */
31 boolean isDropEnabled();
The Android Open Source Project31dd5032009-03-03 19:32:27 -080032
33 /**
34 * Handle an object being dropped on the DropTarget
35 *
36 * @param source DragSource where the drag started
37 * @param x X coordinate of the drop location
38 * @param y Y coordinate of the drop location
Joe Onorato00acb122009-08-04 16:04:30 -040039 * @param xOffset Horizontal offset with the object being dragged where the original
40 * touch happened
41 * @param yOffset Vertical offset with the object being dragged where the original
42 * touch happened
43 * @param dragView The DragView that's being dragged around on screen.
The Android Open Source Project31dd5032009-03-03 19:32:27 -080044 * @param dragInfo Data associated with the object being dragged
45 *
46 */
Joe Onorato00acb122009-08-04 16:04:30 -040047 void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
48 DragView dragView, Object dragInfo);
The Android Open Source Project31dd5032009-03-03 19:32:27 -080049
Joe Onorato00acb122009-08-04 16:04:30 -040050 void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
51 DragView dragView, Object dragInfo);
The Android Open Source Project31dd5032009-03-03 19:32:27 -080052
Joe Onorato00acb122009-08-04 16:04:30 -040053 void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
54 DragView dragView, Object dragInfo);
The Android Open Source Project31dd5032009-03-03 19:32:27 -080055
Joe Onorato00acb122009-08-04 16:04:30 -040056 void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
57 DragView dragView, Object dragInfo);
The Android Open Source Project31dd5032009-03-03 19:32:27 -080058
59 /**
Patrick Dubroy440c3602010-07-13 17:50:32 -070060 * Allows a DropTarget to delegate drag and drop events to another object.
61 *
62 * Most subclasses will should just return null from this method.
63 *
64 * @param source DragSource where the drag started
65 * @param x X coordinate of the drop location
66 * @param y Y coordinate of the drop location
67 * @param xOffset Horizontal offset with the object being dragged where the original
68 * touch happened
69 * @param yOffset Vertical offset with the object being dragged where the original
70 * touch happened
71 * @param dragView The DragView that's being dragged around on screen.
72 * @param dragInfo Data associated with the object being dragged
73 *
74 * @return The DropTarget to delegate to, or null to not delegate to another object.
75 */
76 DropTarget getDropTargetDelegate(DragSource source, int x, int y, int xOffset, int yOffset,
77 DragView dragView, Object dragInfo);
78
79 /**
Jeff Sharkey70864282009-04-07 21:08:40 -070080 * Check if a drop action can occur at, or near, the requested location.
Patrick Dubroy4ed62782010-08-17 15:11:18 -070081 * This will be called just before onDrop.
Jeff Sharkey70864282009-04-07 21:08:40 -070082 *
The Android Open Source Project31dd5032009-03-03 19:32:27 -080083 * @param source DragSource where the drag started
84 * @param x X coordinate of the drop location
85 * @param y Y coordinate of the drop location
Jeff Sharkey70864282009-04-07 21:08:40 -070086 * @param xOffset Horizontal offset with the object being dragged where the
87 * original touch happened
88 * @param yOffset Vertical offset with the object being dragged where the
89 * original touch happened
Joe Onorato00acb122009-08-04 16:04:30 -040090 * @param dragView The DragView that's being dragged around on screen.
The Android Open Source Project31dd5032009-03-03 19:32:27 -080091 * @param dragInfo Data associated with the object being dragged
Jeff Sharkey70864282009-04-07 21:08:40 -070092 * @return True if the drop will be accepted, false otherwise.
The Android Open Source Project31dd5032009-03-03 19:32:27 -080093 */
Joe Onorato00acb122009-08-04 16:04:30 -040094 boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
95 DragView dragView, Object dragInfo);
Jeff Sharkey70864282009-04-07 21:08:40 -070096
Joe Onorato00acb122009-08-04 16:04:30 -040097 // These methods are implemented in Views
98 void getHitRect(Rect outRect);
99 void getLocationOnScreen(int[] loc);
100 int getLeft();
101 int getTop();
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800102}