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 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1126 gfx::Rect rect(GetContentsBounds()); | 1126 gfx::Rect rect(GetContentsBounds()); |
| 1127 if (rect.IsEmpty()) | 1127 if (rect.IsEmpty()) |
| 1128 return; | 1128 return; |
| 1129 | 1129 |
| 1130 gfx::Size tile_size(kPreferredTileWidth, kPreferredTileHeight); | 1130 gfx::Size tile_size(kPreferredTileWidth, kPreferredTileHeight); |
| 1131 | 1131 |
| 1132 gfx::Rect grid_rect(gfx::Size(tile_size.width() * cols_, | 1132 gfx::Rect grid_rect(gfx::Size(tile_size.width() * cols_, |
| 1133 tile_size.height() * rows_per_page_)); | 1133 tile_size.height() * rows_per_page_)); |
| 1134 grid_rect.Intersect(rect); | 1134 grid_rect.Intersect(rect); |
| 1135 | 1135 |
| 1136 // Page width including padding pixels. A tile.x + page_width means the same | 1136 // Page size including padding pixels. A tile.x + page_width means the same |
| 1137 // tile slot in the next page. | 1137 // tile slot in the next page; similarly for tile.y + page_height. |
| 1138 const int page_width = grid_rect.width() + kPagePadding; | 1138 const int page_width = grid_rect.width() + kPagePadding; |
| 1139 const int page_height = grid_rect.height() + kPagePadding; | |
|
calamity
2014/09/01 00:58:12
You can move these down closer to where they're us
Matt Giuca
2014/09/01 01:28:29
Nah, this shouldn't be moved inside the for loop s
| |
| 1139 | 1140 |
| 1140 // If there is a transition, calculates offset for current and target page. | 1141 // If there is a transition, calculates offset for current and target page. |
| 1141 const int current_page = pagination_model_.selected_page(); | 1142 const int current_page = pagination_model_.selected_page(); |
| 1142 const PaginationModel::Transition& transition = | 1143 const PaginationModel::Transition& transition = |
| 1143 pagination_model_.transition(); | 1144 pagination_model_.transition(); |
| 1144 const bool is_valid = pagination_model_.is_valid_page(transition.target_page); | 1145 const bool is_valid = pagination_model_.is_valid_page(transition.target_page); |
| 1145 | 1146 |
| 1146 // Transition to right means negative offset. | 1147 // Transition to previous page means negative offset. |
| 1147 const int dir = transition.target_page > current_page ? -1 : 1; | 1148 const int dir = transition.target_page > current_page ? -1 : 1; |
| 1148 const int transition_offset = is_valid ? | |
| 1149 transition.progress * page_width * dir : 0; | |
| 1150 | 1149 |
| 1151 const int total_views = | 1150 const int total_views = |
| 1152 view_model_.view_size() + pulsing_blocks_model_.view_size(); | 1151 view_model_.view_size() + pulsing_blocks_model_.view_size(); |
| 1153 int slot_index = 0; | 1152 int slot_index = 0; |
| 1154 for (int i = 0; i < total_views; ++i) { | 1153 for (int i = 0; i < total_views; ++i) { |
| 1155 if (i < view_model_.view_size() && view_model_.view_at(i) == drag_view_) { | 1154 if (i < view_model_.view_size() && view_model_.view_at(i) == drag_view_) { |
| 1156 if (EnableFolderDragDropUI() && drop_attempt_ == DROP_FOR_FOLDER) | 1155 if (EnableFolderDragDropUI() && drop_attempt_ == DROP_FOR_FOLDER) |
| 1157 ++slot_index; | 1156 ++slot_index; |
| 1158 continue; | 1157 continue; |
| 1159 } | 1158 } |
| 1160 | 1159 |
| 1161 Index view_index = GetIndexFromModelIndex(slot_index); | 1160 Index view_index = GetIndexFromModelIndex(slot_index); |
| 1162 | 1161 |
| 1163 if (drop_target_ == view_index) { | 1162 if (drop_target_ == view_index) { |
| 1164 if (EnableFolderDragDropUI() && drop_attempt_ == DROP_FOR_FOLDER) { | 1163 if (EnableFolderDragDropUI() && drop_attempt_ == DROP_FOR_FOLDER) { |
| 1165 view_index = GetIndexFromModelIndex(slot_index); | 1164 view_index = GetIndexFromModelIndex(slot_index); |
| 1166 } else if (!EnableFolderDragDropUI() || | 1165 } else if (!EnableFolderDragDropUI() || |
| 1167 drop_attempt_ == DROP_FOR_REORDER) { | 1166 drop_attempt_ == DROP_FOR_REORDER) { |
| 1168 ++slot_index; | 1167 ++slot_index; |
| 1169 view_index = GetIndexFromModelIndex(slot_index); | 1168 view_index = GetIndexFromModelIndex(slot_index); |
| 1170 } | 1169 } |
| 1171 } | 1170 } |
| 1172 | 1171 |
| 1173 // Decides an x_offset for current item. | 1172 // Decide the x or y offset for current item. |
| 1174 int x_offset = 0; | 1173 int x_offset = 0; |
| 1175 if (view_index.page < current_page) | 1174 int y_offset = 0; |
| 1176 x_offset = -page_width; | |
| 1177 else if (view_index.page > current_page) | |
| 1178 x_offset = page_width; | |
| 1179 | 1175 |
| 1180 if (is_valid) { | 1176 if (app_list::switches::IsExperimentalAppListEnabled()) { |
| 1181 if (view_index.page == current_page || | 1177 // The experimental app list transitions vertically. |
| 1182 view_index.page == transition.target_page) { | 1178 if (view_index.page < current_page) |
| 1183 x_offset += transition_offset; | 1179 y_offset = -page_height; |
| 1180 else if (view_index.page > current_page) | |
| 1181 y_offset = page_height; | |
| 1182 | |
| 1183 if (is_valid) { | |
| 1184 if (view_index.page == current_page || | |
| 1185 view_index.page == transition.target_page) { | |
| 1186 y_offset += transition.progress * page_height * dir; | |
| 1187 } | |
| 1188 } | |
| 1189 } else { | |
| 1190 // The normal app list transitions horizontally. | |
| 1191 if (view_index.page < current_page) | |
| 1192 x_offset = -page_width; | |
| 1193 else if (view_index.page > current_page) | |
| 1194 x_offset = page_width; | |
| 1195 | |
| 1196 if (is_valid) { | |
| 1197 if (view_index.page == current_page || | |
| 1198 view_index.page == transition.target_page) { | |
| 1199 x_offset += transition.progress * page_width * dir; | |
| 1200 } | |
| 1184 } | 1201 } |
| 1185 } | 1202 } |
| 1186 | 1203 |
| 1187 const int row = view_index.slot / cols_; | 1204 const int row = view_index.slot / cols_; |
| 1188 const int col = view_index.slot % cols_; | 1205 const int col = view_index.slot % cols_; |
| 1189 gfx::Rect tile_slot( | 1206 gfx::Rect tile_slot( |
| 1190 gfx::Point(grid_rect.x() + col * tile_size.width() + x_offset, | 1207 gfx::Point(grid_rect.x() + col * tile_size.width() + x_offset, |
| 1191 grid_rect.y() + row * tile_size.height()), | 1208 grid_rect.y() + row * tile_size.height() + y_offset), |
| 1192 tile_size); | 1209 tile_size); |
| 1193 if (i < view_model_.view_size()) { | 1210 if (i < view_model_.view_size()) { |
| 1194 view_model_.set_ideal_bounds(i, tile_slot); | 1211 view_model_.set_ideal_bounds(i, tile_slot); |
| 1195 } else { | 1212 } else { |
| 1196 pulsing_blocks_model_.set_ideal_bounds(i - view_model_.view_size(), | 1213 pulsing_blocks_model_.set_ideal_bounds(i - view_model_.view_size(), |
| 1197 tile_slot); | 1214 tile_slot); |
| 1198 } | 1215 } |
| 1199 | 1216 |
| 1200 ++slot_index; | 1217 ++slot_index; |
| 1201 } | 1218 } |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2171 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, | 2188 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, |
| 2172 bool is_target_folder) { | 2189 bool is_target_folder) { |
| 2173 AppListItemView* target_view = | 2190 AppListItemView* target_view = |
| 2174 static_cast<AppListItemView*>( | 2191 static_cast<AppListItemView*>( |
| 2175 GetViewAtSlotOnCurrentPage(target_index.slot)); | 2192 GetViewAtSlotOnCurrentPage(target_index.slot)); |
| 2176 if (target_view) | 2193 if (target_view) |
| 2177 target_view->SetAsAttemptedFolderTarget(is_target_folder); | 2194 target_view->SetAsAttemptedFolderTarget(is_target_folder); |
| 2178 } | 2195 } |
| 2179 | 2196 |
| 2180 } // namespace app_list | 2197 } // namespace app_list |
| OLD | NEW |