| 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/insets.h" | 8 #include "ui/gfx/insets.h" |
| 9 #include "ui/gfx/skia_util.h" | 9 #include "ui/gfx/skia_util.h" |
| 10 #include "ui/native_theme/native_theme.h" | 10 #include "ui/native_theme/native_theme.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // Define the size of the insets | 14 // The size of the insets and the stroke. |
| 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 const int kStrokeWidth = 2; |
| 19 | 20 |
| 20 } // namespace | 21 } // namespace |
| 21 | 22 |
| 22 namespace views { | 23 namespace views { |
| 23 | 24 |
| 24 FocusableBorder::FocusableBorder() | 25 FocusableBorder::FocusableBorder() |
| 25 : insets_(kTopInsetSize, kLeftInsetSize, | 26 : insets_(kTopInsetSize, kLeftInsetSize, |
| 26 kBottomInsetSize, kRightInsetSize), | 27 kBottomInsetSize, kRightInsetSize), |
| 27 override_color_(SK_ColorWHITE), | 28 override_color_(SK_ColorWHITE), |
| 28 use_default_color_(true) { | 29 use_default_color_(true) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 43 SkPaint paint; | 44 SkPaint paint; |
| 44 paint.setStyle(SkPaint::kStroke_Style); | 45 paint.setStyle(SkPaint::kStroke_Style); |
| 45 SkColor color = override_color_; | 46 SkColor color = override_color_; |
| 46 if (use_default_color_) { | 47 if (use_default_color_) { |
| 47 color = view.GetNativeTheme()->GetSystemColor( | 48 color = view.GetNativeTheme()->GetSystemColor( |
| 48 view.HasFocus() ? ui::NativeTheme::kColorId_FocusedBorderColor : | 49 view.HasFocus() ? ui::NativeTheme::kColorId_FocusedBorderColor : |
| 49 ui::NativeTheme::kColorId_UnfocusedBorderColor); | 50 ui::NativeTheme::kColorId_UnfocusedBorderColor); |
| 50 } | 51 } |
| 51 | 52 |
| 52 paint.setColor(color); | 53 paint.setColor(color); |
| 53 paint.setStrokeWidth(SkIntToScalar(2)); | 54 paint.setStrokeWidth(SkIntToScalar(kStrokeWidth)); |
| 54 | 55 |
| 55 canvas->DrawPath(path, paint); | 56 canvas->DrawPath(path, paint); |
| 56 } | 57 } |
| 57 | 58 |
| 58 gfx::Insets FocusableBorder::GetInsets() const { | 59 gfx::Insets FocusableBorder::GetInsets() const { |
| 59 return insets_; | 60 return insets_; |
| 60 } | 61 } |
| 61 | 62 |
| 62 gfx::Size FocusableBorder::GetMinimumSize() const { | 63 gfx::Size FocusableBorder::GetMinimumSize() const { |
| 63 return gfx::Size(); | 64 return gfx::Size(kStrokeWidth, kStrokeWidth); |
| 64 } | 65 } |
| 65 | 66 |
| 66 void FocusableBorder::SetInsets(int top, int left, int bottom, int right) { | 67 void FocusableBorder::SetInsets(int top, int left, int bottom, int right) { |
| 67 insets_.Set(top, left, bottom, right); | 68 insets_.Set(top, left, bottom, right); |
| 68 } | 69 } |
| 69 | 70 |
| 70 } // namespace views | 71 } // namespace views |
| OLD | NEW |