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

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: address comments & Refactor border around item implementation 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..b6326ab143057791d86b9746f93e708768e1555f 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,37 @@ 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 (MaterialDesignController::IsShelfMaterial()) {
+ // SHELF_ALIGNMENT_LEFT and SHELF_ALIGNMENT_RIGHT
tdanderson 2016/06/03 19:25:23 Same comments as in AppListButton: remove comments
yiyix 2016/06/10 19:26:04 Done.
+ if (!shelf_->IsHorizontalAlignment()) {
+ bounds =
+ gfx::Rect(bounds.x() + ((bounds.width() - background->width()) / 2),
+ bounds.y() + (bounds.height() - background->height()) / 2,
+ background->width(), background->height());
+ } else { // SHELF_ALIGNMENT_BOTTOM
+ bounds =
+ gfx::Rect((bounds.x() + (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() - kShelfItemInset,
+ bounds.y() + (bounds.height() - background->height()) / 2,
+ background->width(), background->height());
+ } else if (alignment == wm::SHELF_ALIGNMENT_RIGHT) {
+ bounds =
+ gfx::Rect(bounds.x() + kShelfItemInset,
+ bounds.y() + (bounds.height() - background->height()) / 2,
+ background->width(), background->height());
+ } else {
+ bounds =
+ gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2,
+ bounds.y() + kShelfItemInset, background->width(),
+ background->height());
+ }
}
canvas->DrawImageInt(*background, bounds.x(), bounds.y());

Powered by Google App Engine
This is Rietveld 408576698