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

Side by Side Diff: ash/common/shelf/app_list_button.cc

Issue 2661163003: [Chrome OS] Fix the broken focus rectangle on Launcher icon. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/common/shelf/app_list_button.h" 5 #include "ash/common/shelf/app_list_button.h"
6 6
7 #include "ash/common/ash_constants.h" 7 #include "ash/common/ash_constants.h"
8 #include "ash/common/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/shelf/ink_drop_button_listener.h" 9 #include "ash/common/shelf/ink_drop_button_listener.h"
10 #include "ash/common/shelf/shelf_constants.h" 10 #include "ash/common/shelf/shelf_constants.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 void AppListButton::PaintMd(gfx::Canvas* canvas) { 162 void AppListButton::PaintMd(gfx::Canvas* canvas) {
163 gfx::PointF circle_center(GetCenterPoint()); 163 gfx::PointF circle_center(GetCenterPoint());
164 164
165 // Paint the circular background. 165 // Paint the circular background.
166 SkPaint bg_paint; 166 SkPaint bg_paint;
167 bg_paint.setColor(SkColorSetA(kShelfBaseColor, background_alpha_)); 167 bg_paint.setColor(SkColorSetA(kShelfBaseColor, background_alpha_));
168 bg_paint.setFlags(SkPaint::kAntiAlias_Flag); 168 bg_paint.setFlags(SkPaint::kAntiAlias_Flag);
169 bg_paint.setStyle(SkPaint::kFill_Style); 169 bg_paint.setStyle(SkPaint::kFill_Style);
170 canvas->DrawCircle(circle_center, kAppListButtonRadius, bg_paint); 170 canvas->DrawCircle(circle_center, kAppListButtonRadius, bg_paint);
171 171
172 // Paint a white ring as the foreground. The ceil/dsf math assures that the 172 // Paint a white ring as the foreground.
173 // ring draws sharply and is centered at all scale factors.
Evan Stade 2017/02/01 00:38:13 This logic looks pretty intentional. Are you sure
xdai1 2017/02/01 01:14:06 Sorry for the previous bad fix. Modified as you su
174 const float kRingOuterRadiusDp = 7.f; 173 const float kRingOuterRadiusDp = 7.f;
175 const float kRingThicknessDp = 1.5f; 174 const float kRingThicknessDp = 1.5f;
176 const float dsf = canvas->UndoDeviceScaleFactor();
177 circle_center.Scale(dsf);
178
179 SkPaint fg_paint; 175 SkPaint fg_paint;
180 fg_paint.setFlags(SkPaint::kAntiAlias_Flag); 176 fg_paint.setFlags(SkPaint::kAntiAlias_Flag);
181 fg_paint.setStyle(SkPaint::kStroke_Style); 177 fg_paint.setStyle(SkPaint::kStroke_Style);
182 fg_paint.setColor(kShelfIconColor); 178 fg_paint.setColor(kShelfIconColor);
183 const float thickness = std::ceil(kRingThicknessDp * dsf); 179 fg_paint.setStrokeWidth(kRingThicknessDp);
184 const float radius = std::ceil(kRingOuterRadiusDp * dsf) - thickness / 2; 180 const float radius = kRingOuterRadiusDp - kRingThicknessDp / 2;
185 fg_paint.setStrokeWidth(thickness);
186 // Make sure the center of the circle lands on pixel centers. 181 // Make sure the center of the circle lands on pixel centers.
187 canvas->DrawCircle(circle_center, radius, fg_paint); 182 canvas->DrawCircle(circle_center, radius, fg_paint);
188 } 183 }
189 184
190 void AppListButton::PaintAppListButton(gfx::Canvas* canvas, 185 void AppListButton::PaintAppListButton(gfx::Canvas* canvas,
191 const gfx::ImageSkia& foreground_image) { 186 const gfx::ImageSkia& foreground_image) {
192 int background_image_id = 0; 187 int background_image_id = 0;
193 188
194 if (WmShell::Get()->GetAppListTargetVisibility() || 189 if (WmShell::Get()->GetAppListTargetVisibility() ||
195 draw_background_as_active_) { 190 draw_background_as_active_) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 return gfx::Point(x_mid, x_mid); 296 return gfx::Point(x_mid, x_mid);
302 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { 297 } else if (alignment == SHELF_ALIGNMENT_RIGHT) {
303 return gfx::Point(y_mid, y_mid); 298 return gfx::Point(y_mid, y_mid);
304 } else { 299 } else {
305 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); 300 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT);
306 return gfx::Point(width() - y_mid, y_mid); 301 return gfx::Point(width() - y_mid, y_mid);
307 } 302 }
308 } 303 }
309 304
310 } // namespace ash 305 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698