OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/app_list/views/apps_grid_view.h" | 5 #include "ui/app_list/views/apps_grid_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ui/app_list/app_list_item_model.h" | 9 #include "ui/app_list/app_list_item_model.h" |
10 #include "ui/app_list/apps_grid_view_delegate.h" | 10 #include "ui/app_list/apps_grid_view_delegate.h" |
11 #include "ui/app_list/pagination_model.h" | 11 #include "ui/app_list/pagination_model.h" |
12 #include "ui/app_list/views/app_list_drag_and_drop_host.h" | 12 #include "ui/app_list/views/app_list_drag_and_drop_host.h" |
13 #include "ui/app_list/views/app_list_item_view.h" | 13 #include "ui/app_list/views/app_list_item_view.h" |
14 #include "ui/app_list/views/page_switcher.h" | 14 #include "ui/app_list/views/page_switcher.h" |
15 #include "ui/app_list/views/pulsing_block_view.h" | 15 #include "ui/app_list/views/pulsing_block_view.h" |
16 #include "ui/base/animation/animation.h" | 16 #include "ui/base/animation/animation.h" |
17 #include "ui/base/events/event.h" | 17 #include "ui/base/events/event.h" |
18 #include "ui/compositor/scoped_layer_animation_settings.h" | 18 #include "ui/compositor/scoped_layer_animation_settings.h" |
19 #include "ui/views/border.h" | 19 #include "ui/views/border.h" |
20 #include "ui/views/view_model_utils.h" | 20 #include "ui/views/view_model_utils.h" |
21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
22 | 22 |
23 #if defined(USE_AURA) | 23 #if defined(USE_AURA) |
24 #include "ui/aura/root_window.h" | 24 #include "ui/aura/root_window.h" |
25 #endif | 25 #endif |
26 | 26 |
| 27 #if defined(OS_WIN) && !defined(USE_AURA) |
| 28 #include "base/command_line.h" |
| 29 #include "base/files/file_path.h" |
| 30 #include "base/win/shortcut.h" |
| 31 #include "ui/base/dragdrop/drag_utils.h" |
| 32 #include "ui/base/dragdrop/drop_target_win.h" |
| 33 #include "ui/base/dragdrop/os_exchange_data.h" |
| 34 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
| 35 #endif |
| 36 |
27 namespace { | 37 namespace { |
28 | 38 |
29 // Padding space in pixels for fixed layout. | 39 // Padding space in pixels for fixed layout. |
30 const int kLeftRightPadding = 20; | 40 const int kLeftRightPadding = 20; |
31 const int kTopPadding = 1; | 41 const int kTopPadding = 1; |
32 | 42 |
33 // Padding space in pixels between pages. | 43 // Padding space in pixels between pages. |
34 const int kPagePadding = 40; | 44 const int kPagePadding = 40; |
35 | 45 |
36 // Preferred tile size when showing in fixed layout. | 46 // Preferred tile size when showing in fixed layout. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 const gfx::Rect layer_start_; | 109 const gfx::Rect layer_start_; |
100 const gfx::Rect layer_target_; | 110 const gfx::Rect layer_target_; |
101 | 111 |
102 DISALLOW_COPY_AND_ASSIGN(RowMoveAnimationDelegate); | 112 DISALLOW_COPY_AND_ASSIGN(RowMoveAnimationDelegate); |
103 }; | 113 }; |
104 | 114 |
105 } // namespace | 115 } // namespace |
106 | 116 |
107 namespace app_list { | 117 namespace app_list { |
108 | 118 |
| 119 #if defined(OS_WIN) && !defined(USE_AURA) |
| 120 // Interprets drag events sent from Windows via the drag/drop API and forwards |
| 121 // them to AppsGridView. |
| 122 // On Windows, in order to have the OS perform the drag properly we need to |
| 123 // provide it with a shortcut file which may or may not exist at the time the |
| 124 // drag is started. Therefore while waiting for that shortcut to be located we |
| 125 // just do a regular "internal" drag and transition into the synchronous drag |
| 126 // when the shortcut is found/created. Hence a synchronous drag is an optional |
| 127 // phase of a regular drag and non-Windows platforms drags are equivalent to a |
| 128 // Windows drag that never enters the synchronous drag phase. |
| 129 class SynchronousDrag : public ui::DragSourceWin { |
| 130 public: |
| 131 SynchronousDrag(app_list::AppsGridView* grid_view, |
| 132 app_list::AppListItemView* drag_view, |
| 133 const gfx::Point& drag_view_offset) |
| 134 : grid_view_(grid_view), |
| 135 drag_view_(drag_view), |
| 136 drag_view_offset_(drag_view_offset), |
| 137 has_shortcut_path_(false), |
| 138 running_(false), |
| 139 canceled_(false) { |
| 140 } |
| 141 |
| 142 void set_shortcut_path(const base::FilePath& shortcut_path) { |
| 143 has_shortcut_path_ = true; |
| 144 shortcut_path_ = shortcut_path; |
| 145 } |
| 146 |
| 147 bool CanRun() { |
| 148 return has_shortcut_path_ && !running_; |
| 149 } |
| 150 |
| 151 void Run() { |
| 152 DCHECK(CanRun()); |
| 153 running_ = true; |
| 154 |
| 155 ui::OSExchangeData data; |
| 156 SetupExchangeData(&data); |
| 157 |
| 158 // Hide the dragged view because the OS is going to create its own. |
| 159 const gfx::Size drag_view_size = drag_view_->size(); |
| 160 drag_view_->SetSize(gfx::Size(0, 0)); |
| 161 |
| 162 // Blocks until the drag is finished. Calls into the ui::DragSourceWin |
| 163 // methods. |
| 164 DWORD effects; |
| 165 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), |
| 166 this, DROPEFFECT_MOVE | DROPEFFECT_LINK, &effects); |
| 167 |
| 168 // Restore the dragged view to its original size. |
| 169 drag_view_->SetSize(drag_view_size); |
| 170 |
| 171 grid_view_->EndDrag(canceled_ || !IsCursorWithinGridView()); |
| 172 } |
| 173 |
| 174 private: |
| 175 // Overridden from ui::DragSourceWin. |
| 176 virtual void OnDragSourceCancel() OVERRIDE { |
| 177 canceled_ = true; |
| 178 } |
| 179 |
| 180 virtual void OnDragSourceDrop() OVERRIDE { |
| 181 } |
| 182 |
| 183 virtual void OnDragSourceMove() OVERRIDE { |
| 184 grid_view_->UpdateDrag(app_list::AppsGridView::MOUSE, |
| 185 GetCursorInGridViewCoords()); |
| 186 |
| 187 // Don't turn pages if the cursor is dragged outside the view. |
| 188 if (!IsCursorWithinGridView()) |
| 189 grid_view_->StopPageFlipTimer(); |
| 190 } |
| 191 |
| 192 void SetupExchangeData(ui::OSExchangeData* data) { |
| 193 data->SetFilename(shortcut_path_); |
| 194 gfx::ImageSkia image(drag_view_->GetDragImage()); |
| 195 gfx::Size image_size(image.size()); |
| 196 drag_utils::SetDragImageOnDataObject( |
| 197 image, |
| 198 image.size(), |
| 199 gfx::Vector2d(drag_view_offset_.x(), drag_view_offset_.y()), |
| 200 data); |
| 201 } |
| 202 |
| 203 HWND GetGridViewHWND() { |
| 204 return grid_view_->GetWidget()->GetTopLevelWidget()->GetNativeView(); |
| 205 } |
| 206 |
| 207 bool IsCursorWithinGridView() { |
| 208 POINT p; |
| 209 GetCursorPos(&p); |
| 210 return GetGridViewHWND() == WindowFromPoint(p); |
| 211 } |
| 212 |
| 213 gfx::Point GetCursorInGridViewCoords() { |
| 214 POINT p; |
| 215 GetCursorPos(&p); |
| 216 ScreenToClient(GetGridViewHWND(), &p); |
| 217 gfx::Point grid_view_pt(p.x, p.y); |
| 218 views::View::ConvertPointFromWidget(grid_view_, &grid_view_pt); |
| 219 return grid_view_pt; |
| 220 } |
| 221 |
| 222 app_list::AppsGridView* grid_view_; |
| 223 app_list::AppListItemView* drag_view_; |
| 224 gfx::Point drag_view_offset_; |
| 225 bool has_shortcut_path_; |
| 226 base::FilePath shortcut_path_; |
| 227 bool running_; |
| 228 bool canceled_; |
| 229 |
| 230 DISALLOW_COPY_AND_ASSIGN(SynchronousDrag); |
| 231 }; |
| 232 #endif // defined(OS_WIN) && !defined(USE_AURA) |
| 233 |
109 AppsGridView::AppsGridView(AppsGridViewDelegate* delegate, | 234 AppsGridView::AppsGridView(AppsGridViewDelegate* delegate, |
110 PaginationModel* pagination_model) | 235 PaginationModel* pagination_model) |
111 : model_(NULL), | 236 : model_(NULL), |
112 delegate_(delegate), | 237 delegate_(delegate), |
113 pagination_model_(pagination_model), | 238 pagination_model_(pagination_model), |
114 page_switcher_view_(new PageSwitcher(pagination_model)), | 239 page_switcher_view_(new PageSwitcher(pagination_model)), |
115 cols_(0), | 240 cols_(0), |
116 rows_per_page_(0), | 241 rows_per_page_(0), |
117 selected_view_(NULL), | 242 selected_view_(NULL), |
118 drag_view_(NULL), | 243 drag_view_(NULL), |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 delta.set_y(delta.y() + drag_view_->title()->size().height() / 2); | 335 delta.set_y(delta.y() + drag_view_->title()->size().height() / 2); |
211 // We have to hide the original item since the drag and drop host will do | 336 // We have to hide the original item since the drag and drop host will do |
212 // the OS dependent code to "lift off the dragged item". | 337 // the OS dependent code to "lift off the dragged item". |
213 drag_and_drop_host_->CreateDragIconProxy(event.root_location(), | 338 drag_and_drop_host_->CreateDragIconProxy(event.root_location(), |
214 view->model()->icon(), | 339 view->model()->icon(), |
215 drag_view_, | 340 drag_view_, |
216 delta, | 341 delta, |
217 kDragAndDropProxyScale); | 342 kDragAndDropProxyScale); |
218 HideView(drag_view_, true); | 343 HideView(drag_view_, true); |
219 } | 344 } |
220 drag_start_ = event.location(); | 345 drag_view_offset_ = event.location(); |
| 346 ExtractDragLocation(event, &drag_start_grid_view_); |
| 347 drag_view_start_ = gfx::Point(drag_view_->x(), drag_view_->y()); |
221 } | 348 } |
222 | 349 |
223 void AppsGridView::UpdateDrag(AppListItemView* view, | 350 void AppsGridView::OnGotShortcutPath(const base::FilePath& path) { |
224 Pointer pointer, | 351 #if defined(OS_WIN) && !defined(USE_AURA) |
225 const ui::LocatedEvent& event) { | 352 // Drag may have ended before we get the shortcut path. |
| 353 if (!synchronous_drag_) |
| 354 return; |
| 355 // Setting the shortcut path here means the next time we hit UpdateDrag() |
| 356 // we'll enter the synchronous drag. |
| 357 // NOTE we don't Run() the drag here because that causes animations not to |
| 358 // update for some reason. |
| 359 synchronous_drag_->set_shortcut_path(path); |
| 360 DCHECK(synchronous_drag_->CanRun()); |
| 361 #endif |
| 362 } |
| 363 |
| 364 void AppsGridView::StartSettingUpSynchronousDrag() { |
| 365 #if defined(OS_WIN) && !defined(USE_AURA) |
| 366 delegate_->GetShortcutPathForApp( |
| 367 drag_view_->model()->app_id(), |
| 368 base::Bind(&AppsGridView::OnGotShortcutPath, base::Unretained(this))); |
| 369 synchronous_drag_ = new SynchronousDrag(this, drag_view_, drag_view_offset_); |
| 370 #endif |
| 371 } |
| 372 |
| 373 bool AppsGridView::RunSynchronousDrag() { |
| 374 #if defined(OS_WIN) && !defined(USE_AURA) |
| 375 if (synchronous_drag_ && synchronous_drag_->CanRun()) { |
| 376 synchronous_drag_->Run(); |
| 377 synchronous_drag_ = NULL; |
| 378 return true; |
| 379 } |
| 380 #endif |
| 381 return false; |
| 382 } |
| 383 |
| 384 void AppsGridView::CleanUpSynchronousDrag() { |
| 385 #if defined(OS_WIN) && !defined(USE_AURA) |
| 386 synchronous_drag_ = NULL; |
| 387 #endif |
| 388 } |
| 389 |
| 390 void AppsGridView::UpdateDragFromItem(Pointer pointer, |
| 391 const ui::LocatedEvent& event) { |
| 392 gfx::Point drag_point_in_grid_view; |
| 393 ExtractDragLocation(event, &drag_point_in_grid_view); |
| 394 UpdateDrag(pointer, drag_point_in_grid_view); |
| 395 |
| 396 // If a drag and drop host is provided, see if the drag operation needs to be |
| 397 // forwarded. |
| 398 DispatchDragEventToDragAndDropHost(event.root_location()); |
| 399 if (drag_and_drop_host_) |
| 400 drag_and_drop_host_->UpdateDragIconProxy(event.root_location()); |
| 401 } |
| 402 |
| 403 void AppsGridView::UpdateDrag(Pointer pointer, const gfx::Point& point) { |
226 // EndDrag was called before if |drag_view_| is NULL. | 404 // EndDrag was called before if |drag_view_| is NULL. |
227 if (!drag_view_) | 405 if (!drag_view_) |
228 return; | 406 return; |
229 | 407 |
230 if (!dragging() && ExceededDragThreshold(event.location() - drag_start_)) { | 408 if (RunSynchronousDrag()) |
| 409 return; |
| 410 |
| 411 gfx::Vector2d drag_vector(point - drag_start_grid_view_); |
| 412 if (!dragging() && ExceededDragThreshold(drag_vector)) { |
231 drag_pointer_ = pointer; | 413 drag_pointer_ = pointer; |
232 // Move the view to the front so that it appears on top of other views. | 414 // Move the view to the front so that it appears on top of other views. |
233 ReorderChildView(drag_view_, -1); | 415 ReorderChildView(drag_view_, -1); |
234 bounds_animator_.StopAnimatingView(drag_view_); | 416 bounds_animator_.StopAnimatingView(drag_view_); |
| 417 StartSettingUpSynchronousDrag(); |
235 } | 418 } |
| 419 |
236 if (drag_pointer_ != pointer) | 420 if (drag_pointer_ != pointer) |
237 return; | 421 return; |
238 | 422 |
239 ExtractDragLocation(event, &last_drag_point_); | 423 last_drag_point_ = point; |
240 const Index last_drop_target = drop_target_; | 424 const Index last_drop_target = drop_target_; |
241 CalculateDropTarget(last_drag_point_, false); | 425 CalculateDropTarget(last_drag_point_, false); |
242 | 426 |
243 // If a drag and drop host is provided, see if the drag operation needs to be | |
244 // forwarded. | |
245 DispatchDragEventToDragAndDropHost(event); | |
246 | |
247 MaybeStartPageFlipTimer(last_drag_point_); | 427 MaybeStartPageFlipTimer(last_drag_point_); |
248 | 428 |
249 gfx::Point page_switcher_point(last_drag_point_); | 429 gfx::Point page_switcher_point(last_drag_point_); |
250 views::View::ConvertPointToTarget(this, page_switcher_view_, | 430 views::View::ConvertPointToTarget(this, page_switcher_view_, |
251 &page_switcher_point); | 431 &page_switcher_point); |
252 page_switcher_view_->UpdateUIForDragPoint(page_switcher_point); | 432 page_switcher_view_->UpdateUIForDragPoint(page_switcher_point); |
253 | 433 |
254 if (last_drop_target != drop_target_) | 434 if (last_drop_target != drop_target_) |
255 AnimateToIdealBounds(); | 435 AnimateToIdealBounds(); |
256 | 436 |
257 if (drag_and_drop_host_) | 437 drag_view_->SetPosition(drag_view_start_ + drag_vector); |
258 drag_and_drop_host_->UpdateDragIconProxy(event.root_location()); | |
259 | |
260 drag_view_->SetPosition( | |
261 gfx::PointAtOffsetFromOrigin(last_drag_point_ - drag_start_)); | |
262 } | 438 } |
263 | 439 |
264 void AppsGridView::EndDrag(bool cancel) { | 440 void AppsGridView::EndDrag(bool cancel) { |
265 // EndDrag was called before if |drag_view_| is NULL. | 441 // EndDrag was called before if |drag_view_| is NULL. |
266 if (!drag_view_) | 442 if (!drag_view_) |
267 return; | 443 return; |
268 | 444 |
269 if (forward_events_to_drag_and_drop_host_) { | 445 if (forward_events_to_drag_and_drop_host_) { |
270 forward_events_to_drag_and_drop_host_ = false; | 446 forward_events_to_drag_and_drop_host_ = false; |
271 drag_and_drop_host_->EndDrag(cancel); | 447 drag_and_drop_host_->EndDrag(cancel); |
272 } else if (!cancel && dragging()) { | 448 } else if (!cancel && dragging()) { |
273 CalculateDropTarget(last_drag_point_, true); | 449 CalculateDropTarget(last_drag_point_, true); |
274 if (IsValidIndex(drop_target_)) | 450 if (IsValidIndex(drop_target_)) |
275 MoveItemInModel(drag_view_, drop_target_); | 451 MoveItemInModel(drag_view_, drop_target_); |
276 } | 452 } |
277 | 453 |
278 if (drag_and_drop_host_) { | 454 if (drag_and_drop_host_) { |
279 // If we had a drag and drop proxy icon, we delete it and make the real | 455 // If we had a drag and drop proxy icon, we delete it and make the real |
280 // item visible again. | 456 // item visible again. |
281 drag_and_drop_host_->DestroyDragIconProxy(); | 457 drag_and_drop_host_->DestroyDragIconProxy(); |
282 HideView(drag_view_, false); | 458 HideView(drag_view_, false); |
283 } | 459 } |
284 | 460 |
| 461 // The drag can be ended after the synchronous drag is created but before it |
| 462 // is Run(). |
| 463 CleanUpSynchronousDrag(); |
| 464 |
285 drag_pointer_ = NONE; | 465 drag_pointer_ = NONE; |
286 drop_target_ = Index(); | 466 drop_target_ = Index(); |
287 drag_view_ = NULL; | 467 drag_view_ = NULL; |
288 AnimateToIdealBounds(); | 468 AnimateToIdealBounds(); |
289 | 469 |
| 470 StopPageFlipTimer(); |
| 471 } |
| 472 |
| 473 void AppsGridView::StopPageFlipTimer() { |
290 page_flip_timer_.Stop(); | 474 page_flip_timer_.Stop(); |
291 page_flip_target_ = -1; | 475 page_flip_target_ = -1; |
292 } | 476 } |
293 | 477 |
294 bool AppsGridView::IsDraggedView(const views::View* view) const { | 478 bool AppsGridView::IsDraggedView(const views::View* view) const { |
295 return drag_view_ == view; | 479 return drag_view_ == view; |
296 } | 480 } |
297 | 481 |
298 void AppsGridView::SetDragAndDropHostOfCurrentAppList( | 482 void AppsGridView::SetDragAndDropHostOfCurrentAppList( |
299 ApplicationDragAndDropHost* drag_and_drop_host) { | 483 ApplicationDragAndDropHost* drag_and_drop_host) { |
(...skipping 16 matching lines...) Expand all Loading... |
316 const gfx::Size tile_size = gfx::Size(kPreferredTileWidth, | 500 const gfx::Size tile_size = gfx::Size(kPreferredTileWidth, |
317 kPreferredTileHeight); | 501 kPreferredTileHeight); |
318 const int page_switcher_height = | 502 const int page_switcher_height = |
319 page_switcher_view_->GetPreferredSize().height(); | 503 page_switcher_view_->GetPreferredSize().height(); |
320 return gfx::Size( | 504 return gfx::Size( |
321 tile_size.width() * cols_ + insets.width(), | 505 tile_size.width() * cols_ + insets.width(), |
322 tile_size.height() * rows_per_page_ + | 506 tile_size.height() * rows_per_page_ + |
323 page_switcher_height + insets.height()); | 507 page_switcher_height + insets.height()); |
324 } | 508 } |
325 | 509 |
| 510 bool AppsGridView::GetDropFormats( |
| 511 int* formats, |
| 512 std::set<OSExchangeData::CustomFormat>* custom_formats) { |
| 513 // TODO(koz): Only accept a specific drag type for app shortcuts. |
| 514 *formats = OSExchangeData::FILE_NAME; |
| 515 return true; |
| 516 } |
| 517 |
| 518 bool AppsGridView::CanDrop(const OSExchangeData& data) { |
| 519 return true; |
| 520 } |
| 521 |
| 522 int AppsGridView::OnDragUpdated(const ui::DropTargetEvent& event) { |
| 523 return ui::DragDropTypes::DRAG_MOVE; |
| 524 } |
| 525 |
326 void AppsGridView::Layout() { | 526 void AppsGridView::Layout() { |
327 if (bounds_animator_.IsAnimating()) | 527 if (bounds_animator_.IsAnimating()) |
328 bounds_animator_.Cancel(); | 528 bounds_animator_.Cancel(); |
329 | 529 |
330 CalculateIdealBounds(); | 530 CalculateIdealBounds(); |
331 for (int i = 0; i < view_model_.view_size(); ++i) { | 531 for (int i = 0; i < view_model_.view_size(); ++i) { |
332 views::View* view = view_model_.view_at(i); | 532 views::View* view = view_model_.view_at(i); |
333 if (view != drag_view_) | 533 if (view != drag_view_) |
334 view->SetBoundsRect(view_model_.ideal_bounds(i)); | 534 view->SetBoundsRect(view_model_.ideal_bounds(i)); |
335 } | 535 } |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 | 940 |
741 // Limits to the last possible slot on last page. | 941 // Limits to the last possible slot on last page. |
742 if (drop_target_.page == pagination_model_->total_pages() - 1) { | 942 if (drop_target_.page == pagination_model_->total_pages() - 1) { |
743 drop_target_.slot = std::min( | 943 drop_target_.slot = std::min( |
744 (view_model_.view_size() - 1) % tiles_per_page(), | 944 (view_model_.view_size() - 1) % tiles_per_page(), |
745 drop_target_.slot); | 945 drop_target_.slot); |
746 } | 946 } |
747 } | 947 } |
748 | 948 |
749 void AppsGridView::DispatchDragEventToDragAndDropHost( | 949 void AppsGridView::DispatchDragEventToDragAndDropHost( |
750 const ui::LocatedEvent& event) { | 950 const gfx::Point& point) { |
751 if (!drag_view_ || !drag_and_drop_host_) | 951 if (!drag_view_ || !drag_and_drop_host_) |
752 return; | 952 return; |
753 if (bounds().Contains(last_drag_point_)) { | 953 if (bounds().Contains(last_drag_point_)) { |
754 // The event was issued inside the app menu and we should get all events. | 954 // The event was issued inside the app menu and we should get all events. |
755 if (forward_events_to_drag_and_drop_host_) { | 955 if (forward_events_to_drag_and_drop_host_) { |
756 // The DnD host was previously called and needs to be informed that the | 956 // The DnD host was previously called and needs to be informed that the |
757 // session returns to the owner. | 957 // session returns to the owner. |
758 forward_events_to_drag_and_drop_host_ = false; | 958 forward_events_to_drag_and_drop_host_ = false; |
759 drag_and_drop_host_->EndDrag(true); | 959 drag_and_drop_host_->EndDrag(true); |
760 } | 960 } |
761 } else { | 961 } else { |
762 // The event happened outside our app menu and we might need to dispatch. | 962 // The event happened outside our app menu and we might need to dispatch. |
763 if (forward_events_to_drag_and_drop_host_) { | 963 if (forward_events_to_drag_and_drop_host_) { |
764 // Dispatch since we have already started. | 964 // Dispatch since we have already started. |
765 if (!drag_and_drop_host_->Drag(event.root_location())) { | 965 if (!drag_and_drop_host_->Drag(point)) { |
766 // The host is not active any longer and we cancel the operation. | 966 // The host is not active any longer and we cancel the operation. |
767 forward_events_to_drag_and_drop_host_ = false; | 967 forward_events_to_drag_and_drop_host_ = false; |
768 drag_and_drop_host_->EndDrag(true); | 968 drag_and_drop_host_->EndDrag(true); |
769 } | 969 } |
770 } else { | 970 } else { |
771 if (drag_and_drop_host_->StartDrag(drag_view_->model()->app_id(), | 971 if (drag_and_drop_host_->StartDrag(drag_view_->model()->app_id(), |
772 event.root_location())) { | 972 point)) { |
773 // From now on we forward the drag events. | 973 // From now on we forward the drag events. |
774 forward_events_to_drag_and_drop_host_ = true; | 974 forward_events_to_drag_and_drop_host_ = true; |
775 // Any flip operations are stopped. | 975 // Any flip operations are stopped. |
776 page_flip_timer_.Stop(); | 976 StopPageFlipTimer(); |
777 page_flip_target_ = -1; | |
778 } | 977 } |
779 } | 978 } |
780 } | 979 } |
781 } | 980 } |
782 | 981 |
783 void AppsGridView::MaybeStartPageFlipTimer(const gfx::Point& drag_point) { | 982 void AppsGridView::MaybeStartPageFlipTimer(const gfx::Point& drag_point) { |
784 int new_page_flip_target = -1; | 983 int new_page_flip_target = -1; |
785 | 984 |
786 if (page_switcher_view_->bounds().Contains(drag_point)) { | 985 if (page_switcher_view_->bounds().Contains(drag_point)) { |
787 gfx::Point page_switcher_point(drag_point); | 986 gfx::Point page_switcher_point(drag_point); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 | 1127 |
929 void AppsGridView::HideView(views::View* view, bool hide) { | 1128 void AppsGridView::HideView(views::View* view, bool hide) { |
930 #if defined(USE_AURA) | 1129 #if defined(USE_AURA) |
931 ui::ScopedLayerAnimationSettings animator(view->layer()->GetAnimator()); | 1130 ui::ScopedLayerAnimationSettings animator(view->layer()->GetAnimator()); |
932 animator.SetPreemptionStrategy(ui::LayerAnimator::IMMEDIATELY_SET_NEW_TARGET); | 1131 animator.SetPreemptionStrategy(ui::LayerAnimator::IMMEDIATELY_SET_NEW_TARGET); |
933 view->layer()->SetOpacity(hide ? 0 : 1); | 1132 view->layer()->SetOpacity(hide ? 0 : 1); |
934 #endif | 1133 #endif |
935 } | 1134 } |
936 | 1135 |
937 } // namespace app_list | 1136 } // namespace app_list |
OLD | NEW |