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

Side by Side Diff: ui/views/focus_border.cc

Issue 78803002: Fixing focus highlight on high DPI devices for accessibility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/focus_border.h ('k') | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/focus_border.h" 5 #include "ui/views/focus_border.h"
6 6
7 #include "ui/gfx/canvas.h" 7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/insets.h"
8 #include "ui/gfx/rect.h" 9 #include "ui/gfx/rect.h"
9 #include "ui/views/view.h" 10 #include "ui/views/view.h"
10 11
11 namespace views { 12 namespace views {
12 namespace { 13 namespace {
14
13 class DashedFocusBorder : public FocusBorder { 15 class DashedFocusBorder : public FocusBorder {
14 public: 16 public:
15 DashedFocusBorder( 17 DashedFocusBorder(
16 int left_inset, int top_inset, int right_inset, int bottom_inset) 18 int left_inset, int top_inset, int right_inset, int bottom_inset)
17 : left_inset_(left_inset), 19 : left_inset_(left_inset),
18 top_inset_(top_inset), 20 top_inset_(top_inset),
19 right_inset_(right_inset), 21 right_inset_(right_inset),
20 bottom_inset_(bottom_inset) { 22 bottom_inset_(bottom_inset) {
21 } 23 }
22 24
23 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE { 25 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE {
24 gfx::Rect rect(view.GetLocalBounds()); 26 gfx::Rect rect(view.GetLocalBounds());
25 rect.Inset(left_inset_, top_inset_, right_inset_, bottom_inset_); 27 rect.Inset(left_inset_, top_inset_, right_inset_, bottom_inset_);
26 canvas->DrawFocusRect(rect); 28 canvas->DrawFocusRect(rect);
27 } 29 }
28 30
29 private: 31 private:
30 int left_inset_; 32 int left_inset_;
31 int top_inset_; 33 int top_inset_;
32 int right_inset_; 34 int right_inset_;
33 int bottom_inset_; 35 int bottom_inset_;
34 36
35 DISALLOW_COPY_AND_ASSIGN(DashedFocusBorder); 37 DISALLOW_COPY_AND_ASSIGN(DashedFocusBorder);
36 }; 38 };
39
40 class SolidFocusBorder : public FocusBorder {
41 public:
42 SolidFocusBorder(SkColor focus_color, const gfx::Insets& insets)
43 : focus_color_(focus_color), insets_(insets) {
44 }
45
46 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE {
47 gfx::Rect rect(view.GetLocalBounds());
48 rect.Inset(insets_);
49 canvas->DrawSolidFocusRect(rect, focus_color_);
50 }
51
52 private:
53 // The focus color to use.
54 SkColor focus_color_;
55
56 // The insets to use.
57 gfx::Insets insets_;
58
59 DISALLOW_COPY_AND_ASSIGN(SolidFocusBorder);
60 };
61
37 } // namespace 62 } // namespace
38 63
39 FocusBorder::~FocusBorder() { 64 FocusBorder::~FocusBorder() {
40 } 65 }
41 66
42 // static 67 // static
43 FocusBorder* FocusBorder::CreateDashedFocusBorder() { 68 FocusBorder* FocusBorder::CreateDashedFocusBorder() {
44 return new DashedFocusBorder(0, 0, 0, 0); 69 return new DashedFocusBorder(0, 0, 0, 0);
45 } 70 }
46 71
47 // static 72 // static
48 FocusBorder* FocusBorder::CreateDashedFocusBorder( 73 FocusBorder* FocusBorder::CreateDashedFocusBorder(
49 int left, int top, int right, int bottom) { 74 int left, int top, int right, int bottom) {
50 return new DashedFocusBorder(left, top, right, bottom); 75 return new DashedFocusBorder(left, top, right, bottom);
51 } 76 }
52 77
78 // static
79 FocusBorder* FocusBorder::CreateSolidFocusBorder(
80 SkColor focus_color, const gfx::Insets& insets) {
81 return new SolidFocusBorder(focus_color, insets);
82 }
83
53 FocusBorder::FocusBorder() { 84 FocusBorder::FocusBorder() {
54 } 85 }
55 86
56 } // namespace views 87 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/focus_border.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698