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

Unified Diff: ash/shelf/app_list_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/app_list_button.cc
diff --git a/ash/shelf/app_list_button.cc b/ash/shelf/app_list_button.cc
index a57e12378802c6ebd7720ab4f09aae6c80058aa8..e6c06c4e8354cc3030149f53d194aaea136c29d8 100644
--- a/ash/shelf/app_list_button.cc
+++ b/ash/shelf/app_list_button.cc
@@ -5,6 +5,7 @@
#include "ash/shelf/app_list_button.h"
#include "ash/ash_constants.h"
+#include "ash/material_design/material_design_controller.h"
#include "ash/shelf/shelf_item_types.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_view.h"
@@ -31,7 +32,8 @@ AppListButton::AppListButton(ShelfView* shelf_view)
app_list::switches::IsExperimentalAppListEnabled()
? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)
: l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE));
- SetSize(gfx::Size(kShelfSize, kShelfSize));
+ SetSize(gfx::Size(GetShelfLayoutConstant(SHELF_SIZE),
+ GetShelfLayoutConstant(SHELF_SIZE)));
SetFocusPainter(views::Painter::CreateSolidFocusPainter(
kFocusBorderColor, gfx::Insets(1, 1, 1, 1)));
set_notify_action(CustomButton::NOTIFY_ON_PRESS);
@@ -125,19 +127,48 @@ void AppListButton::OnPaint(gfx::Canvas* canvas) {
wm::ShelfAlignment alignment = shelf_view_->shelf()->alignment();
background_bounds.set_size(background_image->size());
- if (alignment == wm::SHELF_ALIGNMENT_LEFT) {
- background_bounds.set_x(contents_bounds.width() -
- ShelfLayoutManager::kShelfItemInset - background_image->width());
- background_bounds.set_y(contents_bounds.y() +
- (contents_bounds.height() - background_image->height()) / 2);
- } else if (alignment == wm::SHELF_ALIGNMENT_RIGHT) {
- background_bounds.set_x(ShelfLayoutManager::kShelfItemInset);
- background_bounds.set_y(contents_bounds.y() +
- (contents_bounds.height() - background_image->height()) / 2);
+
+ // If Material Design for Chrome OS shelf is enabled.
+ if (MaterialDesignController::IsShelfMaterial()) {
+ if (alignment == wm::SHELF_ALIGNMENT_LEFT ||
+ alignment == wm::SHELF_ALIGNMENT_RIGHT) {
+ background_bounds.set_x(
+ (contents_bounds.width() - background_image->width()) / 2);
+ background_bounds.set_y(
+ contents_bounds.y() + ShelfLayoutManager::GetShelfItemInset(
+ ShelfLayoutManager::SHELF_ITEM_INSET) +
+ (contents_bounds.height() - background_image->height()) / 2);
+ } else { // SHELF_ALIGNMENT_BOTTOM
+ background_bounds.set_y(
+ (contents_bounds.height() - background_image->height()) / 2);
+ background_bounds.set_x(
+ contents_bounds.x() +
+ (contents_bounds.width() - background_image->width()) / 2 +
+ ShelfLayoutManager::GetShelfItemInset(
+ ShelfLayoutManager::SHELF_ITEM_INSET));
+ }
} else {
- background_bounds.set_y(ShelfLayoutManager::kShelfItemInset);
- background_bounds.set_x(contents_bounds.x() +
- (contents_bounds.width() - background_image->width()) / 2);
+ if (alignment == wm::SHELF_ALIGNMENT_LEFT) {
+ background_bounds.set_x(contents_bounds.width() -
+ ShelfLayoutManager::GetShelfItemInset(
+ ShelfLayoutManager::SHELF_ITEM_INSET) -
+ background_image->width());
+ background_bounds.set_y(
+ contents_bounds.y() +
+ (contents_bounds.height() - background_image->height()) / 2);
+ } else if (alignment == wm::SHELF_ALIGNMENT_RIGHT) {
+ background_bounds.set_x(ShelfLayoutManager::GetShelfItemInset(
+ ShelfLayoutManager::SHELF_ITEM_INSET));
+ background_bounds.set_y(
+ contents_bounds.y() +
+ (contents_bounds.height() - background_image->height()) / 2);
+ } else { // SHELF_ALIGNMENT_BOTTOM
+ background_bounds.set_y(ShelfLayoutManager::GetShelfItemInset(
+ ShelfLayoutManager::SHELF_ITEM_INSET));
+ background_bounds.set_x(
+ contents_bounds.x() +
+ (contents_bounds.width() - background_image->width()) / 2);
+ }
}
forground_bounds.set_size(forground_image->size());

Powered by Google App Engine
This is Rietveld 408576698