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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shelf/overflow_button.h" 5 #include "ash/shelf/overflow_button.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/material_design/material_design_controller.h"
8 #include "ash/shelf/shelf.h" 9 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shelf/shelf_widget.h" 11 #include "ash/shelf/shelf_widget.h"
11 #include "grit/ash_resources.h" 12 #include "grit/ash_resources.h"
12 #include "grit/ash_strings.h" 13 #include "grit/ash_strings.h"
13 #include "third_party/skia/include/core/SkPaint.h" 14 #include "third_party/skia/include/core/SkPaint.h"
14 #include "third_party/skia/include/core/SkPath.h" 15 #include "third_party/skia/include/core/SkPath.h"
15 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/animation/throb_animation.h" 18 #include "ui/gfx/animation/throb_animation.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 if (shelf_->IsShowingOverflowBubble()) 87 if (shelf_->IsShowingOverflowBubble())
87 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; 88 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED;
88 else if (shelf_->shelf_widget()->GetDimsShelf()) 89 else if (shelf_->shelf_widget()->GetDimsShelf())
89 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; 90 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK;
90 else 91 else
91 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; 92 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL;
92 93
93 const gfx::ImageSkia* background = 94 const gfx::ImageSkia* background =
94 rb.GetImageNamed(background_image_id).ToImageSkia(); 95 rb.GetImageNamed(background_image_id).ToImageSkia();
95 wm::ShelfAlignment alignment = shelf_->alignment(); 96 wm::ShelfAlignment alignment = shelf_->alignment();
96 if (alignment == wm::SHELF_ALIGNMENT_LEFT) { 97
97 bounds = gfx::Rect( 98 if (MaterialDesignController::IsShelfMaterial()) {
98 bounds.right() - background->width() - 99 // 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.
99 ShelfLayoutManager::kShelfItemInset, 100 if (!shelf_->IsHorizontalAlignment()) {
100 bounds.y() + (bounds.height() - background->height()) / 2, 101 bounds =
101 background->width(), background->height()); 102 gfx::Rect(bounds.x() + ((bounds.width() - background->width()) / 2),
102 } else if (alignment == wm::SHELF_ALIGNMENT_RIGHT) { 103 bounds.y() + (bounds.height() - background->height()) / 2,
103 bounds = gfx::Rect( 104 background->width(), background->height());
104 bounds.x() + ShelfLayoutManager::kShelfItemInset, 105 } else { // SHELF_ALIGNMENT_BOTTOM
105 bounds.y() + (bounds.height() - background->height()) / 2, 106 bounds =
106 background->width(), background->height()); 107 gfx::Rect((bounds.x() + (bounds.width() - background->width()) / 2),
108 bounds.y() + (bounds.height() - background->height()) / 2,
109 background->width(), background->height());
110 }
107 } else { 111 } else {
108 bounds = gfx::Rect( 112 if (alignment == wm::SHELF_ALIGNMENT_LEFT) {
109 bounds.x() + (bounds.width() - background->width()) / 2, 113 bounds =
110 bounds.y() + ShelfLayoutManager::kShelfItemInset, 114 gfx::Rect(bounds.right() - background->width() - kShelfItemInset,
111 background->width(), background->height()); 115 bounds.y() + (bounds.height() - background->height()) / 2,
116 background->width(), background->height());
117 } else if (alignment == wm::SHELF_ALIGNMENT_RIGHT) {
118 bounds =
119 gfx::Rect(bounds.x() + kShelfItemInset,
120 bounds.y() + (bounds.height() - background->height()) / 2,
121 background->width(), background->height());
122 } else {
123 bounds =
124 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2,
125 bounds.y() + kShelfItemInset, background->width(),
126 background->height());
127 }
112 } 128 }
113 canvas->DrawImageInt(*background, bounds.x(), bounds.y()); 129 canvas->DrawImageInt(*background, bounds.x(), bounds.y());
114 130
115 if (height() < kButtonHoverSize) 131 if (height() < kButtonHoverSize)
116 return; 132 return;
117 133
118 const gfx::ImageSkia* image = NULL; 134 const gfx::ImageSkia* image = NULL;
119 135
120 switch(alignment) { 136 switch(alignment) {
121 case wm::SHELF_ALIGNMENT_LEFT: 137 case wm::SHELF_ALIGNMENT_LEFT:
(...skipping 14 matching lines...) Expand all
136 image = bottom_image_; 152 image = bottom_image_;
137 break; 153 break;
138 } 154 }
139 155
140 canvas->DrawImageInt(*image, 156 canvas->DrawImageInt(*image,
141 bounds.x() + ((bounds.width() - image->width()) / 2), 157 bounds.x() + ((bounds.width() - image->width()) / 2),
142 bounds.y() + ((bounds.height() - image->height()) / 2)); 158 bounds.y() + ((bounds.height() - image->height()) / 2));
143 } 159 }
144 160
145 } // namespace ash 161 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698