| OLD | NEW |
| 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 21 matching lines...) Expand all Loading... |
| 32 void FocusableBorder::SetColorId( | 32 void FocusableBorder::SetColorId( |
| 33 const base::Optional<ui::NativeTheme::ColorId>& color_id) { | 33 const base::Optional<ui::NativeTheme::ColorId>& color_id) { |
| 34 override_color_id_ = color_id; | 34 override_color_id_ = color_id; |
| 35 } | 35 } |
| 36 | 36 |
| 37 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) { | 37 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) { |
| 38 // In harmony, the focus indicator is a FocusRing. | 38 // In harmony, the focus indicator is a FocusRing. |
| 39 if (ui::MaterialDesignController::IsSecondaryUiMaterial() && view.HasFocus()) | 39 if (ui::MaterialDesignController::IsSecondaryUiMaterial() && view.HasFocus()) |
| 40 return; | 40 return; |
| 41 | 41 |
| 42 SkPaint paint; | 42 CdlPaint paint; |
| 43 paint.setStyle(SkPaint::kStroke_Style); | 43 paint.setStyle(CdlPaint::kStroke_Style); |
| 44 paint.setColor(GetCurrentColor(view)); | 44 paint.setColor(GetCurrentColor(view)); |
| 45 | 45 |
| 46 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 46 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 47 gfx::ScopedCanvas scoped(canvas); | 47 gfx::ScopedCanvas scoped(canvas); |
| 48 float dsf = canvas->UndoDeviceScaleFactor(); | 48 float dsf = canvas->UndoDeviceScaleFactor(); |
| 49 // Scale the rect and snap to pixel boundaries. | 49 // Scale the rect and snap to pixel boundaries. |
| 50 gfx::RectF rect(gfx::ScaleToEnclosingRect(view.GetLocalBounds(), dsf)); | 50 gfx::RectF rect(gfx::ScaleToEnclosingRect(view.GetLocalBounds(), dsf)); |
| 51 rect.Inset(gfx::InsetsF(0.5f)); | 51 rect.Inset(gfx::InsetsF(0.5f)); |
| 52 SkPath path; | 52 SkPath path; |
| 53 float corner_radius_px = kCornerRadiusDp * dsf; | 53 float corner_radius_px = kCornerRadiusDp * dsf; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 SkColor color = view.GetNativeTheme()->GetSystemColor(color_id); | 89 SkColor color = view.GetNativeTheme()->GetSystemColor(color_id); |
| 90 if (ui::MaterialDesignController::IsSecondaryUiMaterial() && | 90 if (ui::MaterialDesignController::IsSecondaryUiMaterial() && |
| 91 !view.enabled()) { | 91 !view.enabled()) { |
| 92 return color_utils::BlendTowardOppositeLuma(color, | 92 return color_utils::BlendTowardOppositeLuma(color, |
| 93 gfx::kDisabledControlAlpha); | 93 gfx::kDisabledControlAlpha); |
| 94 } | 94 } |
| 95 return color; | 95 return color; |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace views | 98 } // namespace views |
| OLD | NEW |