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 |
11 #include "base/guid.h" | 11 #include "base/guid.h" |
12 #include "ui/app_list/app_list_constants.h" | 12 #include "ui/app_list/app_list_constants.h" |
13 #include "ui/app_list/app_list_folder_item.h" | 13 #include "ui/app_list/app_list_folder_item.h" |
14 #include "ui/app_list/app_list_item.h" | 14 #include "ui/app_list/app_list_item.h" |
15 #include "ui/app_list/app_list_switches.h" | 15 #include "ui/app_list/app_list_switches.h" |
16 #include "ui/app_list/views/app_list_drag_and_drop_host.h" | 16 #include "ui/app_list/views/app_list_drag_and_drop_host.h" |
17 #include "ui/app_list/views/app_list_folder_view.h" | 17 #include "ui/app_list/views/app_list_folder_view.h" |
18 #include "ui/app_list/views/app_list_item_view.h" | 18 #include "ui/app_list/views/app_list_item_view.h" |
19 #include "ui/app_list/views/apps_grid_view_delegate.h" | 19 #include "ui/app_list/views/apps_grid_view_delegate.h" |
20 #include "ui/app_list/views/page_switcher.h" | 20 #include "ui/app_list/views/page_switcher.h" |
21 #include "ui/app_list/views/pulsing_block_view.h" | 21 #include "ui/app_list/views/pulsing_block_view.h" |
22 #include "ui/app_list/views/top_icon_animation_view.h" | 22 #include "ui/app_list/views/top_icon_animation_view.h" |
23 #include "ui/compositor/scoped_layer_animation_settings.h" | 23 #include "ui/compositor/scoped_layer_animation_settings.h" |
24 #include "ui/events/event.h" | 24 #include "ui/events/event.h" |
25 #include "ui/gfx/animation/animation.h" | 25 #include "ui/gfx/animation/animation.h" |
26 #include "ui/views/border.h" | 26 #include "ui/views/border.h" |
| 27 #include "ui/views/controls/label.h" |
27 #include "ui/views/view_model_utils.h" | 28 #include "ui/views/view_model_utils.h" |
28 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
29 | 30 |
30 #if defined(USE_AURA) | 31 #if defined(USE_AURA) |
31 #include "ui/aura/window.h" | 32 #include "ui/aura/window.h" |
32 #include "ui/aura/window_event_dispatcher.h" | 33 #include "ui/aura/window_event_dispatcher.h" |
33 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
34 #include "ui/views/win/hwnd_util.h" | 35 #include "ui/views/win/hwnd_util.h" |
35 #endif // defined(OS_WIN) | 36 #endif // defined(OS_WIN) |
36 #endif // defined(USE_AURA) | 37 #endif // defined(USE_AURA) |
(...skipping 29 matching lines...) Expand all Loading... |
66 // Preferred tile size when showing in fixed layout. | 67 // Preferred tile size when showing in fixed layout. |
67 const int kPreferredTileWidth = 88; | 68 const int kPreferredTileWidth = 88; |
68 const int kPreferredTileHeight = 98; | 69 const int kPreferredTileHeight = 98; |
69 | 70 |
70 // Width in pixels of the area on the sides that triggers a page flip. | 71 // Width in pixels of the area on the sides that triggers a page flip. |
71 const int kPageFlipZoneSize = 40; | 72 const int kPageFlipZoneSize = 40; |
72 | 73 |
73 // Delay in milliseconds to do the page flip. | 74 // Delay in milliseconds to do the page flip. |
74 const int kPageFlipDelayInMs = 1000; | 75 const int kPageFlipDelayInMs = 1000; |
75 | 76 |
76 // How many pages on either side of the selected one we prerender. | |
77 const int kPrerenderPages = 1; | |
78 | |
79 // The drag and drop proxy should get scaled by this factor. | 77 // The drag and drop proxy should get scaled by this factor. |
80 const float kDragAndDropProxyScale = 1.5f; | 78 const float kDragAndDropProxyScale = 1.5f; |
81 | 79 |
82 // Delays in milliseconds to show folder dropping preview circle. | 80 // Delays in milliseconds to show folder dropping preview circle. |
83 const int kFolderDroppingDelay = 150; | 81 const int kFolderDroppingDelay = 150; |
84 | 82 |
85 // Delays in milliseconds to show re-order preview. | 83 // Delays in milliseconds to show re-order preview. |
86 const int kReorderDelay = 120; | 84 const int kReorderDelay = 120; |
87 | 85 |
88 // Delays in milliseconds to show folder item reparent UI. | 86 // Delays in milliseconds to show folder item reparent UI. |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 SetViewHidden(drag_view_, !visible, true); | 828 SetViewHidden(drag_view_, !visible, true); |
831 } | 829 } |
832 | 830 |
833 void AppsGridView::SetDragAndDropHostOfCurrentAppList( | 831 void AppsGridView::SetDragAndDropHostOfCurrentAppList( |
834 ApplicationDragAndDropHost* drag_and_drop_host) { | 832 ApplicationDragAndDropHost* drag_and_drop_host) { |
835 drag_and_drop_host_ = drag_and_drop_host; | 833 drag_and_drop_host_ = drag_and_drop_host; |
836 } | 834 } |
837 | 835 |
838 void AppsGridView::Prerender(int page_index) { | 836 void AppsGridView::Prerender(int page_index) { |
839 Layout(); | 837 Layout(); |
840 int start = std::max(0, (page_index - kPrerenderPages) * tiles_per_page()); | |
841 int end = std::min(view_model_.view_size(), | |
842 (page_index + 1 + kPrerenderPages) * tiles_per_page()); | |
843 for (int i = start; i < end; i++) { | |
844 AppListItemView* v = static_cast<AppListItemView*>(view_model_.view_at(i)); | |
845 v->Prerender(); | |
846 } | |
847 } | 838 } |
848 | 839 |
849 bool AppsGridView::IsAnimatingView(views::View* view) { | 840 bool AppsGridView::IsAnimatingView(views::View* view) { |
850 return bounds_animator_.IsAnimating(view); | 841 return bounds_animator_.IsAnimating(view); |
851 } | 842 } |
852 | 843 |
853 gfx::Size AppsGridView::GetPreferredSize() const { | 844 gfx::Size AppsGridView::GetPreferredSize() const { |
854 const gfx::Insets insets(GetInsets()); | 845 const gfx::Insets insets(GetInsets()); |
855 const gfx::Size tile_size = gfx::Size(kPreferredTileWidth, | 846 const gfx::Size tile_size = gfx::Size(kPreferredTileWidth, |
856 kPreferredTileHeight); | 847 kPreferredTileHeight); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 gfx::Size(kPreferredTileWidth, kPreferredTileHeight), true); | 996 gfx::Size(kPreferredTileWidth, kPreferredTileHeight), true); |
1006 pulsing_blocks_model_.Add(view, 0); | 997 pulsing_blocks_model_.Add(view, 0); |
1007 AddChildView(view); | 998 AddChildView(view); |
1008 } | 999 } |
1009 } | 1000 } |
1010 | 1001 |
1011 views::View* AppsGridView::CreateViewForItemAtIndex(size_t index) { | 1002 views::View* AppsGridView::CreateViewForItemAtIndex(size_t index) { |
1012 // The drag_view_ might be pending for deletion, therefore view_model_ | 1003 // The drag_view_ might be pending for deletion, therefore view_model_ |
1013 // may have one more item than item_list_. | 1004 // may have one more item than item_list_. |
1014 DCHECK_LE(index, item_list_->item_count()); | 1005 DCHECK_LE(index, item_list_->item_count()); |
1015 AppListItemView* view = new AppListItemView(this, | 1006 AppListItemView* view = new AppListItemView(this, item_list_->item_at(index)); |
1016 item_list_->item_at(index)); | |
1017 view->SetIconSize(icon_size_); | 1007 view->SetIconSize(icon_size_); |
1018 view->SetPaintToLayer(true); | 1008 view->SetPaintToLayer(true); |
1019 view->SetFillsBoundsOpaquely(false); | 1009 view->SetFillsBoundsOpaquely(false); |
1020 return view; | 1010 return view; |
1021 } | 1011 } |
1022 | 1012 |
1023 AppsGridView::Index AppsGridView::GetIndexFromModelIndex( | 1013 AppsGridView::Index AppsGridView::GetIndexFromModelIndex( |
1024 int model_index) const { | 1014 int model_index) const { |
1025 return Index(model_index / tiles_per_page(), model_index % tiles_per_page()); | 1015 return Index(model_index / tiles_per_page(), model_index % tiles_per_page()); |
1026 } | 1016 } |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2162 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, | 2152 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, |
2163 bool is_target_folder) { | 2153 bool is_target_folder) { |
2164 AppListItemView* target_view = | 2154 AppListItemView* target_view = |
2165 static_cast<AppListItemView*>( | 2155 static_cast<AppListItemView*>( |
2166 GetViewAtSlotOnCurrentPage(target_index.slot)); | 2156 GetViewAtSlotOnCurrentPage(target_index.slot)); |
2167 if (target_view) | 2157 if (target_view) |
2168 target_view->SetAsAttemptedFolderTarget(is_target_folder); | 2158 target_view->SetAsAttemptedFolderTarget(is_target_folder); |
2169 } | 2159 } |
2170 | 2160 |
2171 } // namespace app_list | 2161 } // namespace app_list |
OLD | NEW |