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

Unified Diff: ash/common/shelf/app_list_button.cc

Issue 2579463002: Fix layout of launcher and overflow buttons in Ash MD shelf (Closed)
Patch Set: Created 4 years 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 | ash/common/shelf/overflow_button.cc » ('j') | ash/common/shelf/overflow_button.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shelf/app_list_button.cc
diff --git a/ash/common/shelf/app_list_button.cc b/ash/common/shelf/app_list_button.cc
index b8cc2564eab7541a42793019f8cae43e108332f1..28dae0d33b72822de3fdd50e84344148a3e7b75f 100644
--- a/ash/common/shelf/app_list_button.cc
+++ b/ash/common/shelf/app_list_button.cc
@@ -287,16 +287,23 @@ void AppListButton::SetDrawBackgroundAsActive(bool draw_background_as_active) {
}
gfx::Point AppListButton::GetCenterPoint() const {
- // During shelf hide/show animations, width and height may not be equal. Take
- // the greater of the two as the one that represents the normal size of the
- // button.
- int center = std::max(width(), height()) / 2.f;
- gfx::Point centroid(center, center);
- // For the left shelf alignment, we need to right-justify. For other shelf
- // alignments, left/top justification (i.e. no adjustments are necessary).
- if (SHELF_ALIGNMENT_LEFT == wm_shelf_->GetAlignment())
- centroid.set_x(width() - center);
- return centroid;
+ const int x_mid = width() / 2.f;
+ const int y_mid = height() / 2.f;
+ gfx::Point center(x_mid, y_mid);
+
+ // For a bottom-aligned shelf, the button bounds could have a larger height
+ // than width (in the case of touch-dragging the shelf updwards) or a larger
+ // width than height (in the case of a shelf hide/show animation), so adjust
+ // the y-position of the circle's center to ensure correct layout. Similarly
+ // adjust the x-position for a left- or right-aligned shelf.
oshima 2016/12/14 21:28:41 am I correct that we assume the button is square?
tdanderson 2016/12/14 21:45:07 The app list button is actually a circle
oshima 2016/12/14 21:52:37 I meant the logical bounds of the button is square
tdanderson 2016/12/14 22:18:04 Thanks, I like that much better. Changed.
+ if (wm_shelf_->GetAlignment() == SHELF_ALIGNMENT_BOTTOM)
+ center.set_y(x_mid);
+ else if (wm_shelf_->GetAlignment() == SHELF_ALIGNMENT_RIGHT)
+ center.set_x(y_mid);
+ else if (wm_shelf_->GetAlignment() == SHELF_ALIGNMENT_LEFT)
+ center.set_x(width() - y_mid);
+
+ return center;
}
} // namespace ash
« no previous file with comments | « no previous file | ash/common/shelf/overflow_button.cc » ('j') | ash/common/shelf/overflow_button.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698