Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: ui/views/controls/separator.cc

Issue 2623753002: Native themes: Add separator color (Closed)
Patch Set: Change function order Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/separator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/separator.cc
diff --git a/ui/views/controls/separator.cc b/ui/views/controls/separator.cc
index cbc4938ea2824efc3df7644fd6ef4c6fc7b18274..5ec611832bd1aa7758a4d86702fb74c4a781b7a9 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,6 +28,7 @@ Separator::~Separator() {
void Separator::SetColor(SkColor color) {
color_ = color;
+ color_overridden_ = true;
SchedulePaint();
}
@@ -39,6 +39,11 @@ void Separator::SetPreferredSize(int size) {
}
}
+void Separator::SetColorFromNativeTheme() {
+ color_ = GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_SeparatorColor);
+}
+
////////////////////////////////////////////////////////////////////////////////
// Separator, View overrides:
@@ -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;
}
« no previous file with comments | « ui/views/controls/separator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698