summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-10 20:39:34 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-10 20:39:34 +0000
commite8f9ca0a0b4ccdf72f33872ea0ea36f89496586c (patch)
tree1ebb836f87551f4895043bf4f4d5de4d79a223fb
parent8eb987dac91a07f56293a0b4c08745815e66b111 (diff)
downloadchromium_src-e8f9ca0a0b4ccdf72f33872ea0ea36f89496586c.zip
chromium_src-e8f9ca0a0b4ccdf72f33872ea0ea36f89496586c.tar.gz
chromium_src-e8f9ca0a0b4ccdf72f33872ea0ea36f89496586c.tar.bz2
Merge 210479 "app_list: Fix unnecessary image zoomy on click."
> app_list: Fix unnecessary image zoomy on click. > > Defer dnd host icon creation until drag is confirmed. > > BUG=251237 > > Review URL: https://chromiumcodereview.appspot.com/18132013 TBR=xiyuan@chromium.org Review URL: https://codereview.chromium.org/18660006 git-svn-id: svn://svn.chromium.org/chrome/branches/1547/src@210922 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/app_list/views/apps_grid_view.cc50
-rw-r--r--ui/app_list/views/apps_grid_view.h4
2 files changed, 34 insertions, 20 deletions
diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc
index c3e0c61..ad9c62a 100644
--- a/ui/app_list/views/apps_grid_view.cc
+++ b/ui/app_list/views/apps_grid_view.cc
@@ -322,26 +322,6 @@ void AppsGridView::InitiateDrag(AppListItemView* view,
return;
drag_view_ = view;
-
- // When a drag and drop host is given, the item can be dragged out of the app
- // list window. In that case a proxy widget needs to be used.
- // Note: This code has very likely to be changed for Windows (non metro mode)
- // when a |drag_and_drop_host_| gets implemented.
- if (drag_and_drop_host_) {
- // Determine the mouse offset to the center of the icon so that the drag and
- // drop host follows this layer.
- gfx::Vector2d delta = event.root_location() -
- drag_view_->GetBoundsInScreen().CenterPoint();
- delta.set_y(delta.y() + drag_view_->title()->size().height() / 2);
- // We have to hide the original item since the drag and drop host will do
- // the OS dependent code to "lift off the dragged item".
- drag_and_drop_host_->CreateDragIconProxy(event.root_location(),
- view->model()->icon(),
- drag_view_,
- delta,
- kDragAndDropProxyScale);
- HideView(drag_view_, true);
- }
drag_view_offset_ = event.location();
ExtractDragLocation(event, &drag_start_grid_view_);
drag_view_start_ = gfx::Point(drag_view_->x(), drag_view_->y());
@@ -392,6 +372,8 @@ void AppsGridView::UpdateDragFromItem(Pointer pointer,
gfx::Point drag_point_in_grid_view;
ExtractDragLocation(event, &drag_point_in_grid_view);
UpdateDrag(pointer, drag_point_in_grid_view);
+ if (!dragging())
+ return;
// If a drag and drop host is provided, see if the drag operation needs to be
// forwarded.
@@ -415,6 +397,7 @@ void AppsGridView::UpdateDrag(Pointer pointer, const gfx::Point& point) {
ReorderChildView(drag_view_, -1);
bounds_animator_.StopAnimatingView(drag_view_);
StartSettingUpSynchronousDrag();
+ StartDragAndDropHostDrag(point);
}
if (drag_pointer_ != pointer)
@@ -946,6 +929,33 @@ void AppsGridView::CalculateDropTarget(const gfx::Point& drag_point,
}
}
+void AppsGridView::StartDragAndDropHostDrag(const gfx::Point& grid_location) {
+ // When a drag and drop host is given, the item can be dragged out of the app
+ // list window. In that case a proxy widget needs to be used.
+ // Note: This code has very likely to be changed for Windows (non metro mode)
+ // when a |drag_and_drop_host_| gets implemented.
+ if (!drag_view_ || !drag_and_drop_host_)
+ return;
+
+ gfx::Point screen_location = grid_location;
+ views::View::ConvertPointToScreen(this, &screen_location);
+
+ // Determine the mouse offset to the center of the icon so that the drag and
+ // drop host follows this layer.
+ gfx::Vector2d delta = drag_view_offset_ -
+ drag_view_->GetLocalBounds().CenterPoint();
+ delta.set_y(delta.y() + drag_view_->title()->size().height() / 2);
+
+ // We have to hide the original item since the drag and drop host will do
+ // the OS dependent code to "lift off the dragged item".
+ drag_and_drop_host_->CreateDragIconProxy(screen_location,
+ drag_view_->model()->icon(),
+ drag_view_,
+ delta,
+ kDragAndDropProxyScale);
+ HideView(drag_view_, true);
+}
+
void AppsGridView::DispatchDragEventToDragAndDropHost(
const gfx::Point& point) {
if (!drag_view_ || !drag_and_drop_host_)
diff --git a/ui/app_list/views/apps_grid_view.h b/ui/app_list/views/apps_grid_view.h
index d8abac2..1118a46 100644
--- a/ui/app_list/views/apps_grid_view.h
+++ b/ui/app_list/views/apps_grid_view.h
@@ -202,6 +202,10 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
void CalculateDropTarget(const gfx::Point& drag_point,
bool use_page_button_hovering);
+ // Prepares |drag_and_drop_host_| for dragging. |grid_location| contains
+ // the drag point in this grid view's coordinates.
+ void StartDragAndDropHostDrag(const gfx::Point& grid_location);
+
// Dispatch the drag and drop update event to the dnd host (if needed).
void DispatchDragEventToDragAndDropHost(const gfx::Point& point);