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. 4 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_ 7 8 #include <string> 9 10 namespace gfx { 11 class Point; 12 class Vector2d; 13 } // namespace gfx 14 15 namespace app_list { 16 17 // This class will get used by the AppListView to drag and drop Application 18 // shortcuts onto another host (the launcher). 19 class ApplicationDragAndDropHost { 20 public: 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; 33 34 // Update the screen location of the Drag icon proxy. 35 virtual void UpdateDragIconProxy( 36 const gfx::Point& location_in_screen_coordinates) = 0; 37 38 // Remove the OS dependent drag proxy from the screen. 39 virtual void DestroyDragIconProxy() = 0; 40 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 44 // get dropped. 45 virtual bool StartDrag(const std::string& app_id, 46 const gfx::Point& location_in_screen_coordinates) = 0; 47 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; 54 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; 59 }; 60 61 } // namespace app_list 62 63 #endif // UI_APP_LIST_VIEWS_APP_LIST_DRAG_AND_DROP_HOST_H_ 64