1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_VIEWS_APP_LIST_DRAG_AND_DROP_HOST_H_
6 #define UI_APP_LIST_VIEWS_APP_LIST_DRAG_AND_DROP_HOST_H_
17 // This class will get used by the AppListView to drag and drop Application
18 // shortcuts onto another host (the launcher).
19 class ApplicationDragAndDropHost {
21 // Create an OS dependent drag proxy icon which can escape the given view.
22 // The proxy should get created using the |icon| with a magnification of
23 // |scale_factor| at a center location of |location_in_screen_coordinates.
24 // Use |replaced_view| to find the screen which is used.
25 // The |cursor_offset_from_center| is the offset from the mouse cursor to
26 // the center of the item.
27 virtual void CreateDragIconProxy(
28 const gfx::Point& location_in_screen_coordinates,
29 const gfx::ImageSkia& icon,
30 views::View* replaced_view,
31 const gfx::Vector2d& cursor_offset_from_center,
32 float scale_factor) = 0;
34 // Update the screen location of the Drag icon proxy.
35 virtual void UpdateDragIconProxy(
36 const gfx::Point& location_in_screen_coordinates) = 0;
38 // Remove the OS dependent drag proxy from the screen.
39 virtual void DestroyDragIconProxy() = 0;
41 // A drag operation could get started. The recipient has to return true if
42 // he wants to take it - e.g. |location_in_screen_poordinates| is over a
43 // target area. The passed |app_id| identifies the application which should
45 virtual bool StartDrag(const std::string& app_id,
46 const gfx::Point& location_in_screen_coordinates) = 0;
48 // This gets only called when the |StartDrag| function returned true and it
49 // dispatches the mouse coordinate change accordingly. When the function
50 // returns false it requests that the operation be aborted since the event
51 // location is out of bounds.
52 // Note that this function does not update the drag proxy's screen position.
53 virtual bool Drag(const gfx::Point& location_in_screen_coordinates) = 0;
55 // Once |StartDrag| returned true, this function is guaranteed to be called
56 // when the mouse / touch events stop. If |cancel| is set, the drag operation
57 // was aborted, otherwise the change should be kept.
58 virtual void EndDrag(bool cancel) = 0;
61 } // namespace app_list
63 #endif // UI_APP_LIST_VIEWS_APP_LIST_DRAG_AND_DROP_HOST_H_