blob: 65451363a6782852a561a244e4b2e3098f61c307 [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_APP_LIST_VIEWS_APP_LIST_DRAG_AND_DROP_HOST_H_
#define UI_APP_LIST_VIEWS_APP_LIST_DRAG_AND_DROP_HOST_H_
#include <string>
namespace gfx {
class Point;
class Vector2d;
} // namespace gfx
namespace views {
class View;
} // namespace views
namespace app_list {
// This class will get used by the AppListView to drag and drop Application
// shortcuts onto another host (the launcher).
class ApplicationDragAndDropHost {
public:
// Create an OS dependent drag proxy icon which can escape the given view.
// The proxy should get created using the |icon| with a magnification of
// |scale_factor| at a center location of |location_in_screen_coordinates.
// Use |replaced_view| to find the screen which is used.
// The |cursor_offset_from_center| is the offset from the mouse cursor to
// the center of the item.
virtual void CreateDragIconProxy(
const gfx::Point& location_in_screen_coordinates,
const gfx::ImageSkia& icon,
views::View* replaced_view,
const gfx::Vector2d& cursor_offset_from_center,
float scale_factor) = 0;
// Update the screen location of the Drag icon proxy.
virtual void UpdateDragIconProxy(
const gfx::Point& location_in_screen_coordinates) = 0;
// Remove the OS dependent drag proxy from the screen.
virtual void DestroyDragIconProxy() = 0;
// A drag operation could get started. The recipient has to return true if
// it wants to take it - e.g. |location_in_screen_poordinates| is over a
// target area. The passed |app_id| identifies the application which should
// get dropped.
virtual bool StartDrag(const std::string& app_id,
const gfx::Point& location_in_screen_coordinates) = 0;
// This gets only called when the |StartDrag| function returned true and it
// dispatches the mouse coordinate change accordingly. When the function
// returns false it requests that the operation be aborted since the event
// location is out of bounds.
// Note that this function does not update the drag proxy's screen position.
virtual bool Drag(const gfx::Point& location_in_screen_coordinates) = 0;
// Once |StartDrag| returned true, this function is guaranteed to be called
// when the mouse / touch events stop. If |cancel| is set, the drag operation
// was aborted, otherwise the change should be kept.
virtual void EndDrag(bool cancel) = 0;
};
} // namespace app_list
#endif // UI_APP_LIST_VIEWS_APP_LIST_DRAG_AND_DROP_HOST_H_