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

Side by Side Diff: ui/views/controls/focusable_border.cc

Issue 2383243002: Refactor MdFocusRing to make it easier to reuse on other controls. (Closed)
Patch Set: install Created 4 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
« no previous file with comments | « ui/views/controls/focusable_border.h ('k') | ui/views/controls/textfield/textfield.cc » ('j') | 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/controls/focusable_border.h" 5 #include "ui/views/controls/focusable_border.h"
6 6
7 #include "third_party/skia/include/core/SkPaint.h" 7 #include "third_party/skia/include/core/SkPaint.h"
8 #include "third_party/skia/include/core/SkPath.h" 8 #include "third_party/skia/include/core/SkPath.h"
9 #include "ui/base/material_design/material_design_controller.h" 9 #include "ui/base/material_design/material_design_controller.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 25 matching lines...) Expand all
36 void FocusableBorder::SetColor(SkColor color) { 36 void FocusableBorder::SetColor(SkColor color) {
37 override_color_ = color; 37 override_color_ = color;
38 use_default_color_ = false; 38 use_default_color_ = false;
39 } 39 }
40 40
41 void FocusableBorder::UseDefaultColor() { 41 void FocusableBorder::UseDefaultColor() {
42 use_default_color_ = true; 42 use_default_color_ = true;
43 } 43 }
44 44
45 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) { 45 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) {
46 // In harmony, the focus indicator is a FocusRing.
47 if (ui::MaterialDesignController::IsSecondaryUiMaterial() && view.HasFocus())
48 return;
49
46 SkPaint paint; 50 SkPaint paint;
47 paint.setStyle(SkPaint::kStroke_Style); 51 paint.setStyle(SkPaint::kStroke_Style);
48 paint.setColor(GetCurrentColor(view)); 52 paint.setColor(GetCurrentColor(view));
49 53
50 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { 54 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
51 gfx::ScopedCanvas scoped(canvas); 55 gfx::ScopedCanvas scoped(canvas);
52 float dsf = canvas->UndoDeviceScaleFactor(); 56 float dsf = canvas->UndoDeviceScaleFactor();
53 // Scale the rect and snap to pixel boundaries. 57 // Scale the rect and snap to pixel boundaries.
54 gfx::RectF rect(gfx::ScaleToEnclosingRect(view.GetLocalBounds(), dsf)); 58 gfx::RectF rect(gfx::ScaleToEnclosingRect(view.GetLocalBounds(), dsf));
55 rect.Inset(gfx::InsetsF(0.5f)); 59 rect.Inset(gfx::InsetsF(0.5f));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 if (ui::MaterialDesignController::IsSecondaryUiMaterial() && 96 if (ui::MaterialDesignController::IsSecondaryUiMaterial() &&
93 !view.enabled()) { 97 !view.enabled()) {
94 return color_utils::BlendTowardOppositeLuma(color, 98 return color_utils::BlendTowardOppositeLuma(color,
95 gfx::kDisabledControlAlpha); 99 gfx::kDisabledControlAlpha);
96 } 100 }
97 101
98 return color; 102 return color;
99 } 103 }
100 104
101 } // namespace views 105 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/focusable_border.h ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698