Chromium Code Reviews| Index: ui/views/controls/separator.cc |
| diff --git a/ui/views/controls/separator.cc b/ui/views/controls/separator.cc |
| index cbc4938ea2824efc3df7644fd6ef4c6fc7b18274..7c4a4227025ac44774d5094c51e2567d9b751072 100644 |
| --- a/ui/views/controls/separator.cc |
| +++ b/ui/views/controls/separator.cc |
| @@ -6,6 +6,7 @@ |
| #include "ui/accessibility/ax_node_data.h" |
| #include "ui/gfx/canvas.h" |
| +#include "ui/native_theme/native_theme.h" |
| namespace views { |
| @@ -15,13 +16,11 @@ const char Separator::kViewClassName[] = "Separator"; |
| // The separator size in pixels. |
| const int kSeparatorSize = 1; |
| -// Default color of the separator. |
| -const SkColor kDefaultColor = SkColorSetARGB(255, 233, 233, 233); |
| - |
| Separator::Separator(Orientation orientation) |
| : orientation_(orientation), |
| - color_(kDefaultColor), |
| + color_overridden_(false), |
| size_(kSeparatorSize) { |
| + SetColorFromNativeTheme(); |
| } |
| Separator::~Separator() { |
| @@ -29,9 +28,15 @@ Separator::~Separator() { |
| void Separator::SetColor(SkColor color) { |
| color_ = color; |
| + color_overridden_ = true; |
| SchedulePaint(); |
| } |
| +void Separator::SetColorFromNativeTheme() { |
|
sky
2017/01/10 15:56:37
Style guide says declaration and definition order
Tom (Use chromium acct)
2017/01/10 20:59:10
Done.
|
| + color_ = GetNativeTheme()->GetSystemColor( |
| + ui::NativeTheme::kColorId_SeparatorColor); |
| +} |
| + |
| void Separator::SetPreferredSize(int size) { |
| if (size != size_) { |
| size_ = size; |
| @@ -58,6 +63,11 @@ void Separator::OnPaint(gfx::Canvas* canvas) { |
| canvas->FillRect(GetContentsBounds(), color_); |
| } |
| +void Separator::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| + if (!color_overridden_) |
| + SetColorFromNativeTheme(); |
| +} |
| + |
| const char* Separator::GetClassName() const { |
| return kViewClassName; |
| } |