| 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 "ui/gfx/canvas.h" | 7 #include "ui/gfx/canvas.h" |
| 8 #include "ui/gfx/canvas_skia.h" | 8 #include "ui/gfx/canvas_skia.h" |
| 9 #include "ui/gfx/insets.h" | 9 #include "ui/gfx/insets.h" |
| 10 #include "ui/gfx/native_theme.h" | 10 #include "ui/gfx/native_theme.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } // namespace | 21 } // namespace |
| 22 | 22 |
| 23 namespace views { | 23 namespace views { |
| 24 | 24 |
| 25 FocusableBorder::FocusableBorder() | 25 FocusableBorder::FocusableBorder() |
| 26 : has_focus_(false), | 26 : has_focus_(false), |
| 27 insets_(kTopInsetSize, kLeftInsetSize, | 27 insets_(kTopInsetSize, kLeftInsetSize, |
| 28 kBottomInsetSize, kRightInsetSize) { | 28 kBottomInsetSize, kRightInsetSize) { |
| 29 } | 29 } |
| 30 | 30 |
| 31 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) const { | 31 void FocusableBorder::Paint(const View& view, gfx::CanvasSkia* canvas) const { |
| 32 SkPath path; | 32 SkPath path; |
| 33 path.addRect(gfx::RectToSkRect(view.GetLocalBounds()), SkPath::kCW_Direction); | 33 path.addRect(gfx::RectToSkRect(view.GetLocalBounds()), SkPath::kCW_Direction); |
| 34 SkPaint paint; | 34 SkPaint paint; |
| 35 paint.setStyle(SkPaint::kStroke_Style); | 35 paint.setStyle(SkPaint::kStroke_Style); |
| 36 SkColor focus_color = gfx::NativeTheme::instance()->GetSystemColor( | 36 SkColor focus_color = gfx::NativeTheme::instance()->GetSystemColor( |
| 37 has_focus_ ? gfx::NativeTheme::kColorId_FocusedBorderColor | 37 has_focus_ ? gfx::NativeTheme::kColorId_FocusedBorderColor |
| 38 : gfx::NativeTheme::kColorId_UnfocusedBorderColor); | 38 : gfx::NativeTheme::kColorId_UnfocusedBorderColor); |
| 39 paint.setColor(focus_color); | 39 paint.setColor(focus_color); |
| 40 paint.setStrokeWidth(SkIntToScalar(2)); | 40 paint.setStrokeWidth(SkIntToScalar(2)); |
| 41 | 41 |
| 42 canvas->GetSkCanvas()->drawPath(path, paint); | 42 canvas->GetSkCanvas()->drawPath(path, paint); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void FocusableBorder::GetInsets(gfx::Insets* insets) const { | 45 void FocusableBorder::GetInsets(gfx::Insets* insets) const { |
| 46 *insets = insets_; | 46 *insets = insets_; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void FocusableBorder::SetInsets(int top, int left, int bottom, int right) { | 49 void FocusableBorder::SetInsets(int top, int left, int bottom, int right) { |
| 50 insets_.Set(top, left, bottom, right); | 50 insets_.Set(top, left, bottom, right); |
| 51 } | 51 } |
| 52 | 52 |
| 53 } // namespace views | 53 } // namespace views |
| OLD | NEW |