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 30 matching lines...) Expand all Loading... |
41 namespace app_list { | 41 namespace app_list { |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 // Distance a drag needs to be from the app grid to be considered 'outside', at | 45 // Distance a drag needs to be from the app grid to be considered 'outside', at |
46 // which point we rearrange the apps to their pre-drag configuration, as a drop | 46 // which point we rearrange the apps to their pre-drag configuration, as a drop |
47 // then would be canceled. We have a buffer to make it easier to drag apps to | 47 // then would be canceled. We have a buffer to make it easier to drag apps to |
48 // other pages. | 48 // other pages. |
49 const int kDragBufferPx = 20; | 49 const int kDragBufferPx = 20; |
50 | 50 |
51 // Padding space in pixels for fixed layout. | |
52 const int kBottomPadding = 2; | |
53 const int kLeftRightPadding = 24; | |
54 | |
55 // Padding space in pixels between pages. | 51 // Padding space in pixels between pages. |
56 const int kPagePadding = 40; | 52 const int kPagePadding = 40; |
57 | 53 |
58 // Preferred tile size when showing in fixed layout. | 54 // Preferred tile size when showing in fixed layout. |
59 const int kPreferredTileWidth = 88; | 55 const int kPreferredTileWidth = 100; |
60 const int kPreferredTileHeight = 98; | 56 const int kPreferredTileHeight = 100; |
61 | |
62 const int kExperimentalPreferredTileWidth = 100; | |
63 const int kExperimentalPreferredTileHeight = 100; | |
64 | 57 |
65 // Padding on each side of a tile. | 58 // Padding on each side of a tile. |
66 const int kExperimentalTileLeftRightPadding = 10; | 59 const int kTileLeftRightPadding = 10; |
67 const int kExperimentalTileBottomPadding = 6; | 60 const int kTileBottomPadding = 6; |
68 const int kExperimentalTileTopPadding = 6; | 61 const int kTileTopPadding = 6; |
69 | 62 |
70 // Width in pixels of the area on the sides that triggers a page flip. | 63 // Width in pixels of the area on the sides that triggers a page flip. |
71 const int kPageFlipZoneSize = 40; | 64 const int kPageFlipZoneSize = 40; |
72 | 65 |
73 // Delay in milliseconds to do the page flip. | 66 // Delay in milliseconds to do the page flip. |
74 const int kPageFlipDelayInMs = 1000; | 67 const int kPageFlipDelayInMs = 1000; |
75 | 68 |
76 // The drag and drop proxy should get scaled by this factor. | 69 // The drag and drop proxy should get scaled by this factor. |
77 const float kDragAndDropProxyScale = 1.5f; | 70 const float kDragAndDropProxyScale = 1.5f; |
78 | 71 |
79 // Delays in milliseconds to show folder dropping preview circle. | 72 // Delays in milliseconds to show folder dropping preview circle. |
80 const int kFolderDroppingDelay = 150; | 73 const int kFolderDroppingDelay = 150; |
81 | 74 |
82 // Delays in milliseconds to show re-order preview. | 75 // Delays in milliseconds to show re-order preview. |
83 const int kReorderDelay = 120; | 76 const int kReorderDelay = 120; |
84 | 77 |
85 // Delays in milliseconds to show folder item reparent UI. | 78 // Delays in milliseconds to show folder item reparent UI. |
86 const int kFolderItemReparentDelay = 50; | 79 const int kFolderItemReparentDelay = 50; |
87 | 80 |
88 // Radius of the circle, in which if entered, show folder dropping preview | 81 // Radius of the circle, in which if entered, show folder dropping preview |
89 // UI. | 82 // UI. |
90 const int kFolderDroppingCircleRadius = 39; | 83 const int kFolderDroppingCircleRadius = 39; |
91 | 84 |
92 // Returns the size of a tile view excluding its padding. | 85 // Returns the size of a tile view excluding its padding. |
93 gfx::Size GetTileViewSize() { | 86 gfx::Size GetTileViewSize() { |
94 return switches::IsExperimentalAppListEnabled() | 87 return gfx::Size(kPreferredTileWidth, kPreferredTileHeight); |
95 ? gfx::Size(kExperimentalPreferredTileWidth, | |
96 kExperimentalPreferredTileHeight) | |
97 : gfx::Size(kPreferredTileWidth, kPreferredTileHeight); | |
98 } | 88 } |
99 | 89 |
100 // Returns the padding around a tile view. | 90 // Returns the padding around a tile view. |
101 gfx::Insets GetTilePadding() { | 91 gfx::Insets GetTilePadding() { |
102 if (!switches::IsExperimentalAppListEnabled()) | 92 return gfx::Insets(-kTileTopPadding, -kTileLeftRightPadding, |
103 return gfx::Insets(); | 93 -kTileBottomPadding, -kTileLeftRightPadding); |
104 | |
105 return gfx::Insets( | |
106 -kExperimentalTileTopPadding, -kExperimentalTileLeftRightPadding, | |
107 -kExperimentalTileBottomPadding, -kExperimentalTileLeftRightPadding); | |
108 } | 94 } |
109 | 95 |
110 // RowMoveAnimationDelegate is used when moving an item into a different row. | 96 // RowMoveAnimationDelegate is used when moving an item into a different row. |
111 // Before running the animation, the item's layer is re-created and kept in | 97 // Before running the animation, the item's layer is re-created and kept in |
112 // the original position, then the item is moved to just before its target | 98 // the original position, then the item is moved to just before its target |
113 // position and opacity set to 0. When the animation runs, this delegate moves | 99 // position and opacity set to 0. When the animation runs, this delegate moves |
114 // the layer and fades it out while fading in the item at the same time. | 100 // the layer and fades it out while fading in the item at the same time. |
115 class RowMoveAnimationDelegate : public gfx::AnimationDelegate { | 101 class RowMoveAnimationDelegate : public gfx::AnimationDelegate { |
116 public: | 102 public: |
117 RowMoveAnimationDelegate(views::View* view, | 103 RowMoveAnimationDelegate(views::View* view, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 255 |
270 // Make sure |page_switcher_view_| is deleted before |pagination_model_|. | 256 // Make sure |page_switcher_view_| is deleted before |pagination_model_|. |
271 view_model_.Clear(); | 257 view_model_.Clear(); |
272 RemoveAllChildViews(true); | 258 RemoveAllChildViews(true); |
273 } | 259 } |
274 | 260 |
275 void AppsGridView::SetLayout(int cols, int rows_per_page) { | 261 void AppsGridView::SetLayout(int cols, int rows_per_page) { |
276 cols_ = cols; | 262 cols_ = cols; |
277 rows_per_page_ = rows_per_page; | 263 rows_per_page_ = rows_per_page; |
278 | 264 |
279 if (switches::IsExperimentalAppListEnabled()) { | 265 SetBorder(views::Border::CreateEmptyBorder(0, kAppsGridPadding, 0, |
280 SetBorder(views::Border::CreateEmptyBorder( | 266 kAppsGridPadding)); |
281 0, kExperimentalAppsGridPadding, 0, kExperimentalAppsGridPadding)); | |
282 } else { | |
283 SetBorder(views::Border::CreateEmptyBorder( | |
284 0, kLeftRightPadding, kBottomPadding, kLeftRightPadding)); | |
285 } | |
286 } | 267 } |
287 | 268 |
288 // static | 269 // static |
289 gfx::Size AppsGridView::GetTotalTileSize() { | 270 gfx::Size AppsGridView::GetTotalTileSize() { |
290 gfx::Rect rect(GetTileViewSize()); | 271 gfx::Rect rect(GetTileViewSize()); |
291 rect.Inset(GetTilePadding()); | 272 rect.Inset(GetTilePadding()); |
292 return rect.size(); | 273 return rect.size(); |
293 } | 274 } |
294 | 275 |
295 void AppsGridView::ResetForShowApps() { | 276 void AppsGridView::ResetForShowApps() { |
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 | 1916 |
1936 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, | 1917 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, |
1937 bool is_target_folder) { | 1918 bool is_target_folder) { |
1938 AppListItemView* target_view = | 1919 AppListItemView* target_view = |
1939 GetViewDisplayedAtSlotOnCurrentPage(target_index.slot); | 1920 GetViewDisplayedAtSlotOnCurrentPage(target_index.slot); |
1940 if (target_view) | 1921 if (target_view) |
1941 target_view->SetAsAttemptedFolderTarget(is_target_folder); | 1922 target_view->SetAsAttemptedFolderTarget(is_target_folder); |
1942 } | 1923 } |
1943 | 1924 |
1944 } // namespace app_list | 1925 } // namespace app_list |
OLD | NEW |