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

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

Issue 2598223002: [ash-md] Fix layout of launcher and overflow buttons in Ash MD shelf (Closed)
Patch Set: Merge branch 'master' into launcher_layout_in_shelf Created 3 years, 11 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 | ash/common/shelf/overflow_button.cc » ('j') | no next file with comments »
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 8847fb81e7e95af51bc5edb0ce2bc6e26623c15b..6ab78cb246c04535783e5dc261b71ffee39e1681 100644
--- a/ash/common/shelf/app_list_button.cc
+++ b/ash/common/shelf/app_list_button.cc
@@ -288,16 +288,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;
+ // 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.
+ const int x_mid = width() / 2.f;
+ const int y_mid = height() / 2.f;
+ ShelfAlignment alignment = wm_shelf_->GetAlignment();
+ if (alignment == SHELF_ALIGNMENT_BOTTOM ||
+ alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) {
oshima 2017/01/06 20:00:43 This is for lock screen state, correct?
bruthig 2017/01/06 20:28:07 Yup
+ return gfx::Point(x_mid, x_mid);
+ } else if (alignment == SHELF_ALIGNMENT_RIGHT) {
+ return gfx::Point(y_mid, y_mid);
+ } else {
+ DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT);
+ return gfx::Point(width() - y_mid, y_mid);
+ }
}
} // namespace ash
« no previous file with comments | « no previous file | ash/common/shelf/overflow_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698