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

Unified Diff: ash/common/shelf/overflow_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
« ash/common/shelf/app_list_button.cc ('K') | « ash/common/shelf/app_list_button.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shelf/overflow_button.cc
diff --git a/ash/common/shelf/overflow_button.cc b/ash/common/shelf/overflow_button.cc
index 7d63c2e243f536984bf8490c320b031ef0393f76..2bf558ac480ddd077ef34a82b75b3515d2ad6eb5 100644
--- a/ash/common/shelf/overflow_button.cc
+++ b/ash/common/shelf/overflow_button.cc
@@ -172,18 +172,17 @@ int OverflowButton::NonMaterialBackgroundImageId() const {
gfx::Rect OverflowButton::CalculateButtonBounds() const {
ShelfAlignment alignment = wm_shelf_->GetAlignment();
gfx::Rect bounds(GetContentsBounds());
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
if (MaterialDesignController::IsShelfMaterial()) {
- const int width_offset = (bounds.width() - kOverflowButtonSize) / 2;
- const int height_offset = (bounds.height() - kOverflowButtonSize) / 2;
- if (IsHorizontalAlignment(alignment)) {
- bounds = gfx::Rect(bounds.x() + width_offset, bounds.y() + height_offset,
- kOverflowButtonSize, kOverflowButtonSize);
- } else {
- bounds = gfx::Rect(bounds.x() + height_offset, bounds.y() + width_offset,
- kOverflowButtonSize, kOverflowButtonSize);
- }
+ // Align the button to the top of a bottom-aligned shelf, to the right edge
+ // a left-aligned shelf, and to the left edge of a right-aligned shelf.
+ const int inset = (GetShelfConstant(SHELF_SIZE) - kOverflowButtonSize) / 2;
+ const int x = alignment == SHELF_ALIGNMENT_LEFT
+ ? bounds.right() - inset - kOverflowButtonSize
+ : bounds.x() + inset;
+ bounds = gfx::Rect(x, bounds.y() + inset, kOverflowButtonSize,
+ kOverflowButtonSize);
} else {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
const gfx::ImageSkia* background =
rb.GetImageNamed(NonMaterialBackgroundImageId()).ToImageSkia();
if (alignment == SHELF_ALIGNMENT_LEFT) {
« ash/common/shelf/app_list_button.cc ('K') | « ash/common/shelf/app_list_button.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698