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

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: found message center offset 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
« ui/views/focus_border.h ('K') | « 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(
43 SkColor focus_color,
oshima 2013/11/25 19:22:26 arguments can be in single line?
Mr4D (OOO till 08-26) 2013/11/25 19:35:14 Done.
44 const gfx::Insets& insets)
45 : focus_color_(focus_color),
46 insets_(insets) {
oshima 2013/11/25 19:22:26 ditto
Mr4D (OOO till 08-26) 2013/11/25 19:35:14 Done.
47 }
48
49 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE {
50 gfx::Rect rect(view.GetLocalBounds());
51 rect.Inset(insets_);
52 canvas->DrawSolidFocusRect(rect, focus_color_);
53 }
54
55 private:
56 // The focus color to use.
57 SkColor focus_color_;
58
59 // The insets to use.
60 gfx::Insets insets_;
61
62 DISALLOW_COPY_AND_ASSIGN(SolidFocusBorder);
63 };
64
37 } // namespace 65 } // namespace
38 66
39 FocusBorder::~FocusBorder() { 67 FocusBorder::~FocusBorder() {
40 } 68 }
41 69
42 // static 70 // static
43 FocusBorder* FocusBorder::CreateDashedFocusBorder() { 71 FocusBorder* FocusBorder::CreateDashedFocusBorder() {
44 return new DashedFocusBorder(0, 0, 0, 0); 72 return new DashedFocusBorder(0, 0, 0, 0);
45 } 73 }
46 74
47 // static 75 // static
48 FocusBorder* FocusBorder::CreateDashedFocusBorder( 76 FocusBorder* FocusBorder::CreateDashedFocusBorder(
49 int left, int top, int right, int bottom) { 77 int left, int top, int right, int bottom) {
50 return new DashedFocusBorder(left, top, right, bottom); 78 return new DashedFocusBorder(left, top, right, bottom);
51 } 79 }
52 80
81 // static
82 FocusBorder* FocusBorder::CreateSolidFocusBorder(
83 SkColor focus_color, const gfx::Insets& insets) {
84 return new SolidFocusBorder(focus_color, insets);
85 }
86
53 FocusBorder::FocusBorder() { 87 FocusBorder::FocusBorder() {
54 } 88 }
55 89
56 } // namespace views 90 } // namespace views
OLDNEW
« ui/views/focus_border.h ('K') | « ui/views/focus_border.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698