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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 namespace { | 54 namespace { |
55 | 55 |
56 // Distance a drag needs to be from the app grid to be considered 'outside', at | 56 // Distance a drag needs to be from the app grid to be considered 'outside', at |
57 // which point we rearrange the apps to their pre-drag configuration, as a drop | 57 // which point we rearrange the apps to their pre-drag configuration, as a drop |
58 // then would be canceled. We have a buffer to make it easier to drag apps to | 58 // then would be canceled. We have a buffer to make it easier to drag apps to |
59 // other pages. | 59 // other pages. |
60 const int kDragBufferPx = 20; | 60 const int kDragBufferPx = 20; |
61 | 61 |
62 // Padding space in pixels for fixed layout. | 62 // Padding space in pixels for fixed layout. |
63 const int kLeftRightPadding = 23; | |
64 const int kTopPadding = 1; | 63 const int kTopPadding = 1; |
| 64 const int kBottomPadding = 1; |
| 65 const int kLeftRightPadding = 24; |
65 | 66 |
66 // Padding space in pixels between pages. | 67 // Padding space in pixels between pages. |
67 const int kPagePadding = 40; | 68 const int kPagePadding = 40; |
68 | 69 |
69 // Preferred tile size when showing in fixed layout. | 70 // Preferred tile size when showing in fixed layout. |
70 const int kPreferredTileWidth = 88; | 71 const int kPreferredTileWidth = 88; |
71 const int kPreferredTileHeight = 98; | 72 const int kPreferredTileHeight = 98; |
72 | 73 |
73 const int kExperimentalPreferredTileWidth = 90; | 74 const int kExperimentalPreferredTileWidth = 90; |
74 const int kExperimentalPrefferedTileHeight = 90; | 75 const int kExperimentalPreferredTileHeight = 90; |
75 | 76 |
76 // Padding on each side of a tile. | 77 // Padding on each side of a tile. |
77 const int kExperimentalTileLeftRightPadding = 15; | 78 const int kExperimentalTileLeftRightPadding = 15; |
78 const int kExperimentalTileTopBottomPadding = 11; | 79 const int kExperimentalTileTopBottomPadding = 11; |
79 | 80 |
80 // Width in pixels of the area on the sides that triggers a page flip. | 81 // Width in pixels of the area on the sides that triggers a page flip. |
81 const int kPageFlipZoneSize = 40; | 82 const int kPageFlipZoneSize = 40; |
82 | 83 |
83 // Delay in milliseconds to do the page flip. | 84 // Delay in milliseconds to do the page flip. |
84 const int kPageFlipDelayInMs = 1000; | 85 const int kPageFlipDelayInMs = 1000; |
(...skipping 14 matching lines...) Expand all Loading... |
99 const int kFolderItemReparentDelay = 50; | 100 const int kFolderItemReparentDelay = 50; |
100 | 101 |
101 // Radius of the circle, in which if entered, show folder dropping preview | 102 // Radius of the circle, in which if entered, show folder dropping preview |
102 // UI. | 103 // UI. |
103 const int kFolderDroppingCircleRadius = 39; | 104 const int kFolderDroppingCircleRadius = 39; |
104 | 105 |
105 // Returns the size of a tile view excluding its padding. | 106 // Returns the size of a tile view excluding its padding. |
106 gfx::Size GetTileViewSize() { | 107 gfx::Size GetTileViewSize() { |
107 return switches::IsExperimentalAppListEnabled() | 108 return switches::IsExperimentalAppListEnabled() |
108 ? gfx::Size(kExperimentalPreferredTileWidth, | 109 ? gfx::Size(kExperimentalPreferredTileWidth, |
109 kExperimentalPrefferedTileHeight) | 110 kExperimentalPreferredTileHeight) |
110 : gfx::Size(kPreferredTileWidth, kPreferredTileHeight); | 111 : gfx::Size(kPreferredTileWidth, kPreferredTileHeight); |
111 } | 112 } |
112 | 113 |
113 // Returns the size of a tile view inccluding its padding. | 114 // Returns the size of a tile view inccluding its padding. |
114 gfx::Size GetTotalTileSize() { | 115 gfx::Size GetTotalTileSize() { |
115 gfx::Size size = GetTileViewSize(); | 116 gfx::Size size = GetTileViewSize(); |
116 if (switches::IsExperimentalAppListEnabled()) | 117 if (switches::IsExperimentalAppListEnabled()) |
117 size.Enlarge(2 * kExperimentalTileLeftRightPadding, | 118 size.Enlarge(2 * kExperimentalTileLeftRightPadding, |
118 2 * kExperimentalTileTopBottomPadding); | 119 2 * kExperimentalTileTopBottomPadding); |
119 return size; | 120 return size; |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 418 |
418 // Make sure |page_switcher_view_| is deleted before |pagination_model_|. | 419 // Make sure |page_switcher_view_| is deleted before |pagination_model_|. |
419 view_model_.Clear(); | 420 view_model_.Clear(); |
420 RemoveAllChildViews(true); | 421 RemoveAllChildViews(true); |
421 } | 422 } |
422 | 423 |
423 void AppsGridView::SetLayout(int cols, int rows_per_page) { | 424 void AppsGridView::SetLayout(int cols, int rows_per_page) { |
424 cols_ = cols; | 425 cols_ = cols; |
425 rows_per_page_ = rows_per_page; | 426 rows_per_page_ = rows_per_page; |
426 | 427 |
427 SetBorder(views::Border::CreateEmptyBorder( | 428 if (switches::IsExperimentalAppListEnabled()) { |
428 switches::IsExperimentalAppListEnabled() ? 0 : kTopPadding, | 429 SetBorder(views::Border::CreateEmptyBorder(0, |
429 kLeftRightPadding, | 430 kExperimentalWindowPadding, |
430 0, | 431 kBottomPadding, |
431 kLeftRightPadding)); | 432 kExperimentalWindowPadding)); |
| 433 } else { |
| 434 SetBorder(views::Border::CreateEmptyBorder( |
| 435 kTopPadding, kLeftRightPadding, kBottomPadding, kLeftRightPadding)); |
| 436 } |
432 } | 437 } |
433 | 438 |
434 void AppsGridView::ResetForShowApps() { | 439 void AppsGridView::ResetForShowApps() { |
435 activated_folder_item_view_ = NULL; | 440 activated_folder_item_view_ = NULL; |
436 ClearDragState(); | 441 ClearDragState(); |
437 layer()->SetOpacity(1.0f); | 442 layer()->SetOpacity(1.0f); |
438 SetVisible(true); | 443 SetVisible(true); |
439 // Set all views to visible in case they weren't made visible again by an | 444 // Set all views to visible in case they weren't made visible again by an |
440 // incomplete animation. | 445 // incomplete animation. |
441 for (int i = 0; i < view_model_.view_size(); ++i) { | 446 for (int i = 0; i < view_model_.view_size(); ++i) { |
(...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 | 2156 |
2152 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, | 2157 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, |
2153 bool is_target_folder) { | 2158 bool is_target_folder) { |
2154 AppListItemView* target_view = | 2159 AppListItemView* target_view = |
2155 GetViewDisplayedAtSlotOnCurrentPage(target_index.slot); | 2160 GetViewDisplayedAtSlotOnCurrentPage(target_index.slot); |
2156 if (target_view) | 2161 if (target_view) |
2157 target_view->SetAsAttemptedFolderTarget(is_target_folder); | 2162 target_view->SetAsAttemptedFolderTarget(is_target_folder); |
2158 } | 2163 } |
2159 | 2164 |
2160 } // namespace app_list | 2165 } // namespace app_list |
OLD | NEW |