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

Side by Side Diff: chrome/browser/chromeos/ui/accessibility_focus_ring_layer.cc

Issue 602813003: Animate the accessibility focus ring and fix some minor visual issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@focus_ring_in_chromevox
Patch Set: Fix unit tests Created 6 years, 2 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 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 "chrome/browser/chromeos/ui/accessibility_focus_ring_layer.h" 5 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_layer.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/compositor/layer.h" 11 #include "ui/compositor/layer.h"
12 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 15
16 namespace { 16 namespace {
17 17
18 // The number of pixels in the color gradient that fades to transparent. 18 // The number of pixels in the color gradient that fades to transparent.
19 const int kGradientWidth = 10; 19 const int kGradientWidth = 6;
20 20
21 // The color of the focus ring. In the future this might be a parameter. 21 // The color of the focus ring. In the future this might be a parameter.
22 const int kFocusRingColorRed = 247; 22 const int kFocusRingColorRed = 247;
23 const int kFocusRingColorGreen = 152; 23 const int kFocusRingColorGreen = 152;
24 const int kFocusRingColorBlue = 58; 24 const int kFocusRingColorBlue = 58;
25 25
26 int sign(int x) { 26 int sign(int x) {
27 return ((x > 0) ? 1 : (x == 0) ? 0 : -1); 27 return ((x > 0) ? 1 : (x == 0) ? 0 : -1);
28 } 28 }
29 29
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 void AccessibilityFocusRingLayer::OnPaintLayer(gfx::Canvas* canvas) { 112 void AccessibilityFocusRingLayer::OnPaintLayer(gfx::Canvas* canvas) {
113 gfx::Vector2d offset = layer()->bounds().OffsetFromOrigin(); 113 gfx::Vector2d offset = layer()->bounds().OffsetFromOrigin();
114 114
115 SkPaint paint; 115 SkPaint paint;
116 paint.setFlags(SkPaint::kAntiAlias_Flag); 116 paint.setFlags(SkPaint::kAntiAlias_Flag);
117 paint.setStyle(SkPaint::kStroke_Style); 117 paint.setStyle(SkPaint::kStroke_Style);
118 paint.setStrokeWidth(2); 118 paint.setStrokeWidth(2);
119 119
120 SkPath path; 120 SkPath path;
121 for (int i = 0; i < kGradientWidth; i++) { 121 const int w = kGradientWidth;
122 for (int i = 0; i < w; ++i) {
122 paint.setColor( 123 paint.setColor(
123 SkColorSetARGBMacro( 124 SkColorSetARGBMacro(
124 255 - (255 * i / kGradientWidth), 125 255 * (w - i) * (w - i) / (w * w),
125 kFocusRingColorRed, kFocusRingColorGreen, kFocusRingColorBlue)); 126 kFocusRingColorRed, kFocusRingColorGreen, kFocusRingColorBlue));
126 path = MakePath(ring_, i, offset); 127 path = MakePath(ring_, i, offset);
127 canvas->DrawPath(path, paint); 128 canvas->DrawPath(path, paint);
128 } 129 }
129 } 130 }
130 131
131 } // namespace chromeos 132 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698