| 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/base/native_theme/native_theme.h" | |
| 8 #include "ui/gfx/canvas.h" | 7 #include "ui/gfx/canvas.h" |
| 9 #include "ui/gfx/insets.h" | 8 #include "ui/gfx/insets.h" |
| 9 #include "ui/gfx/native_theme.h" |
| 10 #include "ui/gfx/skia_util.h" | 10 #include "ui/gfx/skia_util.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // Define the size of the insets | 14 // Define the size of the insets |
| 15 const int kTopInsetSize = 4; | 15 const int kTopInsetSize = 4; |
| 16 const int kLeftInsetSize = 4; | 16 const int kLeftInsetSize = 4; |
| 17 const int kBottomInsetSize = 4; | 17 const int kBottomInsetSize = 4; |
| 18 const int kRightInsetSize = 4; | 18 const int kRightInsetSize = 4; |
| 19 | 19 |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 namespace views { | 22 namespace views { |
| 23 | 23 |
| 24 FocusableBorder::FocusableBorder() | 24 FocusableBorder::FocusableBorder() |
| 25 : has_focus_(false), | 25 : has_focus_(false), |
| 26 insets_(kTopInsetSize, kLeftInsetSize, | 26 insets_(kTopInsetSize, kLeftInsetSize, |
| 27 kBottomInsetSize, kRightInsetSize) { | 27 kBottomInsetSize, kRightInsetSize) { |
| 28 } | 28 } |
| 29 | 29 |
| 30 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) const { | 30 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) const { |
| 31 SkPath path; | 31 SkPath path; |
| 32 path.addRect(gfx::RectToSkRect(view.GetLocalBounds()), SkPath::kCW_Direction); | 32 path.addRect(gfx::RectToSkRect(view.GetLocalBounds()), SkPath::kCW_Direction); |
| 33 SkPaint paint; | 33 SkPaint paint; |
| 34 paint.setStyle(SkPaint::kStroke_Style); | 34 paint.setStyle(SkPaint::kStroke_Style); |
| 35 SkColor focus_color = ui::NativeTheme::instance()->GetSystemColor( | 35 SkColor focus_color = gfx::NativeTheme::instance()->GetSystemColor( |
| 36 has_focus_ ? ui::NativeTheme::kColorId_FocusedBorderColor | 36 has_focus_ ? gfx::NativeTheme::kColorId_FocusedBorderColor |
| 37 : ui::NativeTheme::kColorId_UnfocusedBorderColor); | 37 : gfx::NativeTheme::kColorId_UnfocusedBorderColor); |
| 38 paint.setColor(focus_color); | 38 paint.setColor(focus_color); |
| 39 paint.setStrokeWidth(SkIntToScalar(2)); | 39 paint.setStrokeWidth(SkIntToScalar(2)); |
| 40 | 40 |
| 41 canvas->DrawPath(path, paint); | 41 canvas->DrawPath(path, paint); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void FocusableBorder::GetInsets(gfx::Insets* insets) const { | 44 void FocusableBorder::GetInsets(gfx::Insets* insets) const { |
| 45 *insets = insets_; | 45 *insets = insets_; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void FocusableBorder::SetInsets(int top, int left, int bottom, int right) { | 48 void FocusableBorder::SetInsets(int top, int left, int bottom, int right) { |
| 49 insets_.Set(top, left, bottom, right); | 49 insets_.Set(top, left, bottom, right); |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace views | 52 } // namespace views |
| OLD | NEW |