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 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 drag_view_offset_(drag_view_offset), | 210 drag_view_offset_(drag_view_offset), |
| 211 has_shortcut_path_(false), | 211 has_shortcut_path_(false), |
| 212 running_(false), | 212 running_(false), |
| 213 canceled_(false) {} | 213 canceled_(false) {} |
| 214 | 214 |
| 215 void set_shortcut_path(const base::FilePath& shortcut_path) { | 215 void set_shortcut_path(const base::FilePath& shortcut_path) { |
| 216 has_shortcut_path_ = true; | 216 has_shortcut_path_ = true; |
| 217 shortcut_path_ = shortcut_path; | 217 shortcut_path_ = shortcut_path; |
| 218 } | 218 } |
| 219 | 219 |
| 220 bool running() { return running_; } | |
| 221 | |
| 220 bool CanRun() { | 222 bool CanRun() { |
| 221 return has_shortcut_path_ && !running_; | 223 return has_shortcut_path_ && !running_; |
| 222 } | 224 } |
| 223 | 225 |
| 224 void Run() { | 226 void Run() { |
| 225 DCHECK(CanRun()); | 227 DCHECK(CanRun()); |
| 226 | 228 |
| 227 // Prevent the synchronous dragger being destroyed while the drag is | 229 // Prevent the synchronous dragger being destroyed while the drag is |
| 228 // running. | 230 // running. |
| 229 scoped_refptr<SynchronousDrag> this_ref = this; | 231 scoped_refptr<SynchronousDrag> this_ref = this; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 return; | 486 return; |
| 485 delegate_->GetShortcutPathForApp( | 487 delegate_->GetShortcutPathForApp( |
| 486 drag_view_->item()->id(), | 488 drag_view_->item()->id(), |
| 487 base::Bind(&AppsGridView::OnDelayShortcutPath, base::Unretained(this))); | 489 base::Bind(&AppsGridView::OnDelayShortcutPath, base::Unretained(this))); |
| 488 synchronous_drag_ = new SynchronousDrag(this, drag_view_, drag_view_offset_); | 490 synchronous_drag_ = new SynchronousDrag(this, drag_view_, drag_view_offset_); |
| 489 #endif | 491 #endif |
| 490 } | 492 } |
| 491 | 493 |
| 492 bool AppsGridView::RunSynchronousDrag() { | 494 bool AppsGridView::RunSynchronousDrag() { |
| 493 #if defined(OS_WIN) | 495 #if defined(OS_WIN) |
| 494 if (synchronous_drag_ && synchronous_drag_->CanRun()) { | 496 if (!synchronous_drag_) |
| 497 return false; | |
| 498 | |
| 499 if (synchronous_drag_->CanRun()) { | |
| 500 if (IsDraggingForReparentInHiddenGridView()) | |
| 501 folder_delegate_->SetRootLevelDragViewVisible(false); | |
| 495 synchronous_drag_->Run(); | 502 synchronous_drag_->Run(); |
| 496 synchronous_drag_ = NULL; | 503 synchronous_drag_ = NULL; |
| 497 return true; | 504 return true; |
| 505 } else if (!synchronous_drag_->running()) { | |
|
tapted
2014/05/02 01:52:47
nit: I think the condition is redundant (i.e. can
calamity
2014/05/02 04:28:38
Ah, true.
| |
| 506 // The OS drag is not ready yet. If the root grid has a drag view because | |
| 507 // a reparent has started, ensure it is visible. | |
| 508 if (IsDraggingForReparentInHiddenGridView()) | |
| 509 folder_delegate_->SetRootLevelDragViewVisible(true); | |
| 498 } | 510 } |
| 499 #endif | 511 #endif |
| 500 return false; | 512 return false; |
| 501 } | 513 } |
| 502 | 514 |
| 503 void AppsGridView::CleanUpSynchronousDrag() { | 515 void AppsGridView::CleanUpSynchronousDrag() { |
| 504 #if defined(OS_WIN) | 516 #if defined(OS_WIN) |
| 505 if (synchronous_drag_) | 517 if (synchronous_drag_) |
| 506 synchronous_drag_->EndDragExternally(); | 518 synchronous_drag_->EndDragExternally(); |
| 507 | 519 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 759 drop_target_ = Index(); | 771 drop_target_ = Index(); |
| 760 if (!cancel_reparent && drag_view_) | 772 if (!cancel_reparent && drag_view_) |
| 761 drag_view_->OnDragEnded(); | 773 drag_view_->OnDragEnded(); |
| 762 drag_view_ = NULL; | 774 drag_view_ = NULL; |
| 763 drag_start_grid_view_ = gfx::Point(); | 775 drag_start_grid_view_ = gfx::Point(); |
| 764 drag_start_page_ = -1; | 776 drag_start_page_ = -1; |
| 765 drag_view_offset_ = gfx::Point(); | 777 drag_view_offset_ = gfx::Point(); |
| 766 dragging_for_reparent_item_ = false; | 778 dragging_for_reparent_item_ = false; |
| 767 } | 779 } |
| 768 | 780 |
| 781 void AppsGridView::SetDragViewVisible(bool visible) { | |
| 782 DCHECK(drag_view_); | |
| 783 SetViewHidden(drag_view_, !visible, true); | |
| 784 } | |
| 785 | |
| 769 void AppsGridView::SetDragAndDropHostOfCurrentAppList( | 786 void AppsGridView::SetDragAndDropHostOfCurrentAppList( |
| 770 ApplicationDragAndDropHost* drag_and_drop_host) { | 787 ApplicationDragAndDropHost* drag_and_drop_host) { |
| 771 drag_and_drop_host_ = drag_and_drop_host; | 788 drag_and_drop_host_ = drag_and_drop_host; |
| 772 } | 789 } |
| 773 | 790 |
| 774 void AppsGridView::Prerender(int page_index) { | 791 void AppsGridView::Prerender(int page_index) { |
| 775 Layout(); | 792 Layout(); |
| 776 int start = std::max(0, (page_index - kPrerenderPages) * tiles_per_page()); | 793 int start = std::max(0, (page_index - kPrerenderPages) * tiles_per_page()); |
| 777 int end = std::min(view_model_.view_size(), | 794 int end = std::min(view_model_.view_size(), |
| 778 (page_index + 1 + kPrerenderPages) * tiles_per_page()); | 795 (page_index + 1 + kPrerenderPages) * tiles_per_page()); |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2078 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, | 2095 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, |
| 2079 bool is_target_folder) { | 2096 bool is_target_folder) { |
| 2080 AppListItemView* target_view = | 2097 AppListItemView* target_view = |
| 2081 static_cast<AppListItemView*>( | 2098 static_cast<AppListItemView*>( |
| 2082 GetViewAtSlotOnCurrentPage(target_index.slot)); | 2099 GetViewAtSlotOnCurrentPage(target_index.slot)); |
| 2083 if (target_view) | 2100 if (target_view) |
| 2084 target_view->SetAsAttemptedFolderTarget(is_target_folder); | 2101 target_view->SetAsAttemptedFolderTarget(is_target_folder); |
| 2085 } | 2102 } |
| 2086 | 2103 |
| 2087 } // namespace app_list | 2104 } // namespace app_list |
| OLD | NEW |