Chromium Code Reviews| Index: ash/shelf/overflow_button.cc |
| diff --git a/ash/shelf/overflow_button.cc b/ash/shelf/overflow_button.cc |
| index b1292771fb1467402e1b8578f00bb1f5b923088e..bd8917414950f2e011d554ae177ec5587eab7e37 100644 |
| --- a/ash/shelf/overflow_button.cc |
| +++ b/ash/shelf/overflow_button.cc |
| @@ -5,6 +5,7 @@ |
| #include "ash/shelf/overflow_button.h" |
| #include "ash/ash_switches.h" |
| +#include "ash/material_design/material_design_controller.h" |
| #include "ash/shelf/shelf.h" |
| #include "ash/shelf/shelf_layout_manager.h" |
| #include "ash/shelf/shelf_widget.h" |
| @@ -93,22 +94,46 @@ void OverflowButton::OnPaint(gfx::Canvas* canvas) { |
| const gfx::ImageSkia* background = |
| rb.GetImageNamed(background_image_id).ToImageSkia(); |
| wm::ShelfAlignment alignment = shelf_->alignment(); |
| - if (alignment == wm::SHELF_ALIGNMENT_LEFT) { |
| - bounds = gfx::Rect( |
| - bounds.right() - background->width() - |
| - ShelfLayoutManager::kShelfItemInset, |
| - bounds.y() + (bounds.height() - background->height()) / 2, |
| - background->width(), background->height()); |
| - } else if (alignment == wm::SHELF_ALIGNMENT_RIGHT) { |
| - bounds = gfx::Rect( |
| - bounds.x() + ShelfLayoutManager::kShelfItemInset, |
| - bounds.y() + (bounds.height() - background->height()) / 2, |
| - background->width(), background->height()); |
| + |
| + // If Material Design for Chrome OS shelf is enabled. |
|
tdanderson
2016/05/26 22:55:56
nit: remove comment. (similarly in app_list_button
yiyix
2016/06/02 03:54:53
Done.
|
| + if (MaterialDesignController::IsShelfMaterial()) { |
| + if (alignment == wm::SHELF_ALIGNMENT_LEFT || |
| + alignment == wm::SHELF_ALIGNMENT_RIGHT) { |
|
tdanderson
2016/05/26 22:55:56
nit: can you instead use !wm::IsHorizontalAlignmen
yiyix
2016/06/02 03:54:53
On 2016/05/26 22:55:56, tdanderson wrote:
> nit: c
|
| + bounds = |
| + gfx::Rect(bounds.x() + ((bounds.width() - background->width()) / 2), |
| + bounds.y() + ShelfLayoutManager::GetShelfItemInset( |
| + ShelfLayoutManager::SHELF_ITEM_INSET) + |
| + (bounds.height() - background->height()) / 2, |
| + background->width(), background->height()); |
| + } else { // SHELF_ALIGNMENT_BOTTOM |
| + bounds = |
| + gfx::Rect((bounds.x() + ShelfLayoutManager::GetShelfItemInset( |
| + ShelfLayoutManager::SHELF_ITEM_INSET) + |
| + (bounds.width() - background->width()) / 2), |
| + bounds.y() + (bounds.height() - background->height()) / 2, |
| + background->width(), background->height()); |
| + } |
| } else { |
| - bounds = gfx::Rect( |
| - bounds.x() + (bounds.width() - background->width()) / 2, |
| - bounds.y() + ShelfLayoutManager::kShelfItemInset, |
| - background->width(), background->height()); |
| + if (alignment == wm::SHELF_ALIGNMENT_LEFT) { |
| + bounds = |
| + gfx::Rect(bounds.right() - background->width() - |
| + ShelfLayoutManager::GetShelfItemInset( |
| + ShelfLayoutManager::SHELF_ITEM_INSET), |
| + bounds.y() + (bounds.height() - background->height()) / 2, |
| + background->width(), background->height()); |
| + } else if (alignment == wm::SHELF_ALIGNMENT_RIGHT) { |
| + bounds = |
| + gfx::Rect(bounds.x() + ShelfLayoutManager::GetShelfItemInset( |
| + ShelfLayoutManager::SHELF_ITEM_INSET), |
| + bounds.y() + (bounds.height() - background->height()) / 2, |
| + background->width(), background->height()); |
| + } else { |
| + bounds = |
| + gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, |
| + bounds.y() + ShelfLayoutManager::GetShelfItemInset( |
| + ShelfLayoutManager::SHELF_ITEM_INSET), |
| + background->width(), background->height()); |
| + } |
| } |
| canvas->DrawImageInt(*background, bounds.x(), bounds.y()); |