Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: ui/app_list/views/apps_grid_view.cc

Issue 559373004: Resize app list items in experimental app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dragging_without_grid_resize
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/apps_grid_view.cc
diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc
index 190eb900c9e48ee2402f1e9b3024e3f69355772a..f769659c42f10bd4588381b9e58b319a789f71d0 100644
--- a/ui/app_list/views/apps_grid_view.cc
+++ b/ui/app_list/views/apps_grid_view.cc
@@ -71,6 +71,13 @@ const int kPagePadding = 40;
const int kPreferredTileWidth = 88;
const int kPreferredTileHeight = 98;
+const int kExperimentalTileWidth = 90;
Matt Giuca 2014/09/16 07:37:57 Can this be kExperimentalPreferredTileWidth?
calamity 2014/09/17 01:48:49 Done.
+const int kExperimentalTileHeight = 90;
+
+// Padding on each side of a tile.
+const int kTileLeftRightPadding = 15;
Matt Giuca 2014/09/16 07:37:57 kExperimental...
calamity 2014/09/17 01:48:49 Done.
+const int kTileTopBottomPadding = 11;
+
// Width in pixels of the area on the sides that triggers a page flip.
const int kPageFlipZoneSize = 40;
@@ -96,6 +103,19 @@ const int kFolderItemReparentDelay = 50;
// UI.
const int kFolderDroppingCircleRadius = 39;
+gfx::Size GetTileViewSize() {
Matt Giuca 2014/09/16 07:37:57 Comments.
calamity 2014/09/17 01:48:49 Done.
+ return switches::IsExperimentalAppListEnabled()
+ ? gfx::Size(kExperimentalTileWidth, kExperimentalTileHeight)
+ : gfx::Size(kPreferredTileWidth, kPreferredTileHeight);
+}
+
+gfx::Size GetTotalTileSize() {
+ gfx::Size size = GetTileViewSize();
+ if (switches::IsExperimentalAppListEnabled())
+ size.Enlarge(2 * kTileLeftRightPadding, 2 * kTileTopBottomPadding);
+ return size;
+}
+
// RowMoveAnimationDelegate is used when moving an item into a different row.
// Before running the animation, the item's layer is re-created and kept in
// the original position, then the item is moved to just before its target
@@ -1040,8 +1060,7 @@ void AppsGridView::UpdatePulsingBlockViews() {
}
while (pulsing_blocks_model_.view_size() < desired) {
- views::View* view = new PulsingBlockView(
- gfx::Size(kPreferredTileWidth, kPreferredTileHeight), true);
+ views::View* view = new PulsingBlockView(GetTotalTileSize(), true);
pulsing_blocks_model_.Add(view, 0);
AddChildView(view);
}
@@ -1253,7 +1272,7 @@ void AppsGridView::AnimateToIdealBounds() {
const bool visible = current_visible || target_visible;
const int y_diff = target.y() - current.y();
- if (visible && y_diff && y_diff % kPreferredTileHeight == 0) {
+ if (visible && y_diff && y_diff % GetTotalTileSize().height() == 0) {
AnimationBetweenRows(view,
current_visible,
current,
@@ -1295,12 +1314,13 @@ void AppsGridView::AnimationBetweenRows(views::View* view,
view->layer()->SetOpacity(0.f);
}
+ gfx::Size total_tile_size = GetTotalTileSize();
gfx::Rect current_out(current);
- current_out.Offset(dir * kPreferredTileWidth, 0);
+ current_out.Offset(dir * total_tile_size.width(), 0);
gfx::Rect target_in(target);
if (animate_target)
- target_in.Offset(-dir * kPreferredTileWidth, 0);
+ target_in.Offset(-dir * total_tile_size.width(), 0);
view->SetBoundsRect(target_in);
bounds_animator_.AnimateViewTo(view, target);
@@ -1395,6 +1415,7 @@ void AppsGridView::CalculateReorderDropTarget(const gfx::Point& point,
x_offset_direction = reorder_placeholder_ < grid_index ? -1 : 1;
}
+ gfx::Size total_tile_size = GetTotalTileSize();
int row = grid_index.slot / cols_;
// Offset the target column based on the direction of the target. This will
@@ -1404,8 +1425,8 @@ void AppsGridView::CalculateReorderDropTarget(const gfx::Point& point,
// This makes eordering feel like the user is slotting items into the spaces
// between apps.
int x_offset = x_offset_direction *
- (kPreferredTileWidth - kFolderDroppingCircleRadius) / 2;
- int col = (point.x() - bounds.x() + x_offset) / kPreferredTileWidth;
+ (total_tile_size.width() - kFolderDroppingCircleRadius) / 2;
+ int col = (point.x() - bounds.x() + x_offset) / total_tile_size.width();
col = ClampToRange(col, 0, cols_ - 1);
*drop_target =
std::min(Index(pagination_model_.selected_page(), row * cols_ + col),
@@ -2067,16 +2088,19 @@ bool AppsGridView::CanDropIntoTarget(const Index& drop_target) const {
AppsGridView::Index AppsGridView::GetNearestTileIndexForPoint(
const gfx::Point& point) const {
gfx::Rect bounds = GetContentsBounds();
- int col =
- ClampToRange((point.x() - bounds.x()) / kPreferredTileWidth, 0, cols_);
+ gfx::Size total_tile_size = GetTotalTileSize();
+ int col = ClampToRange(
+ (point.x() - bounds.x()) / total_tile_size.width(), 0, cols_);
int row = ClampToRange(
- (point.y() - bounds.y()) / kPreferredTileHeight, 0, rows_per_page_);
+ (point.y() - bounds.y()) / total_tile_size.height(), 0, rows_per_page_);
return Index(pagination_model_.selected_page(), row * cols_ + col);
}
gfx::Size AppsGridView::GetTileGridSize() const {
gfx::Rect bounds = GetExpectedTileBounds(0, 0);
bounds.Union(GetExpectedTileBounds(rows_per_page_ - 1, cols_ - 1));
+ if (switches::IsExperimentalAppListEnabled())
+ bounds.Inset(-kTileLeftRightPadding, -kTileTopBottomPadding);
return bounds.size();
}
@@ -2086,10 +2110,12 @@ gfx::Rect AppsGridView::GetExpectedTileBounds(int slot) const {
gfx::Rect AppsGridView::GetExpectedTileBounds(int row, int col) const {
gfx::Rect bounds(GetContentsBounds());
- gfx::Size tile_size(kPreferredTileWidth, kPreferredTileHeight);
- return gfx::Rect(gfx::Point(bounds.x() + col * tile_size.width(),
- bounds.y() + row * tile_size.height()),
- tile_size);
+ gfx::Size total_tile_size = GetTotalTileSize();
+ gfx::Rect tile_bounds(gfx::Point(bounds.x() + col * total_tile_size.width(),
+ bounds.y() + row * total_tile_size.height()),
+ total_tile_size);
+ tile_bounds.ClampToCenteredSize(GetTileViewSize());
+ return tile_bounds;
}
views::View* AppsGridView::GetViewAtSlotOnCurrentPage(int slot) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698