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

Unified Diff: ash/shelf/overflow_button.cc

Issue 1998933002: Update shelf spacing in Chrome OS according to the MD specs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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());

Powered by Google App Engine
This is Rietveld 408576698