summaryrefslogtreecommitdiffstats
path: root/views/controls/link.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 16:49:26 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 16:49:26 +0000
commit28065f66296d0d012aa5b02c147f4f77ef8a771e (patch)
tree9fc2567cd9a4edaf09a322e2465b8540787c118c /views/controls/link.cc
parent120e1f1b2728ae5d1d4fed21bddb3533b921fdba (diff)
downloadchromium_src-28065f66296d0d012aa5b02c147f4f77ef8a771e.zip
chromium_src-28065f66296d0d012aa5b02c147f4f77ef8a771e.tar.gz
chromium_src-28065f66296d0d012aa5b02c147f4f77ef8a771e.tar.bz2
Use the system WINDOWTEXT color for labels, instead of black. Also use the system WINDOW color for InfoBubbles, not white. Several places are made to explicitly use black labels where that's correct or respecting system colors is a non-trivial fix (bugs filed for most).
Also, apparently I didn't get all my cleanup changes in the last patch, oops. BUG=92,21027 TEST=Set theme to high-contrast black on white, check that most pieces of chrome UI have readable text Review URL: http://codereview.chromium.org/237005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27196 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/link.cc')
-rw-r--r--views/controls/link.cc62
1 files changed, 49 insertions, 13 deletions
diff --git a/views/controls/link.cc b/views/controls/link.cc
index c9bd256..f2887e0 100644
--- a/views/controls/link.cc
+++ b/views/controls/link.cc
@@ -8,44 +8,75 @@
#include <gdk/gdk.h>
#endif
+#include "app/gfx/color_utils.h"
#include "app/gfx/font.h"
#include "base/logging.h"
#include "views/event.h"
+namespace {
+
+void GetColors(const SkColor* background_color, // NULL means "use default"
+ SkColor* highlighted_color,
+ SkColor* disabled_color,
+ SkColor* normal_color) {
+ static SkColor kHighlightedColor, kDisabledColor, kNormalColor;
+ static bool initialized = false;
+ if (!initialized) {
+#if defined(OS_WIN)
+ kHighlightedColor = color_utils::GetReadableColor(
+ SkColorSetRGB(200, 0, 0), color_utils::GetSysSkColor(COLOR_WINDOW));
+ kDisabledColor = color_utils::GetSysSkColor(COLOR_WINDOWTEXT);
+ kNormalColor = color_utils::GetSysSkColor(COLOR_HOTLIGHT);
+#else
+ // TODO(beng): source from theme provider.
+ kHighlightedColor = SK_ColorRED;
+ kDisabledColor = SK_ColorBLACK;
+ kNormalColor = SkColorSetRGB(0, 51, 153);
+#endif
+
+ initialized = true;
+ }
+
+ if (background_color) {
+ *highlighted_color = color_utils::GetReadableColor(kHighlightedColor,
+ *background_color);
+ *disabled_color = color_utils::GetReadableColor(kDisabledColor,
+ *background_color);
+ *normal_color = color_utils::GetReadableColor(kNormalColor,
+ *background_color);
+ } else {
+ *highlighted_color = kHighlightedColor;
+ *disabled_color = kDisabledColor;
+ *normal_color = kNormalColor;
+ }
+}
+
+}
+
namespace views {
#if defined(OS_WIN)
static HCURSOR g_hand_cursor = NULL;
#endif
-// Default colors used for links.
-static const SkColor kHighlightedColor = SkColorSetRGB(255, 0x00, 0x00);
-static const SkColor kNormalColor = SkColorSetRGB(0, 51, 153);
-static const SkColor kDisabledColor = SkColorSetRGB(0, 0, 0);
-
const char Link::kViewClassName[] = "views/Link";
Link::Link() : Label(L""),
controller_(NULL),
- highlighted_(false),
- highlighted_color_(kHighlightedColor),
- disabled_color_(kDisabledColor),
- normal_color_(kNormalColor) {
+ highlighted_(false) {
Init();
SetFocusable(true);
}
Link::Link(const std::wstring& title) : Label(title),
controller_(NULL),
- highlighted_(false),
- highlighted_color_(kHighlightedColor),
- disabled_color_(kDisabledColor),
- normal_color_(kNormalColor) {
+ highlighted_(false) {
Init();
SetFocusable(true);
}
void Link::Init() {
+ GetColors(NULL, &highlighted_color_, &disabled_color_, &normal_color_);
SetColor(normal_color_);
ValidateStyle();
}
@@ -167,6 +198,11 @@ void Link::SetNormalColor(const SkColor& color) {
ValidateStyle();
}
+void Link::MakeReadableOverBackgroundColor(const SkColor& color) {
+ GetColors(&color, &highlighted_color_, &disabled_color_, &normal_color_);
+ ValidateStyle();
+}
+
void Link::SetHighlighted(bool f) {
if (f != highlighted_) {
highlighted_ = f;