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