blob: e33ec9a63784b06cd9400f1d063fbf5ce4fb1996 [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 {
26
27 /**
28 * Handle an object being dropped on the DropTarget
29 *
30 * @param source DragSource where the drag started
31 * @param x X coordinate of the drop location
32 * @param y Y coordinate of the drop location
Joe Onorato00acb122009-08-04 16:04:30 -040033 * @param xOffset Horizontal offset with the object being dragged where the original
34 * touch happened
35 * @param yOffset Vertical offset with the object being dragged where the original
36 * touch happened
37 * @param dragView The DragView that's being dragged around on screen.
The Android Open Source Project31dd5032009-03-03 19:32:27 -080038 * @param dragInfo Data associated with the object being dragged
39 *
40 */
Joe Onorato00acb122009-08-04 16:04:30 -040041 void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
42 DragView dragView, Object dragInfo);
The Android Open Source Project31dd5032009-03-03 19:32:27 -080043
Joe Onorato00acb122009-08-04 16:04:30 -040044 void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
45 DragView dragView, Object dragInfo);
The Android Open Source Project31dd5032009-03-03 19:32:27 -080046
Joe Onorato00acb122009-08-04 16:04:30 -040047 void onDragOver(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 onDragExit(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
53 /**
Patrick Dubroy440c3602010-07-13 17:50:32 -070054 * Allows a DropTarget to delegate drag and drop events to another object.
55 *
56 * Most subclasses will should just return null from this method.
57 *
58 * @param source DragSource where the drag started
59 * @param x X coordinate of the drop location
60 * @param y Y coordinate of the drop location
61 * @param xOffset Horizontal offset with the object being dragged where the original
62 * touch happened
63 * @param yOffset Vertical offset with the object being dragged where the original
64 * touch happened
65 * @param dragView The DragView that's being dragged around on screen.
66 * @param dragInfo Data associated with the object being dragged
67 *
68 * @return The DropTarget to delegate to, or null to not delegate to another object.
69 */
70 DropTarget getDropTargetDelegate(DragSource source, int x, int y, int xOffset, int yOffset,
71 DragView dragView, Object dragInfo);
72
73 /**
Jeff Sharkey70864282009-04-07 21:08:40 -070074 * Check if a drop action can occur at, or near, the requested location.
Patrick Dubroy4ed62782010-08-17 15:11:18 -070075 * This will be called just before onDrop.
Jeff Sharkey70864282009-04-07 21:08:40 -070076 *
The Android Open Source Project31dd5032009-03-03 19:32:27 -080077 * @param source DragSource where the drag started
78 * @param x X coordinate of the drop location
79 * @param y Y coordinate of the drop location
Jeff Sharkey70864282009-04-07 21:08:40 -070080 * @param xOffset Horizontal offset with the object being dragged where the
81 * original touch happened
82 * @param yOffset Vertical offset with the object being dragged where the
83 * original touch happened
Joe Onorato00acb122009-08-04 16:04:30 -040084 * @param dragView The DragView that's being dragged around on screen.
The Android Open Source Project31dd5032009-03-03 19:32:27 -080085 * @param dragInfo Data associated with the object being dragged
Jeff Sharkey70864282009-04-07 21:08:40 -070086 * @return True if the drop will be accepted, false otherwise.
The Android Open Source Project31dd5032009-03-03 19:32:27 -080087 */
Joe Onorato00acb122009-08-04 16:04:30 -040088 boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
89 DragView dragView, Object dragInfo);
Jeff Sharkey70864282009-04-07 21:08:40 -070090
91 /**
92 * Estimate the surface area where this object would land if dropped at the
93 * given location.
94 *
95 * @param source DragSource where the drag started
96 * @param x X coordinate of the drop location
97 * @param y Y coordinate of the drop location
98 * @param xOffset Horizontal offset with the object being dragged where the
99 * original touch happened
100 * @param yOffset Vertical offset with the object being dragged where the
101 * original touch happened
Joe Onorato00acb122009-08-04 16:04:30 -0400102 * @param dragView The DragView that's being dragged around on screen.
Jeff Sharkey70864282009-04-07 21:08:40 -0700103 * @param dragInfo Data associated with the object being dragged
104 * @param recycle {@link Rect} object to be possibly recycled.
105 * @return Estimated area that would be occupied if object was dropped at
106 * the given location. Should return null if no estimate is found,
107 * or if this target doesn't provide estimations.
108 */
Joe Onorato00acb122009-08-04 16:04:30 -0400109 Rect estimateDropLocation(DragSource source, int x, int y, int xOffset, int yOffset,
110 DragView dragView, Object dragInfo, Rect recycle);
111
112 // These methods are implemented in Views
113 void getHitRect(Rect outRect);
114 void getLocationOnScreen(int[] loc);
115 int getLeft();
116 int getTop();
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800117}